| How programmatically modify model elements' attributes? [message #131984] | 
Mon, 04 June 2007 04:49   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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 04:53   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
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
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.06922 seconds