]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
1 /*******************************************************************************\r
2  * Copyright (c) 2016 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     THTH ry - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.debug.browser.sections;\r
13 \r
14 import java.io.PrintWriter;\r
15 \r
16 import org.simantics.db.ReadGraph;\r
17 import org.simantics.db.exception.DatabaseException;\r
18 import org.simantics.debug.browser.utils.Escapes;\r
19 import org.simantics.debug.browser.utils.ValueInfo;\r
20 \r
21 public class ResourceInfoSection implements ResourceBrowserSection {\r
22 \r
23     ValueInfo valueInfo;\r
24     boolean immutable;\r
25 \r
26     public ResourceInfoSection(ValueInfo valueInfo, boolean immutable) {\r
27         this.valueInfo = valueInfo;\r
28         this.immutable = immutable;\r
29     }\r
30 \r
31     @Override\r
32     public double getPriority() {\r
33         return 2;\r
34     }\r
35 \r
36     @Override\r
37     public void toHtml(ReadGraph graph, PrintWriter out) throws DatabaseException {\r
38         out.println("<div id=\"resourceInfoContent\">");\r
39         out.println("<table>");\r
40         if (immutable) {\r
41             out.println("<tr><td colspan=\"2\" id=\"immutable\">IMMUTABLE</td></tr>");\r
42         }\r
43         if (valueInfo != null) {\r
44             if (valueInfo.datatype != null) {\r
45                 out.print("<tr>");\r
46                 out.print("<td class=\"top_key\">Attached value data type</td>");\r
47                 out.print("<td class=\"resourceType\">");\r
48                 out.print(Escapes.html(valueInfo.datatype));\r
49                 out.println("</td></tr>");\r
50             }\r
51             out.print("<tr><td class=\"top_key\">Attached value</td>");\r
52             out.print("<td id=\"attachedValue\">");\r
53             out.print(Escapes.html(valueInfo.value));\r
54             out.println("</td></tr>");\r
55         }\r
56         out.println("</table>");\r
57         out.println("</div>");\r
58     }\r
59 \r
60 }\r