[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [e4-dev] Show / hide a menu according to the perspective
|
Just one more note: The enabled handling is working in the opposite!
Tom
On 20.01.14 14:00, Tom Schindl wrote:
> Hi,
>
> Well the model is the backing state of the UI which is represented by
> the visible-attribute and the renderer should act according to this
> attribute.
>
> Now we have the situation that this value is calculated based upon 2
> informations:
> a) the value of the attribute
> b) the value of the expression
>
> The renderer need to check both of them and changes must be propagated
> by both so that the renderer is able to update the UI.
>
> I would have found it more logical if the visible-when concept would
> have been implemented by a service where you connect the visible-when
> calculation to a certain *workbench-element* and this service would
> simply set the visible-attribute of the model element.
>
> Tom
>
> On 20.01.14 13:08, Dirk Fauth wrote:
>> @Pawel
>> According to this IMHO it should work:
>> http://www.vogella.com/tutorials/EclipseRCP/article.html#commandsmore_coreexpressions
>>
>> I used this some time ago and the Visible-When Core Expression is
>> working fine so far.
>>
>> @Tom
>> Why was it wrong to add it to the application model? The use cases for
>> visible-when exist. Is it just the implementation you think that is wrong?
>>
>> IMHO the visible-when concept in E4 is really not easy to understand.
>> And you still need the plugin.xml to get it working with the application
>> model. It feels a bit too complicated the way it is now.
>>
>> @Nicolas
>> You could set a value for the active perspective to the IEclipseContext
>> as described in the tutorial I posted above. And then let your
>> expression evaluate your custom value. In that case you would need to
>> implement a listener that reacts on perspective change so you are able
>> to change the value for your expression in the context.
>> I didn't found a special perspective change event, but as a starting
>> point you could try to listen for UIEvents.Perspective.TOPIC_ALL and
>> evaluate the current active perspective.
>>
>> To be honest, I didn't try this myself, but from my understanding this
>> would be the first thing to try.
>>
>>
>> On Mon, Jan 20, 2014 at 12:11 PM, Tom Schindl
>> <tom.schindl@xxxxxxxxxxxxxxx <mailto:tom.schindl@xxxxxxxxxxxxxxx>> wrote:
>>
>> I think it was wrong to add the visible-when expression to the model.
>>
>> Tom
>>
>> On 20.01.14 12:09, Paweł Doleciński wrote:
>> > Hi Nicolas,
>> >
>> > what you need to do is to implement and register your own Visible-When
>> > Expression which will look up Active Perspective. To do so, you simple
>> > can inject MPerspectiveStack from which you can retrieve selected
>> > perspective.
>> >
>> > But this is only one step. Next one is that expressions are not
>> > supported if your menu item is directly placed in Application Model
>> > under MenuToolbar.
>> > To have it working, your menu item with visible-when expression
>> needs to
>> > be under Menu Contributions node.
>> >
>> > Anyway, it seems to be a bug. Either visble-when expression should be
>> > evaluated if menu is somewhere in Windows node or option to set one
>> > should be not available.
>> >
>> > Cheers,
>> > Paweł.
>> >
>> > --
>> > Pozdrawiam / Best regards
>> > Paweł Doleciński
>> >
>> >
>> > On 20 January 2014 11:57, Nicolas Sarazin
>> <nicolas.sarazin.pro@xxxxxxxxx <mailto:nicolas.sarazin.pro@xxxxxxxxx>
>> > <mailto:nicolas.sarazin.pro@xxxxxxxxx
>> <mailto:nicolas.sarazin.pro@xxxxxxxxx>>> wrote:
>> >
>> > Thank you for answer !
>> >
>> > But :
>> >
>> > MPerspective mpOffers = (MPerspective)
>> > modelService.find("fr.sogeti.e4.sogeti.perspective.vdoffers",
>> > application);
>> > MMenu mmOffers = (MMenu)
>> > modelService.find("fr.sogeti.e4.sogeti.menu.business",
>> application);
>> > partService.switchPerspective(mpOffers);
>> > mmOffers.setEnabled(false);
>> >
>> > In this code, mmOffers is null, and I think that it is bound
>> to this
>> > bug : https://bugs.eclipse.org/bugs/show_bug.cgi?id=383403
>> >
>> > I think that I can't change programatically the state of menu.
>> No ?
>> >
>> > Thank you in advance
>> >
>> >
>> > 2014/1/20 Dirk Fauth <dirk.fauth@xxxxxxxxx
>> <mailto:dirk.fauth@xxxxxxxxx>
>> > <mailto:dirk.fauth@xxxxxxxxx <mailto:dirk.fauth@xxxxxxxxx>>>
>> >
>> > Hi,
>> >
>> > this question was asked on the forum a while ago:
>> >
>> > http://www.eclipse.org/forums/index.php/t/627845/
>> >
>> >
>> > There is no equivalent for that, as there is no
>> workbenchWindow
>> > in e4. You could try to workaround that by providing your own
>> > value for the definition which is set by a event listener that
>> > reacts on perspective changes for example.
>> >
>> > Greez,
>> > Dirk
>> >
>> >
>> > On Mon, Jan 20, 2014 at 10:32 AM, Nicolas Sarazin
>> > <nicolas.sarazin.pro@xxxxxxxxx
>> <mailto:nicolas.sarazin.pro@xxxxxxxxx>
>> > <mailto:nicolas.sarazin.pro@xxxxxxxxx
>> <mailto:nicolas.sarazin.pro@xxxxxxxxx>>> wrote:
>> >
>> > Hello,
>> >
>> > I use Eclipse 4.3.1 and Eclipse e4 Tools 0.14.0.
>> >
>> > How can I show / hide a menu according to the current
>> > perspective ?
>> >
>> > Menu : Trimmed Window -> Main Menu -> Menu
>> >
>> > I looked for "Visible-When Expression", but I don't
>> find the
>> > variable equivalent of
>> > "|activeWorkbenchWindow.activePerspective|" in e4.
>> >
>> > Thanks in advance !
>> >
>> > _______________________________________________
>> > e4-dev mailing list
>> > e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> <mailto:e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>>
>> > https://dev.eclipse.org/mailman/listinfo/e4-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > e4-dev mailing list
>> > e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> <mailto:e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>>
>> > https://dev.eclipse.org/mailman/listinfo/e4-dev
>> >
>> >
>> >
>> > _______________________________________________
>> > e4-dev mailing list
>> > e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> <mailto:e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>>
>> > https://dev.eclipse.org/mailman/listinfo/e4-dev
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > e4-dev mailing list
>> > e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> > https://dev.eclipse.org/mailman/listinfo/e4-dev
>> >
>>
>> _______________________________________________
>> e4-dev mailing list
>> e4-dev@xxxxxxxxxxx <mailto:e4-dev@xxxxxxxxxxx>
>> https://dev.eclipse.org/mailman/listinfo/e4-dev
>>
>>
>>
>>
>> _______________________________________________
>> e4-dev mailing list
>> e4-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/e4-dev
>>
>
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/e4-dev
>