Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Extend Papyrus Model Explorer context menue(Extend Papyrus Model Explorer context menue)
Extend Papyrus Model Explorer context menue [message #1552685] Thu, 08 January 2015 08:56 Go to next message
Alexander Fuchs is currently offline Alexander FuchsFriend
Messages: 5
Registered: January 2015
Junior Member
Hi,

I have a problem with adding a context menue entry to the Eclipse Papyrus Model Explorer view (Papyrus v 1.0.1.v201409170932)

I want to access the UML model which is currently opened in Papyrus from an Eclipse plugin.

In order to achieve this, I am trying to add an entry to the Papyrus Model Explorer context menue which triggers a command of my plugin.
Ideally, the context menue entry should exist only for the model element of the model tree.
It seems like this should be possible using 'visibleWhen', but I didn't manage to find the right constraint.

So what I now have is basically the following in the plugin.xml:

<plugin>
   <extension  point="org.eclipse.ui.menus">
	  <menuContribution locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
		 <command
			   commandId="my.command.id"
			   id="my.command.menu.id"
			   label="My Label"
			   style="push">
		 </command>
	  </menuContribution>
   </extension>
</plugin>


This has the effect that the entry exists only for the Papyrus Model Explorer context menue. But for _all_ tree elements, not only the model.

The constraints that I tried did not work - they completely filtered out the context menue entry so that it did not show up anymore at all. This is an example of a filter that I tried (and variations others, e.g. without adapt):

<plugin>
   <extension  point="org.eclipse.ui.menus">
	  <menuContribution locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
		 <command
			   commandId="my.command.id"
			   id="my.command.menu.id"
			   label="My Label"
			   style="push">
			<visibleWhen checkEnabled="false">
			   <iterate ifEmpty="false" operator="and">
				  <adapt type="org.eclipse.uml2.uml.Element">
					 <instanceof  value="org.eclipse.uml2.uml.Model"/>
				  </adapt>
			   </iterate>
			</visibleWhen>
		 </command>
	  </menuContribution>
   </extension>
</plugin>


I would appreciate any help of how to find the proper constraint - add the context menue element for and only for model elements of the tree.

Thanks,
Alexander
Re: Extend Papyrus Model Explorer context menue [message #1553046 is a reply to message #1552685] Thu, 08 January 2015 13:19 Go to previous messageGo to next message
Patrick Tessier is currently offline Patrick TessierFriend
Messages: 245
Registered: July 2009
Location: Paris Saclay, France
Senior Member
In fact you need to adapt model explorer element,
Elements in the model explorer are not directly UML element, there are somethings that reference UML elements.
But the model explorer is very generic so you must to adapt to EObject to obtain UML element.

for example the code that I write to acces to UML element though model explorer is
     if(selectedobject instanceof IAdaptable) {
				EObject selectedEObject = (EObject)((IAdaptable)selectedobject).getAdapter(EObject.class);
				if (selectedEObject instanceof org.eclipse.uml2.uml.Element){

Re: Extend Papyrus Model Explorer context menue [message #1553209 is a reply to message #1553046] Thu, 08 January 2015 15:10 Go to previous message
Alexander Fuchs is currently offline Alexander FuchsFriend
Messages: 5
Registered: January 2015
Junior Member
Hi Patrick,

your proposed change to the adapt type worked:

<plugin>
   <extension  point="org.eclipse.ui.menus">
	  <menuContribution locationURI="popup:org.eclipse.papyrus.views.modelexplorer.modelexplorer.popup">
		 <command
			   commandId="my.command.id"
			   id="my.command.menu.id"
			   label="My Label"
			   style="push">
			<visibleWhen checkEnabled="false">
			   <iterate ifEmpty="false" operator="and">
				  <adapt type="org.eclipse.emf.ecore.EObject">
					 <instanceof  value="org.eclipse.uml2.uml.Model"/>
				  </adapt>
			   </iterate>
			</visibleWhen>
		 </command>
	  </menuContribution>
   </extension>
</plugin>


Thanks,
Alex
Previous Topic:Problem with Off-line installation of Papyrus 1.0.1 with Luna SR1
Next Topic:new to sysml: package?
Goto Forum:
  


Current Time: Sat Jul 11 06:21:58 GMT 2020

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

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

Back to the top