Home » Eclipse Projects » Sirius » [Popup menu] How to disable a context menu item by service
| |
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 |
|
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
|
|
|
Goto Forum:
Current Time: Sat Apr 27 03:47:35 GMT 2024
Powered by FUDForum. Page generated in 0.03073 seconds
|