import java.util.HashSet;
import java.util.Set;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ResourceLocator;
import org.eclipse.swt.widgets.Display;
import org.simantics.db.Resource;
private String libUri;
+ private double lengthFactor = 1.0;
+
public AddComponentAction(InteractiveVtkComposite panel, P3DRootNode root, String libUri) {
super(panel);
this.root = root;
this.libUri = libUri;
}
+ public void setLengthFactor(double lengthFactor) {
+ this.lengthFactor = lengthFactor;
+ }
+
public void setComponent(PipelineComponent component) {
this.component = component;
// Set list of already reserved component names
dialog.addUsedNames(ComponentUtils.getPipelineComponentNames(root));
+ dialog.setLengthFactor(lengthFactor);
if (dialog.open() == ComponentSelectionDialog.CANCEL)
return;
public void doInsert(PositionType position) {
try {
+ if (position == PositionType.SPLIT && length != null && length > component.getControlPoint().getLength()) {
+ MessageDialog.openError(panel.getComponent().getShell(), "Error", "There is no room for a component of length " + length * lengthFactor + " units");
+ return;
+ }
+
InsertInstruction inst = new InsertInstruction();
inst.typeUri = toAdd.getUri();
inst.name = name;