10 package com.generalrobotix.ui.view.graph;
12 import org.eclipse.jface.dialogs.Dialog;
13 import org.eclipse.jface.dialogs.IDialogConstants;
14 import org.eclipse.jface.dialogs.MessageDialog;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.events.KeyEvent;
17 import org.eclipse.swt.events.KeyListener;
18 import org.eclipse.swt.layout.RowLayout;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Control;
21 import org.eclipse.swt.widgets.Label;
22 import org.eclipse.swt.widgets.Scale;
23 import org.eclipse.swt.widgets.Shell;
24 import org.eclipse.swt.widgets.Text;
69 super.configureShell(newShell);
74 Composite composite = (Composite)super.createDialogArea(parent);
75 composite.setLayout(
new RowLayout(SWT.VERTICAL));
76 Composite comp0 =
new Composite(composite, SWT.NONE);
77 comp0.setLayout(
new RowLayout());
79 Label label1 =
new Label(comp0, SWT.NONE);
82 hRangeField_ =
new Text(comp0, SWT.BORDER);
83 hRangeField_.setText(String.format(
"%10.3f", hRange_));
85 hRangeField_.addKeyListener(
new KeyListener(){
86 public void keyPressed(KeyEvent e) {
88 hRangeField_.setText(
"");
92 public void keyReleased(KeyEvent e) {
95 hRangeField_.setFocus();
97 Label label2 =
new Label(comp0, SWT.NONE);
100 Composite comp1 =
new Composite(composite, SWT.NONE);
101 comp1.setLayout(
new RowLayout());
103 Label label3 =
new Label(comp1, SWT.NONE);
106 markerSlider_ =
new Scale(comp1, SWT.HORIZONTAL);
107 markerSlider_.setMinimum(0);
108 markerSlider_.setMaximum(MARKER_POS_STEPS);
109 markerSlider_.setIncrement(10);
110 markerSlider_.setSelection((
int)(markerPos_ * MARKER_POS_STEPS));
117 if (buttonId == IDialogConstants.OK_ID) {
120 range = Double.parseDouble(hRangeField_.getText());
121 }
catch (NumberFormatException ex) {
123 MessageDialog.openError(shell_,
127 hRangeField_.setFocus();
131 if (range < minHRange_ || range > maxHRange_) {
133 MessageDialog.openError(shell_,
136 +
"\n(" + minHRange_ +
" - " + maxHRange_ +
")" );
137 hRangeField_.setFocus();
140 double pos = markerSlider_.getSelection() / (double)MARKER_POS_STEPS;
143 if (range != hRange_) {
147 if (pos != markerPos_) {
152 setReturnCode(buttonId);
154 super.buttonPressed(buttonId);
179 maxHRange_ = maxHRange;
190 minHRange_ = minHRange;
201 markerPos_ = markerPos;
static final String get(String key)
static final int MARKER_POS_STEPS
void setHRange(double hRange)
static final int RANGE_UPDATED
static final int POS_UPDATED
void buttonPressed(int buttonId)
void setMinHRange(double minHRange)
void configureShell(Shell newShell)
void setMaxHRange(double maxHRange)
HRangeDialog(Shell shell)
Control createDialogArea(Composite parent)
void setMarkerPos(double markerPos)