Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [databinding] Data binding and read-only resources
[databinding] Data binding and read-only resources [message #916873] Wed, 19 September 2012 15:21 Go to next message
Vlad Gheorghe is currently offline Vlad GheorgheFriend
Messages: 127
Registered: May 2011
Senior Member
Hi all,

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 ?

Requirements:
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 ?

Best regards,
Vlad Gheorghe
Re: [databinding] Data binding and read-only resources [message #916982 is a reply to message #916873] Wed, 19 September 2012 17:51 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
You could bind the enabled state of your control/button to the 'read only' state of your target model.
In your case, you could define a wrapper class for the editing domain which would just have a property which "listens" to the read only state and use Pojo/BeansObservables.
Previous Topic:[Teneo] Recommended way to override Java to DB Type Mapping for various databases
Next Topic:[CDO] Sharing a resource set amongst views
Goto Forum:
  


Current Time: Fri Mar 29 01:28:18 GMT 2024

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

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

Back to the top