Bug 112045 [CellEditors] ComboBoxCellEditor doesn't set items if creation of control is deferred
If the ComboBoxCellEditor is instantiated without creating the control the items are not set on the ComboBoxCellEditor on call to createControl(Composite parent). The following snippet displays the problem. public class ComboEditor { void run() { Display display = new Display(); Shell shell = new Shell(display); String[] items = new String[]{"Item 1", "Item 2", "Item 3"}; ComboBoxCellEditor editor = new ComboBoxCellEditor(); editor.setItems(items); editor.create(shell); //Uncomment to set items. // editor.setItems(items); editor.activate(); editor.getControl().setVisible(true); editor.getControl().setBounds(0, 0, 100, 20); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } public static void main(String[] args) { new ComboEditor().run(); } }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxCellEditor.java
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
/**
 * A cell editor that presents a list of items in a combo box.
 * The cell editor's value is the zero-based index of the selected
 * item.
 * <p>
 * This class may be instantiated; it is not intended to be subclassed.
 * </p>
 */
public class ComboBoxCellEditor extends CellEditor {
    /**
     * The list of items to present in the combo box.
     */
    private String[] items;
    /**
     * The zero-based index of the selected item.
     */
    int selection;
    /**
     * The custom combo box control.
     */
    CCombo comboBox;
    /**
     * Default ComboBoxCellEditor style
     */