Skip to main content



      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
Eclipse UserFriend
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] by Moderator

Re: XXXDocumentProvider Class DoSave() Method [message #1059424 is a reply to message #1059083] Sat, 18 May 2013 04:53 Go to previous message
Eclipse UserFriend
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] by Moderator

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


Current Time: Tue Jul 08 22:45:40 EDT 2025

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

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

Back to the top