Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get an org.eclipse.gmf.runtime.notation.view from an IResource?
How to get an org.eclipse.gmf.runtime.notation.view from an IResource? [message #209486] Fri, 24 October 2008 17:13 Go to next message
Eclipse UserFriend
Here is what I have so far...

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);

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
Re: How to get an org.eclipse.gmf.runtime.notation.view from an IResource? [message #209494 is a reply to message #209486] Fri, 24 October 2008 22:59 Go to previous messageGo to next message
Eclipse UserFriend
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 12:36 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Source/Target Anchor question
Next Topic:GMF and OAW completion
Goto Forum:
  


Current Time: Sat Jun 07 22:45:13 EDT 2025

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

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

Back to the top