Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Changing programmaticaly the EList of a node
Changing programmaticaly the EList of a node [message #124009] Fri, 04 May 2007 08:58 Go to next message
Youmm P. is currently offline Youmm P.Friend
Messages: 140
Registered: July 2009
Senior Member
Hello,

I can change a feature with a SetRequest without problem but I don't see
how to do it if the feature is an EList.

I tried something like this :

EList<Method> methods = new
EObjectContainmentWithInverseEList<Method>(Method.class,
clazz, ProjectPackage.CLAZZ__METHODS,
ProjectPackage.METHOD__CLAZZ);

methods.add(myMethod); // <-- here I have a "Cannot modify resource set
without a write transaction" error


SetRequest reqSet2 =
new SetRequest(diagramEditor.getEditingDomain(),
clazz, ProjectPackage.eINSTANCE.getClazz_Methods(), methods);

diagramEditor.getDiagramEditDomain()
..getDiagramCommandStack().execute(newICommandProxy(operatio n2));


But it doesn't work. How can I add an element to the node's EList ?
Re: Changing programmaticaly the EList of a node [message #124224 is a reply to message #124009] Fri, 04 May 2007 17:51 Go to previous messageGo to next message
Alex Boyko is currently offline Alex BoykoFriend
Messages: 200
Registered: July 2009
Senior Member
Hi,

I think you should modify the EList within the command that's created for
your SetRequest, namely in the command execute() method. The command
execution goes within a transaction and hence I think your problems will
go away in this case.
Hope this helps.

Cheers,
Alex
icon5.gif  Re: Changing programmaticaly the EList of a node [message #518789 is a reply to message #124009] Fri, 05 March 2010 00:30 Go to previous messageGo to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
Hi,

I'm really excited about having found this discussion. I'v been having troubles with this for the last 48h (all of them)...

I have the same problem, and I tried the same solution of Youmm me too.
Unfortunately I don't understand the solution suggested by Alex.
Could you please explain a little better it? What do you mean with
Quote:
modify the EList within the command


I forgot to say that elements i wanted to add are not graphical! They aren't visible on the editor, so they haven't an editPart. Otherwise I think I could have used the Edit Policy...

Should I implement the editpolicies manualy ? hope no...

many thanks,
Daniele

[Updated on: Sat, 06 March 2010 09:48]

Report message to a moderator

Re: Changing programmaticaly the EList of a node [SOLVED] [message #519088 is a reply to message #518789] Sat, 06 March 2010 10:19 Go to previous message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
Ok, fixed!!!!!! Cool

I have an element "Map" with a reference "has_items", that is an EList of Items.

I can't do EList list = new EList();
I can't do EList list = Map.has_items; list.add(item);

but I can do

BasicEList<Item> list = new BasicEList<Item>();
list.addAll( Map.getHas_items());
list.add(item);
EditingDomain editingDomain = MapEditPart.getEditingDomain(); 
EReference feature = xxxPackage.eINSTANCE.getMap_Hax_item(); 
editingDomain.getCommandStack().execute(
SetCommand.create(editingDomain, Map, feature , list)	);
Previous Topic:[Validation]How to validate my diagrams without opening the diagram editor
Next Topic:saving error: object xyz is not contained in a resource[SOLVED]
Goto Forum:
  


Current Time: Sun Sep 20 09:15:30 GMT 2020

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

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

Back to the top