Bug 243686 - [Commands] Add an option to add an updateWhen element to commands\handlers
Summary: [Commands] Add an option to add an updateWhen element to commands\handlers
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows Vista
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-10 13:31 EDT by Kobi Perl CLA
Modified: 2019-09-06 16:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kobi Perl CLA 2008-08-10 13:31:56 EDT
I have a toggle button, but it's not like most of the toggle buttons in eclipse - its state is unique for every one of the open editors.

I use an Handler that operates when the toggle button is pushed. I made my handler to inherit from IElementUpdater, so when someone calls update on the command it will be updated (change tooltip and everything).

I wanted to put the code that follows the active editor and call refresh on the command according to its id, in the Handler itself. Because I don't want the editor to know about the command, and I don't have any place else to put it there.
But I really don't know where to put it. I don't want to do it in the handler's Ctor, because I don't have a workbench object then. Putting it on the execute isn't good either - I want to update the UIElement, even if noone pushed the button during yet (Some editors are in the second state by default, even without pushing the button).
So I put it in the updateElement. Now I add the part listener in the updateElement. So updateElement is called when the element goes from disabled to enabled (it does it automatically), and it is also called when editors change because there is a part listeners.

The real problem is that my code became disgusting.

My idea is to write in the plugin.xml an updateWhen element. It will be like the activeWhen and the enabledWhen expressions, but the difference will be that the updateElement function will be called even if the expression value hasn't changed. It will be called when the expression returns true, and one of the source variables where changed from last time.

Another option is that updateElement will be called even if the evaluation of the expression in the enabled when hasn't changed, but it involves a variable that did changed. I also think that it will be less confusing - we don't want a different behaviour for activeWhen and updateWhen.
Comment 1 Kobi Perl CLA 2008-08-10 13:39:01 EDT
Just for clarification, the command that the handlers deals with is in the coolbar, and if refreshElements in the ICommandService isn't called directly, the updateElement function in IElementUpdater, is only called when the button changes its state from disabled to enabled.
Comment 2 Mike Wilson CLA 2009-05-05 10:26:42 EDT
Changing Version tag to something more believable. Note that this is not a statement about when the enhancement request will be addressed (the Target Milestone field is used for that); the Version tag should be set to the version of Eclipse you were using when you saw the need for the enhancement.
Comment 3 Eclipse Webmaster CLA 2019-09-06 16:10:15 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.