Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » [Popup menu] How to disable a context menu item by service
[Popup menu] How to disable a context menu item by service [message #1590560] Thu, 29 January 2015 03:11 Go to next message
Huy Le is currently offline Huy LeFriend
Messages: 18
Registered: November 2014
Junior Member
Hello,

I've got a popup menu defined as below (via Popup menu & Operation Actions)

index.php/fa/20651/0/

Scenarios:

- Rigth click on a Node X in diagram.
- a context menu "Set type as" appear, it contains 3 sub menu items A, B, and C
- What we want is Menu item B is disabled programmatically. (because Node X is already type of B)

How can we do that?

As I see, there is no object type of Menu available from Java Service.

Thanks.

LE Thanh Huy.
  • Attachment: popp.png
    (Size: 6.79KB, Downloaded 1328 times)
Re: [Popup menu] How to disable a context menu item by service [message #1593211 is a reply to message #1590560] Fri, 30 January 2015 13:36 Go to previous messageGo to next message
Laurent Redor is currently offline Laurent RedorFriend
Messages: 300
Registered: July 2009
Senior Member
Hi,

Thanks for your feedback.

Le 29/01/2015 04:11, Huy Le a écrit :
> Hello,
>
> I've got a popup menu defined as below (via Popup menu & Operation Actions)
>
>
>
> Scenarios:
>
> - Rigth click on a Node X in diagram.
> - a context menu "Set type as" appear, it contains 3 sub menu items A, B, and C
> - What we want is Menu item B is disabled programmatically. (because Node X is already type of B)
>
> How can we do that?

There is currently no way to do that. You can fill a feature request for
this need here: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Sirius
>
> As I see, there is no object type of Menu available from Java Service.
>
> Thanks.
>
> LE Thanh Huy.
>

Regards,

--
Laurent - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Laurent Redor - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: [Popup menu] How to disable a context menu item by service [message #1619357 is a reply to message #1593211] Mon, 16 February 2015 14:23 Go to previous message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 516
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Huy,

Hi Huy,


The precondition of OperationAction and PopupMenu VSM elements are
computed in
org.eclipse.sirius.diagram.ui.tools.internal.menu.PopupMenuContribution.buildContributionItemToAdd(EditDomain,
Collection<DSemanticDecorator>, PopupMenu, IDiagramCommandFactory,
EditPart, Point) and
org.eclipse.sirius.diagram.ui.tools.internal.menu.PopupMenuContribution.preconditionHolds(MenuItemDescription,
Collection<DSemanticDecorator>, EObject, IInterpreter).

To hide your menu (PopupMenu) or just a menu entry (OperationAction,
ExternalJavaAction, ExternalJavaActionCall), you just have to complete
its precondition.


For example, in a DiagramDescription on ecore used to represent EPackage
and EClass element, you could put [thisEObject.oclIsKindOf(EPackage)/]
to enable your menu only when an EPackage is selected.

The evaluation context will be the first selected semantic element, you
also have access to the "views" variable, which references the selected
views (allows to retrieve all selected semantic elements, if required,
with the DSemanticDecorator.target EReference).



Additional note: if a popup menu is empty or if all its items are
disabled, it will not be displayed.


Regards,

Maxime

Le 30/01/2015 14:36, Laurent Redor a écrit :
> Hi,
>
> Thanks for your feedback.
>
> Le 29/01/2015 04:11, Huy Le a écrit :
>> Hello,
>>
>> I've got a popup menu defined as below (via Popup menu & Operation
>> Actions)
>>
>>
>>
>> Scenarios:
>>
>> - Rigth click on a Node X in diagram.
>> - a context menu "Set type as" appear, it contains 3 sub menu items A,
>> B, and C
>> - What we want is Menu item B is disabled programmatically. (because
>> Node X is already type of B)
>>
>> How can we do that?
>
> There is currently no way to do that. You can fill a feature request for
> this need here: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Sirius
>>
>> As I see, there is no object type of Menu available from Java Service.
>>
>> Thanks.
>>
>> LE Thanh Huy.
>>
>
> Regards,
>


--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Parent and Child Node
Next Topic:Can't find the target of the diagram
Goto Forum:
  


Current Time: Thu Apr 25 19:32:35 GMT 2024

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

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

Back to the top