Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Update model resource when changes are made using the graphical editor
Update model resource when changes are made using the graphical editor [message #210045] Thu, 30 October 2008 15:14 Go to next message
Eclipse UserFriend
Originally posted by: christoph.hausmann.de.ibm.com

Hi everyone,

I'm currently trying to make a GMF editor and I have a problem with the
command framework. What I want to do is to change properties of an
element in the editor. I try to make those changes using the following
code:

XXXXDiagramEditor diagramEditor = (XXXXDiagramEditor) ..... ;

Node element = .... ;

Command sc = SetCommand.create(diagramEditor.getEditingDomain(),element,
XXXXPackage.eINSTANCE.getNode_Value(),"new value");
diagramEditor.getEditingDomain().getCommandStack().execute(s c);

The result of this is, that the value is changed in the graphical
representation of the element, but not in the semantic element.
The editor is also not marked as "dirty", so I can't save my modification.

What works: I can undo/redo the command.

I also found out, that the ResourceSetModificationListener in
XXXXDocumentProvider isn't called, when I make changes using the above
command.

Any suggestions? I'm really stuck with this at the moment...
Re: Update model resource when changes are made using the graphical editor [message #210492 is a reply to message #210045] Wed, 05 November 2008 20:03 Go to previous message
Linda Damus is currently offline Linda DamusFriend
Messages: 85
Registered: July 2009
Member
Christoph,

I'm not sure what's going wrong in your scenario - I think that
theoretically it should work. The editor should be dirtied with any
change that causes the isModified state of a resource in the resource
set to become true.

Anyway, GMF has it's own command framework integrated with the Eclipse
operation history. You could try something like this instead:

XXXDiagramEditor diagramEditor = ...;
Node element = ...;
SetCommand command = new SetCommand(
new SetRequest(diagramEditor.getEditingDomain(), element,

XXXPackage.LITERALS.NODE_VALUE, "new value"));

IOperationHistory history =
diagramEditor.getAdapter(IOperationHistory.class);

try{
history.execute(command, null, null);
} catch (ExecutionException e) {
// handle the failure
}

Hope that helps,
Linda


Christoph Hausmann wrote:
> Hi everyone,
>
> I'm currently trying to make a GMF editor and I have a problem with the
> command framework. What I want to do is to change properties of an
> element in the editor. I try to make those changes using the following
> code:
>
> XXXXDiagramEditor diagramEditor = (XXXXDiagramEditor) ..... ;
>
> Node element = .... ;
>
> Command sc = SetCommand.create(diagramEditor.getEditingDomain(),element,
> XXXXPackage.eINSTANCE.getNode_Value(),"new value");
>
> diagramEditor.getEditingDomain().getCommandStack().execute(s c);
>
> The result of this is, that the value is changed in the graphical
> representation of the element, but not in the semantic element.
> The editor is also not marked as "dirty", so I can't save my modification.
>
> What works: I can undo/redo the command.
>
> I also found out, that the ResourceSetModificationListener in
> XXXXDocumentProvider isn't called, when I make changes using the above
> command.
>
> Any suggestions? I'm really stuck with this at the moment...
Previous Topic:testing tool for the editor?
Next Topic:[Announce] GMF 2.2.0 I200811051822 is available
Goto Forum:
  


Current Time: Tue May 11 11:32:53 GMT 2021

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

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

Back to the top