1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.dialogs
;
16 import org
.eclipse
.jface
.dialogs
.Dialog
;
17 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
18 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.SDWidget
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
22 import org
.eclipse
.swt
.SWT
;
23 import org
.eclipse
.swt
.events
.SelectionEvent
;
24 import org
.eclipse
.swt
.events
.SelectionListener
;
25 import org
.eclipse
.swt
.layout
.GridData
;
26 import org
.eclipse
.swt
.layout
.GridLayout
;
27 import org
.eclipse
.swt
.widgets
.Composite
;
28 import org
.eclipse
.swt
.widgets
.Control
;
29 import org
.eclipse
.swt
.widgets
.Group
;
30 import org
.eclipse
.swt
.widgets
.Label
;
31 import org
.eclipse
.swt
.widgets
.Shell
;
32 import org
.eclipse
.swt
.widgets
.Text
;
35 * Dialog box for entering minimum and maximum time range for time compression bar.
39 * @author Bernd Hufmann
42 public class MinMaxDialog
extends Dialog
{
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
50 protected Label fMinLabel
;
54 protected Label fMaxLabel
;
58 protected Label fScaleLabel
;
60 * Label for precision.
62 protected Label fPrecisionLabel
;
64 * Text field for minimum.
66 protected Text fMinText
;
68 * Text field for maximum.
70 protected Text fMaxText
;
72 * Text field for scale.
74 protected Text fScaleText
;
76 * Text field for precision.
78 protected Text fPrecisionText
;
80 * The sequence diagram widget reference.
82 protected SDWidget fSdWidget
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
88 * Standard constructor.
89 * @param shell The shell
90 * @param viewer The sequence diagram widget reference.
92 public MinMaxDialog(Shell shell
, SDWidget viewer
) {
97 // ------------------------------------------------------------------------
99 // ------------------------------------------------------------------------
101 * Method to create a grid data base on horizontal span.
102 * @param span The horizontal span
103 * @return a grid data object
105 protected GridData
newGridData(int span
) {
106 GridData data
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.HORIZONTAL_ALIGN_FILL
);
107 data
.horizontalSpan
= span
;
113 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
116 protected Control
createDialogArea(Composite p
) {
117 p
.getShell().setText(SDMessages
._123
);
118 Composite parent
= (Composite
) super.createDialogArea(p
);
120 GridLayout parentLayout
= new GridLayout();
121 parentLayout
.numColumns
= 6;
122 parent
.setLayout(parentLayout
);
124 Group g1
= new Group(parent
, SWT
.SHADOW_NONE
);
125 g1
.setLayoutData(newGridData(3));
126 GridLayout g1layout
= new GridLayout();
127 g1layout
.numColumns
= 3;
128 g1
.setLayout(g1layout
);
130 fMinLabel
= new Label(g1
, SWT
.RADIO
);
131 fMinLabel
.setText(SDMessages
._124
);
132 fMinLabel
.setLayoutData(newGridData(1));
134 fMinText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
135 fMinText
.setLayoutData(newGridData(2));
136 fMinText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getValue()));
138 fMaxLabel
= new Label(g1
, SWT
.RADIO
);
139 fMaxLabel
.setText(SDMessages
._125
);
140 fMaxLabel
.setLayoutData(newGridData(1));
142 fMaxText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
143 fMaxText
.setLayoutData(newGridData(2));
144 fMaxText
.setText(String
.valueOf(fSdWidget
.getFrame().getMaxTime().getValue()));
146 fScaleLabel
= new Label(g1
, SWT
.RADIO
);
147 fScaleLabel
.setText(SDMessages
._136
);
148 fScaleLabel
.setLayoutData(newGridData(1));
150 fScaleText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
151 fScaleText
.setLayoutData(newGridData(2));
152 fScaleText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getScale()));
155 fPrecisionLabel
= new Label(g1
, SWT
.RADIO
);
156 fPrecisionLabel
.setText(SDMessages
._137
);
157 fPrecisionLabel
.setLayoutData(newGridData(1));
159 fPrecisionText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
160 fPrecisionText
.setLayoutData(newGridData(2));
161 fPrecisionText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getPrecision()));
168 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
171 protected void okPressed() {
177 min
= Long
.parseLong(fMinText
.getText());
178 max
= Long
.parseLong(fMaxText
.getText());
179 scale
= Integer
.parseInt(fScaleText
.getText());
180 precision
= Integer
.parseInt(fPrecisionText
.getText());
182 fSdWidget
.getFrame().setMax(new TmfTimestamp(max
, scale
, precision
));
183 fSdWidget
.getFrame().setMin(new TmfTimestamp(min
, scale
, precision
));
188 } catch (Exception e
) {
189 MessageDialog
.openError(getShell(), SDMessages
._98
, SDMessages
._99
);
195 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
198 protected void createButtonsForButtonBar(Composite parent
) {
199 super.createButtonsForButtonBar(parent
);
200 createButton(parent
, IDialogConstants
.CLIENT_ID
, SDMessages
._126
, false);
201 getButton(IDialogConstants
.CLIENT_ID
).addSelectionListener(new SelectionListener() {
204 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
207 public void widgetSelected(SelectionEvent e
) {
208 fSdWidget
.getFrame().resetCustomMinMax();
209 fMinText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getValue()));
210 fMaxText
.setText(String
.valueOf(fSdWidget
.getFrame().getMaxTime().getValue()));
211 fScaleText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getScale()));
212 fPrecisionText
.setText(String
.valueOf(fSdWidget
.getFrame().getMinTime().getPrecision()));
213 fMaxText
.getParent().layout(true);
218 * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
221 public void widgetDefaultSelected(SelectionEvent e
) {
This page took 0.035827 seconds and 6 git commands to generate.