From: Reino Ruusu Date: Wed, 1 Apr 2020 11:46:20 +0000 (+0300) Subject: Disable insertion position buttons when inserting to a connected pipe X-Git-Tag: v1.43.0~30 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F84%2F4084%2F1;p=simantics%2F3d.git Disable insertion position buttons when inserting to a connected pipe gitlab #112 Change-Id: I7629729cd22768a4995e4bf18288e2a4f41ecae0 --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java index fb506092..df00bc39 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java @@ -134,6 +134,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange dialogSettings = settings.getSection(DIALOG); if (dialogSettings == null) dialogSettings = settings.addNewSection(DIALOG); + + if (component.getNext() != null && component.getPrevious() != null) + insertPosition = PositionType.PREVIOUS; } public void setLengthFactor(double lengthFactor) { @@ -267,6 +270,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange horizFillData.applyTo(buttonComposite); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); + startButton.setSelection(insertPosition == PositionType.PREVIOUS); + middleButton.setSelection(insertPosition == PositionType.SPLIT); + endButton.setSelection(insertPosition == PositionType.NEXT); + startButton.setEnabled(false); middleButton.setEnabled(false); endButton.setEnabled(false); @@ -290,7 +297,6 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange updateInsertPosition(PositionType.NEXT); } }); - endButton.setSelection(true); label = new Label(composite, SWT.NONE); label.setText("Name"); @@ -428,9 +434,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange private void updateInsertPosition(PositionType type) { if (insertPosition == type) return; - endButton.setSelection(type == PositionType.NEXT); - middleButton.setSelection(type == PositionType.SPLIT); startButton.setSelection(type == PositionType.PREVIOUS); + middleButton.setSelection(type == PositionType.SPLIT); + endButton.setSelection(type == PositionType.NEXT); insertPosition = type; } @@ -481,7 +487,15 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange } else { lenghtAdjustable = ((selected.getType() == Type.INLINE) && (selected.isVariable() || selected.isModifiable())); - if (insertAdjustable) { + + if (component.getNext() != null && component.getPrevious() != null) { + // We are inserting to a fully connected variable length component + // only allow insertion within the component + startButton.setEnabled(false); + middleButton.setEnabled(false); + endButton.setEnabled(false); + updateInsertPosition(PositionType.PREVIOUS); + } else if (insertAdjustable) { switch (selected.getType()) { case END: startButton.setEnabled(false);