Skip to main content



      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] Wed, 28 January 2015 22:11 Go to next message
Eclipse UserFriend
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 1416 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 08:36 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: [Popup menu] How to disable a context menu item by service [message #1619357 is a reply to message #1593211] Mon, 16 February 2015 09:23 Go to previous message
Eclipse UserFriend
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
Previous Topic:Parent and Child Node
Next Topic:Can't find the target of the diagram
Goto Forum:
  


Current Time: Tue May 13 22:42:42 EDT 2025

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

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

Back to the top