-
Notifications
You must be signed in to change notification settings - Fork 227
Description
In the following documentation we describe how one can enhance an exiting toolbar with a contribution:
https://github.com/eclipse-platform/eclipse.platform.ui/blob/master/docs/e4/ToolBarContribution.md
If one creates a direct toolbar item with a visibleWhen Expression like this:
public class ContributedExpression {
@Evaluate
public boolean evaluate(@Named(IServiceConstants.ACTIVE_PART) MPart active) {
System.out.println("ContributedExpression.evaluate()");
return active != null && active.getLabel().contains("2");
}
}
then whenever switching parts and the part label does not contain a "2" the toolbar-item is hidden.
If one do the same thing but with a regular toolbar (e.g. like in the example application here https://github.com/eclipse-pde/eclipse.pde/blob/master/ui/org.eclipse.pde.ui.templates/templates_3.5/E4Application/Application.e4xmi org.eclipse.ui.main.toolbar) then visibleWhen expressions are not evaluated at all!
The code responsible for this is the ToolBarContributionRecord.updateVisibility(IEclipseContext) but it only seems to be working for contributed items so far.