Source code: nectar/view/TreeView.java
1 /*
2 Copyright (C) 2003 Kai Schutte
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18 * Class.java
19 *
20 * Created on April 1, 2003, 6:58 PM
21 */
22
23 package nectar.view;
24
25 import java.util.List;
26 import java.util.LinkedList;
27
28 import nectar.record.RecordTree;
29 import nectar.record.Record;
30
31 /**
32 *
33 * @author Kai Schutte skander@skander.com
34 */
35 public class TreeView implements java.io.Serializable {
36 protected List children = new LinkedList();
37 protected RecordView view = null;
38 /** Creates a new instance of Class */
39 public TreeView() {
40 }
41
42 public List getChildren() {
43 return this.children;
44 }
45
46 public void setChildren(List l) {
47 this.children = l;
48 }
49
50 public void addChild(TreeView tv) {
51 this.children.add(tv);
52 }
53
54 public void loadFromTree(RecordTree tree) {
55 Record r = tree.getRecord();
56 if (r != null) {
57 this.view = r.getView();
58 }
59 for (int t=0; t<tree.getChildCount(); t++) {
60 TreeView child = new TreeView();
61 child.loadFromTree(tree.getChild(t));
62 children.add(child);
63 }
64 }
65
66 public RecordView getView() {
67 return this.view;
68 }
69
70 public void setView(RecordView v) {
71 this.view = v;
72 }
73
74 }