]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Merge "Force zero offset for concentric reducers" into release/1.35.2
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 5 Dec 2019 13:44:55 +0000 (13:44 +0000)
committerGerrit Code Review <gerrit2@simantics>
Thu, 5 Dec 2019 13:44:55 +0000 (13:44 +0000)
org.simantics.g3d/src/org/simantics/g3d/property/AnnotatedPropertyTabContributorFactory.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/TurnComponent.java

index 344dd8cabc1be4805f46f07d46d3025252b880a7..3fcb19f5e21f62fe11b9ab028e6ce6ce62f35bc4 100644 (file)
@@ -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;
@@ -599,23 +599,12 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
                        }
                        ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(
                                        viewer) {
-                               Object lastSource = null;
-                               int clickCount = 0;
-                               
                                protected boolean isEditorActivationEvent(
                                                ColumnViewerEditorActivationEvent event) {
-                                       if (!event.getSource().equals(lastSource))
-                                               clickCount = 0;
-                                       
-                                       lastSource = event.getSource();
-                                       
-                                       if (event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION)
-                                               clickCount += 1;
-                                               
                                        return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL
+                                                       || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION
                                                        || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION
-                                                       || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_CLICK_SELECTION && clickCount >= 2
-                                                       || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR)
+                                                       || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && (event.keyCode == SWT.CR || event.keyCode == SWT.F2))
                                                        || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC;
                                }
                        };
@@ -870,7 +859,8 @@ public class AnnotatedPropertyTabContributorFactory implements PropertyTabContri
                int index;
                NodeMap<?,?,?> nodeMap;
                TableViewer viewer;
-               CellEditor editor;
+               CellEditor propertyItemEditor;
+               Map<ComboPropertyItem,CellEditor> comboEditors = new HashMap<>();
 
                public PropertyEditingSupport(AnnotatedPropertyTab tab, TableViewer viewer, int index, NodeMap<?,?,?> nodeMap) {
                        super(viewer);
@@ -897,38 +887,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
index 5c3a1e981ee16fd1bd07674b62df1e8b8a9aef95..794c53294a0197210674e6bb416aefa5b70401e2 100644 (file)
@@ -140,7 +140,7 @@ public class TurnComponent extends PipelineComponent {
     public void setTurnRadiusIndex(Integer turnRadiusIndex) {
            if (this.turnRadiusIndex == turnRadiusIndex)
                return;
-           if (turnRadiusIndex == null)
+           if (turnRadiusIndex == null || turnRadiusIndex < 0)
                return;
            if (turnRadiusIndex != null && getPipeRun() != null) {
                if (getPipeRun().getTurnRadiusArray().length <= turnRadiusIndex)