Bug 494663 - Visible-When Expression is not evaluated for Tool Items
Summary: Visible-When Expression is not evaluated for Tool Items
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5.2   Edit
Hardware: PC Windows 10
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: bugday, helpwanted, noteworthy
Depends on:
Blocks:
 
Reported: 2016-05-26 11:40 EDT by Daniel Raap CLA
Modified: 2021-05-22 13:55 EDT (History)
10 users (show)

See Also:


Attachments
Example project (17.69 KB, application/zip)
2016-05-26 11:40 EDT, Daniel Raap CLA
no flags Details
model screenshot (54.47 KB, image/png)
2016-05-26 11:43 EDT, Daniel Raap CLA
no flags Details
Using visibleWhen for setting visibility for toolbar contributions (15.12 KB, patch)
2016-07-21 08:36 EDT, Daniel Raap CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Raap CLA 2016-05-26 11:40:05 EDT
Created attachment 262034 [details]
Example project

In an e4 application model, setting a CoreExpression as Visible-When Expression for an item in a Toolbar, has no effect. It seems that the ToolBarManagerRenderer does not check visibleWhen of toolbar items (MToolBarElement), like the MenuManagerRenderer.updateVisibility() does for menu elements (MMenuElement).

The core expression is defined in the plugin.xml as contribution to the extension point 'org.eclipse.core.expressions.definitions'.

I attached a sample project, in which the open command in the menu, application toolbar and part toolbar each has a handled item with a Visible-When expression. The expression is always false, thus should hide the toolbar buttons.
Comment 1 Daniel Raap CLA 2016-05-26 11:43:44 EDT
Created attachment 262035 [details]
model screenshot
Comment 2 Lars Vogel CLA 2016-06-01 08:32:14 EDT
Daniel, are you interested in providing a fix for this?
Comment 3 Daniel Raap CLA 2016-07-21 08:36:32 EDT
Created attachment 263238 [details]
Using visibleWhen for setting visibility for toolbar contributions

Yeah, I looked into it. It's simple to evaluate the expression once, when creating the toolbar. See the patch for the changes.

But I also found a duplicate of this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400217. There the visibility was also updated dynamically, which broke some other tests. So for me it is enough to evaluate the expression when a part is openend and the toolbar gets created.
Comment 4 Dirk Fauth CLA 2016-07-21 10:41:53 EDT
The proposed fix in Bug 400217 works perfectly fine in plain E4 but breaks in compat mode.

In theory you should be able to fix this by creating the necessary renderers with the patches locally and register them instead of the default ones.

There are basically two issues AFAICS:
- the patch introduces class loading because of necessary inspections. That leads to starting bundles, which violates the Equinox startup policy. Even if you just want to check on startup if the value is set (so less dynamic) you will violate that policy.
- in compat layer there are some RunAndTrack instances that perform those checks already. As far as I understand this leads to the rendering issues in compat mode, as now two processes update the UI

To fix this issues completely we need:

a) a test case in platform ui to ensure the policy is not violated. currently the tests are only part of integration tests which means we get the test failures too late
b) identify and remove the RAT to ensure the rendering updates are only triggered once
c) introduce some sort of proxy model objects to avoid unnecessary class loading

I have that on my todo list for a long time, but unfortunately not much time to work on it.
Comment 5 Lars Vogel CLA 2019-04-23 05:28:07 EDT
I played with this in https://git.eclipse.org/r/#/c/121658/

Roof, you are now our menu / toolbar expert. Maybe you can have a look?
Comment 6 Rolf Theunissen CLA 2019-06-01 11:24:30 EDT
(In reply to Lars Vogel from comment #5)
> I played with this in https://git.eclipse.org/r/#/c/121658/
> 
> Rolf, you are now our menu / toolbar expert. Maybe you can have a look?

See my comment Bug 201589 comment 49. All over the code base there are bugs around visibility for menus and toolbars, this is one of them.
Comment 7 Eclipse Genie CLA 2021-05-22 10:19:18 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.

--
The automated Eclipse Genie.
Comment 8 Christoph Laeubrich CLA 2021-05-22 13:55:26 EDT
Still an issue