| Summary: | IEvaluationContext.getVariable(ISources.ACTIVE_EDITOR_ID_NAME) returns nothing if active editor has not focus | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Tobias Melcher <tobias.melcher> | ||||
| Component: | UI | Assignee: | Michael Rennie <Michael_Rennie> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | dalexiev, daniel_megert, jdsalingerjr, Michael_Rennie, pelder.eclipse, pwebster | ||||
| Version: | 4.2 | ||||||
| Target Milestone: | 4.2.2 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
(In reply to comment #0) > - add an eclipse main toolbar menu contribution and use the "with > variable=activePart" mechanism to define the visibility of the toolbar > entry. Here an example: > <menuContribution > allPopups="true" > locationURI="toolbar:myToolbar"> > <command commandId="myCommandId" > icon="icons/myicon.gif" > label="%command.label" > style="push"> > <visibleWhen> > <iterate operator="or"> > <with variable="activePart"> > <instanceof value="myEditorId"> > </instanceof> > </with> > </iterate> > </visibleWhen> > </command> > </menuContribution> > Could you please update your example? Above, you're asking for the activePart, which is an instance of IWorkbenchPart. From there, your instanceof wouldn't be related to an ID, but to the part implementation class name. PW Here is another use case that exposes this problem we believe. What I want to achieve with this example (MyPlugin2): 1. Add multiple actions ( menus and toolbars ) and only make them visible in my perspectives. 2. My users to be able to easily hide or show all my actions if they are not planning to use them. How I made it ( and it worked in Eclipse 3.8). 1. I contributed a action set "myplugin2.myActionSet" that is not visible - I want my actions to be visible only in my perspective. 2. I contributed a perspective "myplugin2.perspective1" and added “myplugin2.myActionSet” to my perspective. 3. I contributed a menu item and a toolbar and made them visible when the active context had "myplugin2.myActionSet" in it. When I run Eclipse 4.x with my plugin my actions appear only in my perspective. If I open a model dialog in my perspective my actions disappear, that creates lots of flickering. Created attachment 222235 [details]
Sample project showing the issue
This has been fixed in the latest M builds for 4.2.2 PW Thanks a lot for providing the fix. It solves my problem. Verified in 4.2.2 (M20130116-1800) |
Version: 4.2.0 Build id: I20120608-1400 Hi colleagues, in eclipse 4.2, the call org.eclipse.core.expressions.IEvaluationContext.getVariable(ISources.ACTIVE_EDITOR_ID_NAME) doesn't return the editorId as String when the active visible editor has not the focus. This is an incompatible change compared to eclipse 3.7 and makes a problem for following case: - add an eclipse main toolbar menu contribution and use the "with variable=activePart" mechanism to define the visibility of the toolbar entry. Here an example: <menuContribution allPopups="true" locationURI="toolbar:myToolbar"> <command commandId="myCommandId" icon="icons/myicon.gif" label="%command.label" style="push"> <visibleWhen> <iterate operator="or"> <with variable="activePart"> <instanceof value="myEditorId"> </instanceof> </with> </iterate> </visibleWhen> </command> </menuContribution> The toolbar entry gets visible when editor with id "myEditorId" is opened. If this editor now brings up a popup dialog or a progress dialog (by starting an eclipse ui job), then the toolbar menu item immediately disappears and appears again when the dialog is closed. The toolbar now starts flickering when a progress monitor dialog is opened for a short timeframe. Is this incompatible change of IEvaluationContext.getVariable(ISources.ACTIVE_EDITOR_ID_NAME) intended? Is there another option to define a toolbar menu contribution which is always then visible when a specified editor is visible whithout having the focus? With best regards, Tobias