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
.event
.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 minLabel
;
54 protected Label maxLabel
;
58 protected Label scaleLabel
;
60 * Label for precision.
62 protected Label precisionLabel
;
64 * Text field for minimum.
66 protected Text minText
;
68 * Text field for maximum.
70 protected Text maxText
;
72 * Text field for scale.
74 protected Text scaleText
;
76 * Text field for precision.
78 protected Text precisionText
;
80 * The sequence diagram widget reference.
82 protected SDWidget sdWidget
;
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 minLabel
= new Label(g1
, SWT
.RADIO
);
131 minLabel
.setText(SDMessages
._124
);
132 minLabel
.setLayoutData(newGridData(1));
134 minText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
135 minText
.setLayoutData(newGridData(2));
136 minText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getValue()));
138 maxLabel
= new Label(g1
, SWT
.RADIO
);
139 maxLabel
.setText(SDMessages
._125
);
140 maxLabel
.setLayoutData(newGridData(1));
142 maxText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
143 maxText
.setLayoutData(newGridData(2));
144 maxText
.setText(String
.valueOf(sdWidget
.getFrame().getMaxTime().getValue()));
146 scaleLabel
= new Label(g1
, SWT
.RADIO
);
147 scaleLabel
.setText(SDMessages
._136
);
148 scaleLabel
.setLayoutData(newGridData(1));
150 scaleText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
151 scaleText
.setLayoutData(newGridData(2));
152 scaleText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getScale()));
155 precisionLabel
= new Label(g1
, SWT
.RADIO
);
156 precisionLabel
.setText(SDMessages
._137
);
157 precisionLabel
.setLayoutData(newGridData(1));
159 precisionText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
160 precisionText
.setLayoutData(newGridData(2));
161 precisionText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getPrecision()));
168 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
171 protected void okPressed() {
177 min
= Long
.parseLong(minText
.getText());
178 max
= Long
.parseLong(maxText
.getText());
179 scale
= Integer
.parseInt(scaleText
.getText());
180 precision
= Integer
.parseInt(precisionText
.getText());
182 sdWidget
.getFrame().setMax(new TmfTimestamp(max
, scale
, precision
));
183 sdWidget
.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 sdWidget
.getFrame().resetCustomMinMax();
209 minText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getValue()));
210 maxText
.setText(String
.valueOf(sdWidget
.getFrame().getMaxTime().getValue()));
211 scaleText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getScale()));
212 precisionText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getPrecision()));
213 maxText
.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.036057 seconds and 6 git commands to generate.