Note:these methods:
Tip:subclass Abstracthandler rather than implementing Ihandler. But you can use it to the below sections you need to set:
Ihandler The chosen operation is not enabled
Not use Popupmenus instead of Menus
Isenabled:should is set to True
Ishandled:should is set to True
ImportOrg.eclipse.core.commands.AbstractHandler;Importorg.eclipse.core.commands.ExecutionEvent;Importorg.eclipse.core.commands.ExecutionException;ImportOrg.eclipse.core.commands.IHandler;ImportOrg.eclipse.core.commands.IHandlerListener;ImportOrg.eclipse.jface.dialogs.MessageDialog;ImportOrg.eclipse.swt.widgets.MessageBox;ImportOrg.eclipse.ui.IWorkbenchWindow;ImportOrg.eclipse.ui.handlers.HandlerUtil; Public classMyHandlerImplementsIhandler {PrivateFontchanger font=fontchanger.getinstance (); @Override PublicObject Execute (executionevent event)throwsexecutionexception {//TODO auto-generated Method StubIworkbenchwindow window=handlerutil.getactiveworkbenchwindowchecked (event); Messagedialog.openinformation (Window.getshell (),"Demo", "Hello, Eclipse World"); Font.decreasesize (); return NULL; } @Override Public voidAddhandlerlistener (Ihandlerlistener handlerlistener) {//TODO auto-generated Method Stub} @Override Public voidDispose () {//TODO auto-generated Method Stub} @Override Public Booleanisenabled () {//TODO auto-generated Method Stub return true; } @Override Public Booleanishandled () {//TODO auto-generated Method Stub return true; } @Override Public voidRemovehandlerlistener (Ihandlerlistener handlerlistener) {//TODO auto-generated Method Stub } }
Eclipse Default Handler Ihandler interface "The chosen operation is not enabled"