]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.image.ui/src/org/simantics/image/ui/ImportImagesActionFactory.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.image.ui / src / org / simantics / image / ui / ImportImagesActionFactory.java
index cd5cab77c2e44ab96a2c893c0f5f646e5ea9f23e..a0e966f98f947df987e5f0842eab0a630be68260 100644 (file)
@@ -1,82 +1,82 @@
-/*******************************************************************************\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
-package org.simantics.image.ui;\r
-\r
- import java.io.File;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.FileDialog;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.ui.IWorkbenchWindow;\r
-import org.eclipse.ui.PlatformUI;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.layer0.adapter.ActionFactory;\r
-import org.simantics.ui.SimanticsUI;\r
-import org.simantics.utils.FileUtils;\r
-import org.simantics.utils.ui.AdaptionUtils;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class ImportImagesActionFactory implements ActionFactory {\r
-\r
-    @Override\r
-    public Runnable create(Object target) {\r
-        final Resource container = AdaptionUtils.adaptToSingle(target, Resource.class);\r
-        if (container == null)\r
-            return null;\r
-\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();\r
-                if (win == null)\r
-                    return;\r
-                Collection<File> files = requestImportedImages(win.getShell());\r
-                if (files.isEmpty())\r
-                    return;\r
-\r
-                SimanticsUI.getSession().markUndoPoint();\r
-                SimanticsUI.getSession().asyncRequest( new CreateImages(container, files) );\r
-            }\r
-        };\r
-    }\r
-\r
-    public static Collection<File> requestImportedImages(Shell parentShell) {\r
-        FileDialog dialog = new FileDialog(parentShell, SWT.MULTI);\r
-        dialog.setText("Choose image to be imported");\r
-        dialog.setFilterExtensions( new String[] {"*.jpg;*.png;*.gif;*.svg", "*.jpg;*.jpeg", "*.png", "*.gif", "*.svg"} );\r
-        dialog.setFilterNames( new String[] {"All Images", "JPEG Image", "PNG Image", "GIF Image", "SVG Image"} );\r
-        //dialog.setFilterExtensions( new String[] {"*.jpg", "*.png", "*.gif"} );\r
-        final String filename = dialog.open();\r
-        if (filename == null)\r
-            return Collections.emptyList();\r
-        String[] files = dialog.getFileNames();\r
-        File parent = new File(dialog.getFilterPath());\r
-        ArrayList<File> result = new ArrayList<File>(files.length);\r
-        for (String file : files)\r
-            result.add( new File(parent, file) );\r
-        return result;\r
-    }\r
-\r
-    public static ImageSource toImageSource(File file) throws IOException {\r
-        ImageSource src = new ImageSource();\r
-        src.name = file.getName();\r
-        src.data = FileUtils.readFile(file);\r
-        return src;\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
+ *******************************************************************************/
+package org.simantics.image.ui;
+
+ import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.simantics.db.Resource;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.ui.SimanticsUI;
+import org.simantics.utils.FileUtils;
+import org.simantics.utils.ui.AdaptionUtils;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class ImportImagesActionFactory implements ActionFactory {
+
+    @Override
+    public Runnable create(Object target) {
+        final Resource container = AdaptionUtils.adaptToSingle(target, Resource.class);
+        if (container == null)
+            return null;
+
+        return new Runnable() {
+            @Override
+            public void run() {
+                IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+                if (win == null)
+                    return;
+                Collection<File> files = requestImportedImages(win.getShell());
+                if (files.isEmpty())
+                    return;
+
+                SimanticsUI.getSession().markUndoPoint();
+                SimanticsUI.getSession().asyncRequest( new CreateImages(container, files) );
+            }
+        };
+    }
+
+    public static Collection<File> requestImportedImages(Shell parentShell) {
+        FileDialog dialog = new FileDialog(parentShell, SWT.MULTI);
+        dialog.setText("Choose image to be imported");
+        dialog.setFilterExtensions( new String[] {"*.jpg;*.png;*.gif;*.svg", "*.jpg;*.jpeg", "*.png", "*.gif", "*.svg"} );
+        dialog.setFilterNames( new String[] {"All Images", "JPEG Image", "PNG Image", "GIF Image", "SVG Image"} );
+        //dialog.setFilterExtensions( new String[] {"*.jpg", "*.png", "*.gif"} );
+        final String filename = dialog.open();
+        if (filename == null)
+            return Collections.emptyList();
+        String[] files = dialog.getFileNames();
+        File parent = new File(dialog.getFilterPath());
+        ArrayList<File> result = new ArrayList<File>(files.length);
+        for (String file : files)
+            result.add( new File(parent, file) );
+        return result;
+    }
+
+    public static ImageSource toImageSource(File file) throws IOException {
+        ImageSource src = new ImageSource();
+        src.name = file.getName();
+        src.data = FileUtils.readFile(file);
+        return src;
+    }
+
+}