Skip to main content


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 10:32 Go to next message
Daniel McGreal is currently offline Daniel McGrealFriend
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 12:34 Go to previous messageGo to next message
Daniel McGreal is currently offline Daniel McGrealFriend
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 09:15 Go to previous messageGo to next message
Marco Maccaferri is currently offline Marco MaccaferriFriend
Messages: 147
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 10:21 Go to previous message
Daniel McGreal is currently offline Daniel McGrealFriend
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:How can I update status message in JFace ApplicationWindow?
Next Topic:How to use the progress monitor with a custom wizard
Goto Forum:
  


Current Time: Sat Apr 27 02:56:33 GMT 2024

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

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

Back to the top