Update model resource when changes are made using the graphical editor [message #210045] |
Thu, 30 October 2008 11:14  |
Eclipse User |
|
|
|
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 15:03  |
Eclipse User |
|
|
|
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...
|
|
|
Powered by
FUDForum. Page generated in 0.05334 seconds