Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » core experssion not evaluated for wisibleWhen(core experssion not evaluated for wisibleWhen)
core experssion not evaluated for wisibleWhen [message #1020954] Tue, 19 March 2013 08:51 Go to next message
pascal migazzi is currently offline pascal migazziFriend
Messages: 5
Registered: March 2013
Junior Member
I'm trying to contribute to a toolbar from a plugin and I want to show or hide button depending on the active part.

My application is split in two plugins

- One describe the main windows and place the perspective stack with this model :
<?xml version="1.0" encoding="UTF-8"?>
<application:Application xmi:version="2.0"
        xmi:id="_8yVlkIsTEeKgZOk1yAcXPw"
        elementId="org.eclipse.e4.ide.application">
    <children xsi:type="basic:TrimmedWindow" xmi:id="_8yVlkYsTEeKgZOk1yAcXPw" label="app" width="500" height="400">
        <children xsi:type="advanced:PerspectiveStack" xmi:id="_UKleYIsUEeKgZOk1yAcXPw" elementId="app.perspectivestack.main"/>
        <mainMenu xmi:id="_q2A-IIu8EeKBdI72k9aRrQ" elementId="app.menu.main">
            <children xsi:type="menu:Menu" xmi:id="_VW9qQIx6EeKFcYjUvyvuxA" elementId="app.menu.file" label="File"/>
        </mainMenu>
        <trimBars xmi:id="_C3yJgIvHEeKBdI72k9aRrQ" elementId="app.trimbar.main">
            <children xsi:type="menu:ToolBar" xmi:id="_fLXbcIvpEeKmo9Wj0fPtng" elementId="app.toolbar.main"/>
            <children xsi:type="menu:ToolControl" xmi:id="_WsSoMIyrEeKwBKsEERioyA" elementId="app.toolcontrol.1" contributionURI="bundleclass://app/app.PerspectiveToolBar">
                <tags>stretch</tags>
            </children>
        </trimBars>
    </children>
    <rootContext xmi:id="_XDTNIIuyEeKBdI72k9aRrQ" elementId="app.bindingcontext.application" name="binding context for the application"/>
    <addons xmi:id="_8yVlkosTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
    <addons xmi:id="_8yVlk4sTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
    <addons xmi:id="_8yVllIsTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>
    <addons xmi:id="_8yVllYsTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.ui.workbench.commands.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.CommandProcessingAddon"/>
    <addons xmi:id="_8yVllosTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.ui.workbench.contexts.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench/org.eclipse.e4.ui.internal.workbench.addons.ContextProcessingAddon"/>
    <addons xmi:id="_8yVll4sTEeKgZOk1yAcXPw" elementId="org.eclipse.e4.ui.workbench.bindings.model" contributionURI="bundleclass://org.eclipse.e4.ui.workbench.swt/org.eclipse.e4.ui.workbench.swt.util.BindingProcessingAddon"/>
</application:Application>


the second plugin is contributing to the main model like this :
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmi:id="_hZ_ZgIvFEeKBdI72k9aRrQ">
    <fragments xsi:type="fragment:StringModelFragment" xmi:id="_lusI4IvFEeKBdI72k9aRrQ" featurename="children" parentElementId="app.perspectivestack.main">
        <elements xsi:type="advanced:Perspective" xmi:id="_qGPX8IvFEeKBdI72k9aRrQ" elementId="planner.perspective.planning" label="planner">
            <children xsi:type="basic:PartSashContainer" xmi:id="_sGA3UIvFEeKBdI72k9aRrQ" elementId="planner.partsashcontainer.0">
                <children xsi:type="basic:PartStack" xmi:id="_scfdoIvFEeKBdI72k9aRrQ" elementId="planner.partstack.editors"/>
                <children xsi:type="basic:PartStack" xmi:id="_uI58IIvFEeKBdI72k9aRrQ" elementId="planner.partstack.1">
                    <children xsi:type="basic:Part" xmi:id="_uis8MIvFEeKBdI72k9aRrQ" elementId="planner.part.0" label="Properties"/>
                </children>
            </children>
            <properties key="displayButton" value="true"/>
        </elements>
    </fragments>
    <fragments xsi:type="fragment:StringModelFragment" xmi:id="_YHDcMIyOEeKFcYjUvyvuxA" featurename="commands" parentElementId="org.eclipse.e4.ide.application">
        <elements xsi:type="commands:Command" xmi:id="_aUdu8IyOEeKFcYjUvyvuxA" elementId="planner.command.open" commandName="open planning">
            <parameters xmi:id="_e54dEIydEeKFcYjUvyvuxA" elementId="input.uri" name="input.uri"/>
        </elements>
    </fragments>
    <fragments xsi:type="fragment:StringModelFragment" xmi:id="_de8G4IyOEeKFcYjUvyvuxA" featurename="handlers" parentElementId="org.eclipse.e4.ide.application">
        <elements xsi:type="commands:Handler" xmi:id="_fKFaEIyOEeKFcYjUvyvuxA" elementId="planner.handler.0" contributionURI="bundleclass://planner/planner.handlers.OpenPlanningHandler" command="_aUdu8IyOEeKFcYjUvyvuxA"/>
    </fragments>
    <fragments xsi:type="fragment:StringModelFragment" xmi:id="_P_u0IIysEeKwBKsEERioyA" featurename="children" parentElementId="app.toolbar.main">
        <elements xsi:type="menu:HandledToolItem" xmi:id="_Cv_2YJBwEeKqG_6TIukAgA" elementId="planner.handledtoolitem.0" accessibilityPhrase="" label="test" tooltip="test" command="_aUdu8IyOEeKFcYjUvyvuxA">
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_Dy3ooJBwEeKqG_6TIukAgA" coreExpressionId="planner.displayButton"/>
        </elements>
    </fragments>
</fragment:ModelFragments>


and finally my plugin.xml contain :
<extension point="org.eclipse.core.expressions.definitions">
    <definition id="planner.displayButton">
        <with variable="e4ActivePart">
            <instanceof value="org.eclipse.e4.ui.model.application.ui.basic.MPart">
            </instanceof>
        </with>
    </definition>
</extension>


when I run the application everything is display correctly but doesn't matter what I put in the instanceof element of my core expression the button is always displayed.

can someone tell what I missed ? seems that the expression is never evaluated.
Re: core experssion not evaluated for wisibleWhen [message #1021282 is a reply to message #1020954] Tue, 19 March 2013 19:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1434
Registered: July 2012
Senior Member
Maybe this helps:

http://www.eclipse.org/forums/index.php/t/452445/
Re: core experssion not evaluated for wisibleWhen [message #1021697 is a reply to message #1021282] Wed, 20 March 2013 14:30 Go to previous messageGo to next message
pascal migazzi is currently offline pascal migazziFriend
Messages: 5
Registered: March 2013
Junior Member
I have try to add the addon specify in the thread you send but change nothing. first the addon is not present in eclipse 4.2 so I copy the code and configure the application to load the addon. after reading the code of this addon it's seems to be used to enable or disable command but it have no effect on the visibility of the button.
Re: core experssion not evaluated for wisibleWhen [message #1021724 is a reply to message #1021697] Wed, 20 March 2013 15:22 Go to previous messageGo to next message
pascal migazzi is currently offline pascal migazziFriend
Messages: 5
Registered: March 2013
Junior Member
I'm a bit confused. when I put breakpoints in setCoreExpressionId and setCoreExpression of the CoreExpressionImpl, the setCoreExpressionId method is called with and the correct id is set but the setCoreExpression method is never called. the same the getter corresponding are never called neither. it's seems that core expression is totally ignored. So I wondering how in eclipse 4 perspective can contribute to the toolbar ?
Re: core experssion not evaluated for wisibleWhen [message #1022931 is a reply to message #1021724] Fri, 22 March 2013 20:40 Go to previous messageGo to next message
pascal migazzi is currently offline pascal migazziFriend
Messages: 5
Registered: March 2013
Junior Member
So I succeed to use core expressions. I don't know if it's normal or not : I have dig through eclipse code to check how core expression are used in eclipse 4.2 and it's evaluated only if your items are part of contributions not if you directly put them in your toolbar. So I have created a contribution and put my items in it and problem solved.
Re: core experssion not evaluated for wisibleWhen [message #1022994 is a reply to message #1022931] Sat, 23 March 2013 00:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
If this is the case I'd consider it a bug that needs to be fixed. Please
file a bugzilla and attach a minimal sample to reproduce.

Tom

On 22.03.13 21:40, pascal migazzi wrote:
> So I succeed to use core expressions. I don't know if it's normal or not
> : I have dig through eclipse code to check how core expression are used
> in eclipse 4.2 and it's evaluated only if your items are part of
> contributions not if you directly put them in your toolbar. So I have
> created a contribution and put my items in it and problem solved.
Re: core experssion not evaluated for wisibleWhen [message #1023087 is a reply to message #1022994] Sat, 23 March 2013 07:54 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 1434
Registered: July 2012
Senior Member
Sorry misunderstood your issue in first place. I think the issue you are reporting is the same I reported a while ago
https://bugs.eclipse.org/bugs/show_bug.cgi?id=400217

Unfortunately no response to it yet
Re: core experssion not evaluated for wisibleWhen [message #1023119 is a reply to message #1023087] Sat, 23 March 2013 09:58 Go to previous message
pascal migazzi is currently offline pascal migazziFriend
Messages: 5
Registered: March 2013
Junior Member
yes seems to be the same bug. I will add a comment to it.
Previous Topic:Eclipse juno stability problems
Next Topic:Preferences page
Goto Forum:
  


Current Time: Sun Dec 21 22:20:31 GMT 2014

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

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