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.eclipse.swt.widgets.Composite;
22 import org.seasar.uruma.annotation.ComponentElement;
23 import org.seasar.uruma.component.CommonAttributes;
24 import org.seasar.uruma.component.LayoutDataInfo;
25 import org.seasar.uruma.component.LayoutInfo;
26 import org.seasar.uruma.component.UIComponent;
27 import org.seasar.uruma.component.UICompositeComponent;
28 import org.seasar.uruma.component.UIElement;
29 import org.seasar.uruma.component.UIElementVisitor;
30 import org.seasar.uruma.context.PartContext;
31 import org.seasar.uruma.context.WidgetHandle;
32 import org.seasar.uruma.context.WindowContext;
33
34
35
36
37
38
39 @ComponentElement
40 public class CompositeComponent extends ControlComponent implements
41 UICompositeComponent {
42 private LayoutInfo<?> layoutInfo;
43
44 private LayoutDataInfo childLayoutDataInfo;
45
46 private CommonAttributes commonAttributes;
47
48 private List<UIElement> children = new ArrayList<UIElement>();
49
50
51
52
53 public LayoutInfo<?> getLayoutInfo() {
54 return this.layoutInfo;
55 }
56
57
58
59
60 public void setLayoutInfo(final LayoutInfo<?> layoutInfo) {
61 this.layoutInfo = layoutInfo;
62 }
63
64
65
66
67
68
69 public LayoutDataInfo getChildLayoutDataInfo() {
70 return this.childLayoutDataInfo;
71 }
72
73
74
75
76
77
78
79 public void setChildLayoutDataInfo(final LayoutDataInfo childLayoutDataInfo) {
80 this.childLayoutDataInfo = childLayoutDataInfo;
81 }
82
83
84
85
86 public CommonAttributes getCommonAttributes() {
87 return commonAttributes;
88 }
89
90
91
92
93 public void setCommonAttributes(final CommonAttributes commonAttributes) {
94 this.commonAttributes = commonAttributes;
95 }
96
97
98
99
100 public void addChild(final UIElement child) {
101 this.children.add(child);
102
103 if (child instanceof UIComponent) {
104 ((UIComponent) child).setParent(this);
105 }
106 }
107
108
109
110
111 public List<UIElement> getChildren() {
112 return children;
113 }
114
115
116
117
118
119 @Override
120 protected void doPreRender(final WidgetHandle parent,
121 final WindowContext context) {
122 preRenderChild(context.getWidgetHandle(getId()), context);
123 }
124
125
126
127
128
129 @Override
130 protected void doRender(final WidgetHandle parent, final PartContext context) {
131 renderChild(context.getWidgetHandle(getId()), context);
132 }
133
134
135
136
137 @Override
138 public void accept(final UIElementVisitor visitor) {
139 visitor.visit(this);
140 }
141
142
143
144
145
146
147
148
149
150 protected void preRenderChild(final WidgetHandle parent,
151 final WindowContext context) {
152 for (UIElement child : children) {
153 if (child instanceof UIComponent) {
154 ((UIComponent) child).preRender(parent, context);
155 }
156 }
157 }
158
159
160
161
162
163
164
165
166
167 protected void renderChild(final WidgetHandle parent,
168 final PartContext context) {
169 for (UIElement child : children) {
170 if (child instanceof UIComponent) {
171 ((UIComponent) child).render(parent, context);
172 }
173 }
174 }
175 }