简体   繁体   English

Eclipse命令关闭/启动我的插件

[英]Eclipse command to close/start my plugin

So I am working on my first Eclipse plugin, and I want to have the possibility of closing the plugin(or deactivating it). 因此,我正在开发我的第一个Eclipse插件,并且希望能够关闭(或停用)该插件。

Now I read here and there about bindings and commands, I managed to get the binding(CTRL+4) appear in the Eclipse->Preferences->Keys . 现在,我在这里和那里阅读了有关绑定和命令的信息,我设法使binding(CTRL + 4)出现在Eclipse-> Preferences-> Keys中

But can't seem to know how to implement the execute method from the class implementing the IHandler to actually close my plugin. 但是似乎不知道如何从实现IHandler的类中实现execute方法来实际关闭我的插件。

In the code below, you can see my attempts of getting something displayed, but they also don't work.. 在下面的代码中,您可以看到我尝试显示的内容,但是它们也没有用。

     <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;
    }
}

So any ideas on how to close and then start a plugin that I've created using this approach? 那么关于如何关闭然后启动使用此方法创建的插件的任何想法吗? Is it enough if I implement just the execute method..? 如果仅实现execute方法,就足够了吗?

Dan

SOLUTION

So as Gred said in a comment below, I should have extended org.eclipse.core.commands.AbstractHandler and implement the execute method. 因此,正如Gred在下面的评论中所述,我应该扩展org.eclipse.core.commands.AbstractHandler并实现execute方法。

SOLUTION

So as Gred said in a comment below, I should have extended org.eclipse.core.commands.AbstractHandler and implement the execute method. 因此,正如Gred在下面的评论中所述,我应该扩展org.eclipse.core.commands.AbstractHandler并实现execute方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM