1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.dialogs;
\r
13 import org.eclipse.jface.dialogs.Dialog;
\r
14 import org.eclipse.jface.dialogs.IDialogConstants;
\r
15 import org.eclipse.swt.SWT;
\r
16 import org.eclipse.swt.events.KeyEvent;
\r
17 import org.eclipse.swt.events.KeyListener;
\r
18 import org.eclipse.swt.events.SelectionEvent;
\r
19 import org.eclipse.swt.events.SelectionListener;
\r
20 import org.eclipse.swt.layout.GridData;
\r
21 import org.eclipse.swt.widgets.Button;
\r
22 import org.eclipse.swt.widgets.Composite;
\r
23 import org.eclipse.swt.widgets.Control;
\r
24 import org.eclipse.swt.widgets.Label;
\r
25 import org.eclipse.swt.widgets.Shell;
\r
26 import org.eclipse.swt.widgets.Text;
\r
28 public class FloorConfigureDialog extends Dialog implements KeyListener,SelectionListener {
\r
30 private boolean floorEnabled = true;
\r
31 private double floorHeight = 0.0;
\r
33 private Text floorHeightText = null;
\r
34 private Button floorEnabledButton = null;
\r
36 public FloorConfigureDialog(Shell shell) {
\r
41 protected Control createDialogArea(Composite parent) {
\r
42 Composite composite = (Composite) super.createDialogArea(parent);
\r
43 Label label = new Label(composite, SWT.WRAP);
\r
44 label.setText("Configure floor");
\r
45 GridData data = new GridData(GridData.GRAB_HORIZONTAL
\r
46 | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL
\r
47 | GridData.VERTICAL_ALIGN_CENTER);
\r
49 data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
\r
50 label.setLayoutData(data);
\r
51 label.setFont(parent.getFont());
\r
52 floorEnabledButton = new Button(composite,SWT.CHECK);
\r
53 floorEnabledButton.setText("Enabled");
\r
54 label = new Label(composite, SWT.WRAP);
\r
55 label.setText("Height");
\r
56 label.setLayoutData(data);
\r
57 label.setFont(parent.getFont());
\r
58 floorHeightText = new Text(composite,SWT.NONE);
\r
61 floorHeightText.addKeyListener(this);
\r
62 floorEnabledButton.addSelectionListener(this);
\r
63 floorEnabledButton.setSelection(floorEnabled);
\r
64 floorHeightText.setText(Double.toString(floorHeight));
\r
70 protected void configureShell(Shell newShell) {
\r
71 super.configureShell(newShell);
\r
72 newShell.setText("Configure floor");
\r
75 public void keyPressed(KeyEvent e) {
\r
79 public void keyReleased(KeyEvent e) {
\r
82 floorHeight = Double.parseDouble(floorHeightText.getText());
\r
83 } catch (NumberFormatException err) {
\r
87 this.getButton(IDialogConstants.OK_ID).setEnabled(true);
\r
89 this.getButton(IDialogConstants.OK_ID).setEnabled(false);
\r
93 public void widgetDefaultSelected(SelectionEvent e) {
\r
97 public void widgetSelected(SelectionEvent e) {
\r
98 floorEnabled = floorEnabledButton.getSelection();
\r
101 public boolean isFloorEnabled() {
\r
102 return floorEnabled;
\r
105 public double getFloorHeight() {
\r
106 return floorHeight;
\r