Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Visibility of toolbar items in Eclipse 4 model(Cannot understand how to properly define Core Expression)
Visibility of toolbar items in Eclipse 4 model [message #1352768] Tue, 13 May 2014 16:20 Go to next message
Konstantin Avdeev is currently offline Konstantin AvdeevFriend
Messages: 2
Registered: May 2014
Junior Member
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/

The second part is defined as

ID: simple1.part.rightpart
Label: RightPart
ClassURI: bundleclass://Simple1/

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"/>

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">

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?


Ok, I did some debugging and found out that there is a method
public EvaluationResult evaluate(IEvaluationContext context)

of the class

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;


public Object getActive(final String name) {
    return getActiveLeaf().get(name);


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

Re: Visibility of toolbar items in Eclipse 4 model [message #1369319 is a reply to message #1352768] Tue, 20 May 2014 14:27 Go to previous messageGo to next message
Konstantin Avdeev is currently offline Konstantin AvdeevFriend
Messages: 2
Registered: May 2014
Junior Member
Update added.
Re: Visibility of toolbar items in Eclipse 4 model [message #1738608 is a reply to message #1352768] Thu, 21 July 2016 11:29 Go to previous message
Daniel Raap is currently offline Daniel RaapFriend
Messages: 2
Registered: July 2016
Junior Member
A bit late, but it seems to be a bug, that toolbars ignore 'visibleWhen' on its items (at least up to Eclipse 4.6.0 neon). I created to get it fixed.
Previous Topic:Disable Double Click on RCP Toolbar Items
Next Topic:How to get the "Eclipse 4 Application Project" Wizard for Neon
Goto Forum:

Current Time: Sun Jun 26 21:42:37 GMT 2022

Powered by FUDForum. Page generated in 0.02237 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top