XXXDocumentProvider Class DoSave() Method [message #1059083] |
Thu, 16 May 2013 15:07 |
serhat gezgin 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 |
Ralph Gerbig 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
|
|
|
Powered by
FUDForum. Page generated in 0.06454 seconds