]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/ResourceInfoSection.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.debug.browser / src / org / simantics / debug / browser / sections / ResourceInfoSection.java
diff --git a/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/ResourceInfoSection.java b/bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/ResourceInfoSection.java
new file mode 100644 (file)
index 0000000..54f5312
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************\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.sections;\r
+\r
+import java.io.PrintWriter;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.debug.browser.utils.Escapes;\r
+import org.simantics.debug.browser.utils.ValueInfo;\r
+\r
+public class ResourceInfoSection implements ResourceBrowserSection {\r
+\r
+    ValueInfo valueInfo;\r
+    boolean immutable;\r
+\r
+    public ResourceInfoSection(ValueInfo valueInfo, boolean immutable) {\r
+        this.valueInfo = valueInfo;\r
+        this.immutable = immutable;\r
+    }\r
+\r
+    @Override\r
+    public double getPriority() {\r
+        return 2;\r
+    }\r
+\r
+    @Override\r
+    public void toHtml(ReadGraph graph, PrintWriter out) throws DatabaseException {\r
+        out.println("<div id=\"resourceInfoContent\">");\r
+        out.println("<table>");\r
+        if (immutable) {\r
+            out.println("<tr><td colspan=\"2\" id=\"immutable\">IMMUTABLE</td></tr>");\r
+        }\r
+        if (valueInfo != null) {\r
+            if (valueInfo.datatype != null) {\r
+                out.print("<tr>");\r
+                out.print("<td class=\"top_key\">Attached value data type</td>");\r
+                out.print("<td class=\"resourceType\">");\r
+                out.print(Escapes.html(valueInfo.datatype));\r
+                out.println("</td></tr>");\r
+            }\r
+            out.print("<tr><td class=\"top_key\">Attached value</td>");\r
+            out.print("<td id=\"attachedValue\">");\r
+            out.print(Escapes.html(valueInfo.value));\r
+            out.println("</td></tr>");\r
+        }\r
+        out.println("</table>");\r
+        out.println("</div>");\r
+    }\r
+\r
+}\r