From: Marko Luukkainen Date: Mon, 5 Aug 2019 13:26:38 +0000 (+0300) Subject: Fix cap typing. X-Git-Tag: v1.43.0~236 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F61%2F3061%2F1;p=simantics%2F3d.git Fix cap typing. Additionally, fixed a NPE when user clicks empty space in component selection dialog. gitlab #18 Change-Id: If30d7f51bcaeadf2f6643055e656817f36a3a432 --- diff --git a/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph b/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph index 6ab68fcc..1f1f7cff 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph @@ -129,7 +129,7 @@ P3D.Builtin.GateValve filterAllowed = new HashSet(); 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);