1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.mevenide.idea.util.ui.tree;
18
19 import javax.swing.tree.DefaultMutableTreeNode;
20 import org.mevenide.idea.Res;
21
22 /***
23 * @author Arik
24 */
25 public class GoalTreeNode extends DefaultMutableTreeNode {
26 private static final Res RES = Res.getInstance(GoalTreeNode.class);
27 private final String description;
28 private final String[] prereqs;
29
30 public GoalTreeNode(final String pGoal) {
31 this(pGoal, null, null);
32 }
33
34 public GoalTreeNode(final String pGoal, final String pDescription) {
35 this(pGoal, pDescription, null);
36 }
37
38 public GoalTreeNode(final String pGoal, final String[] pPrereqs) {
39 this(pGoal, null, pPrereqs);
40 }
41
42 public GoalTreeNode(final String pGoal,
43 final String pDescription,
44 final String[] pPrereqs) {
45 super(pGoal);
46
47 if (pGoal == null || pGoal.trim().length() == 0)
48 throw new IllegalArgumentException(RES.get("empty.goal.name"));
49
50 if (pDescription == null || pDescription.trim().length() == 0 || pDescription.equalsIgnoreCase(
51 "null"))
52 description = null;
53 else
54 description = pDescription;
55
56 if (pPrereqs == null)
57 prereqs = new String[0];
58 else
59 prereqs = pPrereqs;
60 }
61
62 public String getUserObject() {
63 return (String) super.getUserObject();
64 }
65
66 public String getGoal() {
67 return getUserObject();
68 }
69
70 public String getDescription() {
71 return description;
72 }
73
74 public String[] getPrereqs() {
75 return prereqs;
76 }
77
78 public String toString() {
79 if (description == null || description.trim().length() == 0)
80 return super.toString();
81 else
82 return super.toString() + " - " + description;
83 }
84
85 @Override
86 public boolean getAllowsChildren() {
87 return false;
88 }
89 }