1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package p3j.gui.panels;
17
18 import java.awt.BorderLayout;
19
20 import javax.swing.JPanel;
21 import javax.swing.JScrollPane;
22 import javax.swing.JTree;
23 import javax.swing.tree.DefaultTreeModel;
24
25 import p3j.pppm.ProjectionModel;
26
27
28
29
30
31
32
33
34 public abstract class AbstractNavigationPanel extends JPanel {
35
36
37 private static final long serialVersionUID = -8802994657383849297L;
38
39
40 private JTree tree;
41
42
43 private DefaultTreeModel treeModel;
44
45
46 private JScrollPane scrollPane;
47
48
49 private ProjectionModel projection;
50
51
52 private final JPanel contentPanel;
53
54
55
56
57
58
59
60
61
62 public AbstractNavigationPanel(ProjectionModel projectionModel, JPanel content) {
63 projection = projectionModel;
64 contentPanel = content;
65 if (projection == null) {
66 return;
67 }
68 setProjection(projection);
69 }
70
71
72
73
74
75
76
77 public final void setProjection(ProjectionModel projMod) {
78 projection = projMod;
79 removeAll();
80 initTree();
81 setLayout(new BorderLayout());
82 if (getScrollPane() != null) {
83 add(getScrollPane(), BorderLayout.CENTER);
84 }
85 }
86
87
88
89
90 protected abstract void initTree();
91
92 public final JTree getTree() {
93 return tree;
94 }
95
96 public void setTree(JTree tree) {
97 this.tree = tree;
98 }
99
100 public final DefaultTreeModel getTreeModel() {
101 return treeModel;
102 }
103
104 public void setTreeModel(DefaultTreeModel treeModel) {
105 this.treeModel = treeModel;
106 }
107
108 public final JScrollPane getScrollPane() {
109 return scrollPane;
110 }
111
112 public void setScrollPane(JScrollPane scrollPane) {
113 this.scrollPane = scrollPane;
114 }
115
116 public ProjectionModel getProjectionModel() {
117 return projection;
118 }
119
120 public JPanel getContentPanel() {
121 return contentPanel;
122 }
123 }