Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Getting a path to a file when right clicked
Getting a path to a file when right clicked [message #647252] Wed, 05 January 2011 12:19 Go to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
I know this is strictly not a Papyrus issue but people have been so helpful to me before so I hope you can forgive me this time.

My problem is that I've added a context menu entry to the Papyrus editor and from there an IAction is triggered. I can get the specific element that was right-clicked from the IStructuredSelection but now I need to get the path to the file (diagram) where the action was triggered. It does not seem to be part of the IStructuredSelection (hopefully I'm wrong) so I have no idea how to get the path to the file.
Re: Getting a path to a file when right clicked [message #648091 is a reply to message #647252] Tue, 11 January 2011 08:33 Go to previous messageGo to next message
Wojciech Trocki is currently offline Wojciech TrockiFriend
Messages: 64
Registered: May 2010
Member
This is a wrong place to talk about this.
I think that we make similar customizations so
please send me your contact info(gtalk, mail, or other)
Re: Getting a path to a file when right clicked [message #648132 is a reply to message #648091] Tue, 11 January 2011 11:32 Go to previous messageGo to next message
Wojciech Trocki is currently offline Wojciech TrockiFriend
Messages: 64
Registered: May 2010
Member
My gmail account: wtrocki
Re: Getting a path to a file when right clicked [message #648134 is a reply to message #647252] Tue, 11 January 2011 11:48 Go to previous message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
I've found the solution to the problem so if it can benefit anyone else, here is the code for getting the URI of the file:
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
CoreMultiDiagramEditor activeEditor = (CoreMultiDiagramEditor)activePage.getActiveEditor();
EObject model = (EObject)activeEditor.getDiagramEditPart().getModel();
URI uri = model.eResource().getURI();
Path pathToDiagram = new Path(uri.toPlatformString(false));

[Updated on: Tue, 11 January 2011 11:49]

Report message to a moderator

Previous Topic:XText Documentation
Next Topic:Old Payrus Code
Goto Forum:
  


Current Time: Thu Mar 28 11:42:03 GMT 2024

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

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

Back to the top