1 package org.simantics.processeditor.dialogs;
\r
3 import org.eclipse.jface.dialogs.Dialog;
\r
4 import org.eclipse.jface.dialogs.IDialogConstants;
\r
5 import org.eclipse.swt.SWT;
\r
6 import org.eclipse.swt.events.KeyEvent;
\r
7 import org.eclipse.swt.events.KeyListener;
\r
8 import org.eclipse.swt.events.SelectionEvent;
\r
9 import org.eclipse.swt.events.SelectionListener;
\r
10 import org.eclipse.swt.layout.GridData;
\r
11 import org.eclipse.swt.widgets.Button;
\r
12 import org.eclipse.swt.widgets.Composite;
\r
13 import org.eclipse.swt.widgets.Control;
\r
14 import org.eclipse.swt.widgets.Label;
\r
15 import org.eclipse.swt.widgets.Shell;
\r
16 import org.eclipse.swt.widgets.Text;
\r
18 public class FloorConfigureDialog extends Dialog implements KeyListener,SelectionListener {
\r
20 private boolean floorEnabled = true;
\r
21 private double floorHeight = 0.0;
\r
23 private Text floorHeightText = null;
\r
24 private Button floorEnabledButton = null;
\r
26 public FloorConfigureDialog(Shell shell) {
\r
31 protected Control createDialogArea(Composite parent) {
\r
32 Composite composite = (Composite) super.createDialogArea(parent);
\r
33 Label label = new Label(composite, SWT.WRAP);
\r
34 label.setText("Configure floor");
\r
35 GridData data = new GridData(GridData.GRAB_HORIZONTAL
\r
36 | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
\r
37 | GridData.VERTICAL_ALIGN_CENTER);
\r
39 data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
\r
40 label.setLayoutData(data);
\r
41 label.setFont(parent.getFont());
\r
42 floorEnabledButton = new Button(composite,SWT.CHECK);
\r
43 floorEnabledButton.setText("Enabled");
\r
44 label = new Label(composite, SWT.WRAP);
\r
45 label.setText("Height");
\r
46 label.setLayoutData(data);
\r
47 label.setFont(parent.getFont());
\r
48 floorHeightText = new Text(composite,SWT.NONE);
\r
51 floorHeightText.addKeyListener(this);
\r
52 floorEnabledButton.addSelectionListener(this);
\r
53 floorEnabledButton.setSelection(floorEnabled);
\r
54 floorHeightText.setText(Double.toString(floorHeight));
\r
60 protected void configureShell(Shell newShell) {
\r
61 super.configureShell(newShell);
\r
62 newShell.setText("Configure floor");
\r
65 public void keyPressed(KeyEvent e) {
\r
69 public void keyReleased(KeyEvent e) {
\r
72 floorHeight = Double.parseDouble(floorHeightText.getText());
\r
73 } catch (NumberFormatException err) {
\r
77 this.getButton(IDialogConstants.OK_ID).setEnabled(true);
\r
79 this.getButton(IDialogConstants.OK_ID).setEnabled(false);
\r
83 public void widgetDefaultSelected(SelectionEvent e) {
\r
87 public void widgetSelected(SelectionEvent e) {
\r
88 floorEnabled = floorEnabledButton.getSelection();
\r
91 public boolean isFloorEnabled() {
\r
92 return floorEnabled;
\r
95 public double getFloorHeight() {
\r