X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Factions%2FAddComponentAction.java;h=d9ee9d70849188f7f50e7ba0bc2b58513609c3ac;hb=b464f638f47c449c3ddad850a2466773c3453999;hp=ea25230ab57c745bbe8e229e648d5604c293d4a7;hpb=b35befd422dd71c2358bcc3b198f38d52ac0b966;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java index ea25230a..d9ee9d70 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/actions/AddComponentAction.java @@ -6,6 +6,7 @@ import java.awt.event.MouseWheelEvent; import java.util.HashSet; import java.util.Set; +import org.eclipse.jface.resource.ResourceLocator; import org.eclipse.swt.widgets.Display; import org.simantics.db.Resource; import org.simantics.g3d.math.MathTools; @@ -53,7 +54,7 @@ public class AddComponentAction extends vtkSwtAction { super(panel); this.root = root; setText("Add Component"); - setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/Component.png")); + setImageDescriptor(ResourceLocator.imageDescriptorFromBundle(Activator.PLUGIN_ID, "icons/Component.png").get()); nodeMap = root.getNodeMap(); gizmo = new TerminalSelectionGizmo(panel); this.libUri = libUri; @@ -81,6 +82,8 @@ public class AddComponentAction extends vtkSwtAction { setEnabled(allowed.size() > 0); } + private String name; + private Double length; private Double angle; private Double rotationAngle; @@ -91,11 +94,16 @@ public class AddComponentAction extends vtkSwtAction { public void run() { ComponentSelectionDialog dialog = new ComponentSelectionDialog(Display.getCurrent().getActiveShell(), allowed, component, libUri); + + // Set list of already reserved component names + dialog.addUsedNames(ComponentUtils.getPipelineComponentNames(root)); + if (dialog.open() == ComponentSelectionDialog.CANCEL) return; toAdd = dialog.getSelected(); if (toAdd == null) return; + this.name = dialog.getName(); this.insertPosition = dialog.getInsertPosition(); this.insertAdjustable = dialog.isInsertAdjustable(); this.lengthAdjustable = dialog.isLenghtAdjustable(); @@ -174,6 +182,7 @@ public class AddComponentAction extends vtkSwtAction { try { InsertInstruction inst = new InsertInstruction(); inst.typeUri = toAdd.getUri(); + inst.name = name; inst.angle = angle != null ? MathTools.degToRad(angle) : null; inst.diameter = diameter; inst.length = length;