]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Disable insertion position buttons when inserting to a connected pipe 62/4062/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 1 Apr 2020 11:46:20 +0000 (14:46 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 1 Apr 2020 11:56:52 +0000 (11:56 +0000)
gitlab #112

Change-Id: I7629729cd22768a4995e4bf18288e2a4f41ecae0
(cherry picked from commit f3f581189d66c01f258dcbecd6e3beb180a15fc6)

org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java

index fb5060922a7aaf24678c692686bee4fca59e001e..df00bc39f468804efcde3b91afa6d133087c1000 100644 (file)
@@ -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);