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;
this.libUri = libUri;
}
+ protected List<Item> 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);
List<Item> turns = null;
List<Item> 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());
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);
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");
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) {
}
});
+ 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) {
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);
} 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:
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;
}
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()) {
return length;
}
+ public Double getRotationAngle() {
+ return rotationAngle;
+ }
+
public Double getDiameter() {
return diameter;
}