X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fdialog%2FComponentSelectionDialog.java;h=75b124119830199167eb827c1618b666a44b8161;hb=refs%2Fchanges%2F28%2F3528%2F1;hp=30f2540d5ccee1be1953ff0db181d2247c24a2ae;hpb=53d55c24c779745f188bdb18d32f71d20acb61b2;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java index 30f2540d..75b12411 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java @@ -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 allowed; private Set filterAllowed; @@ -81,14 +84,19 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange public ComponentSelectionDialog(Shell parentShell, Set allowed, PipelineComponent component){ - super(parentShell); - this.allowed = allowed; - this.component = component; - filterAllowed = new HashSet(); - insertAdjustable = component instanceof InlineComponent ? ((InlineComponent)component).isVariableLength() : false; - lenghtAdjustable = false; + this(parentShell, allowed, component, Plant3D.URIs.Builtin); } + public ComponentSelectionDialog(Shell parentShell, Set allowed, PipelineComponent component, String libUri){ + super(parentShell); + this.allowed = allowed; + this.component = component; + filterAllowed = new HashSet(); + 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 turns = null; List 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);