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);