]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/utils/ResourceInfo.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.browser / src / org / simantics / debug / browser / utils / ResourceInfo.java
index 655ef935e488de0cbd409b938693372a3883944c..009623f4b8bcecc35c1ca2f33359886de8a70a83 100644 (file)
@@ -1,92 +1,92 @@
-/*******************************************************************************\r
- * Copyright (c) 2016 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
- *     THTH ry - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.debug.browser.utils;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.databoard.binding.Binding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.type.Datatype;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.utils.strings.AlphanumComparator;\r
-\r
-public class ResourceInfo implements Comparable<ResourceInfo> {\r
-    public final String label;\r
-    public final String uri;\r
-    public final long resourceId;\r
-    public final Resource resource;\r
-    \r
-    public ResourceInfo(ReadGraph graph, Resource resource) throws DatabaseException {\r
-        this.label = getLabel(graph, resource);\r
-        this.uri = graph.getPossibleURI(resource);\r
-        this.resourceId = resource.getResourceId();\r
-        this.resource = resource;\r
-    }\r
-    \r
-    @Override\r
-    public String toString() {\r
-        StringBuilder sb = new StringBuilder(80);\r
-        sb.append("<a href=\"")\r
-          .append(resourceId)\r
-          .append("\"");\r
-        \r
-        if (uri != null)\r
-            sb.append(" title=\"").append(uri).append("\"");\r
-        \r
-        sb.append(">")\r
-          .append(Escapes.html(label))\r
-          .append("</a>");\r
-        \r
-        return sb.toString();\r
-    }\r
-    \r
-    public static String getLabel(ReadGraph graph, Resource resource) throws DatabaseException {\r
-        Layer0 L0 = Layer0.getInstance(graph);\r
-        String name = graph.getPossibleRelatedValue(resource, L0.HasName);\r
-        if(name != null) {\r
-            if(name.equals("Inverse")) {\r
-                Resource inverse = graph.getPossibleInverse(resource);\r
-                Resource parent = graph.getPossibleObject(resource, L0.PartOf);\r
-                if(inverse != null && inverse.equals(parent)) {\r
-                    String parentName = graph.getPossibleRelatedValue(parent, L0.HasName);\r
-                    if(parentName != null)\r
-                        return parentName + "/Inverse";\r
-                }\r
-            }\r
-            return name;\r
-        }\r
-        \r
-        if(graph.hasValue(resource)) {\r
-            Datatype datatype = graph.getDataType(resource);\r
-            Binding binding = Bindings.getBinding(datatype);\r
-            Object value = graph.getValue(resource, binding);\r
-            try {\r
-                String valueString = binding.toString(value, true);\r
-                if(valueString.length() < 100)\r
-                    return valueString;\r
-                else\r
-                    return valueString.substring(0, 100) + "...";\r
-            } catch (BindingException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-        \r
-        return "$" + resource.getResourceId();\r
-    }\r
-\r
-    @Override\r
-    public int compareTo(ResourceInfo o) {\r
-        return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(label, o.label);\r
-    }\r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2016 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:
+ *     THTH ry - initial API and implementation
+ *******************************************************************************/
+package org.simantics.debug.browser.utils;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.databoard.binding.Binding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.type.Datatype;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.utils.strings.AlphanumComparator;
+
+public class ResourceInfo implements Comparable<ResourceInfo> {
+    public final String label;
+    public final String uri;
+    public final long resourceId;
+    public final Resource resource;
+    
+    public ResourceInfo(ReadGraph graph, Resource resource) throws DatabaseException {
+        this.label = getLabel(graph, resource);
+        this.uri = graph.getPossibleURI(resource);
+        this.resourceId = resource.getResourceId();
+        this.resource = resource;
+    }
+    
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(80);
+        sb.append("<a href=\"")
+          .append(resourceId)
+          .append("\"");
+        
+        if (uri != null)
+            sb.append(" title=\"").append(uri).append("\"");
+        
+        sb.append(">")
+          .append(Escapes.html(label))
+          .append("</a>");
+        
+        return sb.toString();
+    }
+    
+    public static String getLabel(ReadGraph graph, Resource resource) throws DatabaseException {
+        Layer0 L0 = Layer0.getInstance(graph);
+        String name = graph.getPossibleRelatedValue(resource, L0.HasName);
+        if(name != null) {
+            if(name.equals("Inverse")) {
+                Resource inverse = graph.getPossibleInverse(resource);
+                Resource parent = graph.getPossibleObject(resource, L0.PartOf);
+                if(inverse != null && inverse.equals(parent)) {
+                    String parentName = graph.getPossibleRelatedValue(parent, L0.HasName);
+                    if(parentName != null)
+                        return parentName + "/Inverse";
+                }
+            }
+            return name;
+        }
+        
+        if(graph.hasValue(resource)) {
+            Datatype datatype = graph.getDataType(resource);
+            Binding binding = Bindings.getBinding(datatype);
+            Object value = graph.getValue(resource, binding);
+            try {
+                String valueString = binding.toString(value, true);
+                if(valueString.length() < 100)
+                    return valueString;
+                else
+                    return valueString.substring(0, 100) + "...";
+            } catch (BindingException e) {
+                e.printStackTrace();
+            }
+        }
+        
+        return "$" + resource.getResourceId();
+    }
+
+    @Override
+    public int compareTo(ResourceInfo o) {
+        return AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(label, o.label);
+    }
+}