X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fdialog%2FComponentSelectionDialog.java;h=00b52f3bb1073b0e12e1cb43dd64b5b18f47b97d;hb=f8e541f1d66cda57802da11aaa715b9f9c1c79a9;hp=93a305bb9d74ea67fddb1ed35c088c09044d12e4;hpb=dad2672f12421f28805df9d97acf20d0a8efe71f;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 93a305bb..00b52f3b 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/dialog/ComponentSelectionDialog.java @@ -62,16 +62,23 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange private Double angle; private Double length; + private Double rotationAngle; + // In-line component private Text lengthText; + // Turn component private Text angleText; + // Rotated In-line, or turn conponent. + private Text rotationAngleText; + // Input for new PipeRun private Double diameter; private Double turnRadius; private Text diameterText; private Text turnRadiusText; + // Position selection private Button startButton; private Button middleButton; private Button endButton; @@ -97,6 +104,18 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange this.libUri = libUri; } + protected List getItems(Class c, String libUri) throws DatabaseException{ + if (InlineComponent.class.equals(c)) { + return P3DUtil.getInlines(libUri); + } else if (TurnComponent.class.equals(c)) { + return P3DUtil.getTurns(libUri); + } else if (EndComponent.class.equals(c)) { + return P3DUtil.getEnds(libUri); + } else { + return null; + } + } + @Override protected Control createDialogArea(Composite parent) { resourceManager = new LocalResourceManager(JFaceResources.getResources(), parent); @@ -123,9 +142,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange List turns = null; List inlines = null; try { - ends = P3DUtil.getEnds(libUri); - turns= P3DUtil.getTurns(libUri); - inlines = P3DUtil.getInlines(libUri); + ends = getItems(EndComponent.class, libUri); + turns= getItems(TurnComponent.class, libUri); + inlines = getItems(InlineComponent.class, libUri); } catch (DatabaseException e) { Label label = new Label(composite, SWT.NONE); label.setText("Cannot load pipeline components: " + e.getMessage()); @@ -186,6 +205,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange startButton.setImage(resourceManager.createImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/insert_start.png"))); middleButton.setImage(resourceManager.createImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/insert_middle.png"))); endButton.setImage(resourceManager.createImage(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/insert_end.png"))); + startButton.setToolTipText("Overlapping insert"); + middleButton.setToolTipText("Cutting insert"); + endButton.setToolTipText("Adding insert"); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(buttonComposite); GridLayoutFactory.fillDefaults().numColumns(3).applyTo(buttonComposite); @@ -220,6 +242,9 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange label = new Label(composite, SWT.NONE); label.setText("Angle"); angleText = new Text(composite, SWT.SINGLE|SWT.BORDER); + label = new Label(composite, SWT.NONE); + label.setText("Rotation angle"); + rotationAngleText = new Text(composite, SWT.SINGLE|SWT.BORDER); label = new Label(composite, SWT.NONE); label.setText("Diameter"); @@ -230,9 +255,11 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange lengthText.setEnabled(false); angleText.setEnabled(false); + rotationAngleText.setEnabled(false); turnRadiusText.setEnabled(false); diameterText.setEnabled(false); + lengthText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { @@ -257,6 +284,18 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange } }); + rotationAngleText.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + try { + rotationAngle = Double.parseDouble(rotationAngleText.getText()); + } catch (NumberFormatException err) { + rotationAngle = null; + } + validate(); + } + }); + diameterText.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { @@ -283,6 +322,7 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(lengthText); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(angleText); + GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(rotationAngleText); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(diameterText); GridDataFactory.fillDefaults().grab(true, false).align(SWT.FILL, SWT.TOP).applyTo(turnRadiusText); @@ -334,7 +374,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: @@ -393,18 +433,20 @@ 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); - if (inlineSplit) { + if (inlineSplit && selected.isVariable()) { lengthText.setEnabled(false); angleText.setEnabled(false); + rotationAngleText.setEnabled(selected.isRotated()); ok = false; } else { lengthText.setEnabled(true); angleText.setEnabled(false); + rotationAngleText.setEnabled(selected.isRotated()); if (length == null) ok = false; } @@ -413,16 +455,20 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange filterAllowed.add(PositionType.PREVIOUS); lengthText.setEnabled(false); angleText.setEnabled(true); + rotationAngleText.setEnabled(true); if (angle == null) ok = false; } else { - // this should not happen + // this should not happen, since end components should not have variable, or modifiable flag. lengthText.setEnabled(false); angleText.setEnabled(false); + rotationAngleText.setEnabled(false); + } } else { lengthText.setEnabled(false); - angleText.setEnabled(false); + angleText.setEnabled(false); + rotationAngleText.setEnabled(selected.getType() == Type.TURN || selected.isRotated()); } if (selected.isSizeChange()) { @@ -483,6 +529,10 @@ public class ComponentSelectionDialog extends Dialog implements ISelectionChange return length; } + public Double getRotationAngle() { + return rotationAngle; + } + public Double getDiameter() { return diameter; }