Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Editing diagram programatically
Editing diagram programatically [message #492109] Sun, 18 October 2009 18:55 Go to next message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
Hi guys,

I have a diagram and I need to create a similar one. I am already
creating the file, but it is empty. How can I put the elements there?

Does anyone can help?

Thanks,
Vanessa Aline
Bacharelanda em Ciência da Computação - UFBA
Re: Editing diagram programatically [message #492189 is a reply to message #492109] Mon, 19 October 2009 11:47 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

you can getContents from one and addContents to the other EResource.

Regards,

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Editing diagram programatically [message #492788 is a reply to message #492189] Wed, 21 October 2009 17:29 Go to previous messageGo to next message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
Thanks Aurelien,

I am trying to do like you said.

To get the original resource, i am doing like this:

TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE .createEditingDomain();
URI uri = URI.createFileURI(diagramPath.toPortableString());
Resource diagramResource = editingDomain.getResourceSet().getResource
(uri, false);


Then, I add in the second one:
if (object2 instanceof Diagram) {
diagram.getContents().remove(object);
diagram.getContents().add(object2); }


But it is not working...
What is worng?

Aurelien Pupier escreveu:
> Hi,
>
> you can getContents from one and addContents to the other EResource.
>
> Regards,
>
> Aurelien Pupier
Re: Editing diagram programatically [message #492792 is a reply to message #492788] Wed, 21 October 2009 17:38 Go to previous messageGo to next message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
The problem is my getResource() is returning null. I don't know Why.

This is the code:
TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE.createEditingDomain();
URI uri = URI.createFileURI(diagramPath.toOSString()); Resource
diagramResource = editingDomain.getResourceSet().getResource(uri, false);


Vanessa Aline escreveu:
> Thanks Aurelien,
>
> I am trying to do like you said.
>
> To get the original resource, i am doing like this:
>
> TransactionalEditingDomain editingDomain =
> GMFEditingDomainFactory.INSTANCE
> .createEditingDomain();
> URI uri = URI.createFileURI(diagramPath.toPortableString());
> Resource diagramResource =
> editingDomain.getResourceSet().getResource (uri, false);
>
>
> Then, I add in the second one:
> if (object2 instanceof Diagram) {
> diagram.getContents().remove(object);
> diagram.getContents().add(object2); }
>
>
> But it is not working...
> What is worng?
>
> Aurelien Pupier escreveu:
>> Hi,
>>
>> you can getContents from one and addContents to the other EResource.
>>
>> Regards,
>>
>> Aurelien Pupier
Re: Editing diagram programatically [message #492796 is a reply to message #492792] Wed, 21 October 2009 17:56 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Vanessa Aline wrote on Wed, 21 October 2009 13:38
The problem is my getResource() is returning null. I don't know Why.

This is the code:
TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE.createEditingDomain();
URI uri = URI.createFileURI(diagramPath.toOSString()); Resource
diagramResource = editingDomain.getResourceSet().getResource(uri, false);



I think that the createFileUri with the toOSString may bot give you the right uri


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Editing diagram programatically [message #492842 is a reply to message #492796] Thu, 22 October 2009 01:51 Go to previous message
Vanessa Aline is currently offline Vanessa AlineFriend
Messages: 11
Registered: July 2009
Junior Member
It is because a have a Path and need to transform into URI, so i did this.


How Is the use of GMFEditingDomainFactory? I think I am doing wrong,
because there is no Resource in the ResourceSet when I looked in debug.


Aurelien Pupier escreveu:
> Vanessa Aline wrote on Wed, 21 October 2009 13:38
>> The problem is my getResource() is returning null. I don't know Why.
>>
>> This is the code:
>> TransactionalEditingDomain editingDomain =
>> GMFEditingDomainFactory.INSTANCE.createEditingDomain();
>> URI uri = URI.createFileURI(diagramPath.toOSString());
>> Resource diagramResource =
>> editingDomain.getResourceSet().getResource(uri, false);
>
>
> I think that the createFileUri with the toOSString may bot give you the
> right uri
Previous Topic:WrappingLabel multiline when editing
Next Topic:Issue with shared editing domain
Goto Forum:
  


Current Time: Sun Sep 22 03:31:40 GMT 2024

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

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

Back to the top