org.eclipse.ui.commands、org.eclipse.ui.menus、および org.eclipse.ui.handlers に基づいて単純な Eclipse ボタンを作成しようとしています。
しかし、デバッグ時に、作成したボタンがグレー表示されます: http://i.stack.imgur.com/rNpbz.png
ここに私の plugin.xml と私の LoginHandler.java があります
プラグイン.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>
そして、ここに私のコマンドハンドラーがあります:
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
}
}