Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to programmatically select an element in Papyrus Model Explorer
How to programmatically select an element in Papyrus Model Explorer [message #661633] Fri, 25 March 2011 11:56 Go to next message
Wladimir Schamai is currently offline Wladimir Schamai
Messages: 47
Registered: May 2010
Member
Hi all,

I implemented a specific view that shows a tree of UML properties based on the Papyrus model that is open. Now I would like to select a particular property (or its type) in the Papyrus model explorer.

This is the similar to the feature "Link with Editor" in Papyrus. When element is selected on a diagram it is also selected in the model explorer. Can anyone point me to Papyrus code that does it to see how can I access the model explorer and let select a particular tree item based on its associated UML element?

Thanks for your support!
Wladimir
Re: How to programmatically select an element in Papyrus Model Explorer [message #892355 is a reply to message #661633] Wed, 27 June 2012 16:55 Go to previous messageGo to next message
Michael Gärtner is currently offline Michael Gärtner
Messages: 8
Registered: June 2012
Junior Member
Hi,

I faced a similar issue. Do you have already a solution?

Thanks for Help!

Mike
Re: How to programmatically select an element in Papyrus Model Explorer [message #892840 is a reply to message #892355] Sat, 30 June 2012 04:33 Go to previous message
Wladimir Schamai is currently offline Wladimir Schamai
Messages: 47
Registered: May 2010
Member
Hi,

I am using the following code:

public static void locateInModelExplorer(Object object){
		if (object instanceof EObject) {
			
			IViewPart view = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView("org.eclipse.papyrus.modelexplorer.modelexplorer");

			ModelExplorerPageBookView modelExplorerPageBookView = null;
			if (view instanceof ModelExplorerPageBookView) {
				modelExplorerPageBookView = (ModelExplorerPageBookView)view;
			}
			CommonViewer modelExplorerView = ((ModelExplorerView) modelExplorerPageBookView.getAdapter(ModelExplorerView.class)).getCommonViewer();
			List<Object> items = new ArrayList<Object>();
			items.add(modelExplorerPageBookView.findElementForEObject( modelExplorerView, (EObject)object));

			// set focus
			modelExplorerView.getControl().setFocus();
			
			// set new selection
			modelExplorerView.setSelection(new StructuredSelection(items), true);
      	}
}


hope it helps.
Wladimir
Previous Topic:Problems with Papyrus 0.9.0
Next Topic:I don't find Papyrus in Eclipse overview ?
Goto Forum:
  


Current Time: Fri Jul 25 05:06:45 EDT 2014

Powered by FUDForum. Page generated in 0.01825 seconds