Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » EMF databinding to multiple fields
EMF databinding to multiple fields [message #481591] Fri, 21 August 2009 17:05 Go to next message
Sue  is currently offline Sue
Messages: 14
Registered: July 2009
Junior Member
I'm trying to figure out how to bind enablement of a field to multiple
values in my model. So, if my model is:

Person
isOld()
isTall()

I want to enable a text field if both of those values are true. When then
are changed, either by UI action or undo/redo, I would like the enablement
of the text field to change accordingly.

The only way I know to do this is to bind the enablement to each
separately. But this is an "OR" relationship and not the desired "AND"
relationship.

For example:

emfDbc.bindValue(SWTObservables.observeEnabled(_txt),
EMFEditObservables.observeValue(_editor.getEditingDomain(), model,
ModelPackage.Literals.MODEL__OLD), null, null);

emfDbc.bindValue(SWTObservables.observeEnabled(_txt),
EMFEditObservables.observeValue(_editor.getEditingDomain(), model,
ModelPackage.Literals.MODEL__TALL), null, null);

Is there a way to combine these enablements. I tried to use a
WritableValue but it seems like this requires that value to be changed
when either field gets changed. This is doable, but I have a lot of
different combinations and that would mean creating a bunch of
WritableValues and updating them all when the values change.
Re: EMF databinding to multiple fields [message #481643 is a reply to message #481591] Sat, 22 August 2009 07:09 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26051
Registered: July 2009
Senior Member
Sue,

I see you reposted this to the EMF newsgroup, where Matthew was so kind
to answer it.


Sue wrote:
> I'm trying to figure out how to bind enablement of a field to multiple
> values in my model. So, if my model is:
>
> Person
> isOld()
> isTall()
>
> I want to enable a text field if both of those values are true. When
> then are changed, either by UI action or undo/redo, I would like the
> enablement of the text field to change accordingly.
>
> The only way I know to do this is to bind the enablement to each
> separately. But this is an "OR" relationship and not the desired
> "AND" relationship.
>
> For example:
>
> emfDbc.bindValue(SWTObservables.observeEnabled(_txt),
> EMFEditObservables.observeValue(_editor.getEditingDomain(), model,
> ModelPackage.Literals.MODEL__OLD), null, null);
>
> emfDbc.bindValue(SWTObservables.observeEnabled(_txt),
> EMFEditObservables.observeValue(_editor.getEditingDomain(), model,
> ModelPackage.Literals.MODEL__TALL), null, null);
>
> Is there a way to combine these enablements. I tried to use a
> WritableValue but it seems like this requires that value to be changed
> when either field gets changed. This is doable, but I have a lot of
> different combinations and that would mean creating a bunch of
> WritableValues and updating them all when the values change.
>
>
Previous Topic:Command appearing enabled when editPart not in focus
Next Topic:Suppress general views in dialog "Window->Show View"?
Goto Forum:
  


Current Time: Fri Sep 19 09:49:17 GMT 2014

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

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