Skip to main content



      Home
Home » Eclipse Projects » JFace » ComboViewer with a value not on the list(ComboViewer with a value not on the list)
ComboViewer with a value not on the list [message #857134] Thu, 26 April 2012 05:16 Go to next message
Eclipse UserFriend
Hello everyone,

I have a problem with the JFace ComboViewer. I try to do the following:
I have a combo viewer that is bound to some property. I also have a content provider providing some values. The problem is that the initial value of the property is not on the list form the content provider. In this case the ComboViewer is empty. What I want to achieve, is that the initial value is shown in ComboViewer, but it isn't displayed on the dropdown list.

I've tried to do it with filters, but it doesn't make any difference.

Is it even possible? Anyone has an idea how it could be done?

Thanks in advance,
Marek

[Updated on: Thu, 26 April 2012 05:17] by Moderator

Re: ComboViewer with a value not on the list [message #857332 is a reply to message #857134] Thu, 26 April 2012 09:09 Go to previous messageGo to next message
Eclipse UserFriend
Most probably not really an option but you could set the initial value as text into the combo itself. But this only works if the Combo is not READ_ONLY.

Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final ComboViewer combo = new ComboViewer(shell, SWT.NONE);
	
combo.setContentProvider(new ArrayContentProvider());
combo.setLabelProvider(new LabelProvider());
combo.setInput(new String[]{"1","2","3","4"});
combo.getCombo().setText("0");

shell.pack();
shell.open();
while (!shell.isDisposed()) {
	if (!display.readAndDispatch())
		display.sleep();
}
display.dispose();
Re: ComboViewer with a value not on the list [message #858735 is a reply to message #857134] Fri, 27 April 2012 05:16 Go to previous message
Eclipse UserFriend
Well, I've done something similar, I've overridden the setSelectionToWidget method and set the text directly to the CCombo widget, but it's more of a hack than an intended usage in such cases.
Previous Topic:Operation on Collapsed Tree Item
Next Topic:Model to Treeviewer databinding problem
Goto Forum:
  


Current Time: Fri Jul 25 01:42:21 EDT 2025

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

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

Back to the top