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;
private String libUri;
+ private double lengthFactor = 1.0;
+
public AddComponentAction(InteractiveVtkComposite panel, P3DRootNode root, String libUri) {
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;
}
+ public void setLengthFactor(double lengthFactor) {
+ this.lengthFactor = lengthFactor;
+ }
+
public void setComponent(PipelineComponent component) {
this.component = component;
setEnabled(allowed.size() > 0);
}
+ private String name;
+
private Double length;
private Double angle;
private Double rotationAngle;
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));
+ dialog.setLengthFactor(lengthFactor);
+
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();
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;