]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/BundleIcon.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.swt / src / org / simantics / browsing / ui / swt / BundleIcon.java
index a577d76ac12d44585835d5d3b98e3b98896245a4..f3ac3d8af4110944c76c072ab6d7bfdc31f903d7 100644 (file)
@@ -1,76 +1,76 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2012 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.browsing.ui.swt;\r
-\r
-import java.net.URL;\r
-\r
-import org.eclipse.core.runtime.Platform;\r
-import org.eclipse.jface.resource.ImageDescriptor;\r
-import org.osgi.framework.Bundle;\r
-import org.simantics.Simantics;\r
-import org.simantics.browsing.ui.swt.stubs.BrowsingResource;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.utils.datastructures.Pair;\r
-\r
-/**\r
- * @author Antti Villberg\r
- */\r
-public class BundleIcon implements ModelledIcon {\r
-\r
-    private final Resource       configuration;\r
-    private Pair<String, String> location;\r
-\r
-    public BundleIcon(ReadGraph graph, Resource configuration) throws DatabaseException {\r
-        this.configuration = configuration;\r
-        this.location = graph.syncRequest(new Location(configuration));\r
-    }\r
-\r
-    @Override\r
-    public ImageDescriptor create() throws DatabaseException {\r
-        Pair<String, String> bundleAndPath = Simantics.getSession().syncRequest(new Location(configuration));\r
-        if (bundleAndPath == null)\r
-            return null;\r
-\r
-        Bundle bundle = Platform.getBundle(bundleAndPath.first);\r
-        if (bundle == null)\r
-            return null;\r
-        URL url = bundle.getEntry(bundleAndPath.second);\r
-        return ImageDescriptor.createFromURL(url);\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return super.toString() + "[" + location + "]";\r
-    }\r
-\r
-    static class Location implements Read<Pair<String, String>> {\r
-        Resource configuration;\r
-        public Location(Resource configuration) {\r
-            this.configuration = configuration;\r
-        }\r
-        @Override\r
-        public Pair<String, String> perform(ReadGraph graph) throws DatabaseException {\r
-            BrowsingResource BRO = BrowsingResource.getInstance(graph);\r
-            String bundle = graph.getPossibleRelatedValue(configuration, BRO.BundleIcon_Bundle);\r
-            if (bundle == null)\r
-                return null;\r
-            String path = graph.getPossibleRelatedValue(configuration, BRO.BundleIcon_Path);\r
-            if (path == null)\r
-                return null;\r
-            return Pair.make(bundle, path);\r
-        }\r
-    }\r
-\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 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.net.URL;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.Bundle;
+import org.simantics.Simantics;
+import org.simantics.browsing.ui.swt.stubs.BrowsingResource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.request.Read;
+import org.simantics.utils.datastructures.Pair;
+
+/**
+ * @author Antti Villberg
+ */
+public class BundleIcon implements ModelledIcon {
+
+    private final Resource       configuration;
+    private Pair<String, String> location;
+
+    public BundleIcon(ReadGraph graph, Resource configuration) throws DatabaseException {
+        this.configuration = configuration;
+        this.location = graph.syncRequest(new Location(configuration));
+    }
+
+    @Override
+    public ImageDescriptor create() throws DatabaseException {
+        Pair<String, String> bundleAndPath = Simantics.getSession().syncRequest(new Location(configuration));
+        if (bundleAndPath == null)
+            return null;
+
+        Bundle bundle = Platform.getBundle(bundleAndPath.first);
+        if (bundle == null)
+            return null;
+        URL url = bundle.getEntry(bundleAndPath.second);
+        return ImageDescriptor.createFromURL(url);
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + "[" + location + "]";
+    }
+
+    static class Location implements Read<Pair<String, String>> {
+        Resource configuration;
+        public Location(Resource configuration) {
+            this.configuration = configuration;
+        }
+        @Override
+        public Pair<String, String> perform(ReadGraph graph) throws DatabaseException {
+            BrowsingResource BRO = BrowsingResource.getInstance(graph);
+            String bundle = graph.getPossibleRelatedValue(configuration, BRO.BundleIcon_Bundle);
+            if (bundle == null)
+                return null;
+            String path = graph.getPossibleRelatedValue(configuration, BRO.BundleIcon_Path);
+            if (path == null)
+                return null;
+            return Pair.make(bundle, path);
+        }
+    }
+
+}