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 } }
menu :
http://stackoverflow.com/questions/1342532/how-to-add-items-in-popup-menu
add it as a menu or menu item
Eclipse base location uri for menus
Since they are impossible to find on the net here is the list of all base location uri's in eclipse that are used in the org.eclipse.ui.menus extension point:
menu:org.eclipse.ui.main.menu // the top-level menu
popup:org.eclipse.ui.popup.any // all pop-up menus
toolbar:org.eclipse.ui.main.toolbar // the top-level tool bar
toolbar:org.eclipse.ui.trim.command1 // the top left trim (main toolbar area)
toolbar:org.eclipse.ui.trim.command2 // the top right trim (perspective switcher area)
toolbar:org.eclipse.ui.trim.vertical1 // the left vertical trim
toolbar:org.eclipse.ui.trim.vertical2 // the right vertical trim
toolbar:org.eclipse.ui.trim.status // the status line trim
to access the menu/toolbar/popup of a part (view or editor):
menu:partid //the part's chevron menu
toolbar:partid //the part's toolbar (cannot contain other toolbars)
popup:partid //the part's popup menu (register the context menu in createPartControl first)
eclipse plugin menu gray out
check the handler class is correct set ,or not implement
eclipse default handler IHandler interface “the chosen operation is not enabled”的更多相关文章
- rcp(插件开发)点击按钮出现 The chosen operation is not enabled 解决办法
别的项目组,遇到以下错误信息: 首先看一下log日志里的异常信息,估计就知道是什么问题了. 项目组遇到的这个错误是source 指向错误 找不到相关的class.
- Eclipse进度条出现“Remote System Explorer Operation”解决方法
Eclipse进度条出现“Remote System Explorer Operation”解决方法
- eclipse 离线安装插件报cannot perform operation.Computing alternate solutions...解决办法
当不能连接外网,离线安装SVN插件时,可能会发现以下问题:eclipse长时间停留在下图所示状态,提示“cannot perform operation.Computing alternate sol ...
- Difference Between static and default methods in interface
I was learning through interfaces when I noticed that you can now define static and default methods ...
- eclipse plugin development -menu
org.eclipse.ui.menus locationURI MenuContribution locationURI = "[Scheme]:[id]?[argument-list]& ...
- Interface default method介绍
一.introduce interface default method Introduce default methodWrite the default method at interfaceTh ...
- [原][Java]eclipse 修改自动提示
下载 jar 链接:http://files.cnblogs.com/files/z5337/org.eclipse.jface.text_3.7.2.v20111213-1208.zip 或者这个: ...
- eclipse中hibernate和mybatis中xml配置文件的没有标签提醒解决方法
当我们使用eclipse编写Mybatis或hibernate的xml文件时,面对众多标签的配置文件,却没有自动提醒,对于工作和学习都十分不方便. 之所以没有自动提醒,是因为dtd文件没有加载成功. ...
- Android中Handler的消息处理机制以及源码分析
在实际项目当中,一个很常见的需求场景就是在根据子线程当中的数据去更新ui.我们知道,android中ui是单线程模型的,就是只能在UI线程(也称为主线程)中更新ui.而一些耗时操作,比如数据库,网络请 ...
随机推荐
- 2018-2019 2 20165203 《网络对抗技术》 Exp1 PC平台逆向破解
2018-2019 2 20165203 <网络对抗技术> Exp1 PC平台逆向破解 实验要求 1.掌握NOP, JNE, JE, JMP, CMP汇编指令的机器码 2.掌握反汇编与十六 ...
- 委托----Func和Action
平时我们如果要用到委托一般都是先声明一个委托类型,比如: private delegate string Say(); string说明适用于这个委托的方法的返回类型是string类型,委托名Say后 ...
- POJ 3262 Protecting the Flowers 【贪心】
题意:有n个牛在FJ的花园乱吃.所以FJ要赶他们回牛棚.每个牛在被赶走之前每秒吃Di个花朵.赶它回去FJ来回要花的总时间是Ti×2.在被赶走的过程中,被赶走的牛就不能乱吃 思路: 先赶走破坏力大的牛假 ...
- 3237: [Ahoi2013]连通图 线段树分治
题解: cf765f cf671e bzoj4184 bzoj4552 线段树分治裸题 还是介绍一下线段树分治 这个东西其实挺简单但也挺有用的 可以把删除+插入操作变成只有插入(倒着就是删除) 像这一 ...
- python全栈开发day18-模块和导入
1.昨日内容回顾 2.模块和模块导入 1.什么是模块,为什么要模块? py文件就是模块, 把相似的功能放到一个文件,要用的时候 引入就可以直接调用了. import py文件名,导入模块就是执行他的代 ...
- java实现判断一个经纬度坐标是否在一个多边形内(经自己亲测)
1.在高德地图上绘制的多边形:经纬度逗号分隔格式:上面是用来方便存坐标的对象:下面是方法测试:直接复制代码即可运行 public class Point { private Double x; pri ...
- 【Java】 剑指offer(4) 替换空格
本文参考自<剑指offer>一书,代码采用Java语言. 更多:<剑指Offer>Java实现合集 题目 请实现一个函数,把字符串中的每个空格替换成"%20&quo ...
- ubuntu卸载opencv并重装opencv3.0.0
一. 卸载opencv2.4.9: Going to the "build" folder directory of opencv from terminal, and execu ...
- shell 安装使用VIM
安装:http://jingyan.baidu.com/article/046a7b3efd165bf9c27fa915.html ubuntu系统: 普通用户下输入命令:sudo apt-get i ...
- hihoCoder挑战赛19 A.Rikka with Sequence(状压DP)
题目链接 比赛链接 \(Description\) \(Solution\) 参考:https://www.cnblogs.com/SovietPower/p/9781573.html 暴力:\(f[ ...