]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Hide insertion position controls when adding to a connected pipe 08/4108/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Tue, 7 Apr 2020 10:17:21 +0000 (13:17 +0300)
committerReino Ruusu <reino.ruusu@semantum.fi>
Tue, 7 Apr 2020 10:17:21 +0000 (13:17 +0300)
gitlab #112

Change-Id: Ifebee86babe1a869e9dec1bffe4efaa47aa454d5

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

index df00bc39f468804efcde3b91afa6d133087c1000..56a81c49ccf961cbe7badc3be85edf48313bfdfc 100644 (file)
@@ -297,6 +297,11 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                                updateInsertPosition(PositionType.NEXT);
                        }
                });
+               
+               if (!hasInsertPosition()) {
+                       label.setVisible(false);
+                       buttonComposite.setVisible(false);
+               }
 
                label = new Label(composite, SWT.NONE);
                label.setText("Name");
@@ -431,6 +436,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                return composite;
        }
 
+       private boolean hasInsertPosition() {
+               return component.getNext() == null || component.getPrevious() == null;
+       }
+
        private void updateInsertPosition(PositionType type) {
                if (insertPosition == type)
                        return;
@@ -488,7 +497,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                        lenghtAdjustable = ((selected.getType() == Type.INLINE)
                                        && (selected.isVariable() || selected.isModifiable()));
                        
-                       if (component.getNext() != null && component.getPrevious() != null) {
+                       if (!hasInsertPosition()) {
                                // We are inserting to a fully connected variable length component
                                // only allow insertion within the component
                                startButton.setEnabled(false);