首页 > 代码库 > eclipse default handler IHandler interface “the chosen operation is not enabled”
eclipse default handler IHandler interface “the chosen operation is not enabled”
NOTE: These two methods:
Tip: Subclass AbstractHandler rather than implementing IHandler. but you can use it to the below section you need to set:
IHandler the chosen operation is not enabled
NOT USE popupMenus instead of Menus
isEnabled: should be set to true
isHandled:should be set to true
import org.eclipse.core.commands.AbstractHandler;import org.eclipse.core.commands.ExecutionEvent;import org.eclipse.core.commands.ExecutionException;import org.eclipse.core.commands.IHandler;import org.eclipse.core.commands.IHandlerListener;import org.eclipse.jface.dialogs.MessageDialog;import org.eclipse.swt.widgets.MessageBox;import org.eclipse.ui.IWorkbenchWindow;import org.eclipse.ui.handlers.HandlerUtil;public class MyHandler implements IHandler { private FontChanger font=FontChanger.getInstance(); @Override public Object execute(ExecutionEvent event) throws ExecutionException { // TODO Auto-generated method stub IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openInformation( window.getShell(), "Demo", "Hello, Eclipse world"); font.decreaseSize(); return null; } @Override public void addHandlerListener(IHandlerListener handlerListener) { // TODO Auto-generated method stub } @Override public void dispose() { // TODO Auto-generated method stub } @Override public boolean isEnabled() { // TODO Auto-generated method stub return true; } @Override public boolean isHandled() { // TODO Auto-generated method stub return true; } @Override public void removeHandlerListener(IHandlerListener handlerListener) { // TODO Auto-generated method stub } }
eclipse default handler IHandler interface “the chosen operation is not enabled”
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。