Bug 60462 [CellEditors] applyEditorValueAndDeactivate() in ComboBoxCellEditor gets index exception.
The problem is in this method. See line marked with "@ERROR" below. private void applyEditorValueAndDeactivate() { selection = comboBox.getSelectionIndex(); Object newValue = doGetValue(); markDirty(); boolean isValid = isCorrect(newValue); setValueValid(isValid); if (!isValid) { //@ERROR //THIS LINE CAUSES AN ERROR. IT ASSUMES SOMETHING IS SELECTED. IN EDIT //MODE, THIS IS NOT TRUE IF I JUST TYPE SOMETHING INTO THE CELL EDITOR. //IN THIS CASE, selection IS AN INVALID INDEX. setErrorMessage( MessageFormat.format(getErrorMessage(), new Object[] {items[selection]})); } fireApplyEditorValue(); deactivate(); }
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ComboBoxCellEditor.java
*******************************************************************************/
package org.eclipse.jface.viewers;
import java.text.MessageFormat;
import org.eclipse.jface.util.Assert;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.SelectionAdapter;
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;