]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InstanceOfTest.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.browsing.ui.model / src / org / simantics / browsing / ui / model / tests / InstanceOfTest.java
index a2c78aded73df959735f9b825cafa885579e4f4c..70b6ecaa419854896a7d09675c1f3ea2bdd7a72e 100644 (file)
@@ -1,70 +1,70 @@
-package org.simantics.browsing.ui.model.tests;\r
-\r
-import org.eclipse.core.runtime.Platform;\r
-import org.osgi.framework.Bundle;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.viewpoint.ontology.ViewpointResource;\r
-\r
-/**\r
- * A visual contribution rule test that checks whether the input content is an\r
- * instance of a Java class. The class is specified by identifying the source\r
- * bundle and the class name.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class InstanceOfTest implements Test {\r
-\r
-    String   bundleName;\r
-    String   className;\r
-    Class<?> clazz;\r
-    boolean  failed;\r
-\r
-    public InstanceOfTest(String bundle, String className) {\r
-        this.bundleName = bundle;\r
-        this.className = className;\r
-    }\r
-\r
-    public InstanceOfTest(ReadGraph graph, Resource test) throws DatabaseException {\r
-        ViewpointResource VP = ViewpointResource.getInstance(graph);\r
-        this.bundleName = graph.getRelatedValue(test, VP.InstanceOfTest_bundleName, Bindings.STRING);\r
-        this.className = graph.getRelatedValue(test, VP.InstanceOfTest_className, Bindings.STRING);\r
-    }\r
-\r
-    private Class<?> resolveClass() {\r
-        if (failed)\r
-            return null;\r
-        if (clazz != null)\r
-            return clazz;\r
-        Bundle b = Platform.getBundle(bundleName);\r
-        if (b == null) {\r
-            System.err.println(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");\r
-            failed = true;\r
-            return null;\r
-        }\r
-        try {\r
-            this.clazz = b.loadClass(className);\r
-            return clazz;\r
-        } catch (ClassNotFoundException e) {\r
-            System.err.println(getClass() + " could not resolve class " + className + ", from bundle " + bundleName);\r
-            failed = true;\r
-            return null;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public boolean isCompatible(Class<?> contentType) {\r
-        Class<?> clazz = resolveClass();\r
-        return clazz != null && clazz.equals(contentType);\r
-    }\r
-\r
-    @Override\r
-    public boolean test(ReadGraph graph, Object content)\r
-            throws DatabaseException {\r
-        Class<?> clazz = resolveClass();\r
-        return clazz != null && clazz.isInstance(content);\r
-    }\r
-\r
-}\r
+package org.simantics.browsing.ui.model.tests;
+
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+import org.simantics.databoard.Bindings;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.viewpoint.ontology.ViewpointResource;
+
+/**
+ * A visual contribution rule test that checks whether the input content is an
+ * instance of a Java class. The class is specified by identifying the source
+ * bundle and the class name.
+ * 
+ * @author Tuukka Lehtonen
+ */
+public class InstanceOfTest implements Test {
+
+    String   bundleName;
+    String   className;
+    Class<?> clazz;
+    boolean  failed;
+
+    public InstanceOfTest(String bundle, String className) {
+        this.bundleName = bundle;
+        this.className = className;
+    }
+
+    public InstanceOfTest(ReadGraph graph, Resource test) throws DatabaseException {
+        ViewpointResource VP = ViewpointResource.getInstance(graph);
+        this.bundleName = graph.getRelatedValue(test, VP.InstanceOfTest_bundleName, Bindings.STRING);
+        this.className = graph.getRelatedValue(test, VP.InstanceOfTest_className, Bindings.STRING);
+    }
+
+    private Class<?> resolveClass() {
+        if (failed)
+            return null;
+        if (clazz != null)
+            return clazz;
+        Bundle b = Platform.getBundle(bundleName);
+        if (b == null) {
+            System.err.println(getClass() + " could not resolve class " + className + ", bundle " + bundleName + " not found in platform");
+            failed = true;
+            return null;
+        }
+        try {
+            this.clazz = b.loadClass(className);
+            return clazz;
+        } catch (ClassNotFoundException e) {
+            System.err.println(getClass() + " could not resolve class " + className + ", from bundle " + bundleName);
+            failed = true;
+            return null;
+        }
+    }
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        Class<?> clazz = resolveClass();
+        return clazz != null && clazz.equals(contentType);
+    }
+
+    @Override
+    public boolean test(ReadGraph graph, Object content)
+            throws DatabaseException {
+        Class<?> clazz = resolveClass();
+        return clazz != null && clazz.isInstance(content);
+    }
+
+}