Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:16 Go to next message
Kame Sennin is currently offline Kame Sennin
Messages: 2
Registered: July 2009
Junior Member
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 09:17]

Report message to a moderator

Re: ComboViewer with a value not on the list [message #857332 is a reply to message #857134] Thu, 26 April 2012 13:09 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten Schlathölter
Messages: 208
Registered: February 2012
Location: Düsseldorf
Senior Member
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 09:16 Go to previous message
Kame Sennin is currently offline Kame Sennin
Messages: 2
Registered: July 2009
Junior Member
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:An example of Eclipse ui service contribution
Next Topic:Operation on Collapsed Tree Item
Goto Forum:
  


Current Time: Mon Sep 22 22:26:32 GMT 2014

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

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