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

    }

}
时间: 2024-12-13 06:22:43

eclipse default handler IHandler interface “the chosen operation is not enabled”的相关文章

The chosen operation is not currently available

android错误之The chosen operation is not currently available 今天遇到一个很奇葩的一个问题  电脑突然卡了  然后没有办法只有被迫重新启动  按照以前的操作去打开eclipse 可以操作SDK ADT两个按钮 ,可是突然弹出"The chosen operation is not currently available"    意思说当前的选择不可以使用   当时就在想 为啥不可以使用呢?之前就用着蛮好的  不就是电脑卡了一下吗??

eclipse plugin development -menu

org.eclipse.ui.menus locationURI MenuContribution locationURI = "[Scheme]:[id]?[argument-list]" 1.menu or toolbar 2. problem view popup:org.eclipse.ui.views.ProblemView?after= org.eclipse.ui.main.menu?after= org.eclipse.search.menu?dialogGroup o

Java 8 - Interface Default Method接口默认方法

Java 8 相比于Java 7 推出了几大特色(features)(接口默认方法)default methods in interface, (接口静态方法)static method in interface, 函数编程(functional programming), lamda expression, stream API. 这里首先介绍以下默认接口方法 1.什么是默认接口方法 java 8 允许在接口定义并编写实现方法.例子: interface Collection{ void ad

[原][Java]eclipse 修改自动提示

本文按 http://blog.csdn.net/tomsheng321/article/details/39548627 修改 /******************************************************************************* * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accom

Spring官方文档翻译——15.4 处理器映射(Handler mappings)

15.4 处理器映射(Handler mappings) 注:下面将handler翻译成处理器 在Spring早先的版本中,用户还需要在web应用上下文中定义处理器映射来配置请求(requests)与处理器之间的关系.而在Spring2.5中,DispatcherServlet实现了一个默认的处理器映射的注解实现--DefaultAnnotationHandlerMapping,它能够寻找@RequestMapping和@Controllers注解(译者注:需要配置component-scan)

Handler和Message以及Looper之间的三角关系

说到Handler想必大家都经常用到,在非UI线程更新UI那可是利器,用起来也非常容易上手 从使用上来说,我们只需要关注sendMessage和handleMessage即可 所以我们先从Handler和Message来说起,先看一小段代码 public static final int UPDATE_TEXT_VIEW = 0; public TextView mResultTextView = null; // new 一个 Handler 对象, 以内部类的方式重写 handleMessa

eclipse中安装jetty插件并使用

一.eclipse中jetty插件安装: 打开eclipse,依次点击菜单Help->Eclipse Marketplace,在Find后面的框中输入jetty,选择第一项进行install即可. 二.jetty插件的使用: 安装成功后可能要重启eclipse: 然后开始配置: Run>run configurations> 在Jetty Webapp>右键>new,Browser想要启动的项目,配置端口号(我配的是8080),Arguments需要指向一个jetty.xml

The Eclipse runtime options

Version 3.6 - Last revised August 5, 2009 The Eclipse platform is highly configurable. Configuration input takes the form of command line arguments and System property settings. In many cases the command line arguments are simply short cuts for setti

android源码解析--Handler

转载自:http://blog.csdn.net/lilu_leo/article/details/8143205 开始,先看下android官方对于Handler的解释: [java] view plaincopy /** * A Handler allows you to send and process {@link Message} and Runnable * objects associated with a thread's {@link MessageQueue}.  Each