Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Combo-Binding for User-Entries
Combo-Binding for User-Entries [message #816906] Fri, 09 March 2012 12:10 Go to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Hi,
I have an editable ComboBox on my screen. Input is a String array und its bound to a String Property in my data model.

The bindings looks like this:


        IViewerObservableValue orderNumberViewerObsevable = ViewersObservables.observeSingleSelection(this.orderNumberComboViewer);
        IObservableValue orderNumberModelObsevable = EMFEditProperties.value(editingDomain, TimetablePackage.Literals.PROTOCOL_SHEET_ENTRY__ORDER_NUMBER).observeDetail(masterTreeViewerObservable);
        bindingContext.bindValue(orderNumberViewerObsevable, orderNumberModelObsevable);


The binding works if I select a choice from the input list. BUT if I enter a custom String into the combos textfield nothing is written to the model.
And in turn, if I enter something to the model property that is not in the combos input list it wont be displayed in the UI.

Anyone knows how to do this ?

Regards
Re: Combo-Binding for User-Entries [message #816910 is a reply to message #816906] Fri, 09 March 2012 12:16 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Well if you enter a choice that is not part of the drop down the
selection is NULL.

I think that you should not bind to the selection but the text-value of
tje Combo (conversion from/to a number will happen by default).

So you code changes to:

IObservableValue orderNumberViewerObsevable =
WidgetProperties.text(this.orderNumberComboViewer.getControl())


Tom

Am 09.03.12 13:10, schrieb Markus Jo:
> Hi,
> I have an editable ComboBox on my screen. Input is a String array und
> its bound to a String Property in my data model.
>
> The bindings looks like this:
>
>
>
> IViewerObservableValue orderNumberViewerObsevable =
> ViewersObservables.observeSingleSelection(this.orderNumberComboViewer);
> IObservableValue orderNumberModelObsevable =
> EMFEditProperties.value(editingDomain,
> TimetablePackage.Literals.PROTOCOL_SHEET_ENTRY__ORDER_NUMBER).observeDetail(masterTreeViewerObservable);
>
> bindingContext.bindValue(orderNumberViewerObsevable,
> orderNumberModelObsevable);
>
>
> The binding works if I select a choice from the input list. BUT if I
> enter a custom String into the combos textfield nothing is written to
> the model.
> And in turn, if I enter something to the model property that is not in
> the combos input list it wont be displayed in the UI.
>
> Anyone knows how to do this ?
>
> Regards
Re: Combo-Binding for User-Entries [message #816926 is a reply to message #816910] Fri, 09 March 2012 12:32 Go to previous messageGo to next message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
Hi Tom,
I already tried this....then I get a

java.lang.IllegalArgumentException: Widget [org.eclipse.swt.widgets.Combo] is not supported.
	at org.eclipse.jface.internal.databinding.swt.WidgetDelegatingValueProperty.notSupported(WidgetDelegatingValueProperty.java:23)
	at org.eclipse.jface.internal.databinding.swt.WidgetTextWithEventsProperty.doGetDelegate(WidgetTextWithEventsProperty.java:61)
	at org.eclipse.core.databinding.property.value.DelegatingValueProperty.getDelegate(DelegatingValueProperty.java:54)



....because the Control is a Combo and not the TextField of the combo. Any other ideas ?
Re: Combo-Binding for User-Entries [message #816953 is a reply to message #816926] Fri, 09 March 2012 13:05 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Are you really sure you use the correct WidgetProperties-method you
should use the one WITHOUT any parameters.

IObservableValue orderNumberViewerObsevable =
WidgetProperties.text().observe(this.orderNumberComboViewer.getControl());


Tom

Am 09.03.12 13:32, schrieb Markus Jo:
> Hi Tom,
> I already tried this....then I get a
>
>
> java.lang.IllegalArgumentException: Widget
> [org.eclipse.swt.widgets.Combo] is not supported.
> at
> org.eclipse.jface.internal.databinding.swt.WidgetDelegatingValueProperty.notSupported(WidgetDelegatingValueProperty.java:23)
>
> at
> org.eclipse.jface.internal.databinding.swt.WidgetTextWithEventsProperty.doGetDelegate(WidgetTextWithEventsProperty.java:61)
>
> at
> org.eclipse.core.databinding.property.value.DelegatingValueProperty.getDelegate(DelegatingValueProperty.java:54)
>
>
>
>
> ...because the Control is a Combo and not the TextField of the combo.
> Any other ideas ?
Re: Combo-Binding for User-Entries [message #816964 is a reply to message #816953] Fri, 09 March 2012 13:20 Go to previous message
Markus Jo is currently offline Markus JoFriend
Messages: 83
Registered: January 2012
Member
You got me....used the one with .text(SWT.MODIFY).... without parameter it works.

Thx
Previous Topic:Proxy resolution problem
Next Topic:automaticaly save referenced resources
Goto Forum:
  


Current Time: Fri Apr 26 03:48:35 GMT 2024

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

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

Back to the top