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