1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.apache.tapestry.spec; |
16 |
|
|
17 |
|
import org.apache.hivemind.ApplicationRuntimeException; |
18 |
|
import org.apache.hivemind.HiveMind; |
19 |
|
import org.apache.hivemind.Resource; |
20 |
|
import org.apache.hivemind.util.Defense; |
21 |
|
import org.apache.hivemind.util.ToStringBuilder; |
22 |
|
import org.apache.tapestry.IComponent; |
23 |
|
import org.apache.tapestry.IForm; |
24 |
|
import org.apache.tapestry.event.BrowserEvent; |
25 |
|
import org.apache.tapestry.internal.event.ComponentEventProperty; |
26 |
|
import org.apache.tapestry.internal.event.EventBoundListener; |
27 |
|
|
28 |
|
import java.util.*; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
301 |
public class ComponentSpecification extends LocatablePropertyHolder implements IComponentSpecification |
57 |
|
{ |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
protected Map _components; |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
protected Map _assets; |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
protected Map _parameters; |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
protected Map _beans; |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
protected Set _reservedParameterNames; |
93 |
|
|
94 |
|
private String _componentClassName; |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
private String _description; |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
301 |
private boolean _allowBody = true; |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
301 |
private boolean _allowInformalParameters = true; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
private String _publicId; |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
private boolean _pageSpecification; |
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
private Resource _specificationLocation; |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
private Map _propertySpecifications; |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
private List _injectSpecifications; |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
private Map _claimedProperties; |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
301 |
private boolean _deprecated = false; |
166 |
|
|
167 |
301 |
private Map _componentEvents = new HashMap(); |
168 |
301 |
private Map _elementEvents = new HashMap(); |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
public void addAsset(String name, IAssetSpecification asset) |
176 |
|
{ |
177 |
10 |
if (_assets == null) |
178 |
5 |
_assets = new HashMap(); |
179 |
|
|
180 |
10 |
IAssetSpecification existing = (IAssetSpecification) _assets.get(name); |
181 |
|
|
182 |
10 |
if (existing != null) |
183 |
1 |
throw new ApplicationRuntimeException(SpecMessages.duplicateAsset(name, existing), |
184 |
|
asset.getLocation(), null); |
185 |
|
|
186 |
9 |
claimProperty(asset.getPropertyName(), asset); |
187 |
|
|
188 |
9 |
_assets.put(name, asset); |
189 |
9 |
} |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
public void addComponent(String id, IContainedComponent component) |
196 |
|
{ |
197 |
22 |
if (_components == null) |
198 |
17 |
_components = new HashMap(); |
199 |
|
|
200 |
22 |
IContainedComponent existing = (IContainedComponent) _components.get(id); |
201 |
|
|
202 |
22 |
if (existing != null) |
203 |
1 |
throw new ApplicationRuntimeException(SpecMessages.duplicateComponent(id, existing), |
204 |
|
component.getLocation(), null); |
205 |
|
|
206 |
21 |
_components.put(id, component); |
207 |
|
|
208 |
21 |
claimProperty(component.getPropertyName(), component); |
209 |
21 |
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
public void addParameter(IParameterSpecification spec) |
218 |
|
{ |
219 |
23 |
if (_parameters == null) |
220 |
12 |
_parameters = new HashMap(); |
221 |
|
|
222 |
23 |
String name = spec.getParameterName(); |
223 |
|
|
224 |
23 |
addParameterByName(name, spec); |
225 |
|
|
226 |
22 |
Iterator i = spec.getAliasNames().iterator(); |
227 |
30 |
while (i.hasNext()) |
228 |
|
{ |
229 |
8 |
String alias = (String) i.next(); |
230 |
|
|
231 |
8 |
addParameterByName(alias, spec); |
232 |
8 |
} |
233 |
|
|
234 |
22 |
claimProperty(spec.getPropertyName(), spec); |
235 |
22 |
} |
236 |
|
|
237 |
|
private void addParameterByName(String name, IParameterSpecification spec) |
238 |
|
{ |
239 |
31 |
IParameterSpecification existing = (IParameterSpecification) _parameters.get(name); |
240 |
|
|
241 |
31 |
if (existing != null) |
242 |
1 |
throw new ApplicationRuntimeException(SpecMessages.duplicateParameter(name, existing), |
243 |
|
spec.getLocation(), null); |
244 |
|
|
245 |
30 |
_parameters.put(name, spec); |
246 |
|
|
247 |
30 |
addReservedParameterName(name); |
248 |
30 |
} |
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
public boolean getAllowBody() |
258 |
|
{ |
259 |
0 |
return _allowBody; |
260 |
|
} |
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
public boolean getAllowInformalParameters() |
274 |
|
{ |
275 |
2 |
return _allowInformalParameters; |
276 |
|
} |
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
|
284 |
|
|
285 |
|
public IAssetSpecification getAsset(String name) |
286 |
|
{ |
287 |
7 |
return (IAssetSpecification) get(_assets, name); |
288 |
|
} |
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
public List getAssetNames() |
295 |
|
{ |
296 |
1 |
return sortedKeys(_assets); |
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
public IContainedComponent getComponent(String id) |
307 |
|
{ |
308 |
17 |
return (IContainedComponent) get(_components, id); |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
|
public String getComponentClassName() |
313 |
|
{ |
314 |
6 |
return _componentClassName; |
315 |
|
} |
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
public List getComponentIds() |
325 |
|
{ |
326 |
0 |
return sortedKeys(_components); |
327 |
|
} |
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
public IParameterSpecification getParameter(String name) |
337 |
|
{ |
338 |
25 |
return (IParameterSpecification) get(_parameters, name); |
339 |
|
} |
340 |
|
|
341 |
|
public Collection getRequiredParameters() |
342 |
|
{ |
343 |
6 |
if (_parameters == null) |
344 |
1 |
return Collections.EMPTY_LIST; |
345 |
|
|
346 |
5 |
Collection result = new ArrayList(); |
347 |
|
|
348 |
5 |
Iterator i = _parameters.entrySet().iterator(); |
349 |
13 |
while (i.hasNext()) |
350 |
|
{ |
351 |
8 |
Map.Entry entry = (Map.Entry) i.next(); |
352 |
8 |
String name = (String) entry.getKey(); |
353 |
8 |
IParameterSpecification spec = (IParameterSpecification) entry.getValue(); |
354 |
|
|
355 |
8 |
if (!spec.isRequired()) |
356 |
3 |
continue; |
357 |
|
|
358 |
5 |
if (!name.equals(spec.getParameterName())) |
359 |
2 |
continue; |
360 |
|
|
361 |
3 |
result.add(spec); |
362 |
3 |
} |
363 |
|
|
364 |
5 |
return result; |
365 |
|
} |
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
|
372 |
|
|
373 |
|
public List getParameterNames() |
374 |
|
{ |
375 |
7 |
return sortedKeys(_parameters); |
376 |
|
} |
377 |
|
|
378 |
|
public void setAllowBody(boolean value) |
379 |
|
{ |
380 |
26 |
_allowBody = value; |
381 |
26 |
} |
382 |
|
|
383 |
|
public void setAllowInformalParameters(boolean value) |
384 |
|
{ |
385 |
26 |
_allowInformalParameters = value; |
386 |
26 |
} |
387 |
|
|
388 |
|
public void setComponentClassName(String value) |
389 |
|
{ |
390 |
13 |
_componentClassName = value; |
391 |
13 |
} |
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
public void addBeanSpecification(String name, IBeanSpecification specification) |
400 |
|
{ |
401 |
10 |
if (_beans == null) |
402 |
9 |
_beans = new HashMap(); |
403 |
|
|
404 |
10 |
IBeanSpecification existing = (IBeanSpecification) _beans.get(name); |
405 |
|
|
406 |
10 |
if (existing != null) |
407 |
1 |
throw new ApplicationRuntimeException(SpecMessages.duplicateBean(name, existing), |
408 |
|
specification.getLocation(), null); |
409 |
|
|
410 |
9 |
claimProperty(specification.getPropertyName(), specification); |
411 |
|
|
412 |
9 |
_beans.put(name, specification); |
413 |
9 |
} |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
public IBeanSpecification getBeanSpecification(String name) |
423 |
|
{ |
424 |
8 |
return (IBeanSpecification) get(_beans, name); |
425 |
|
} |
426 |
|
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
public Collection getBeanNames() |
432 |
|
{ |
433 |
0 |
if (_beans == null) |
434 |
0 |
return Collections.EMPTY_LIST; |
435 |
|
|
436 |
0 |
return Collections.unmodifiableCollection(_beans.keySet()); |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
|
|
441 |
|
|
442 |
|
|
443 |
|
|
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
public void addReservedParameterName(String value) |
448 |
|
{ |
449 |
31 |
if (_reservedParameterNames == null) |
450 |
12 |
_reservedParameterNames = new HashSet(); |
451 |
|
|
452 |
31 |
_reservedParameterNames.add(value.toLowerCase()); |
453 |
31 |
} |
454 |
|
|
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
public boolean isReservedParameterName(String value) |
465 |
|
{ |
466 |
0 |
if (_reservedParameterNames == null) |
467 |
0 |
return false; |
468 |
|
|
469 |
0 |
return _reservedParameterNames.contains(value.toLowerCase()); |
470 |
|
} |
471 |
|
|
472 |
|
public String toString() |
473 |
|
{ |
474 |
0 |
ToStringBuilder builder = new ToStringBuilder(this); |
475 |
|
|
476 |
0 |
builder.append("componentClassName", _componentClassName); |
477 |
0 |
builder.append("pageSpecification", _pageSpecification); |
478 |
0 |
builder.append("specificationLocation", _specificationLocation); |
479 |
0 |
builder.append("allowBody", _allowBody); |
480 |
0 |
builder.append("allowInformalParameter", _allowInformalParameters); |
481 |
|
|
482 |
0 |
return builder.toString(); |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
public String getDescription() |
492 |
|
{ |
493 |
1 |
return _description; |
494 |
|
} |
495 |
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
public void setDescription(String description) |
503 |
|
{ |
504 |
1 |
_description = description; |
505 |
1 |
} |
506 |
|
|
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
public String getPublicId() |
517 |
|
{ |
518 |
0 |
return _publicId; |
519 |
|
} |
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
public void setPublicId(String publicId) |
524 |
|
{ |
525 |
0 |
_publicId = publicId; |
526 |
0 |
} |
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
|
536 |
|
|
537 |
|
public boolean isPageSpecification() |
538 |
|
{ |
539 |
7 |
return _pageSpecification; |
540 |
|
} |
541 |
|
|
542 |
|
|
543 |
|
|
544 |
|
public void setPageSpecification(boolean pageSpecification) |
545 |
|
{ |
546 |
17 |
_pageSpecification = pageSpecification; |
547 |
17 |
} |
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
private List sortedKeys(Map input) |
552 |
|
{ |
553 |
10 |
if (input == null) |
554 |
7 |
return Collections.EMPTY_LIST; |
555 |
|
|
556 |
3 |
List result = new ArrayList(input.keySet()); |
557 |
|
|
558 |
3 |
Collections.sort(result); |
559 |
|
|
560 |
3 |
return result; |
561 |
|
} |
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
private Object get(Map map, Object key) |
566 |
|
{ |
567 |
67 |
if (map == null) |
568 |
8 |
return null; |
569 |
|
|
570 |
59 |
return map.get(key); |
571 |
|
} |
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
public Resource getSpecificationLocation() |
576 |
|
{ |
577 |
146 |
return _specificationLocation; |
578 |
|
} |
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
public void setSpecificationLocation(Resource specificationLocation) |
583 |
|
{ |
584 |
68 |
_specificationLocation = specificationLocation; |
585 |
68 |
} |
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
|
|
593 |
|
|
594 |
|
public void addPropertySpecification(IPropertySpecification spec) |
595 |
|
{ |
596 |
8 |
if (_propertySpecifications == null) |
597 |
2 |
_propertySpecifications = new HashMap(); |
598 |
|
|
599 |
8 |
String name = spec.getName(); |
600 |
8 |
IPropertySpecification existing = (IPropertySpecification) _propertySpecifications |
601 |
|
.get(name); |
602 |
|
|
603 |
8 |
if (existing != null) |
604 |
0 |
throw new ApplicationRuntimeException(SpecMessages.duplicateProperty(name, existing), spec.getLocation(), null); |
605 |
|
|
606 |
8 |
claimProperty(name, spec); |
607 |
|
|
608 |
8 |
_propertySpecifications.put(name, spec); |
609 |
8 |
} |
610 |
|
|
611 |
|
|
612 |
|
|
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
public List getPropertySpecificationNames() |
619 |
|
{ |
620 |
2 |
return sortedKeys(_propertySpecifications); |
621 |
|
} |
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
public IPropertySpecification getPropertySpecification(String name) |
632 |
|
{ |
633 |
10 |
return (IPropertySpecification) get(_propertySpecifications, name); |
634 |
|
} |
635 |
|
|
636 |
|
public void addInjectSpecification(InjectSpecification spec) |
637 |
|
{ |
638 |
6 |
if (_injectSpecifications == null) |
639 |
3 |
_injectSpecifications = new ArrayList(); |
640 |
|
|
641 |
6 |
claimProperty(spec.getProperty(), spec); |
642 |
|
|
643 |
5 |
_injectSpecifications.add(spec); |
644 |
5 |
} |
645 |
|
|
646 |
|
public List getInjectSpecifications() |
647 |
|
{ |
648 |
3 |
return safeList(_injectSpecifications); |
649 |
|
} |
650 |
|
|
651 |
|
private List safeList(List input) |
652 |
|
{ |
653 |
3 |
if (input == null) |
654 |
0 |
return Collections.EMPTY_LIST; |
655 |
|
|
656 |
3 |
return Collections.unmodifiableList(input); |
657 |
|
} |
658 |
|
|
659 |
|
private void claimProperty(String propertyName, Object subSpecification) |
660 |
|
{ |
661 |
75 |
if (propertyName == null) |
662 |
45 |
return; |
663 |
|
|
664 |
30 |
if (_claimedProperties == null) |
665 |
11 |
_claimedProperties = new HashMap(); |
666 |
|
|
667 |
30 |
Object existing = _claimedProperties.get(propertyName); |
668 |
|
|
669 |
30 |
if (existing != null) |
670 |
1 |
throw new ApplicationRuntimeException(SpecMessages.claimedProperty( |
671 |
|
propertyName, |
672 |
|
existing), HiveMind.getLocation(subSpecification), null); |
673 |
|
|
674 |
29 |
_claimedProperties.put(propertyName, subSpecification); |
675 |
29 |
} |
676 |
|
|
677 |
|
|
678 |
|
public boolean isDeprecated() |
679 |
|
{ |
680 |
2 |
return _deprecated; |
681 |
|
} |
682 |
|
|
683 |
|
|
684 |
|
public void setDeprecated(boolean deprecated) |
685 |
|
{ |
686 |
26 |
_deprecated = deprecated; |
687 |
26 |
} |
688 |
|
|
689 |
|
public Set getReservedParameterNames() |
690 |
|
{ |
691 |
4 |
if (_reservedParameterNames == null) |
692 |
1 |
return Collections.EMPTY_SET; |
693 |
|
|
694 |
3 |
return Collections.unmodifiableSet(_reservedParameterNames); |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
public void addEventListener(String componentId, String[] events, |
701 |
|
String methodName, String formId, boolean validateForm, boolean async, boolean focus, boolean autoSubmit) |
702 |
|
{ |
703 |
19 |
ComponentEventProperty property = getComponentEvents(componentId); |
704 |
19 |
if (property == null) { |
705 |
16 |
property = new ComponentEventProperty(componentId); |
706 |
16 |
_componentEvents.put(componentId, property); |
707 |
|
} |
708 |
|
|
709 |
19 |
property.addListener(events, methodName, formId, validateForm, async, focus, autoSubmit); |
710 |
19 |
} |
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
public void addElementEventListener(String elementId, String[] events, |
716 |
|
String methodName, String formId, boolean validateForm, boolean async, boolean focus) |
717 |
|
{ |
718 |
3 |
ComponentEventProperty property = getElementEvents(elementId); |
719 |
3 |
if (property == null) { |
720 |
3 |
property = new ComponentEventProperty(elementId); |
721 |
3 |
_elementEvents.put(elementId, property); |
722 |
|
} |
723 |
|
|
724 |
3 |
property.addListener(events, methodName, formId, validateForm, async, focus, true); |
725 |
3 |
} |
726 |
|
|
727 |
|
public void connectAutoSubmitEvents(IComponent component, IForm form) |
728 |
|
{ |
729 |
0 |
Defense.notNull(form, "form"); |
730 |
|
|
731 |
0 |
ComponentEventProperty property = getComponentEvents(component.getExtendedId()); |
732 |
|
|
733 |
0 |
if (property == null) |
734 |
0 |
return; |
735 |
|
|
736 |
0 |
property.connectAutoSubmitEvents(form.getExtendedId()); |
737 |
0 |
} |
738 |
|
|
739 |
|
public void rewireComponentId(String componentId, String idPath) |
740 |
|
{ |
741 |
4 |
ComponentEventProperty prop = getComponentEvents(componentId); |
742 |
4 |
if (prop == null) |
743 |
1 |
return; |
744 |
|
|
745 |
3 |
if (_componentEvents.containsKey(idPath)) |
746 |
1 |
return; |
747 |
|
|
748 |
|
try { |
749 |
|
|
750 |
2 |
ComponentEventProperty clone = (ComponentEventProperty) prop.clone(); |
751 |
|
|
752 |
2 |
clone.rewireComponentId(idPath); |
753 |
|
|
754 |
2 |
_componentEvents.put(idPath, clone); |
755 |
|
|
756 |
0 |
} catch (CloneNotSupportedException e) { |
757 |
|
|
758 |
0 |
throw new ApplicationRuntimeException(e); |
759 |
2 |
} |
760 |
2 |
} |
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
|
765 |
|
public ComponentEventProperty getComponentEvents(String id) |
766 |
|
{ |
767 |
45 |
return (ComponentEventProperty)_componentEvents.get(id); |
768 |
|
} |
769 |
|
|
770 |
|
public Map getComponentEvents() |
771 |
|
{ |
772 |
6 |
return _componentEvents; |
773 |
|
} |
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
public ComponentEventProperty getElementEvents(String id) |
779 |
|
{ |
780 |
5 |
return (ComponentEventProperty)_elementEvents.get(id); |
781 |
|
} |
782 |
|
|
783 |
|
|
784 |
|
|
785 |
|
|
786 |
|
public Map getElementEvents() |
787 |
|
{ |
788 |
5 |
return _elementEvents; |
789 |
|
} |
790 |
|
|
791 |
|
|
792 |
|
|
793 |
|
|
794 |
|
public EventBoundListener[] getFormEvents(String formId, BrowserEvent event) |
795 |
|
{ |
796 |
2 |
List ret = new ArrayList(); |
797 |
|
|
798 |
2 |
Iterator it = _componentEvents.keySet().iterator(); |
799 |
4 |
while (it.hasNext()) { |
800 |
|
|
801 |
2 |
String compId = (String)it.next(); |
802 |
2 |
ComponentEventProperty prop = (ComponentEventProperty)_componentEvents.get(compId); |
803 |
|
|
804 |
2 |
ret.addAll(prop.getFormEventListeners(formId, event, null)); |
805 |
2 |
} |
806 |
|
|
807 |
2 |
it = _elementEvents.keySet().iterator(); |
808 |
2 |
while (it.hasNext()) { |
809 |
|
|
810 |
0 |
String compId = (String)it.next(); |
811 |
0 |
ComponentEventProperty prop = (ComponentEventProperty)_elementEvents.get(compId); |
812 |
|
|
813 |
0 |
ret.addAll(prop.getFormEventListeners(formId, event, null)); |
814 |
0 |
} |
815 |
|
|
816 |
2 |
return (EventBoundListener[])ret.toArray(new EventBoundListener[ret.size()]); |
817 |
|
} |
818 |
|
|
819 |
|
|
820 |
|
|
821 |
|
|
822 |
|
public boolean hasElementEvents() |
823 |
|
{ |
824 |
11 |
return _elementEvents.size() > 0; |
825 |
|
} |
826 |
|
|
827 |
|
|
828 |
|
|
829 |
|
|
830 |
|
public int hashCode() |
831 |
|
{ |
832 |
0 |
final int prime = 31; |
833 |
0 |
int result = 1; |
834 |
0 |
result = prime * result + ((_componentClassName == null) ? 0 : _componentClassName.hashCode()); |
835 |
0 |
result = prime * result + ((_description == null) ? 0 : _description.hashCode()); |
836 |
0 |
result = prime * result + (_pageSpecification ? 1231 : 1237); |
837 |
0 |
result = prime * result + ((_publicId == null) ? 0 : _publicId.hashCode()); |
838 |
0 |
return result; |
839 |
|
} |
840 |
|
|
841 |
|
|
842 |
|
|
843 |
|
|
844 |
|
public boolean equals(Object obj) |
845 |
|
{ |
846 |
22 |
if (this == obj) return true; |
847 |
1 |
if (obj == null) return false; |
848 |
1 |
if (getClass() != obj.getClass()) return false; |
849 |
1 |
final ComponentSpecification other = (ComponentSpecification) obj; |
850 |
1 |
if (_componentClassName == null) { |
851 |
1 |
if (other._componentClassName != null) return false; |
852 |
0 |
} else if (!_componentClassName.equals(other._componentClassName)) return false; |
853 |
0 |
if (_description == null) { |
854 |
0 |
if (other._description != null) return false; |
855 |
0 |
} else if (!_description.equals(other._description)) return false; |
856 |
0 |
if (_pageSpecification != other._pageSpecification) return false; |
857 |
0 |
if (_publicId == null) { |
858 |
0 |
if (other._publicId != null) return false; |
859 |
0 |
} else if (!_publicId.equals(other._publicId)) return false; |
860 |
0 |
if (_specificationLocation == null) { |
861 |
0 |
if (other._specificationLocation != null) return false; |
862 |
0 |
} else if (!_specificationLocation.getPath().equals(other._specificationLocation.getPath())) return false; |
863 |
0 |
return true; |
864 |
|
} |
865 |
|
|
866 |
|
|
867 |
|
} |