]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
Hide insertion position controls when adding to a connected pipe
[simantics/3d.git] / 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);