- private class FloorConfigureDialog extends Dialog implements KeyListener,SelectionListener {\r
- \r
- private boolean floorEnabled = true;\r
- private double floorHeight = 0.0;\r
- \r
- private Text floorHeightText = null;\r
- private Button floorEnabledButton = null;\r
- \r
- public FloorConfigureDialog(Shell shell) {\r
- super(shell);\r
- }\r
- \r
- @Override\r
- protected Control createDialogArea(Composite parent) {\r
- Composite composite = (Composite) super.createDialogArea(parent);\r
- Label label = new Label(composite, SWT.WRAP);\r
- label.setText("Configure floor");\r
- GridData data = new GridData(GridData.GRAB_HORIZONTAL\r
- | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL\r
- | GridData.VERTICAL_ALIGN_CENTER);\r
- \r
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);\r
- label.setLayoutData(data);\r
- label.setFont(parent.getFont());\r
- floorEnabledButton = new Button(composite,SWT.CHECK);\r
- floorEnabledButton.setText("Enabled");\r
- label = new Label(composite, SWT.WRAP);\r
- label.setText("Height");\r
- label.setLayoutData(data);\r
- label.setFont(parent.getFont());\r
- floorHeightText = new Text(composite,SWT.NONE);\r
- \r
- \r
- floorHeightText.addKeyListener(this);\r
- floorEnabledButton.addSelectionListener(this);\r
- floorEnabledButton.setSelection(floorEnabled);\r
- floorHeightText.setText(Double.toString(floorHeight));\r
- \r
- return composite;\r
- }\r
- \r
- @Override\r
- protected void configureShell(Shell newShell) {\r
- super.configureShell(newShell);\r
- newShell.setText("Configure floor");\r
- }\r
- \r
- public void keyPressed(KeyEvent e) {\r
- \r
- }\r
- \r
- public void keyReleased(KeyEvent e) {\r
- boolean ok = true;\r
- try {\r
- floorHeight = Double.parseDouble(floorHeightText.getText()); \r
- } catch (NumberFormatException err) {\r
- ok = false;\r
- }\r
- if (ok) {\r
- this.getButton(IDialogConstants.OK_ID).setEnabled(true);\r
- } else {\r
- this.getButton(IDialogConstants.OK_ID).setEnabled(false);\r
- }\r
- }\r
- \r
- public void widgetDefaultSelected(SelectionEvent e) {\r
- \r
- }\r
- \r
- public void widgetSelected(SelectionEvent e) {\r
- floorEnabled = floorEnabledButton.getSelection();\r
- }\r
-\r
- public boolean isFloorEnabled() {\r
- return floorEnabled;\r
- }\r
-\r
- public double getFloorHeight() {\r
- return floorHeight;\r
- }\r
-\r
- }\r
- \r