Problem syncing EMF data binding and CommandStack [message #425593] |
Tue, 02 December 2008 20:59 |
Preston Appel 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 |
Thomas Schindl Messages: 6651 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
------------------------------------------------------------ --------
|
|
|
|
Powered by
FUDForum. Page generated in 0.03419 seconds