| 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 | 0 | public EnablesDependableVisitor(final WindowContext context) { |
| 42 | 0 | this.context = context; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
public void visit(final UIElement element) { |
| 49 | 0 | if ((element instanceof UIComponent) |
| 50 | |
&& (element instanceof EnablesDependable)) { |
| 51 | 0 | EnablesDependable dependable = (EnablesDependable) element; |
| 52 | 0 | String id = ((UIComponent) element).getId(); |
| 53 | |
|
| 54 | 0 | if (id != null) { |
| 55 | |
|
| 56 | 0 | String enablesDependingId = dependable.getEnablesDependingId(); |
| 57 | 0 | String enablesForType = dependable.getEnablesFor(); |
| 58 | |
|
| 59 | 0 | if (!StringUtil.isEmpty(enablesDependingId)) { |
| 60 | 0 | EnablesForType type = EnablesForType.SELECTION; |
| 61 | 0 | if (!StringUtil.isEmpty(enablesForType)) { |
| 62 | 0 | type = EnablesForType.valueOf(enablesForType); |
| 63 | |
} |
| 64 | |
|
| 65 | 0 | WidgetHandle handle = context.getWidgetHandle(id); |
| 66 | 0 | if (handle != null) { |
| 67 | 0 | EnablesDependingDef def = new EnablesDependingDef( |
| 68 | |
handle, enablesDependingId, type); |
| 69 | 0 | context.addEnablesDependingDef(def); |
| 70 | 0 | } else { |
| 71 | 0 | throw new NotFoundException(UICOMPONENT_NOT_FOUND, id); |
| 72 | |
} |
| 73 | |
} |
| 74 | |
} |
| 75 | |
} |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public void visit(final UIElementContainer container) { |
| 82 | 0 | for (UIElement element : container.getChildren()) { |
| 83 | 0 | element.accept(this); |
| 84 | |
} |
| 85 | 0 | } |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public void visit(final Template template) { |
| 91 | |
|
| 92 | 0 | } |
| 93 | |
} |