01: package tide.exttools.PMD;
02:
03: import javax.swing.tree.DefaultMutableTreeNode;
04:
05: public final class RuleSet extends DefaultMutableTreeNode {
06: String fullName; // ruleset/basics.xml
07: String name;
08: String descr;
09: private boolean selected = false;
10:
11: public RuleSet(String fullName, String name, String descr) {
12: super (name);
13:
14: this .fullName = fullName;
15: this .name = name;
16: this .descr = descr;
17: }
18:
19: public void setAllRulesetSelected(boolean is) {
20: selected = is;
21:
22: // recursive
23: for (int i = 0; i < getChildCount(); i++) {
24: Rule rii = (Rule) getChildAt(i);
25: rii.selected = is;
26: }
27: }
28:
29: public Rule getRule(String name) {
30: for (int i = 0; i < getChildCount(); i++) {
31: Rule rii = (Rule) getChildAt(i);
32: if (rii.name.equals(name))
33: return rii;
34: }
35: return null;
36: }
37:
38: @Override
39: public final String toString() {
40: StringBuilder sb = new StringBuilder();
41: sb.append("" + fullName);
42: sb.append("\nname= " + name);
43: sb.append("\ndescr= " + descr);
44: return sb.toString();
45: }
46:
47: public boolean isRuleSetFullSelected() {
48: return selected;
49: }
50:
51: public boolean[] getSelectionState() {
52: boolean hasSel = false;
53: boolean hasDes = false;
54:
55: // recursive
56: for (int i = 0; i < getChildCount(); i++) {
57: if (getChildAt(i) instanceof Rule) {
58: Rule rii = (Rule) getChildAt(i);
59: if (rii.selected) {
60: hasSel = true;
61: } else {
62: hasDes = true;
63: }
64: } else {
65: RuleSet rii = (RuleSet) getChildAt(i);
66: //TODOif(rii.selected) { hasSel = true; }
67: //else { hasDes = true; }
68: }
69: }
70: return new boolean[] { hasSel, hasDes };
71: }
72:
73: }
|