diff options
author | Dirk Fauth | 2016-12-01 21:20:13 +0000 |
---|---|---|
committer | Dirk Fauth | 2016-12-02 19:45:07 +0000 |
commit | 2a2804efc10b26cd4d1f1829ed1b112bb75fa565 (patch) | |
tree | 8888e9dd4f7c58057cdbb77d4e884aa6a5f1cdad | |
parent | 2ff043643a5911226b8284b73b2dca4b06450bf5 (diff) | |
download | org.eclipse.nebula.widgets.nattable-2a2804efc10b26cd4d1f1829ed1b112bb75fa565.tar.gz org.eclipse.nebula.widgets.nattable-2a2804efc10b26cd4d1f1829ed1b112bb75fa565.tar.xz org.eclipse.nebula.widgets.nattable-2a2804efc10b26cd4d1f1829ed1b112bb75fa565.zip |
Bug 508565 - Potential concurrency issues in ComboBoxCellEditor
Change-Id: Id70950dfbca47d3831fc020b55bfe42cba6b06c6
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
-rw-r--r-- | org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java index cc15cfa0..60088eb5 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/edit/editor/ComboBoxCellEditor.java @@ -149,6 +149,13 @@ public class ComboBoxCellEditor extends AbstractCellEditor { protected Image iconImage; /** + * The list of the canonical values that are currently shown in the opened + * NatCombo. Needed in case of multi selection and dynamic changing content + * via data provider. + */ + private List<?> currentCanonicalValues; + + /** * Create a new single selection {@link ComboBoxCellEditor} based on the * given list of items, showing the default number of items in the dropdown * of the combo. @@ -282,14 +289,8 @@ public class ComboBoxCellEditor extends AbstractCellEditor { // Item selected from list if (selectionIndices.length > 0) { - List<?> values = null; - if (this.dataProvider != null) { - values = this.dataProvider.getValues(getColumnIndex(), getRowIndex()); - } else { - values = this.canonicalValues; - } for (int i : selectionIndices) { - result.add(values.get(i)); + result.add(this.currentCanonicalValues.get(i)); } } else { // if there is no selection in the dropdown, we need to check if @@ -357,14 +358,13 @@ public class ComboBoxCellEditor extends AbstractCellEditor { private void fillCombo() { List<String> displayValues = new ArrayList<String>(); - List<?> values; if (this.dataProvider != null) { - values = this.dataProvider.getValues(getColumnIndex(), getRowIndex()); + this.currentCanonicalValues = this.dataProvider.getValues(getColumnIndex(), getRowIndex()); } else { - values = this.canonicalValues; + this.currentCanonicalValues = this.canonicalValues; } - for (Object canonicalValue : values) { + for (Object canonicalValue : this.currentCanonicalValues) { Object displayValue = this.displayConverter.canonicalToDisplayValue( this.layerCell, this.configRegistry, canonicalValue); displayValues.add(displayValue != null ? displayValue.toString() : ""); //$NON-NLS-1$ @@ -374,6 +374,12 @@ public class ComboBoxCellEditor extends AbstractCellEditor { } @Override + public void close() { + super.close(); + this.currentCanonicalValues = null; + } + + @Override public Object getEditorValue() { if (!this.multiselect) { return this.combo.getSelection()[0]; |