Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » ObservableMap binding to a Combo
ObservableMap binding to a Combo [message #902939] Tue, 21 August 2012 06:32 Go to next message
Daniel McGreal is currently offline Daniel McGreal
Messages: 27
Registered: April 2012
Junior Member
Hi,
I would like to bind an ObservableMap to a Combo. I currently have code which binds an ObservableSet:
WritableSet selectedSet = new WritableSet(SWTObservables.getRealm(RedMobileControl.getDisplay()));

ComboViewer selectedViewer = new ComboViewer(this, SWT.READ_ONLY | SWT.DROP_DOWN);
selectedViewer.setContentProvider(new ObservableSetContentProvider());
selectedViewer.setInput(selectedSet);
selectedViewer.setLabelProvider(new LabelProvider(){
	@Override public String getText(Object element) {
		//Some irrelevant code here.
	}
});


The problem is that I would like the set to have a nice fast lookup key for use elsewhere in the application (I don't care whether I have access to the key in the LabelProvider for example) and there is no ObservableMapContentProvider. Any ideas how I can achieve this binding?

Many thanks,
Dan.
Re: ObservableMap binding to a Combo [message #904441 is a reply to message #902939] Tue, 28 August 2012 08:34 Go to previous messageGo to next message
Daniel McGreal is currently offline Daniel McGreal
Messages: 27
Registered: April 2012
Junior Member
So there is no easy way to achieve this? Any hard ways? Smile
Thanks, Dan.
Re: ObservableMap binding to a Combo [message #904851 is a reply to message #904441] Wed, 29 August 2012 05:15 Go to previous messageGo to next message
Marco Maccaferri is currently offline Marco Maccaferri
Messages: 132
Registered: July 2009
Senior Member
On 28/08/2012 14:34 Daniel McGreal ha scritto:

> So there is no easy way to achieve this? Any hard ways? :)

Use a WritableList as input to the combo, then add a IMapChangeListener
to the map and update the list with the content differences.

Regards,
Marco.
Re: ObservableMap binding to a Combo [message #905929 is a reply to message #904851] Fri, 31 August 2012 06:21 Go to previous message
Daniel McGreal is currently offline Daniel McGreal
Messages: 27
Registered: April 2012
Junior Member
Marco Maccaferri wrote on Wed, 29 August 2012 05:15
On 28/08/2012 14:34 Daniel McGreal ha scritto:

> So there is no easy way to achieve this? Any hard ways? Smile

Use a WritableList as input to the combo, then add a IMapChangeListener
to the map and update the list with the content differences.

Regards,
Marco.


Thanks. That's the approach I've ended up using, but the duplication is not so neat as being able to use a map directly input to the combo.
Previous Topic:TreeViewer with multiple same objects,adds child to first occurence of its parent
Next Topic:Customizing content assistant
Goto Forum:
  


Current Time: Fri Aug 29 06:15:56 EDT 2014

Powered by FUDForum. Page generated in 0.01639 seconds