Skip to main content


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 15:07 Go to next message
serhat gezgin is currently offline serhat gezginFriend
Messages: 243
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 15:09]

Report message to a moderator

Re: XXXDocumentProvider Class DoSave() Method [message #1059424 is a reply to message #1059083] Sat, 18 May 2013 08:53 Go to previous message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
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 08: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: Thu Mar 28 08:26:49 GMT 2024

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

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

Back to the top