How to get domain file info if you have diagram file [message #135221] |
Tue, 12 June 2007 15:17 |
Eclipse User |
|
|
|
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 |
|
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 |
Eclipse User |
|
|
|
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 |
|
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 #160188 is a reply to message #135415] |
Wed, 14 November 2007 10:28 |
Eclipse User |
|
|
|
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 |
Boris Blajer 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
>
|
|
|
Powered by
FUDForum. Page generated in 0.02035 seconds