Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem syncing EMF data binding and CommandStack
Problem syncing EMF data binding and CommandStack [message #425593] Tue, 02 December 2008 20:59 Go to next message
Preston Appel is currently offline Preston AppelFriend
Messages: 6
Registered: July 2009
Junior Member
I'm having a problem with some changes I made to an EMF-generated editor.
I created a class called PropertyEditor with a control and have been using
EMF data binding to sync the control and the model. Here's what I tried
originally (the control in this case is a Text object):

EMFDataBindingContext context = new EMFDataBindingContext();
context.bindValue(SWTObservables.observeText(control, SWT.FocusOut),
EMFObservables.observeValue(eobject, feature),
null,
null);

Since this didn't link in with the CommandStack--resulting in no updates
to the Properties view, no marking the editor as dirty and no undo/redo--I
tried the following:

EMFDataBindingContext context = new EMFDataBindingContext();
context.bindValue(SWTObservables.observeText(control, SWT.FocusOut),
new EObjectObservableValue(eobject, feature)
{
@Override
protected void doSetValue(Object value)
{
super.doSetValue(value);
EditingDomain domain =
AdapterFactoryEditingDomain.getEditingDomainFor(eObject);
domain.getCommandStack().execute(IdentityCommand.INSTANCE);
}
},
null,
null);

This takes care of updating the Properties view and marking the editor as
dirty, but since the IdentityCommand.INSTANCE is essentially a no-op, it
doesn't solve the undo/redo problem.

What's the correct way to sync up the EMF data binding and the
CommandStack?

Thanks.
Re: Problem syncing EMF data binding and CommandStack [message #425594 is a reply to message #425593] Tue, 02 December 2008 21:25 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6559
Registered: July 2009
Senior Member
You are using the wrong EMF-Databinding-Module you should have used
EMFEditObservables and everything works out of the box.

TOm

Preston Appel schrieb:
> I'm having a problem with some changes I made to an EMF-generated
> editor. I created a class called PropertyEditor with a control and have
> been using EMF data binding to sync the control and the model. Here's
> what I tried originally (the control in this case is a Text object):
>
> EMFDataBindingContext context = new EMFDataBindingContext();
> context.bindValue(SWTObservables.observeText(control, SWT.FocusOut),
> EMFObservables.observeValue(eobject, feature),
> null, null);
>
> Since this didn't link in with the CommandStack--resulting in no updates
> to the Properties view, no marking the editor as dirty and no
> undo/redo--I tried the following:
>
> EMFDataBindingContext context = new EMFDataBindingContext();
> context.bindValue(SWTObservables.observeText(control, SWT.FocusOut),
> new EObjectObservableValue(eobject, feature)
> {
> @Override
> protected void doSetValue(Object value)
> {
> super.doSetValue(value);
> EditingDomain domain =
> AdapterFactoryEditingDomain.getEditingDomainFor(eObject);
> domain.getCommandStack().execute(IdentityCommand.INSTANCE);
> }
> },
> null, null);
>
> This takes care of updating the Properties view and marking the editor
> as dirty, but since the IdentityCommand.INSTANCE is essentially a no-op,
> it doesn't solve the undo/redo problem.
>
> What's the correct way to sync up the EMF data binding and the
> CommandStack?
>
> Thanks.
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Problem syncing EMF data binding and CommandStack [message #425746 is a reply to message #425594] Fri, 05 December 2008 20:18 Go to previous message
Preston Appel is currently offline Preston AppelFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks, that did the trick.
Previous Topic:How to get the main Editor from an EditPart
Next Topic:[TENEO] MappingException
Goto Forum:
  


Current Time: Sat May 30 09:44:59 GMT 2020

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

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

Back to the top