5

On developing an eclipse plugin i created a command in the Manifest extensions with id crtc_v4.session with a default handler crtc_v4.handlers.StartSession , I added a handler in the manifest for this command this handler enables the command according to the variable crtc_v4.sessionvar.

The problem which appears on the console is :

!MESSAGE Conflicting handlers for crtc_v4.session:  {crtc_v4.handlers.StartSession@98bc5c} vs {crtc_v4.handlers.StartSession@1265d09}

But it doesn't block running the plugin. I'm asking about the solution for this problem, and whether it affects the performance of my plugin in general ?

Edit :

The snippet that define the command :

 <extension
     point="org.eclipse.ui.menus">
  <menuContribution
        allPopups="false"
        locationURI="toolbar:org.eclipse.ui.main.toolbar">
     <toolbar
           id="crtc_v5.crtctoolbar">
        <command
              commandId="crtc_v5.session"
              icon="icons/neutral.png"
              label="Start Session"
              style="push">
        </command>
     </toolbar>
  </menuContribution>

The snippet that define the handler :

 </extension>
      <command
        defaultHandler="crtc_v5.handlers.StartSession"
        id="crtc_v5.session"
        name="session">
  </command>
 </extension>

And here is the enablement against sessionvar :

  <extension
     point="org.eclipse.ui.handlers">
  <handler
        class="crtc_v5.handlers.StartSession"
        commandId="crtc_v5.session">
     <enabledWhen>
        <with
              variable="crtc_v5.sessionvar">
           <equals
                 value="LOGGEDIN">
           </equals>
        </with>
     </enabledWhen>
  </handler>

4

1 回答 1

9

You've defined a default handler in the command and another one in the org.eclipse.ui.handlers extension. If you want to use enabledWhen, simply remove the defaultHandler attribute (since both instances provide the same handler, crtc_v5.handlers.StartSession).

When you want to have different handlers provide the behaviour for your command depending on the application state, you would use activeWhen in the org.eclipse.ui.handlers definition, but that doesn't seem to be the case here.

于 2013-06-21T14:28:14.000 回答