|[databinding] Data binding and read-only resources [message #916873]
||Wed, 19 September 2012 15:21
| Vlad Gheorghe
Registered: May 2011
I'm trying to use EMF Edit databinding in a form-based editor (jface/swt).
Suppose we bind a checkbox (Button) selection to a Boolean attribute of a model object,
and that the object's resource is read-only in its EditingDomain (EditingDomain#isReadonly(Resoruce)).
In this case, when the user clicks on the checkbox its visual state is changed,
but the model is not changed - view and model become inconsistent.
This is because the view selecton value is changed, the binding updates the model observable,
EMF Edit creates and sends a SetCommand to the EditingDomain's command stack, but the
command is (correctly) not executed because Command#canExecute checks the resrouce read-only
state and returns false.
What would be a good design to solve this problem ?
R1. View and model must be always consistent
R2. User must be notified when the model cannot be changed
For R2, I can see two exclusive approaches:
a) The Control's enabled state always reflects the read-only state of the resource storing the
bound model object
b) The Control is always enabled, but when a model change is not performed
- the control is synchronized with the model
- user is notified by other channel (e.g. status line error)
My current design draft is:
- control is always enabled
- subclass BasicCommandStack - override execute(Command) so that when a command with
cmd.canExecute()==false is attempted
- refresh view from model (e.g. using DataBindingContext.updateTargets())
- notify user via status line error message
- Assumption: EMF Edit always calls CommandStack#execute(Command) on value update,
even when cmd.canExecute()==false.
One issue if that this assumption does not currently hold at least for
EMFEditSetProperty. (reported in https://bugs.eclipse.org/bugs/show_bug.cgi?id=389893)
An additional requirement is that the editor must handle read-only state changes of
files storing the model during editing, and these changes must be immediately be reflected
in the UI.
Is there any known pattern to handle this problem ?
(That is, EMF/databinding editor aware of read-only file status).
Also, is there any framework support targeted at this case ?
Powered by FUDForum
. Page generated in 0.01564 seconds