]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java
Tag user modifiable length
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / dialog / ComponentSelectionDialog.java
index 30f2540d5ccee1be1953ff0db181d2247c24a2ae..75b124119830199167eb827c1618b666a44b8161 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.plant3d.Activator;
+import org.simantics.plant3d.ontology.Plant3D;
 import org.simantics.plant3d.scenegraph.EndComponent;
 import org.simantics.plant3d.scenegraph.InlineComponent;
 import org.simantics.plant3d.scenegraph.Nozzle;
@@ -48,6 +49,8 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
 
        private ResourceManager resourceManager;
        
+       private String libUri;
+       
        private Item selected;
        private Set<PositionType> allowed;
        private Set<PositionType> filterAllowed;
@@ -81,14 +84,19 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
        
        
        public ComponentSelectionDialog(Shell parentShell, Set<PositionType> allowed, PipelineComponent component){
-               super(parentShell);
-               this.allowed = allowed;
-               this.component = component;
-               filterAllowed = new HashSet<PositionType>();
-               insertAdjustable = component instanceof InlineComponent ? ((InlineComponent)component).isVariableLength() : false;
-               lenghtAdjustable = false;
+               this(parentShell, allowed, component, Plant3D.URIs.Builtin);
        }
        
+       public ComponentSelectionDialog(Shell parentShell, Set<PositionType> allowed, PipelineComponent component, String libUri){
+        super(parentShell);
+        this.allowed = allowed;
+        this.component = component;
+        filterAllowed = new HashSet<PositionType>();
+        insertAdjustable = component instanceof InlineComponent ? ((InlineComponent)component).isVariableLength() : false;
+        lenghtAdjustable = false;
+        this.libUri = libUri;
+    }
+       
        @Override
        protected Control createDialogArea(Composite parent) {
                resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent);
@@ -115,9 +123,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange
                List<Item> turns = null;
                List<Item> inlines = null;
                try {
-                       ends = P3DUtil.getEnds();
-                       turns= P3DUtil.getTurns();
-                       inlines = P3DUtil.getInlines();
+                       ends = P3DUtil.getEnds(libUri);
+                       turns= P3DUtil.getTurns(libUri);
+                       inlines = P3DUtil.getInlines(libUri);
                } catch (DatabaseException e) {
                        Label label = new Label(composite, SWT.NONE);
                        label.setText("Cannot load pipeline components: " + e.getMessage());
@@ -326,7 +334,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:
@@ -385,7 +393,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);