Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get domain file info if you have diagram file
How to get domain file info if you have diagram file [message #135221] Tue, 12 June 2007 15:17 Go to next message
Eclipse UserFriend
Originally posted by: vinsarwate.yahoo.com

Hi,

May be this sounds absurd but please bear with me.

My requirement is to find domain file info (name and extension) at runtime
for a particular diagram file. When a user clicks on a particular diagram
file, I want to show name of the associated doamin model file (including
its extention).

As per I know, I can parse diagram file xml contents and can find the
associated domain file name but I have different kind of diagram files
with different kinds of elements in it. I want a generic kind of code
which can be applied to all type of diagram files.

GenModel has properties like "Domain File Extention", "Diagram File
Extention" but they are only used for code generation. Is there any way to
get this info at runtime when user has selected a particular diagram file
in the navigator view.

Thanks in advance.

Vinay
Re: How to get domain file info if you have diagram file [message #135247 is a reply to message #135221] Tue, 12 June 2007 15:30 Go to previous messageGo to next message
Vincent Zurczak is currently offline Vincent ZurczakFriend
Messages: 149
Registered: July 2009
Senior Member

Hi. :)

You can do this with a popup extension (for example, in a separate
plugin). In your plugin, you add an extension following the popup wizard
(the target should be IFILE if you want to use it with the package
explorer).

Then, in the "catch event" class, you should have a "selectionChange"
method with two parameters IAction and ISelection. In this method, you
can get the path and the name of the file. Here is an example I use...


if (selection instanceof TreeSelection) {
TreeSelection ts = (TreeSelection) selection;
// get the first file - several may be selected in the package explorer
treeViewerFile = (IFile) ts.getFirstElement();

// get absolute path of the input file
IPath inputFilePath =
treeViewerFile.getWorkspace().getRoot().getLocation();
inputFilePath = inputFilePath.append( treeViewerFile.getFullPath() );
}

Vinay Sarwate wrote:
> Hi,
>
> May be this sounds absurd but please bear with me.
>
> My requirement is to find domain file info (name and extension) at
> runtime for a particular diagram file. When a user clicks on a
> particular diagram file, I want to show name of the associated doamin
> model file (including its extention).
>
> As per I know, I can parse diagram file xml contents and can find the
> associated domain file name but I have different kind of diagram files
> with different kinds of elements in it. I want a generic kind of code
> which can be applied to all type of diagram files.
>
> GenModel has properties like "Domain File Extention", "Diagram File
> Extention" but they are only used for code generation. Is there any way
> to get this info at runtime when user has selected a particular diagram
> file in the navigator view.
>
> Thanks in advance.
>
> Vinay
>
Re: How to get domain file info if you have diagram file [message #135258 is a reply to message #135247] Tue, 12 June 2007 15:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vinsarwate.yahoo.com

Hi,

Thanks for the reply. But this will give me fullpath info about the
selected file.

My requirement is - user will select a diagram file (say
SomeThing.abc_diagram) which can be edited in a graphical editor and I
need to know the associated model (domain) file info which is
(SomeThing.abc) that keeps the model updates done by user in graphical
editor.

Thanks.
Vinay
Re: How to get domain file info if you have diagram file [message #135403 is a reply to message #135258] Wed, 13 June 2007 08:06 Go to previous messageGo to next message
Vincent Zurczak is currently offline Vincent ZurczakFriend
Messages: 149
Registered: July 2009
Senior Member

Hi.

If you know the extension of your model file, you get the path of your
diagram file and change the extension.

But if the extension is different from what you specified in your
genmodel, then I don't know (sorry if I didn't understand).

Bye.

Vincent.



Vinay Sarwate wrote:
> Hi,
>
> Thanks for the reply. But this will give me fullpath info about the
> selected file.
> My requirement is - user will select a diagram file (say
> SomeThing.abc_diagram) which can be edited in a graphical editor and I
> need to know the associated model (domain) file info which is
> (SomeThing.abc) that keeps the model updates done by user in graphical
> editor.
>
> Thanks.
> Vinay
>
Re: How to get domain file info if you have diagram file [message #135415 is a reply to message #135258] Wed, 13 June 2007 08:31 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Vinay,

In the most general case, this information is only available after the
diagram is loaded into a resource set. Because it is always possible to
create more than one diagram file based on a given underlying model file
(see XYZInitDiagramFileAction), you cannot always guess the underlying
file name by only looking at the diagram file name.

org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile (diagram.getElement().eResource())

will give you the IFile that corresponds to the domain element that your
diagram displays. Use IFile.getName() and/or IFile.getFileExtension() to
find out what you need.

If I understand your requirements correctly, you may perform the loading
in a separate thread and update your tooltip (or whatever visual
indication you may choose) after the load is completed.

Best regards,
Boris


Vinay Sarwate wrote:
> Hi,
>
> Thanks for the reply. But this will give me fullpath info about the
> selected file.
> My requirement is - user will select a diagram file (say
> SomeThing.abc_diagram) which can be edited in a graphical editor and I
> need to know the associated model (domain) file info which is
> (SomeThing.abc) that keeps the model updates done by user in graphical
> editor.
>
> Thanks.
> Vinay
>
Re: How to get domain file info if you have diagram file [message #160188 is a reply to message #135415] Wed, 14 November 2007 10:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stefan.bley.dd.gmx.de

Hi Boris,

you show a way how to retrieve the model file from the currently displayed
domain element.
How can I find out the model file from the container element, i. e. the
first/outer element in the xml?

Regards, Stevy


"Boris Blajer" <boris.blajer@borland.com> schrieb im Newsbeitrag
news:f4oa0l$fnc$1@build.eclipse.org...
>
> org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile (diagram.getElement().eResource())
>
> will give you the IFile that corresponds to the domain element that your
> diagram displays. Use IFile.getName() and/or IFile.getFileExtension() to
> find out what you need.
> [...]
> Best regards,
> Boris
Re: How to get domain file info if you have diagram file [message #160241 is a reply to message #160188] Wed, 14 November 2007 12:17 Go to previous message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
Hi Stefan,

If the first/outer element in the xml is a View (most likely, a
diagram), then the answer is as given above. Otherwise, the "model file"
does not make sense, and there is no answer.

Best regards,
Boris

Stefan Bley wrote:
> Hi Boris,
>
> you show a way how to retrieve the model file from the currently
> displayed domain element.
> How can I find out the model file from the container element, i. e. the
> first/outer element in the xml?
>
> Regards, Stevy
>
>
> "Boris Blajer" <boris.blajer@borland.com> schrieb im Newsbeitrag
> news:f4oa0l$fnc$1@build.eclipse.org...
>>
>> org.eclipse.emf.workspace.util.WorkspaceSynchronizer.getFile (diagram.getElement().eResource())
>>
>>
>> will give you the IFile that corresponds to the domain element that
>> your diagram displays. Use IFile.getName() and/or
>> IFile.getFileExtension() to find out what you need.
>> [...]
>> Best regards,
>> Boris
>
Previous Topic:Problem with viewing of an element
Next Topic:[Announce] The EclipseCon 2008 Submission Deadline is Rapidly Approaching.
Goto Forum:
  


Current Time: Fri Apr 19 13:34:34 GMT 2024

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

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

Back to the top