01: package net.sourceforge.tracelog.ui;
02:
03: import java.util.LinkedList;
04: import java.util.List;
05:
06: public class ShellOptionMenu {
07: private List<ShellOptionMenu> children;
08: private String menu;
09: private String parent;
10: private AbstractWidget widget;
11:
12: public ShellOptionMenu(String menu, AbstractWidget widget) {
13: this .menu = menu;
14: this .widget = widget;
15: this .parent = null;
16: this .children = new LinkedList<ShellOptionMenu>();
17: }
18:
19: public void addChild(ShellOptionMenu childMenu) {
20: childMenu.setParent(menu);
21: children.add(childMenu);
22: }
23:
24: public ShellOptionMenu[] getChildren() {
25: return children.toArray(new ShellOptionMenu[children.size()]);
26: }
27:
28: public String getMenu() {
29: return menu;
30: }
31:
32: public String getParent() {
33: return parent;
34: }
35:
36: public boolean hasChildren() {
37: return children.size() > 0;
38: }
39:
40: public void setParent(String parent) {
41: this .parent = parent;
42: }
43:
44: public void showContent() {
45: if (widget != null) {
46: widget.run();
47: }
48: }
49:
50: public String toString() {
51: return menu;
52: }
53: }
|