|
Re: How to get an org.eclipse.gmf.runtime.notation.view from an IResource? [message #209494 is a reply to message #209486] |
Sat, 25 October 2008 02:59 |
Eclipse User |
|
|
|
Originally posted by: mklinchin.yahoo.com
Hi Brian,
I think that you need to load the model from file like this:
On Fri, 24 Oct 2008 16:13:38 -0500, Brian Jakubik wrote:
> Here is what I have so far...
>
> TransactionalEditingDomain myEditingDomain =
> DiagramEditingDomainFactory.INSTANCE.createEditingDomain();
> ResourceSet resourceSet = myEditingDomain.getResourceSet();
URI uri =
URI.createPlatformResourceURI(resource.getFullPath().toStrin g(),true);
Resource modelResource = resourceSet.createResource(uri);
modelResource.load(null);
Then your modelResource .getContents().get(0) will be instance of Diagram
or your main model object (depending of what resource point to).
>
> // resource is my diagram file
> Resource modelResource =
> resourceSet.getResource(URI.createPlatformResourceURI(resour ce.getFullPath().toString(),
> true), true);
>
> if (modelResource .getContents().get(0) instanceof Diagram) {
> Diagram obj = (Diagram) modelResource.getContents().get(0);
> ...
> }
>
> However, when inspecting obj, all my children and edges are null, when
> in fact there are edges and elements in my opened editor diagram...
>
> Is there something I am doing wrong?
>
> The ultimate goal is to pass this into the validate action class so I
> can validate all my diagrams without having to do it as the document is
> opened and saved, and currently it reports invalid validation errors as
> the opened editor diagram view is different than what I'm validating
> against. Hope that makes sense.
>
> Thanks
> Brian Jakubik
I hope it helps,
Igor
|
|
|
Re: How to get an org.eclipse.gmf.runtime.notation.view from an IResource? [message #209635 is a reply to message #209494] |
Mon, 27 October 2008 16:36 |
Brian Jakubik Messages: 140 Registered: July 2009 |
Senior Member |
|
|
Thanks for the reply, however it did not do what I was expecting.
Inspecting modelResource before the load shows it is already loaded, and
the load did not change much for me.
My diagram and model are in separate files? do they need to be linked
together some how?
Igor Klinchin wrote:
> Hi Brian,
>
> I think that you need to load the model from file like this:
>
> On Fri, 24 Oct 2008 16:13:38 -0500, Brian Jakubik wrote:
>
>> Here is what I have so far...
>>
>> TransactionalEditingDomain myEditingDomain =
>> DiagramEditingDomainFactory.INSTANCE.createEditingDomain();
>> ResourceSet resourceSet = myEditingDomain.getResourceSet();
>
> URI uri =
> URI.createPlatformResourceURI(resource.getFullPath().toStrin g(),true);
> Resource modelResource = resourceSet.createResource(uri);
> modelResource.load(null);
>
> Then your modelResource .getContents().get(0) will be instance of Diagram
> or your main model object (depending of what resource point to).
>
>
>
>
>> // resource is my diagram file
>> Resource modelResource =
>> resourceSet.getResource(URI.createPlatformResourceURI(resour ce.getFullPath().toString(),
>> true), true);
>>
>> if (modelResource .getContents().get(0) instanceof Diagram) {
>> Diagram obj = (Diagram) modelResource.getContents().get(0);
>> ...
>> }
>>
>> However, when inspecting obj, all my children and edges are null, when
>> in fact there are edges and elements in my opened editor diagram...
>>
>> Is there something I am doing wrong?
>>
>> The ultimate goal is to pass this into the validate action class so I
>> can validate all my diagrams without having to do it as the document is
>> opened and saved, and currently it reports invalid validation errors as
>> the opened editor diagram view is different than what I'm validating
>> against. Hope that makes sense.
>>
>> Thanks
>> Brian Jakubik
>
> I hope it helps,
> Igor
>
|
|
|
Powered by
FUDForum. Page generated in 0.03213 seconds