X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fproperty%2FAnnotatedPropertyTabContributorFactory.java;fp=org.simantics.g3d%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fproperty%2FAnnotatedPropertyTabContributorFactory.java;h=15b787d6d91781b8177e5b824c71eb4860cd611d;hb=adacf2d554617e099485801fbf480a7be166e39d;hp=344dd8cabc1be4805f46f07d46d3025252b880a7;hpb=d7f763511294343dca804fc5909a41fff39db91c;p=simantics%2F3d.git diff --git a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java index 344dd8ca..15b787d6 100644 --- a/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java +++ b/org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java @@ -39,7 +39,6 @@ import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent; import org.eclipse.jface.viewers.ColumnViewerEditorActivationListener; import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; import org.eclipse.jface.viewers.ColumnViewerEditorDeactivationEvent; -import org.eclipse.jface.viewers.ComboBoxCellEditor; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter; import org.eclipse.jface.viewers.ISelection; @@ -67,6 +66,7 @@ import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.IWorkbenchSite; +import org.simantics.browsing.ui.swt.ComboBoxCellEditor2; import org.simantics.db.management.ISessionContext; import org.simantics.g3d.property.annotations.CompoundGetPropertyValue; import org.simantics.g3d.property.annotations.CompoundSetPropertyValue; @@ -870,7 +870,8 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri int index; NodeMap nodeMap; TableViewer viewer; - CellEditor editor; + CellEditor propertyItemEditor; + Map comboEditors = new HashMap<>(); public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap nodeMap) { super(viewer); @@ -897,38 +898,52 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri IPropertyItem item = (IPropertyItem)element; if (tab.getManipulator(item).getValueCount() <= index) return null; - if (editor == null) - if (item instanceof PropertyItem) - editor = new TextCellEditor(viewer.getTable(),SWT.NONE) { - @Override - public void activate() { - tab.setEditing(true); - } - - @Override - public void deactivate() { - super.deactivate(); - tab.setEditing(false); - } - }; - else if (item instanceof ComboPropertyItem) { - ComboPropertyItem comboPropertyItem = (ComboPropertyItem)item; - ComboPropertyManipulator manipulator = (ComboPropertyManipulator)tab.manipulators.get(comboPropertyItem); - editor = new ComboBoxCellEditor(viewer.getTable(), manipulator.getItems()) { - @Override - public void activate() { - tab.setEditing(true); - } - - @Override - public void deactivate() { - super.deactivate(); - tab.setEditing(false); - } - }; - } - if (DEBUG)System.err.println("CELL EDITOR: " + element); - return editor; + if (item instanceof PropertyItem) { + if (propertyItemEditor == null) { + propertyItemEditor = new TextCellEditor(viewer.getTable(),SWT.NONE) { + @Override + public void activate() { + tab.setEditing(true); + } + + @Override + public void deactivate() { + super.deactivate(); + tab.setEditing(false); + } + }; + } + + if (DEBUG) System.err.println("CELL EDITOR: " + element); + return propertyItemEditor; + } + else if (item instanceof ComboPropertyItem) { + ComboPropertyItem comboPropertyItem = (ComboPropertyItem)item; + CellEditor editor = comboEditors.get(comboPropertyItem); + if (editor == null) { + ComboPropertyManipulator manipulator = (ComboPropertyManipulator)tab.manipulators.get(comboPropertyItem); + editor = new ComboBoxCellEditor2(viewer.getTable(), manipulator.getItems(), SWT.DROP_DOWN | SWT.READ_ONLY) { + @Override + public void activate() { + tab.setEditing(true); + } + + @Override + public void deactivate() { + super.deactivate(); + tab.setEditing(false); + } + }; + + comboEditors.put(comboPropertyItem, editor); + } + + if (DEBUG) System.err.println("CELL EDITOR: " + element); + return editor; + } + else { + throw new IllegalStateException("Unsupported property item type " + item.getClass().getName()); + } } @Override