Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How programmatically modify model elements' attributes?
How programmatically modify model elements' attributes? [message #131984] Mon, 04 June 2007 08:49 Go to next message
Eclipse UserFriend
Originally posted by: tyhoho.gmail.com

I use my gmf developed editor draw a gragh, the model file and diagram
file are named"hello.test"and "hello.diagram_test".I want to rename one of
the elements in the model file programmatically,here is the code

TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE
.createEditingDomain();
ResourceSet resourceSet = editingDomain.getResourceSet();
EMDiagramImpl modelDiagram=null;//it's the diagram for the model
Resource resourceModel = resourceSet.getResource(URI
.createPlatformResourceURI("fileroot/hello.test", true), true);
diagramRoot= (EMDiagramImpl) resourceModel.getContents().get(0);

EList docList=modelDiagram.getDocument();
EMPDocumentImpl doc=(EMPDocumentImpl)(docList.get(0));//
doc.setName("can i change it");//!!note:doc is not null!!

Errors are arised by the last sentence,they are:
1.java.lang.IllegalStateException: Cannot modify resource set without a
write transaction
2.Unhandled event loop exception

Anybody can help?
Thanks in advance.

Tina
Re: How programmatically modify model elements' attributes? [message #131997 is a reply to message #131984] Mon, 04 June 2007 08:53 Go to previous message
Eclipse UserFriend
Originally posted by: tyhoho.gmail.com

Tina Chen wrote:

> I use my gmf developed editor draw a gragh, the model file and diagram
> file are named"hello.test"and "hello.diagram_test".I want to rename one of
> the elements in the model file programmatically,here is the code

> TransactionalEditingDomain editingDomain =
> GMFEditingDomainFactory.INSTANCE
> .createEditingDomain();
> ResourceSet resourceSet = editingDomain.getResourceSet();
> EMDiagramImpl modelDiagram=null;//it's the diagram for the model
> Resource resourceModel = resourceSet.getResource(URI
> .createPlatformResourceURI("fileroot/hello.test", true), true);
> diagramRoot= (EMDiagramImpl) resourceModel.getContents().get(0);

> EList docList=modelDiagram.getDocument();
> EMPDocumentImpl doc=(EMPDocumentImpl)(docList.get(0));//
> doc.setName("can i change it");//!!note:doc is not null!!

> Errors are arised by the last sentence,they are:
> 1.java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction
> 2.Unhandled event loop exception

> Anybody can help?
> Thanks in advance.

> Tina
Previous Topic:GMF learning materials
Next Topic:Error opening gmfmap file with GMF 1.0.3
Goto Forum:
  


Current Time: Mon Jul 08 14:34:03 GMT 2024

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

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

Back to the top