java - Eclipse plugin: menu button greyed out -
i'm trying create simple eclipse button based on org.eclipse.ui.commands, org.eclipse.ui.menus , org.eclipse.ui.handlers
but when debugging, button created greyed out: http://i.stack.imgur.com/rnpbz.png
here plugin.xml , loginhandler.java
plugin.xml
<?xml version="1.0" encoding="utf-8"?> <?eclipse version="3.4"?> <plugin> <extension point="org.eclipse.ui.views"> <category name="server browsing" id="com.abc.serverapi"> </category> <view name="server browser" icon="icons/sample.gif" category="com.abc.serverapi" class="com.abc.serverapi.views.serverbrowser" id="com.abc.serverapi.views.serverbrowser"> </view> </extension> <extension point="org.eclipse.ui.perspectiveextensions"> <perspectiveextension targetid="org.eclipse.jdt.ui.javaperspective"> <view ratio="0.5" relative="org.eclipse.ui.views.problemview" relationship="right" id="com.abc.serverapi.views.serverbrowser"> </view> </perspectiveextension> </extension> <extension point="org.eclipse.help.contexts"> <contexts file="contexts.xml"> </contexts> </extension> <extension point="org.eclipse.ui.commands"> <command id="com.abc.serverapi.command.login" name="open server login"> </command> </extension> <extension point="org.eclipse.ui.handlers"> <handler class="com.abc.serverapi.handler.loginhandler" commandid="com.abc.serverapi.command.login"> </handler> </extension> <extension point="org.eclipse.ui.menus"> <menucontribution allpopups="false" locationuri="menu:org.eclipse.ui.main.menu"> <menu id="com.abc.serverapi.menu.login" label="server login menu"> <command commandid="com.abc.serverapi.command.login" icon="icons/sample.gif" id="com.abc.serverapi.menu.openlogindialog" mnemonic="o" style="push"> </command> </menu> </menucontribution> </extension> </plugin>
and here command handler:
package com.abc.serverapi.handler; 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.ui.iworkbenchwindow; import org.eclipse.ui.handlers.handlerutil; public class loginhandler implements ihandler { @override public void addhandlerlistener(ihandlerlistener handlerlistener) { // todo auto-generated method stub } @override public void dispose() { // todo auto-generated method stub } @override public object execute(executionevent event) throws executionexception { iworkbenchwindow window = handlerutil.getactiveworkbenchwindowchecked(event); messagedialog.openinformation( window.getshell(), "test", "hello, eclipse world"); return null; } @override public boolean isenabled() { // todo auto-generated method stub return false; } @override public boolean ishandled() { // todo auto-generated method stub return false; } @override public void removehandlerlistener(ihandlerlistener handlerlistener) { // todo auto-generated method stub } }
your isenabled()
method in handler returning false
- handler not enabled!
you can extend org.eclipse.core.commands.abstracthandler
rather implementing of ihandler
.
Comments
Post a Comment