]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.utils.ui/src/org/simantics/utils/ui/dialogs/SafeMessageDialog.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.utils.ui / src / org / simantics / utils / ui / dialogs / SafeMessageDialog.java
index db2f7e9d62e16b0a596471de0c668e2bf49f4f84..b474614a1c2730c7cd7f0e4a484dbb8961f6469b 100644 (file)
@@ -1,71 +1,71 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-/*\r
- * Created on 16.12.2005\r
- * @author Toni Kalajainen\r
- */\r
-package org.simantics.utils.ui.dialogs;\r
-\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.dialogs.MessageDialog;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.simantics.utils.DataContainer;\r
-\r
-\r
-/**\r
- * Tool for making blocking message dialogs queries from non-UI thread\r
- * \r
- * \r
- */\r
-public class SafeMessageDialog {\r
-\r
-    /** Yes and No buttons */\r
-    public final static String[] YES_NO = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };\r
-\r
-    public static Integer doMessageDialog(final String title, final Image image, final String message, final int type,\r
-            final String buttons[], final int defaultIndex) {\r
-        final DataContainer<Integer> result = new DataContainer<Integer>();\r
-        Runnable r = new Runnable() {\r
-            public void run() {\r
-                Shell shell = Display.getCurrent().getActiveShell();\r
-                MessageDialog dialog = new MessageDialog(shell, title, image, message, type, buttons, defaultIndex);\r
-                dialog.open();\r
-                result.set(dialog.getReturnCode());\r
-            }\r
-        };\r
-        Display display = Display.getCurrent();\r
-        if (display == null)\r
-               display = Display.getDefault();\r
-        display.syncExec(r);\r
-\r
-        if (result.get() == null)\r
-            return null;\r
-        return result.get();\r
-    }\r
-\r
-    /**\r
-     * method for asking simple yes/no question in a dialog.\r
-     * \r
-     * @param title the dialog's title, or <code>null</code> if none\r
-     * @param message the message\r
-     * @return true if user pressed OK\r
-     */\r
-    public static boolean openQuestion(String title, String message) {\r
-        Integer result = doMessageDialog(title, null, message, MessageDialog.QUESTION, YES_NO, 0);\r
-        if (result == null)\r
-            return false;\r
-        return result == 0;\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+/*
+ * Created on 16.12.2005
+ * @author Toni Kalajainen
+ */
+package org.simantics.utils.ui.dialogs;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.simantics.utils.DataContainer;
+
+
+/**
+ * Tool for making blocking message dialogs queries from non-UI thread
+ * 
+ * 
+ */
+public class SafeMessageDialog {
+
+    /** Yes and No buttons */
+    public final static String[] YES_NO = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL };
+
+    public static Integer doMessageDialog(final String title, final Image image, final String message, final int type,
+            final String buttons[], final int defaultIndex) {
+        final DataContainer<Integer> result = new DataContainer<Integer>();
+        Runnable r = new Runnable() {
+            public void run() {
+                Shell shell = Display.getCurrent().getActiveShell();
+                MessageDialog dialog = new MessageDialog(shell, title, image, message, type, buttons, defaultIndex);
+                dialog.open();
+                result.set(dialog.getReturnCode());
+            }
+        };
+        Display display = Display.getCurrent();
+        if (display == null)
+               display = Display.getDefault();
+        display.syncExec(r);
+
+        if (result.get() == null)
+            return null;
+        return result.get();
+    }
+
+    /**
+     * method for asking simple yes/no question in a dialog.
+     * 
+     * @param title the dialog's title, or <code>null</code> if none
+     * @param message the message
+     * @return true if user pressed OK
+     */
+    public static boolean openQuestion(String title, String message) {
+        Integer result = doMessageDialog(title, null, message, MessageDialog.QUESTION, YES_NO, 0);
+        if (result == null)
+            return false;
+        return result == 0;
+    }
+
+}