I have a simple e4 RPC application, based on e4 model. I have two parts in PartSachContainer - left one and right one. And I need a certain toolbar item to be visible when one part is active, and another item to be visible when another part is active.
I tried to use CoreExpression for this, but to no avail. I can't understand what do I need to write in the expression itself.
My config is as follows:
First part is defined as
ID: simple1.part.leftpart
Label: LeftPart
ClassURI: bundleclass://Simple1/simple1.parts.LeftPart
The second part is defined as
ID: simple1.part.rightpart
Label: RightPart
ClassURI: bundleclass://Simple1/simple1.parts.RightPart
The ToolBar Contribution is defined as
<toolBarContributions xmi:id="_gqB4gNaWEeO3iqh7a9kwnw" elementId="simple1.toolbarcontribution.0" parentId="simple1.toolbar.0">
<children xsi:type="menu:HandledToolItem" xmi:id="_PtGaINaSEeO3iqh7a9kwnw" elementId="simple1.handledtoolitem.leftpitem" iconURI="platform:/plugin/Simple1/icons/sample.png" command="_vFvtcNaREeO3iqh7a9kwnw">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_z_87oNanEeO3iqh7a9kwnw" coreExpressionId="Simple1.RightPartActive"/>
</children>
</toolBarContributions>
When I set Visible-When Expression to I can see the toolbar item. But when I try to use CoreExpression (and I tried various combinations) I never see the toolbar item.
This is what I start with:
<definition id="Simple1.RightPartActive">
<with variable="activePartId">
<equals
value="simple1.part.rightpart">
</equals>
</with>
</definition>
No luck.
I tried several approaches, but I can't seem to find the sufficient documentation on what variables are allowed, what do they really mean, etc.
So, how should I define the CoreExpression to see the toolbar item?
I've also been advised that my problem may be a variant of Eclipse bug 400217, but, frankly, I believe that it's all my fault.
And here's to the real problem: This right part should really be an editor (in e3 terms) - the same implementaion class for multiple various instances of editable data. So, I will use the runtime-generated unique IDs for this parts (the parts themleves would be created from PartDescription). So how should I address these parts with generated IDs in CoreExpression?
UPDATE
Ok, I did some debugging and found out that there is a method
public EvaluationResult evaluate(IEvaluationContext context)
of the class
org.eclipse.core.internal.expressions.WithExpression
that is being called.
The very first line :
Object variable= context.getVariable(fVariable);
calls method of
public Object getVariable(String name) {
if (IEclipseContext.class.getName().equals(name)) {
return eclipseContext;
}
Object obj = eclipseContext.getActive(name);
return obj == null ? IEvaluationContext.UNDEFINED_VARIABLE : obj;
}
where
public Object getActive(final String name) {
return getActiveLeaf().get(name);
}
and
public IEclipseContext getActiveLeaf() {
IEclipseContext activeContext = this;
IEclipseContext child = getActiveChild();
while (child != null) {
activeContext = child;
child = child.getActiveChild();
}
return activeContext;
}
and activeChild is always null.
And I don't see anything in EclipseContext which would be something like "activePartId" or anything close to it.
So why is it so??
How can we even use the CoreExpressions??
[Updated on: Tue, 20 May 2014 14:26]
Report message to a moderator