Eclipse plugin handler not invoked in production

时间:2016-07-11 22:33:53

标签: java eclipse eclipse-plugin

I have plugin command and a corresponding handler both defined in plugin.xml. When I test the plugin every thing works but when I copy the plugin .jar files to the Eclipse plugin directory to test the plugin in production the handler doesn't get invoked. The menu shows th e the corresponding label but when I click on the menu item nothing happened.I plase a show message in the begining of the handler's code but it never get called. Is there any help? The Plugin.xml

<command >
categoryId="CatID" 
      description="sample Desc"
      id="ToggleMe"
      name="Toggle Name" >   
     <state
        class="org.eclipse.ui.handlers.RegistryToggleState"
        id="org.eclipse.ui.commands.toggleState">         
        <class
           class="org.eclipse.ui.handlers.RegistryToggleState">
           <parameter
                 name="persisted"
                 value="true">
           </parameter>
        </class>           
    </state> 
</command>

<extension
   point="org.eclipse.ui.handlers">
   <handler
      class="org.application.ToggleStatusHandler"
      commandId="ToggleMe">      
   </handler>

<extension     point="org.eclipse.ui.menus">
<menuContribution 
    locationURI="popup:org.eclipse.ui.popup.any?after=additions">       
        <command
              commandId="ToggleMe"
              label="Turn Me On/Off"                 
              style="toggle"
              tooltip="Turn Me On/Off"   >  
        </command>        
  </menuContribution>

And this is the handler's code:

public class ToggleStatusHandler extends AbstractHandler {

private IWorkbenchPart targetPart;
IProject selectProject = null;

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

    MessageDialog.openInformation(null, "sd", "before"); // Just to ensure it is called but never 

    Command command = event.getCommand();
     boolean oldValue = HandlerUtil.toggleCommandState(command);
    ...
}

0 个答案:

没有答案