1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.component.jface;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.seasar.framework.util.StringUtil;
22 import org.seasar.uruma.annotation.ComponentAttribute;
23 import org.seasar.uruma.annotation.ComponentElement;
24 import org.seasar.uruma.annotation.FieldDescription;
25 import org.seasar.uruma.annotation.RenderingPolicy;
26 import org.seasar.uruma.annotation.RenderingPolicy.TargetType;
27 import org.seasar.uruma.component.UIComponent;
28 import org.seasar.uruma.component.UIComponentContainer;
29 import org.seasar.uruma.component.UIElement;
30 import org.seasar.uruma.component.UIElementVisitor;
31 import org.seasar.uruma.component.rcp.ViewPartComponent;
32 import org.seasar.uruma.context.WidgetHandle;
33 import org.seasar.uruma.context.WindowContext;
34 import org.seasar.uruma.util.AssertionUtil;
35
36
37
38
39
40
41
42 @ComponentElement
43 public class MenuComponent extends MenuItemComponent implements
44 UIComponentContainer {
45
46
47
48 @RenderingPolicy(targetType = TargetType.NONE)
49 @ComponentAttribute
50 @FieldDescription("デフォルトアイテムID")
51 public String defaultItemId;
52
53
54
55
56 @RenderingPolicy(targetType = TargetType.NONE)
57 @ComponentAttribute
58 @FieldDescription("可視状態")
59 public String visible;
60
61
62
63
64 @RenderingPolicy(targetType = TargetType.NONE)
65 @ComponentAttribute
66 @FieldDescription("メニューの表示 X 座標")
67 public String x;
68
69
70
71
72 @RenderingPolicy(targetType = TargetType.NONE)
73 @ComponentAttribute
74 @FieldDescription("メニューの表示 Y 座標")
75 public String y;
76
77 private List<UIElement> children = new ArrayList<UIElement>();
78
79
80
81
82
83
84 public void addChild(final UIElement child) {
85 AssertionUtil.assertNotNull("child", child);
86 AssertionUtil.assertInstanceOf("child", MenuItemComponent.class, child);
87
88 this.children.add(child);
89 }
90
91
92
93
94 public List<UIElement> getChildren() {
95 return this.children;
96 }
97
98
99
100
101
102
103
104 @Override
105 protected void doPreRender(final WidgetHandle parent,
106 final WindowContext context) {
107 UIComponentContainer parentComponent = getParent();
108
109 if (parentComponent instanceof WindowComponent) {
110 WindowComponent windowComponent = (WindowComponent) parentComponent;
111 if (StringUtil.isEmpty(windowComponent.menu)) {
112 windowComponent.menu = getId();
113 }
114 } else if (parentComponent instanceof ViewPartComponent) {
115
116 return;
117 }
118
119 for (UIElement child : children) {
120 if (child instanceof UIComponent) {
121 ((UIComponent) child).preRender(context
122 .getWidgetHandle(getId()), context);
123 }
124 }
125 }
126
127
128
129
130
131
132 @Override
133 public void accept(final UIElementVisitor visitor) {
134 visitor.visit(this);
135 }
136 }