]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
Adding specified equipment with nozzles did not work
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / dialog / ComponentSelectionDialog.java
index 93a305bb9d74ea67fddb1ed35c088c09044d12e4..7c124eb0ecb269076d4979bc1155305befc385dd 100644 (file)
@@ -97,6 +97,18 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
         this.libUri = libUri;
     }
        
+        protected List<Item> getItems(Class c, String libUri) throws DatabaseException{
+            if (InlineComponent.class.equals(c)) {
+                return P3DUtil.getInlines(libUri);
+            } else if (TurnComponent.class.equals(c)) {
+                return P3DUtil.getTurns(libUri);
+            } else if (EndComponent.class.equals(c)) {
+                return P3DUtil.getEnds(libUri);
+            } else {
+                return null;
+            }
+        }
+       
        @Override
        protected Control createDialogArea(Composite parent) {
                resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
@@ -123,9 +135,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                List<Item> turns = null;
                List<Item> inlines = null;
                try {
-                       ends = P3DUtil.getEnds(libUri);
-                       turns= P3DUtil.getTurns(libUri);
-                       inlines = P3DUtil.getInlines(libUri);
+                       ends = getItems(EndComponent.class, libUri);
+                       turns= getItems(TurnComponent.class, libUri);
+                       inlines = getItems(InlineComponent.class, libUri);
                } catch (DatabaseException e) {
                        Label label = new Label(composite, SWT.NONE);
                        label.setText("Cannot load pipeline components: " + e.getMessage());
@@ -334,7 +346,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                } else if (selected.isCode()) {// TODO : instead of disabling the button, we should filter the content.
                        ok = false;
                } else {
-                       lenghtAdjustable = ((selected.getType() == Type.INLINE) && selected.isVariable());
+                       lenghtAdjustable = ((selected.getType() == Type.INLINE) && (selected.isVariable() || selected.isModifiable()));
                        if (insertAdjustable) {
                                switch (selected.getType()) {
                                case END:
@@ -393,7 +405,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                                middleButton.setEnabled(false);
                                endButton.setEnabled(true);
                        }
-                       if (selected.isVariable()) {
+                       if (selected.isVariable() || selected.isModifiable()) {
                                if (selected.getType() == Type.INLINE) {
                                        filterAllowed.add(PositionType.NEXT);
                                        filterAllowed.add(PositionType.PREVIOUS);