[英]Eclipse command to close/start my plugin
因此,我正在開發我的第一個Eclipse插件,並且希望能夠關閉(或停用)該插件。
現在,我在這里和那里閱讀了有關綁定和命令的信息,我設法使binding(CTRL + 4)出現在Eclipse-> Preferences-> Keys中 。
但是似乎不知道如何從實現IHandler的類中實現execute方法來實際關閉我的插件。
在下面的代碼中,您可以看到我嘗試顯示的內容,但是它們也沒有用。
<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
方法。
解
因此,正如Gred在下面的評論中所述,我應該擴展org.eclipse.core.commands.AbstractHandler並實現execute方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.