Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » One handler sees source provider, another doesn't
icon5.gif  One handler sees source provider, another doesn't [message #694404] Fri, 08 July 2011 14:00 Go to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
I have several plugins where commands need to be disabled when the user isn't logged in. This is done via an ISourceProvider. In one plugin.xml I have:
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="menu:org.eclipse.ui.main.menu">
         <menu
               id="menus.arm"
               label="%menu.label"
               mnemonic="%menu.mnemonic">
            <command
                  commandId="ru.focusmedia.odp.arm.commands.login"
                  style="push">
               <visibleWhen
                     checkEnabled="false">
                  <with
                        variable="arm.variables.loggedIn">
                     <equals
                           value="false">
                     </equals>
                  </with>
               </visibleWhen>
            </command>
            <command
                  commandId="ru.focusmedia.odp.arm.commands.logout"
                  style="push">
               <visibleWhen
                     checkEnabled="false">
                  <with
                        variable="arm.variables.loggedIn">
                     <equals
                           value="true">
                     </equals>
                  </with>
               </visibleWhen>
            </command>
            <command
                  commandId="org.eclipse.ui.file.exit"
                  label="%command.label"
                  style="push"
                  tooltip="%command.tooltip">
            </command>
         </menu>
         <menu
               id="menus.help"
               label="%menu.label.0"
               mnemonic="%menu.mnemonic.0">
            <command
                  commandId="org.eclipse.ui.help.aboutAction"
                  label="%command.label.0"
                  style="push"
                  tooltip="%command.tooltip.0">
            </command>
         </menu>
      </menuContribution>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            defaultHandler="ru.focusmedia.odp.arm.login.LogoutHandler"
            id="ru.focusmedia.odp.arm.commands.logout"
            name="%command.name.logout">
      </command>
      <command
            defaultHandler="ru.focusmedia.odp.arm.login.LoginHandler"
            id="ru.focusmedia.odp.arm.commands.login"
            name="%command.name.login">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.services">
      <sourceProvider
            provider="ru.focusmedia.odp.arm.login.LoginStateSourceProvider">
         <variable
               name="arm.variables.loggedIn"
               priorityLevel="workbench">
         </variable>
      </sourceProvider>
   </extension>

This works fine; the correct command is visible all the time. In another plugin, which depends on this one, I have
   <extension
         point="org.eclipse.ui.commands">
      <command
            defaultHandler="ru.focusmedia.odp.arm.alarms.RequestMoreAlarmsHandler"
            id="arm.alarms.commands.request_more_alarms"
            name="Request more alarms">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="ru.focusmedia.odp.arm.alarms.RequestMoreAlarmsHandler"
            commandId="arm.alarms.commands.request_more_alarms">
         <enabledWhen>
            <with
                  variable="arm.variables.loggedIn">
               <equals
                     value="true">
               </equals>
            </with>
         </enabledWhen>
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:arm.views.alarms">
         <command
               commandId="arm.alarms.commands.request_more_alarms"
               style="push">
         </command>
      </menuContribution>
   </extension>

And this command is disabled all the time Sad What's going wrong?
Re: One handler sees source provider, another doesn't [message #694653 is a reply to message #694404] Sat, 09 July 2011 05:23 Go to previous messageGo to next message
Alexey Romanov is currently offline Alexey RomanovFriend
Messages: 263
Registered: May 2010
Senior Member
The problem was the conflict between the defaultHandler attribute in command element and the handler element. After removing defaultHandler="ru.focusmedia.odp.arm.alarms.RequestMoreAlarmsHandler", it works fine.
(no subject) [message #697379 is a reply to message #694653] Sat, 16 July 2011 13:04 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Alexey,

Yes, in these cases it is also good to look at the log. It tells about
handler conflicts.

Regards,

Wim


> The problem was the conflict between the defaultHandler attribute in
command element and the handler element. After removing
defaultHandler="ru.focusmedia.odp.arm.alarms.RequestMoreAlarmsHandler", it
works fine.
Previous Topic:New placeholders are rendering in wrong view parts
Next Topic:Master block in forms
Goto Forum:
  


Current Time: Sat Apr 20 01:32:53 GMT 2024

Powered by FUDForum. Page generated in 0.03115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top