1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.uruma.component;
17
18 import org.seasar.framework.util.StringUtil;
19 import org.seasar.uruma.binding.enables.EnablesDependingDef;
20 import org.seasar.uruma.binding.enables.EnablesForType;
21 import org.seasar.uruma.context.WidgetHandle;
22 import org.seasar.uruma.context.WindowContext;
23 import org.seasar.uruma.core.UrumaMessageCodes;
24 import org.seasar.uruma.exception.NotFoundException;
25
26
27
28
29
30
31
32 public class EnablesDependableVisitor implements UIElementVisitor,
33 UrumaMessageCodes {
34 private WindowContext context;
35
36
37
38
39
40
41 public EnablesDependableVisitor(final WindowContext context) {
42 this.context = context;
43 }
44
45
46
47
48 public void visit(final UIElement element) {
49 if ((element instanceof UIComponent)
50 && (element instanceof EnablesDependable)) {
51 EnablesDependable dependable = (EnablesDependable) element;
52 String id = ((UIComponent) element).getId();
53
54 if (id != null) {
55
56 String enablesDependingId = dependable.getEnablesDependingId();
57 String enablesForType = dependable.getEnablesFor();
58
59 if (!StringUtil.isEmpty(enablesDependingId)) {
60 EnablesForType type = EnablesForType.SELECTION;
61 if (!StringUtil.isEmpty(enablesForType)) {
62 type = EnablesForType.valueOf(enablesForType);
63 }
64
65 WidgetHandle handle = context.getWidgetHandle(id);
66 if (handle != null) {
67 EnablesDependingDef def = new EnablesDependingDef(
68 handle, enablesDependingId, type);
69 context.addEnablesDependingDef(def);
70 } else {
71 throw new NotFoundException(UICOMPONENT_NOT_FOUND, id);
72 }
73 }
74 }
75 }
76 }
77
78
79
80
81 public void visit(final UIElementContainer container) {
82 for (UIElement element : container.getChildren()) {
83 element.accept(this);
84 }
85 }
86
87
88
89
90 public void visit(final Template template) {
91
92 }
93 }