]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.image.ui/src/org/simantics/image/ui/CreateImage.java
Externalize strings
[simantics/platform.git] / bundles / org.simantics.image.ui / src / org / simantics / image / ui / CreateImage.java
index 8fd6375819102dd22e883635440d698317f92870..f602d31d40a86a691bdd5bb899bee12deb08171d 100644 (file)
@@ -1,99 +1,99 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 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.image.ui;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.Layer0Utils;\r
-import org.simantics.image2.ontology.ImageResource;\r
-import org.simantics.layer0.Layer0;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class CreateImage extends WriteRequest {\r
-\r
-    private Resource container;\r
-    private ImageSource source;\r
-\r
-    public CreateImage(Resource container, ImageSource source) {\r
-        this.container = container;\r
-        this.source = source;\r
-    }\r
-\r
-    public static Resource getType(ReadGraph graph, ImageSource source) throws DatabaseException {\r
-       ImageResource IMAGE = ImageResource.getInstance(graph);\r
-       String name = source.name.toLowerCase();\r
-       if(name.endsWith("svg")) return IMAGE.SvgImage;\r
-       else if(name.endsWith("png")) return IMAGE.PngImage;\r
-       else if(name.endsWith("jpg") || name.endsWith("jpeg")) return IMAGE.JpegImage;\r
-       else if(name.endsWith("gif")) return IMAGE.GifImage;\r
-       else throw new DatabaseException("Unsupported image format " + source.name);\r
-    }\r
-    \r
-    public static void claimLiteral(WriteGraph graph, Resource image, ImageSource source) throws DatabaseException {\r
-        String name = source.name.toLowerCase();\r
-        if (name.endsWith("svg"))\r
-            graph.claimValue(image, new String(source.data), Bindings.STRING);\r
-        else if (name.endsWith("png") || name.endsWith("jpg") || name.endsWith("jpeg") || name.endsWith("gif"))\r
-            graph.claimValue(image, source.data, Bindings.BYTE_ARRAY);\r
-       else throw new DatabaseException("Unsupported image format " + source.name);\r
-    }\r
-\r
-    @Override\r
-    public void perform(WriteGraph graph) throws DatabaseException {\r
-       doImage(graph, container, source);\r
-    }\r
-    \r
-    public Resource doImage(WriteGraph graph, Resource parent, ImageSource source) throws DatabaseException {\r
-        graph.markUndoPoint();\r
-       Layer0 L0 = Layer0.getInstance(graph);\r
-       Resource image = graph.newResource();\r
-       graph.claim(image, L0.InstanceOf, null, getType(graph, source));\r
-       graph.claimLiteral(image, L0.HasName, source.name, Bindings.STRING);\r
-       claimLiteral(graph, image, source);\r
-       graph.claim(parent, L0.ConsistsOf, image);\r
-       Layer0Utils.addCommentMetadata(graph, "Imported image " + source.name + " " + image.toString());\r
-       return image;\r
-       \r
-//     if(file.getPath().endsWith("svg")) {\r
-//            ImageSource src = ImportImagesActionFactory.toImageSource(file);\r
-//            Layer0 l0 = Layer0.getInstance(graph);\r
-//            ImageResource img = ImageResource.getInstance(graph);\r
-//            Resource image = graph.newResource();\r
-//            graph.claim(image, l0.InstanceOf, null, img.Image);\r
-//            graph.claimLiteral(image, l0.HasName, src.name, Bindings.STRING);\r
-//            String document = FileUtils.getContents(file.getAbsolutePath());\r
-//            graph.claimLiteral(image, img.HasImageDocument, document, Bindings.STRING);\r
-//            graph.claim(container, l0.ConsistsOf, image);\r
-//            graph.claim(container, img.HasImage, image);\r
-//     } else {\r
-//     }\r
-//\r
-//     \r
-//        Layer0 l0 = Layer0.getInstance(graph);\r
-//        ImageResource img = ImageResource.getInstance(graph);\r
-//\r
-//        Resource image = graph.newResource();\r
-//        graph.claim(image, l0.InstanceOf, null, img.Image);\r
-//        graph.claimLiteral(image, l0.HasName, source.name, Bindings.STRING);\r
-//        graph.claimLiteral(image, img.HasImageData, source.data, Bindings.BYTE_ARRAY);\r
-//        graph.claim(container, l0.ConsistsOf, image);\r
-//        graph.claim(container, img.HasImage, image);\r
-               \r
-    }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 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 org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
+import org.simantics.image2.ontology.ImageResource;
+import org.simantics.layer0.Layer0;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class CreateImage extends WriteRequest {
+
+    private Resource container;
+    private ImageSource source;
+
+    public CreateImage(Resource container, ImageSource source) {
+        this.container = container;
+        this.source = source;
+    }
+
+    public static Resource getType(ReadGraph graph, ImageSource source) throws DatabaseException {
+       ImageResource IMAGE = ImageResource.getInstance(graph);
+       String name = source.name.toLowerCase();
+       if(name.endsWith("svg")) return IMAGE.SvgImage; //$NON-NLS-1$
+       else if(name.endsWith("png")) return IMAGE.PngImage; //$NON-NLS-1$
+       else if(name.endsWith("jpg") || name.endsWith("jpeg")) return IMAGE.JpegImage; //$NON-NLS-1$ //$NON-NLS-2$
+       else if(name.endsWith("gif")) return IMAGE.GifImage; //$NON-NLS-1$
+       else throw new DatabaseException("Unsupported image format " + source.name); //$NON-NLS-1$
+    }
+    
+    public static void claimLiteral(WriteGraph graph, Resource image, ImageSource source) throws DatabaseException {
+        String name = source.name.toLowerCase();
+        if (name.endsWith("svg")) //$NON-NLS-1$
+            graph.claimValue(image, new String(source.data), Bindings.STRING);
+        else if (name.endsWith("png") || name.endsWith("jpg") || name.endsWith("jpeg") || name.endsWith("gif")) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+            graph.claimValue(image, source.data, Bindings.BYTE_ARRAY);
+       else throw new DatabaseException("Unsupported image format " + source.name); //$NON-NLS-1$
+    }
+
+    @Override
+    public void perform(WriteGraph graph) throws DatabaseException {
+       doImage(graph, container, source);
+    }
+    
+    public Resource doImage(WriteGraph graph, Resource parent, ImageSource source) throws DatabaseException {
+        graph.markUndoPoint();
+       Layer0 L0 = Layer0.getInstance(graph);
+       Resource image = graph.newResource();
+       graph.claim(image, L0.InstanceOf, null, getType(graph, source));
+       graph.claimLiteral(image, L0.HasName, source.name, Bindings.STRING);
+       claimLiteral(graph, image, source);
+       graph.claim(parent, L0.ConsistsOf, image);
+       Layer0Utils.addCommentMetadata(graph, "Imported image " + source.name + " " + image.toString()); //$NON-NLS-1$ //$NON-NLS-2$
+       return image;
+       
+//     if(file.getPath().endsWith("svg")) {
+//            ImageSource src = ImportImagesActionFactory.toImageSource(file);
+//            Layer0 l0 = Layer0.getInstance(graph);
+//            ImageResource img = ImageResource.getInstance(graph);
+//            Resource image = graph.newResource();
+//            graph.claim(image, l0.InstanceOf, null, img.Image);
+//            graph.claimLiteral(image, l0.HasName, src.name, Bindings.STRING);
+//            String document = FileUtils.getContents(file.getAbsolutePath());
+//            graph.claimLiteral(image, img.HasImageDocument, document, Bindings.STRING);
+//            graph.claim(container, l0.ConsistsOf, image);
+//            graph.claim(container, img.HasImage, image);
+//     } else {
+//     }
+//
+//     
+//        Layer0 l0 = Layer0.getInstance(graph);
+//        ImageResource img = ImageResource.getInstance(graph);
+//
+//        Resource image = graph.newResource();
+//        graph.claim(image, l0.InstanceOf, null, img.Image);
+//        graph.claimLiteral(image, l0.HasName, source.name, Bindings.STRING);
+//        graph.claimLiteral(image, img.HasImageData, source.data, Bindings.BYTE_ARRAY);
+//        graph.claim(container, l0.ConsistsOf, image);
+//        graph.claim(container, img.HasImage, image);
+               
+    }
+
 }
\ No newline at end of file