Created
January 19, 2017 08:25
-
-
Save cyberpirate92/785b5f000cee9317a3c4666f2b49e1a9 to your computer and use it in GitHub Desktop.
The sample handler code in eclipse PDT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my_first_plugin.handlers; | |
import org.eclipse.core.commands.AbstractHandler; | |
import org.eclipse.core.commands.ExecutionEvent; | |
import org.eclipse.core.commands.ExecutionException; | |
import org.eclipse.ui.IWorkbenchWindow; | |
import org.eclipse.ui.handlers.HandlerUtil; | |
import org.eclipse.jface.dialogs.MessageDialog; | |
/** | |
* Our sample handler extends AbstractHandler, an IHandler base class. | |
* @see org.eclipse.core.commands.IHandler | |
* @see org.eclipse.core.commands.AbstractHandler | |
*/ | |
public class SampleHandler extends AbstractHandler { | |
/** | |
* The constructor. | |
*/ | |
public SampleHandler() { | |
} | |
/** | |
* the command has been executed, so extract extract the needed information | |
* from the application context. | |
*/ | |
public Object execute(ExecutionEvent event) throws ExecutionException { | |
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); | |
MessageDialog.openInformation( | |
window.getShell(), | |
"My_first_plugin", | |
"Hello, Eclipse world"); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment