1 /**
2 * This file is part of the equanda project.
3 *
4 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
7 *
8 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
9 * ANY KIND, either express or implied. See the License for the specific language governing rights and
10 * limitations under the License.
11 *
12 * Alternatively, the contents of this file may be used under the terms of
13 * either the GNU General Public License Version 2 or later (the "GPL"), or
14 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
15 * in which case the provisions of the GPL or the LGPL are applicable instead
16 * of those above. If you wish to allow use of your version of this file only
17 * under the terms of either the GPL or the LGPL, and not to allow others to
18 * use your version of this file under the terms of the MPL, indicate your
19 * decision by deleting the provisions above and replace them with the notice
20 * and other provisions required by the GPL or the LGPL. If you do not delete
21 * the provisions above, a recipient may use your version of this file under
22 * the terms of any one of the MPL, the GPL or the LGPL.
23 */
24
25 package org.equanda.tapestry5.data;
26
27 /**
28 * This class is used by the TreeTable component to flatten a given Tree structure
29 * so that it can be represented in an html table.
30 * <p/>
31 * A Tree is nested, an html table is flat and this class represent each node of the
32 * tree, but without nesting. The TreeTable component can then convert a Tree structure
33 * (each Tree can contain other Tree childs) into a list of FlattenedTree objects.
34 * The FlattenedTree still remember the position of the node in the original tree in order
35 * to render the tree correctly in html (reference to javascript used
36 * by TreeTable component for details).
37 *
38 * @author Geert Mergan
39 */
40 public class FlattenedTree
41 implements java.io.Serializable
42 {
43 private Tree tree;
44 private String dotId;
45 private int depth;
46
47 public FlattenedTree( Tree tree, int depth, String dotId )
48 {
49 super();
50 this.tree = tree;
51 this.dotId = dotId;
52 this.depth = depth;
53 }
54
55 public Tree getTree()
56 {
57 return tree;
58 }
59
60 public String getDotId()
61 {
62 return dotId;
63 }
64
65 public int getDepth()
66 {
67 return depth;
68 }
69
70 public boolean isLeaf()
71 {
72 return tree.isLeaf();
73 }
74 }