Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » XXXDocumentProvider Class DoSave() Method
XXXDocumentProvider Class DoSave() Method [message #1059083] Thu, 16 May 2013 11:07 Go to next message
serhat gezgin is currently offline serhat gezgin
Messages: 236
Registered: January 2013
Location: Izmir
Senior Member
Hi all,

When i write this code to XXXDocumentProviderClass on DoSave() Method;

DiagramImpl di= (DiagramImpl) document.getContent();
		ContentModelImpl cmi = (ContentModelImpl) di.getElement();
		
		//cmi dolasılır eger her listenin altında default fieldlar yoksa eklenir.
		WebApplicationImpl wa = (WebApplicationImpl) cmi.getOwnedWebApplication();
		EList<SiteCollection> scl =  wa.getOwnedSiteColection();
		for(int z = 0; z<scl.size(); z++){
			SiteCollectionImpl sc = (SiteCollectionImpl) scl.get(z);
			WebImpl rw= (WebImpl) sc.getOwnedWeb();
			//artık burada dolasılır.
			for(int i = 0; i < rw.getOwnedList().size(); i++){
				WebListImpl list = (WebListImpl) rw.getOwnedList().get(i);
				boolean isFound = false;
				for(int j = 0; j < list.getOwnedField().size(); j++){
					FieldImpl f = (FieldImpl) list.getOwnedField().get(j);
					if(f.getName().equals("Textt")){
						isFound = true;
						break;
					}
				}
				if(!isFound){
					TextFieldImpl text= (TextFieldImpl) ContentFactoryImpl.eINSTANCE.createTextField();
					text.setName("Textt");
					text.setGuID(GUIDGenerator.generateUniqueId());
					list.getOwnedField().add(text);
				}
			}
		}


i always get Save Failed
"Cannot modify resource set without a write transaction error."

But on save method i must create element so how can i do this anyone can help me ?

Regards

[Updated on: Thu, 16 May 2013 11:09]

Report message to a moderator

Re: XXXDocumentProvider Class DoSave() Method [message #1059424 is a reply to message #1059083] Sat, 18 May 2013 04:53 Go to previous message
Ralph Gerbig is currently offline Ralph Gerbig
Messages: 697
Registered: November 2009
Senior Member
Hi,

your problem is this line:

list.getOwnedField().add(text);


You should use a EMF command to achieve you goal. With AddCommand.create() you can create one. As parameters you need to call getEditDomain() on your edit part and as feature you use something like xxxPackage.eInstance.getList_ownedField. The you call getEditDomain().getCommandStack().execute(Command).

Ralph

[Updated on: Sat, 18 May 2013 04:54]

Report message to a moderator

Previous Topic:Name of deleted Node
Next Topic:Error creating gmfgen file and editor code (GMF Tutorial Cheat Sheet)
Goto Forum:
  


Current Time: Wed Jul 23 16:27:31 EDT 2014

Powered by FUDForum. Page generated in 0.02720 seconds