1 /**********************************************************************
2 * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 * $Id: MinMaxDialog.java,v 1.2 2008/01/24 02:28:51 apnan Exp $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
;
15 import org
.eclipse
.jface
.dialogs
.Dialog
;
16 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
17 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.SDWidget
;
20 import org
.eclipse
.swt
.SWT
;
21 import org
.eclipse
.swt
.events
.SelectionEvent
;
22 import org
.eclipse
.swt
.events
.SelectionListener
;
23 import org
.eclipse
.swt
.layout
.GridData
;
24 import org
.eclipse
.swt
.layout
.GridLayout
;
25 import org
.eclipse
.swt
.widgets
.Composite
;
26 import org
.eclipse
.swt
.widgets
.Control
;
27 import org
.eclipse
.swt
.widgets
.Group
;
28 import org
.eclipse
.swt
.widgets
.Label
;
29 import org
.eclipse
.swt
.widgets
.Shell
;
30 import org
.eclipse
.swt
.widgets
.Text
;
36 public class MinMaxDialog
extends Dialog
{
38 protected Label minLabel
;
40 protected Label maxLabel
;
42 protected Label scaleLabel
;
44 protected Label precisionLabel
;
46 protected Text minText
;
48 protected Text maxText
;
50 protected Text scaleText
;
52 protected Text precisionText
;
56 public MinMaxDialog(Shell s
, SDWidget v
) {
61 protected GridData
newGridData(int span
) {
62 GridData data
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.HORIZONTAL_ALIGN_FILL
);
63 data
.horizontalSpan
= span
;
68 protected Control
createDialogArea(Composite p
) {
69 p
.getShell().setText(SDMessages
._123
);
70 Composite parent
= (Composite
) super.createDialogArea(p
);
72 GridLayout parentLayout
= new GridLayout();
73 parentLayout
.numColumns
= 6;
74 parent
.setLayout(parentLayout
);
76 Group g1
= new Group(parent
, SWT
.SHADOW_NONE
);
77 g1
.setLayoutData(newGridData(3));
78 GridLayout g1layout
= new GridLayout();
79 g1layout
.numColumns
= 3;
80 g1
.setLayout(g1layout
);
82 minLabel
= new Label(g1
, SWT
.RADIO
);
83 minLabel
.setText(SDMessages
._124
);
84 minLabel
.setLayoutData(newGridData(1));
86 minText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
87 minText
.setLayoutData(newGridData(2));
88 minText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getValue()));
90 maxLabel
= new Label(g1
, SWT
.RADIO
);
91 maxLabel
.setText(SDMessages
._125
);
92 maxLabel
.setLayoutData(newGridData(1));
94 maxText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
95 maxText
.setLayoutData(newGridData(2));
96 maxText
.setText(String
.valueOf(sdWidget
.getFrame().getMaxTime().getValue()));
98 scaleLabel
= new Label(g1
, SWT
.RADIO
);
99 scaleLabel
.setText(SDMessages
._136
);
100 scaleLabel
.setLayoutData(newGridData(1));
102 scaleText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
103 scaleText
.setLayoutData(newGridData(2));
104 scaleText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getScale()));
107 precisionLabel
= new Label(g1
, SWT
.RADIO
);
108 precisionLabel
.setText(SDMessages
._137
);
109 precisionLabel
.setLayoutData(newGridData(1));
111 precisionText
= new Text(g1
, SWT
.SINGLE
| SWT
.BORDER
);
112 precisionText
.setLayoutData(newGridData(2));
113 precisionText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getPrecision()));
119 protected void okPressed() {
127 min
= Long
.parseLong(minText
.getText());
128 max
= Long
.parseLong(maxText
.getText());
129 scale
= Byte
.parseByte(scaleText
.getText());
130 precision
= Long
.parseLong(precisionText
.getText());
132 sdWidget
.getFrame().setMax(new TmfTimestamp(max
, scale
, precision
));
133 sdWidget
.getFrame().setMin(new TmfTimestamp(min
, scale
, precision
));
138 } catch (Exception e
) {
139 MessageDialog
.openError(getShell(), SDMessages
._98
, SDMessages
._99
);
144 protected void createButtonsForButtonBar(Composite parent
) {
145 super.createButtonsForButtonBar(parent
);
146 createButton(parent
, IDialogConstants
.CLIENT_ID
, SDMessages
._126
, false);
147 getButton(IDialogConstants
.CLIENT_ID
).addSelectionListener(new SelectionListener() {
150 public void widgetSelected(SelectionEvent e
) {
151 sdWidget
.getFrame().resetCustomMinMax();
152 minText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getValue()));
153 maxText
.setText(String
.valueOf(sdWidget
.getFrame().getMaxTime().getValue()));
154 scaleText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getScale()));
155 precisionText
.setText(String
.valueOf(sdWidget
.getFrame().getMinTime().getPrecision()));
156 maxText
.getParent().layout(true);
160 public void widgetDefaultSelected(SelectionEvent e
) {
This page took 0.033865 seconds and 5 git commands to generate.