1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package p3j.gui.panels.dboverview;
17
18 import james.SimSystem;
19
20 import java.awt.event.ActionEvent;
21 import java.awt.event.ActionListener;
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import javax.swing.JButton;
26 import javax.swing.JPanel;
27 import javax.swing.tree.TreePath;
28
29 import p3j.database.DatabaseFactory;
30 import p3j.gui.P3J;
31 import p3j.gui.panels.PropertiesShowPanelFactory;
32 import p3j.gui.panels.projections.IProjectionTree;
33 import p3j.gui.panels.projections.ProjectionTreeNode;
34 import p3j.misc.Misc;
35 import p3j.pppm.ProjectionModel;
36
37
38
39
40
41
42
43
44
45 public class OverviewProjectionNode extends ProjectionTreeNode<ProjectionModel> {
46
47
48 private static final long serialVersionUID = -7668884101075657298L;
49
50
51
52
53
54
55
56
57
58 public OverviewProjectionNode(ProjectionModel projectionModel, String name) {
59 super(projectionModel, name);
60 }
61
62 @Override
63 public JPanel selected(TreePath selectionPath, final IProjectionTree projTree) {
64
65 JButton loadProjection = new JButton("<html><b>Load</b></html>");
66 loadProjection.addActionListener(new ActionListener() {
67 @Override
68 public void actionPerformed(ActionEvent e) {
69 P3J.getInstance().setCurrentProjection(getEntity());
70 }
71 });
72
73 JButton removeProjection = new JButton("Remove");
74 removeProjection.addActionListener(new ActionListener() {
75 @Override
76 public void actionPerformed(ActionEvent e) {
77 try {
78 DatabaseFactory.getDatabaseSingleton().deleteProjection(getEntity());
79 P3J.getInstance().projectionDeleted(getEntity());
80 } catch (Exception ex) {
81 SimSystem.report(ex);
82 }
83 }
84 });
85
86 List<JButton> buttons = new ArrayList<JButton>();
87 buttons.add(removeProjection);
88 buttons.add(loadProjection);
89
90 PropertiesShowPanelFactory pspf = new PropertiesShowPanelFactory(buttons, 1);
91 pspf.sep("General Information");
92 pspf.app(Misc.GUI_LABEL_NAME, getEntity().getName());
93 pspf.app(Misc.GUI_LABEL_DESCRIPTION, getEntity().getDescription());
94 pspf.app(Misc.GUI_LABEL_JUMP_OFF_YEAR,
95 Integer.toString(getEntity().getJumpOffYear()));
96 pspf.app("Settypes:", getEntity().getAllSetTypes().size());
97 pspf.app("Descendant Generations:", getEntity().getGenerations() - 1);
98 pspf.app("Years to be predicted:", getEntity().getYears());
99 pspf.app("Number of age classes:", getEntity().getNumberOfAgeClasses());
100 return pspf.constructPanel();
101 }
102
103 }