简体   繁体   中英

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).

Now I read here and there about bindings and commands, I managed to get the binding(CTRL+4) appear in the 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.

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..?

Dan

SOLUTION

So as Gred said in a comment below, I should have extended org.eclipse.core.commands.AbstractHandler and implement the execute method.

SOLUTION

So as Gred said in a comment below, I should have extended org.eclipse.core.commands.AbstractHandler and implement the execute method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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