所以我正在开发我的第一个Eclipse插件,我想有可能关闭插件(或停用它)。
现在我在这里和那里阅读有关绑定和命令的信息,我设法让绑定(CTRL + 4)出现在 Eclipse-> Preferences-> Keys 中。
但似乎不知道如何从实现 IHandler 的类实现执行方法来实际关闭我的插件。
在下面的代码中,您可以看到我尝试显示某些内容,但它们也无效..
<extension
point="org.eclipse.ui.commands">
<category
id="com.myplugin.myCategory"
name="Category"
description="a description">
</category>
<command
defaultHandler="mypackage.ExitHandler"
id="myproject.exit"
categoryId="com.myplugin.myCategory"
name="Close Plugin">
</command>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="myproject.exit"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+4">
</key>
</extension>
public class ExitHandler implements IHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MessageDialog.openInformation(HandlerUtil.getActiveWorkbenchWindow(
event).getShell(), "Info", "Info for you");
System.out.println("I wanna exittttttttttttttt");
return null;
}
}
那么关于如何关闭然后启动我使用这种方法创建的插件的任何想法? 如果我只实现execute方法就足够了吗?
丹
解
正如Gred在下面的评论中所说,我应该延长org.eclipse.core.commands.AbstractHandler
并实施execute
方法。
答案 0 :(得分:0)
解
正如Gred在下面的评论中所说,我应该扩展 org.eclipse.core.commands.AbstractHandler 并实现执行方法。