X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Fdialogs%2FSingleValueDialog.java;fp=eclipse%2Forg.argeo.cms.swt%2Fsrc%2Forg%2Fargeo%2Fcms%2Fswt%2Fdialogs%2FSingleValueDialog.java;h=0000000000000000000000000000000000000000;hb=7b242851c0094d13cbaca5b68261ad92c873a59f;hp=9404b81da49a432516771f2c2f3e5a0399c9e3c2;hpb=dbb84b4ec2d313ec0724d035c32f482ac57974c5;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/dialogs/SingleValueDialog.java b/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/dialogs/SingleValueDialog.java deleted file mode 100644 index 9404b81da..000000000 --- a/eclipse/org.argeo.cms.swt/src/org/argeo/cms/swt/dialogs/SingleValueDialog.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.argeo.cms.swt.dialogs; - -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -/** A dialog asking a for a single value. */ -public class SingleValueDialog extends CmsMessageDialog { - private Text valueT; - private String value; - private String defaultValue; - - public SingleValueDialog(Shell parentShell, String message) { - super(parentShell, message, QUESTION); - } - - public SingleValueDialog(Shell parentShell, String message, String defaultValue) { - super(parentShell, message, QUESTION); - this.defaultValue = defaultValue; - } - - @Override - protected Control createInputArea(Composite parent) { - valueT = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.SINGLE); - valueT.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); - if (defaultValue != null) - valueT.setText(defaultValue); - return valueT; - } - - @Override - protected void okPressed() { - value = valueT.getText(); - super.okPressed(); - } - - public String getString() { - return value; - } - - public Long getLong() { - return Long.valueOf(getString()); - } - - public Double getDouble() { - return Double.valueOf(getString()); - } - - public static String ask(String message) { - return ask(message, null); - } - - public static String ask(String message, String defaultValue) { - SingleValueDialog svd = new SingleValueDialog(Display.getCurrent().getActiveShell(), message, defaultValue); - if (svd.open() == Window.OK) - return svd.getString(); - else - return null; - } - - public static Long askLong(String message) { - SingleValueDialog svd = new SingleValueDialog(Display.getCurrent().getActiveShell(), message); - if (svd.open() == Window.OK) - return svd.getLong(); - else - return null; - } - - public static Double askDouble(String message) { - SingleValueDialog svd = new SingleValueDialog(Display.getCurrent().getActiveShell(), message); - if (svd.open() == Window.OK) - return svd.getDouble(); - else - return null; - } - -}