Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » can not deactivate handler (only toolbar)
can not deactivate handler (only toolbar) [message #890326] Thu, 21 June 2012 20:38 Go to next message
yuta kobayashi is currently offline yuta kobayashi
Messages: 3
Registered: June 2012
Junior Member
hi, I'm yuta.

I live in japan.
And, sorry to bad English.

I developing RCP product by eclipse3.7 and i have a question.

I can't deactivate handler(toolbar).
I wrote handler as follows.
----------------------------------------------
<handler
      class="ExecuteHandler"
      commandId="command">
    <enabledWhen>
        <with
            variable="activeWorkbenchWindow">
            <test
                property="org.eclipse.ui.workbenchWindow.isPerspectiveOpen">
            </test>
        </with>
    </enabledWhen>
</handler>
----------------------------------------------





and register to <extension point="org.eclipse.ui.menus"> as follows.
----------------------------------------------
<menuContribution
            locationURI="menu:xxx">
         <command
               commandId="command"
               style="push">
         </command>
</menuContribution>
<menuContribution
            locationURI="toolbar:yyy">
         <command
               commandId="command"
               style="push">
         </command>
</menuContribution>
----------------------------------------------



then, close all perspective.

menu handler deactivated, but toolbar handler not deactivated.
they use same command but why only toolbar not deactivated?

I want to deactivate Both.

pls help me.




Re: can not deactivate handler (only toolbar) [message #890353 is a reply to message #890326] Fri, 22 June 2012 02:29 Go to previous messageGo to next message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Member
Hello yuta,

Maybe you could try this:

// Update the enabled state of the ToolBar controls.
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
     IEvaluationService evaluationService = (IEvaluationService) PlatformUI
                        .getWorkbench().getService(IEvaluationService.class);

     evaluationService
          .requestEvaluation("org.eclipse.ui.workbenchWindow.isPerspectiveOpen");
}


The evaluationService.requestEvaluation("link for the Property of the defined propertytester") method enforces the PropertyTesters to make a test again.

Tell us/me if that does not work, because there are also other solutions I can image for you.

Quote:

And, sorry to bad English.

Don´t worry about that, as long as we can understand you. The main thing is that you can get ahead with your work.
Best regards,

Simon

[Updated on: Fri, 22 June 2012 03:17]

Report message to a moderator

Re: can not deactivate handler (only toolbar) [message #891448 is a reply to message #890353] Sun, 24 June 2012 22:15 Go to previous messageGo to next message
yuta kobayashi is currently offline yuta kobayashi
Messages: 3
Registered: June 2012
Junior Member
Hello Simon,

Thank you very much for your advice.

I tried your suggestion. And it worked well.

I used your code in IPerspectiveListener4#perspectiveClosed and IPerspectiveListener4#perspectiveActivated.
(in IPerspectiveListener4#perspectiveOpened, does not work well)


I will adopt it to my program.
However, I can not understand why "re-evaluation" is necessary for only toolbar.

eclipse's bug?


Best regards,


Yuta.




Re: can not deactivate handler (only toolbar) [message #891635 is a reply to message #891448] Mon, 25 June 2012 07:46 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

There are extra evaluation points available to menus (when the user shows the menu) that aren't available to toolbars. When depending on a property, it's up to the property user to make sure that a change is updated in the system using IEvaluationService#requestEvaluation(*) (that's why it is API)

PW


Re: can not deactivate handler (only toolbar) [message #892820 is a reply to message #891448] Fri, 29 June 2012 17:56 Go to previous message
Simon Scholz is currently offline Simon Scholz
Messages: 73
Registered: April 2012
Location: Germany
Member
yuta kobayashi wrote on Mon, 25 June 2012 04:15

(in IPerspectiveListener4#perspectiveOpened, does not work well)

This depends on what you actually want to achieve with the listener.
You did not mention, what your aim is, when the IPerspectiveListener3#perspectiveOpened listener is invoked.
But the IPerspectiveListener3#perspectiveOpened is only invoked if a perpective is added to the org.eclipse.ui.internal.WorkbenchPage and not if it is already opened and the user activates the perspective.
@see WorkbenchPage#addPerspective(Perspective persp)
@see WorkbenchPage#createPerspective(PerspectiveDescriptor desc, boolean notify)
Only those two methods invoke the firePerspectiveOpened method of the org.eclipse.ui.internal.WorkbenchWindow

yuta kobayashi wrote on Mon, 25 June 2012 04:15

However, I can not understand why "re-evaluation" is necessary for only toolbar.

eclipse's bug?


I think the performance of the Client would lack, if the PropertyTester would be tested all the time.
But that would be necessary, if you want the handler´s state to be updated out of the box, because the toolbar is always visible to the user.
Concerning a menu the state is evaluated, when the user opens the menu, but the toolbar is kind of "always opened" and there is not user action to be done in order to see the toolbaritem.
Got it? Rolling Eyes
So the developer is reponsible to update the state by using the IEvaluationService, like Paul Webster explained.

Is that correct Paul?

Best regards,

Simon
Previous Topic:Inactive save button wiht new handler to save command
Next Topic:Different Properties in properties view for multiple objects selction
Goto Forum:
  


Current Time: Fri Aug 29 08:09:36 EDT 2014

Powered by FUDForum. Page generated in 0.10530 seconds