]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/Dialogs.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / Dialogs.java
index 59fa17ce2514f4bbd8a43c50f28064ca5e6a38d2..47dab1963baad6013181b57e0bb058ed3cf2b44d 100644 (file)
@@ -1,86 +1,86 @@
-/*******************************************************************************\r
- * Copyright (c) 2012 Association for Decentralized Information Management in\r
- * 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
-package org.simantics.browsing.ui.swt;\r
-\r
-import java.util.function.Consumer;\r
-\r
-import org.eclipse.core.commands.ExecutionEvent;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.DirectoryDialog;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.handlers.HandlerUtil;\r
-import org.simantics.utils.datastructures.UnaryFunction;\r
-\r
-public class Dialogs {\r
-\r
-       public static <T> void invoke(final UnaryFunction<SimanticsDialog, Shell> function, final Consumer<T> callback) {\r
-               \r
-               Display.getDefault().asyncExec(new Runnable() {\r
-\r
-                       @SuppressWarnings("unchecked")\r
-                       @Override\r
-                       public void run() {\r
-                               \r
-                               SimanticsDialog dialog = function.call(Display.getCurrent().getActiveShell()); \r
-                               \r
-                               dialog.open();\r
-                               if(Window.CANCEL == dialog.getReturnCode()) callback.accept(null);\r
-                               else callback.accept((T)dialog.getSelection());\r
-                               \r
-                       }\r
-                       \r
-               });\r
-               \r
-       }\r
-       \r
-       public static String file(Shell shell, int style, String extension) {\r
-\r
-        FileDialog dialog = new FileDialog(shell, style);\r
-        dialog.setFilterExtensions(new String[] { extension });\r
-        String newFileName = dialog.open();\r
-        return newFileName;\r
-\r
-       }\r
-\r
-       public static String directory(Shell shell, int style, String filterPath) {\r
-\r
-        DirectoryDialog dialog = new DirectoryDialog(shell, style);\r
-        if(filterPath != null) dialog.setFilterPath(filterPath);\r
-        String newFileName = dialog.open();\r
-        return newFileName;\r
-\r
-       }\r
-\r
-       public static String file(int style, String extension) {\r
-               return file(Display.getDefault().getActiveShell(), style, extension);\r
-       }\r
-\r
-       public static String file(Shell shell, String extension) {\r
-               return file(shell, SWT.OPEN, extension);\r
-       }\r
-\r
-       public static String file(ExecutionEvent event, String extension) {\r
-               return file(HandlerUtil.getActiveShell(event), extension);\r
-       }\r
-\r
-       public static String file(ExecutionEvent event, int style, String extension) {\r
-               return file(HandlerUtil.getActiveShell(event), style, extension);\r
-       }\r
-\r
-       public static String directory(int style, String filterPath) {\r
-               return directory(Display.getDefault().getActiveShell(), style, filterPath);\r
-       }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ *******************************************************************************/
+package org.simantics.browsing.ui.swt;
+
+import java.util.function.Consumer;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.simantics.utils.datastructures.UnaryFunction;
+
+public class Dialogs {
+
+       public static <T> void invoke(final UnaryFunction<SimanticsDialog, Shell> function, final Consumer<T> callback) {
+               
+               Display.getDefault().asyncExec(new Runnable() {
+
+                       @SuppressWarnings("unchecked")
+                       @Override
+                       public void run() {
+                               
+                               SimanticsDialog dialog = function.call(Display.getCurrent().getActiveShell()); 
+                               
+                               dialog.open();
+                               if(Window.CANCEL == dialog.getReturnCode()) callback.accept(null);
+                               else callback.accept((T)dialog.getSelection());
+                               
+                       }
+                       
+               });
+               
+       }
+       
+       public static String file(Shell shell, int style, String extension) {
+
+        FileDialog dialog = new FileDialog(shell, style);
+        dialog.setFilterExtensions(new String[] { extension });
+        String newFileName = dialog.open();
+        return newFileName;
+
+       }
+
+       public static String directory(Shell shell, int style, String filterPath) {
+
+        DirectoryDialog dialog = new DirectoryDialog(shell, style);
+        if(filterPath != null) dialog.setFilterPath(filterPath);
+        String newFileName = dialog.open();
+        return newFileName;
+
+       }
+
+       public static String file(int style, String extension) {
+               return file(Display.getDefault().getActiveShell(), style, extension);
+       }
+
+       public static String file(Shell shell, String extension) {
+               return file(shell, SWT.OPEN, extension);
+       }
+
+       public static String file(ExecutionEvent event, String extension) {
+               return file(HandlerUtil.getActiveShell(event), extension);
+       }
+
+       public static String file(ExecutionEvent event, int style, String extension) {
+               return file(HandlerUtil.getActiveShell(event), style, extension);
+       }
+
+       public static String directory(int style, String filterPath) {
+               return directory(Display.getDefault().getActiveShell(), style, filterPath);
+       }
+
+}