1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.uruma.context.impl; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collections; |
20 | |
import java.util.HashSet; |
21 | |
import java.util.List; |
22 | |
import java.util.Set; |
23 | |
|
24 | |
import org.seasar.uruma.binding.enables.EnablesDependingDef; |
25 | |
import org.seasar.uruma.context.ApplicationContext; |
26 | |
import org.seasar.uruma.context.PartContext; |
27 | |
import org.seasar.uruma.context.WidgetHandle; |
28 | |
import org.seasar.uruma.context.WindowContext; |
29 | |
import org.seasar.uruma.desc.FormDesc; |
30 | |
import org.seasar.uruma.desc.PartActionDesc; |
31 | |
import org.seasar.uruma.exception.DuplicateComponentIdException; |
32 | |
import org.seasar.uruma.util.AssertionUtil; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class WindowContextImpl extends AbstractWidgetHolder implements |
40 | |
WindowContext { |
41 | |
|
42 | |
private String windowName; |
43 | |
|
44 | 112 | private List<PartContext> partContextList = new ArrayList<PartContext>(); |
45 | |
|
46 | |
private ApplicationContextImpl parent; |
47 | |
|
48 | 112 | private List<EnablesDependingDef> enablesDependingDefList = new ArrayList<EnablesDependingDef>(); |
49 | |
|
50 | |
private Object partActionObj; |
51 | |
|
52 | |
private PartActionDesc partActionDesc; |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public WindowContextImpl(final String windowName, |
63 | |
final ApplicationContext parent) { |
64 | 112 | super(); |
65 | |
|
66 | 112 | this.windowName = windowName; |
67 | 112 | this.parent = (ApplicationContextImpl) parent; |
68 | 112 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public String getName() { |
74 | 224 | return this.windowName; |
75 | |
} |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
public PartContext getPartContext() { |
81 | 0 | if ((partContextList != null) && (partContextList.size() > 0)) { |
82 | 0 | return partContextList.get(0); |
83 | |
} else { |
84 | 0 | return null; |
85 | |
} |
86 | |
} |
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
public PartContext getPartContext(final String partName) { |
92 | 112 | for (PartContext context : partContextList) { |
93 | 0 | if (context.getName().equals(partName)) { |
94 | 0 | return context; |
95 | |
} |
96 | |
} |
97 | 112 | return null; |
98 | |
} |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public List<PartContext> getPartContextList() { |
104 | 468 | return Collections.unmodifiableList(partContextList); |
105 | |
} |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public ApplicationContext getApplicationContext() { |
111 | 336 | return parent; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void addPartContext(final PartContext context) { |
123 | 112 | if (getPartContext(context.getName()) == null) { |
124 | 112 | partContextList.add(context); |
125 | |
} else { |
126 | 0 | throw new DuplicateComponentIdException(context.getName()); |
127 | |
} |
128 | 112 | } |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public void disposePartContext(final String partName) { |
137 | 0 | PartContext partContext = getPartContext(partName); |
138 | 0 | if (partContext != null) { |
139 | 0 | partContextList.remove(partContext); |
140 | |
} |
141 | 0 | } |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
public void dispose() { |
147 | 0 | for (PartContext part : partContextList) { |
148 | 0 | disposePartContext(part.getName()); |
149 | |
} |
150 | 0 | parent.disposeWindowContext(windowName); |
151 | 0 | parent = null; |
152 | 0 | } |
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
public Set<WidgetHandle> findWidgetHandles(final String handleId) { |
158 | 468 | Set<WidgetHandle> results = new HashSet<WidgetHandle>(); |
159 | |
|
160 | 468 | WidgetHandle handle = getWidgetHandle(handleId); |
161 | 468 | if (handle != null) { |
162 | 8 | results.add(handle); |
163 | |
} |
164 | |
|
165 | 468 | for (PartContext part : getPartContextList()) { |
166 | 468 | handle = part.getWidgetHandle(handleId); |
167 | 468 | if (handle != null) { |
168 | 468 | results.add(handle); |
169 | |
} |
170 | |
} |
171 | 468 | return results; |
172 | |
} |
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
public Set<WidgetHandle> getAllWidgetHandles(final Class<?> clazz) { |
178 | 0 | Set<WidgetHandle> handles = new HashSet<WidgetHandle>(); |
179 | 0 | handles.addAll(getWidgetHandles(clazz)); |
180 | |
|
181 | 0 | for (PartContext part : getPartContextList()) { |
182 | 0 | handles.addAll(part.getWidgetHandles(clazz)); |
183 | |
} |
184 | |
|
185 | 0 | return handles; |
186 | |
} |
187 | |
|
188 | |
|
189 | |
|
190 | |
|
191 | |
|
192 | |
public void addEnablesDependingDef( |
193 | |
final EnablesDependingDef enablesDependingDef) { |
194 | 40 | AssertionUtil.assertNotNull("enablesDependingDef", enablesDependingDef); |
195 | 40 | enablesDependingDefList.add(enablesDependingDef); |
196 | 40 | } |
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
public List<EnablesDependingDef> getEnablesDependingDefList() { |
202 | 112 | return Collections.unmodifiableList(enablesDependingDefList); |
203 | |
} |
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
public Object getPartActionObject() { |
209 | 0 | return this.partActionObj; |
210 | |
} |
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
public void setPartActionDesc(final PartActionDesc desc) { |
216 | 0 | this.partActionDesc = desc; |
217 | 0 | } |
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
public void setPartActionObject(final Object partActionObj) { |
224 | 0 | this.partActionObj = partActionObj; |
225 | 0 | } |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
public PartActionDesc getPartActionDesc() { |
231 | 0 | return this.partActionDesc; |
232 | |
} |
233 | |
|
234 | |
|
235 | |
|
236 | |
|
237 | |
public WindowContext getWindowContext() { |
238 | 0 | return this; |
239 | |
} |
240 | |
|
241 | |
|
242 | |
|
243 | |
|
244 | |
public FormDesc getFormDesc() { |
245 | |
|
246 | 0 | return null; |
247 | |
} |
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
public Object getFormObject() { |
253 | |
|
254 | 0 | return null; |
255 | |
} |
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
public void setFormDesc(final FormDesc desc) { |
261 | |
|
262 | 0 | } |
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
public void setFormObject(final Object object) { |
268 | |
|
269 | 0 | } |
270 | |
|
271 | |
} |