Skip to content

Instantly share code, notes, and snippets.

@cyberpirate92
Created January 19, 2017 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberpirate92/785b5f000cee9317a3c4666f2b49e1a9 to your computer and use it in GitHub Desktop.
Save cyberpirate92/785b5f000cee9317a3c4666f2b49e1a9 to your computer and use it in GitHub Desktop.
The sample handler code in eclipse PDT
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