]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.debug.browser/src/org/simantics/debug/browser/sections/BreadcrumbSection.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.debug.browser / src / org / simantics / debug / browser / sections / BreadcrumbSection.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
20 public class BreadcrumbSection implements ResourceBrowserSection {
21
22     public final Node[] breadcrumb;
23     
24     public BreadcrumbSection(Node[] breadcrumb) {
25         this.breadcrumb = breadcrumb;
26     }
27
28     public static class Node {
29         public final String separator;
30         public final String name;
31         public final long resourceId;
32         
33         public Node(String separator, String name, long resourceId) {
34             this.separator = separator;
35             this.name = name;
36             this.resourceId = resourceId;
37         }
38     }
39     
40     @Override
41     public double getPriority() {
42         return 0;
43     }
44
45     @Override
46     public void toHtml(ReadGraph graph, PrintWriter out)
47             throws DatabaseException {
48         
49         if (breadcrumb.length > 0) {
50             out.println("<div class=\"breadcrumbSection\">");
51             for(Node node : breadcrumb) {
52                 out.print(node.separator);
53                 out.print("<a href=\"");
54                 out.print(node.resourceId);
55                 out.print("\">");
56                 out.print(Escapes.html(node.name));
57                 out.print("</a>");
58             }
59             out.println("</div>");
60         }
61     }
62
63 }