Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-ui-dev] update user interface

Hello, 
 
I read the message below which described how to enable or disable a ui
action with System.properties. But I don’t now how to automatic call a
refresh to UI. 
 
In last chapter the autor descript that actions have to be notifyed about 
property change. HOW TO DO THAT. 
 
 
<oldPOST>
You did not explain what your use case is so I'm just going to guess at it
based on what you mentionned below... You want to add 2 tool items to the
main toolbar, one to login and one to logout. You want the login button to
be enable while the user has not log on, disabled after that. You want the
inverse for the logout button.
Declare an action set with two actions...
<extension point = "org.eclipse.ui.actionSets">
<actionSet
 id="com.xyz.actionSet"
 label="My Actions">
  <action
   id="com.xyz.login"
   label="Login"
   style="push"
   toolbarPath="Normal/group1"
   icon="icons/login.gif"
   tooltip="Login"
   helpContextId="com.xyz.login_action_context"
   class="com.xyz.actions.LoginDelegate">
      <enablement>
         <not>
            <systemProperty name="com.xyz.LoginState" value="true"/>
         </not>
      </enablement>
  </action>
  <action
   id="com.xyz.logout"
   label="Logout"
   style="push"
   toolbarPath="Normal/group1"
   icon="icons/logout.gif"
   tooltip="Logout"
   helpContextId="com.xyz.logout_action_context"
   class="com.xyz.actions.LogoutDelegate">
      <enablement>
         <systemProperty name="com.xyz.LoginState" value= "true"/>
      </enablement>
  </action>
</extension>
When the workbench is started, the login button will be enabled because
there will be no system property named "com.xyz.LoginState" yet (so it
systemProperty element will evaluate to false, but the not element will
turn
it into a true). The logout button will be disabled because there will be
no
system property named "com.xyz.LoginState" yet.
When the user presses the login button, your login delegate will be loaded
(and in a background thread, your logout delegate will be loaded... this is
[news.eclipse.tools] Re: Action enblement and menus ssuming your plugin
has not been activated yet). Once the login is complete, set the system
property com.xyz.LoginState to be true (and of course to false if its the
logout delegate running).
 
Now there is only one more thing. The enablement state for your actions is
only calculated when the selection changes (even though it is not dependent
on the selection but on a system property). So when this system property is
changed in your code, you will need to notify both delegate so they can
lookup the value and adjust the enablement state of the proxy action.
Simon :-)
</oldPOST>
 
Thanks 
 
Alexander Schneider

 


Back to the top