|
Re: Change attribute programmatically [message #189759 is a reply to message #189652] |
Wed, 28 May 2008 14:34 |
Francisco Javier Cano Messages: 21 Registered: July 2009 |
Junior Member |
|
|
Hi Martin,
when changing any element or attribute of the model, either in the
diagram or in a property tab, you need to use Commands that will be
executed in an EditingDomain.
Looks like you could use
org.eclipse.gmf.runtime.emf.type.core.commands.SetValueComma nd.
Take a look at it.
Cheers,
Javi
--
Martin Schmidt escribió:
> Hi @all...
> I think my problem is easy to solve, but I am not able to find the answer
> myself :(
>
> I´ve got a GMF-Editor. I can draw for example nodes A and B. Both have an
> ID-attribute "name". A has an additional reference to B.
> My objective: I have one A and one B. When i set the reference of A, i want
> its name change to the name of B.
>
> To put it into practice, I extended xxx.diagram.sheet.MyPropertySection
> class with this:
>
> if(notification.getFeature() instanceof EReferenceImpl ){
>
> EReference ref = (EReference) notification.getFeature();
>
>
> if(ref.getName().equals("reference_to")){
>
> if(notification.getNewValue() != null){
>
> B b = (B) notification.getNewValue();
>
> ((AImpl) element).setName(b.getName());
>
> }
>
>
> }
>
> }
>
> The effect is, that the name of A changes in the propertys, but not in
> diagram. Debugging leads to java.lang.IllegalStateException: Cannot modify
> resource set without a write transaction
> Can somebody tell me in an understandable way, what I have to do (where to
> get a write transaction and what to do with it)? Sorry, my knowledge about
> internal functionality of GMF is very small.
>
> Best Regards, Martin
>
>
>
|
|
|
Re: Change attribute programmatically [message #189919 is a reply to message #189759] |
Thu, 29 May 2008 08:44 |
Eclipse User |
|
|
|
Originally posted by: martinschmidt.83.web.de
Hi,
Thank u very much for your answer. I made a first try, but dont had success:
1st try:
SetRequest setrequest = new SetRequest(editingdomain, element,
ShadowtestPackage.eINSTANCE.getshadow().getEIDAttribute(),
hidden_shadow.getName());
SetValueCommand setvalue = new SetValueCommand(setrequest);
editingdomain.getCommandStack().execute(setvalue);
Here i get an error: "The method execute(Command) in the type CommandStack
is not applicable for the arguments (SetValueCommand)"
2nd try:
SetCommand setName = new SetCommand(editingdomain, element,
ShadowtestPackage.eINSTANCE.getshadow().getEIDAttribute(),
hidden_shadow.getName());
boolean dsf = setName.canExecute();
editingdomain.getCommandStack().execute(setName);
Here i get an exception: "Cannot activate read/write transaction in
read-only transaction context"
Any ideas?
Regards, Martin
"Francisco Javier Cano Mu
|
|
|
Powered by
FUDForum. Page generated in 0.02894 seconds