]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix cap typing. 61/3061/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 5 Aug 2019 13:26:38 +0000 (16:26 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 5 Aug 2019 13:26:38 +0000 (16:26 +0300)
Additionally, fixed a NPE when user clicks empty space in component
selection dialog.

gitlab #18

Change-Id: If30d7f51bcaeadf2f6643055e656817f36a3a432

org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph
org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java

index 6ab68fcc5c5aa9fcd347604deffaad9f4df1260e..1f1f7cff06702d8a5f5d5b25b470bef457b5a99c 100644 (file)
@@ -129,7 +129,7 @@ P3D.Builtin.GateValve <T P3D.InlineComponent : P3D.InlineComponent
            L0.HasName "radius" : L0.String
            P3D.hasParameterValue 0.1 : L0.Double
            
-P3D.Builtin.Cap <T P3D.EndComponent : P3D.InlineComponent
+P3D.Builtin.Cap <T P3D.EndComponent : P3D.EndComponent
     @L0.assert P3D.hasGeometry P3D.Builtin.CapGeometryProvider
     @L0.assert P3D.hasParameter
          _ :P3D.Parameter
index 33d5882c2f45f57956a75be9b4b88158a96edce5..e5e220af561866364d72a7b6427b8474e1598527 100644 (file)
@@ -225,77 +225,81 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                filterAllowed.clear();
                Set<PositionType> filterAllowed = new HashSet<PositionType>();
                boolean ok = true;
-               if (selected.isCode())// TODO : instead of disabling the button, we should filter the content.
+               if (selected == null) {
                        ok = false;
+               } else if (selected.isCode()) {// TODO : instead of disabling the button, we should filter the content.
+                       ok = false;
+               } else {
+                       if (selected.isVariable()) {
+                               if (selected.getType() == Type.INLINE) {
+                                       filterAllowed.add(PositionType.NEXT);
+                                       filterAllowed.add(PositionType.PREVIOUS);
+                                       if (inlineSplit) {
+                                               lengthText.setEnabled(false);
+                                               angleText.setEnabled(false);
+                                               ok = false;
+                                               
+                                       } else {
+                                               lengthText.setEnabled(true);
+                                               angleText.setEnabled(false);
+                                               if (length == null)
+                                                       ok = false;
+                                       }
+                               } else if (selected.getType() == Type.TURN) {
+                                       filterAllowed.add(PositionType.NEXT);
+                                       filterAllowed.add(PositionType.PREVIOUS);
+                                       lengthText.setEnabled(false);
+                                       angleText.setEnabled(true);
+                                       if (angle == null)
+                                               ok = false;
+                               } else {
+                                       // this should not happen
+                                       lengthText.setEnabled(false);
+                                       angleText.setEnabled(false);
+                               }
+                       } else {
+                               lengthText.setEnabled(false);
+                               angleText.setEnabled(false);                    
+                       }
                
-               if (selected.isVariable()) {
-                       if (selected.getType() == Type.INLINE) {
+                       if (selected.isSizeChange()) {
                                filterAllowed.add(PositionType.NEXT);
                                filterAllowed.add(PositionType.PREVIOUS);
                                if (inlineSplit) {
-                                       lengthText.setEnabled(false);
-                                       angleText.setEnabled(false);
+                                       turnRadiusText.setEnabled(false);
+                                       diameterText.setEnabled(false);
                                        ok = false;
-                                       
                                } else {
-                                       lengthText.setEnabled(true);
-                                       angleText.setEnabled(false);
-                                       if (length == null)
+                                       turnRadiusText.setEnabled(true);
+                                       diameterText.setEnabled(true);
+                                       if (diameter == null || turnRadius == null)
                                                ok = false;
                                }
-                       } else if (selected.getType() == Type.TURN) {
-                               filterAllowed.add(PositionType.NEXT);
-                               filterAllowed.add(PositionType.PREVIOUS);
-                               lengthText.setEnabled(false);
-                               angleText.setEnabled(true);
-                               if (angle == null)
-                                       ok = false;
+                               
                        } else {
-                               // this should not happen
-                               lengthText.setEnabled(false);
-                               angleText.setEnabled(false);
-                       }
-               } else {
-                       lengthText.setEnabled(false);
-                       angleText.setEnabled(false);                    
-               }
-               if (selected.isSizeChange()) {
-                       filterAllowed.add(PositionType.NEXT);
-                       filterAllowed.add(PositionType.PREVIOUS);
-                       if (inlineSplit) {
                                turnRadiusText.setEnabled(false);
                                diameterText.setEnabled(false);
-                               ok = false;
-                       } else {
-                               turnRadiusText.setEnabled(true);
-                               diameterText.setEnabled(true);
-                               if (diameter == null || turnRadius == null)
-                                       ok = false;
                        }
                        
-               } else {
-                       turnRadiusText.setEnabled(false);
-                       diameterText.setEnabled(false);
-               }
-               if (!selected.isSizeChange() && !selected.isVariable()) {
-                       switch (selected.getType()) {
-                               case END:
-                                       filterAllowed.add(PositionType.NEXT);
-                                       filterAllowed.add(PositionType.PREVIOUS);
-                                       break;
-                               case NOZZLE:
-                               case EQUIPMENT:
-                                       break;
-                               case INLINE:
-                                       filterAllowed.add(PositionType.NEXT);
-                                       filterAllowed.add(PositionType.PREVIOUS);
-                                       filterAllowed.add(PositionType.SPLIT);
-                               case TURN:
-                                       filterAllowed.add(PositionType.NEXT);
-                                       filterAllowed.add(PositionType.PREVIOUS);
+                       if (!selected.isSizeChange() && !selected.isVariable()) {
+                               switch (selected.getType()) {
+                                       case END:
+                                               filterAllowed.add(PositionType.NEXT);
+                                               filterAllowed.add(PositionType.PREVIOUS);
+                                               break;
+                                       case NOZZLE:
+                                       case EQUIPMENT:
+                                               break;
+                                       case INLINE:
+                                               filterAllowed.add(PositionType.NEXT);
+                                               filterAllowed.add(PositionType.PREVIOUS);
+                                               filterAllowed.add(PositionType.SPLIT);
+                                       case TURN:
+                                               filterAllowed.add(PositionType.NEXT);
+                                               filterAllowed.add(PositionType.PREVIOUS);
+                               }
                        }
                }
-               
                for (PositionType t : filterAllowed) {
                        if (allowed.contains(t))
                                this.filterAllowed.add(t);