]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - eclipse/org.argeo.cms.swt/src/org/argeo/eclipse/ui/dialogs/SingleValue.java
8ce9b44fb5bade306d868ceff17634fc8cf74934
1 package org
.argeo
.eclipse
.ui
.dialogs
;
3 import org
.argeo
.eclipse
.ui
.EclipseUiUtils
;
4 import org
.eclipse
.jface
.dialogs
.IMessageProvider
;
5 import org
.eclipse
.jface
.dialogs
.TitleAreaDialog
;
6 import org
.eclipse
.jface
.window
.Window
;
7 import org
.eclipse
.swt
.SWT
;
8 import org
.eclipse
.swt
.graphics
.Point
;
9 import org
.eclipse
.swt
.layout
.GridData
;
10 import org
.eclipse
.swt
.layout
.GridLayout
;
11 import org
.eclipse
.swt
.widgets
.Composite
;
12 import org
.eclipse
.swt
.widgets
.Control
;
13 import org
.eclipse
.swt
.widgets
.Display
;
14 import org
.eclipse
.swt
.widgets
.Label
;
15 import org
.eclipse
.swt
.widgets
.Shell
;
16 import org
.eclipse
.swt
.widgets
.Text
;
19 * Dialog to retrieve a single value.
21 * @deprecated Use CMS dialogs instead.
24 public class SingleValue
extends TitleAreaDialog
{
25 private static final long serialVersionUID
= 2843538207460082349L;
29 private final String title
, message
, label
;
30 private final Boolean multiline
;
32 public static String
ask(String label
, String message
) {
33 SingleValue svd
= new SingleValue(label
, message
);
34 if (svd
.open() == Window
.OK
)
35 return svd
.getString();
40 public static Long
askLong(String label
, String message
) {
41 SingleValue svd
= new SingleValue(label
, message
);
42 if (svd
.open() == Window
.OK
)
48 public static Double
askDouble(String label
, String message
) {
49 SingleValue svd
= new SingleValue(label
, message
);
50 if (svd
.open() == Window
.OK
)
51 return svd
.getDouble();
56 public SingleValue(String label
, String message
) {
57 this(Display
.getDefault().getActiveShell(), label
, message
, label
, false);
60 public SingleValue(Shell parentShell
, String title
, String message
, String label
, Boolean multiline
) {
63 this.message
= message
;
65 this.multiline
= multiline
;
68 protected Point
getInitialSize() {
70 return new Point(450, 350);
73 return new Point(400, 270);
76 protected Control
createDialogArea(Composite parent
) {
77 Composite dialogarea
= (Composite
) super.createDialogArea(parent
);
78 dialogarea
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
79 Composite composite
= new Composite(dialogarea
, SWT
.NONE
);
80 composite
.setLayoutData(EclipseUiUtils
.fillAll());
81 GridLayout layout
= new GridLayout(2, false);
82 layout
.marginWidth
= layout
.marginHeight
= 20;
83 composite
.setLayout(layout
);
85 valueT
= createLT(composite
, label
);
87 setMessage(message
, IMessageProvider
.NONE
);
95 protected void okPressed() {
96 value
= valueT
.getText();
100 /** Creates label and text. */
101 protected Text
createLT(Composite parent
, String label
) {
102 new Label(parent
, SWT
.NONE
).setText(label
);
105 text
= new Text(parent
, SWT
.LEAD
| SWT
.BORDER
| SWT
.MULTI
);
106 text
.setLayoutData(EclipseUiUtils
.fillAll());
108 text
= new Text(parent
, SWT
.LEAD
| SWT
.BORDER
| SWT
.SINGLE
);
109 text
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, true));
114 protected void configureShell(Shell shell
) {
115 super.configureShell(shell
);
116 shell
.setText(title
);
119 public String
getString() {
123 public Long
getLong() {
124 return Long
.valueOf(getString());
127 public Double
getDouble() {
128 return Double
.valueOf(getString());