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
public void focusLost(FocusEvent e) {
                ComboBoxCellEditor.this.focusLost();
            }
        });
        return comboBox;
    }
    /**
     * The <code>ComboBoxCellEditor</code> implementation of
     * this <code>CellEditor</code> framework method returns
     * the zero-based index of the current selection.
     *
     * @return the zero-based index of the current selection wrapped
     *  as an <code>Integer</code>
     */
    protected Object doGetValue() {
        return new Integer(selection);
    }
    /* (non-Javadoc)
     * Method declared on CellEditor.
     */
    protected void doSetFocus() {
        comboBox.setFocus();
    }
    /**
     * The <code>ComboBoxCellEditor</code> implementation of
     * this <code>CellEditor</code> framework method sets the 
     * minimum width of the cell.  The minimum width is 10 characters
     * if <code>comboBox</code> is not <code>null</code> or <code>disposed</code>
     * eles it is 60 pixels to make sure the arrow button and some text is visible.
     * The list of CCombo will be wide enough to show its longest item.