Skip to main content


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 15:56 Go to next message
Wladimir Schamai is currently offline Wladimir SchamaiFriend
Messages: 53
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 20:55 Go to previous messageGo to next message
Michael Gärtner is currently offline Michael GärtnerFriend
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 08:33 Go to previous message
Wladimir Schamai is currently offline Wladimir SchamaiFriend
Messages: 53
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: Thu Mar 28 14:56:02 GMT 2024

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

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

Back to the top