Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsHow to get an org.eclipse.gmf.runtime.notation.view from an IResource?
https://www.eclipse.org/forums/index.php/mv/msg/66714/209486/#msg_209486
TransactionalEditingDomain myEditingDomain =
DiagramEditingDomainFactory.INSTANCE.createEditingDomain();
ResourceSet resourceSet = myEditingDomain.getResourceSet();
// resource is my diagram file
Resource modelResource =
resourceSet.getResource(URI.createPlatformResourceURI(resour ce.getFullPath().toString(),
true), true);
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]]>Brian Jakubik2008-10-24T21:13:38-00:00Re: How to get an org.eclipse.gmf.runtime.notation.view from an IResource?
https://www.eclipse.org/forums/index.php/mv/msg/66714/209494/#msg_209494
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]]>2008-10-25T02:59:50-00:00Re: How to get an org.eclipse.gmf.runtime.notation.view from an IResource?
https://www.eclipse.org/forums/index.php/mv/msg/66714/209635/#msg_209635
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
>]]>Brian Jakubik2008-10-27T16:36:14-00:00