Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EnablesDependingListenerSupport |
|
| 0.0;0 |
1 | /* | |
2 | * Copyright 2004-2008 the Seasar Foundation and the Others. | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
13 | * either express or implied. See the License for the specific language | |
14 | * governing permissions and limitations under the License. | |
15 | */ | |
16 | package org.seasar.uruma.binding.enables; | |
17 | ||
18 | import java.util.Set; | |
19 | ||
20 | import org.seasar.uruma.context.WidgetHandle; | |
21 | import org.seasar.uruma.context.WindowContext; | |
22 | import org.seasar.uruma.core.UrumaMessageCodes; | |
23 | import org.seasar.uruma.exception.NotFoundException; | |
24 | ||
25 | /** | |
26 | * EnablesDepending のセットアップを行うクラスです。<br /> | |
27 | * | |
28 | * @author y-komori | |
29 | */ | |
30 | public class EnablesDependingListenerSupport { | |
31 | 0 | private EnablesDependingListenerSupport() { |
32 | 0 | } |
33 | ||
34 | /** | |
35 | * {@link WindowContext} が保持する {@link EnablesDependingDef} について、{@link EnablesDependingListener} | |
36 | * をセットアップして EnablesDepending が機能するようにします。<br /> | |
37 | * | |
38 | * @param context | |
39 | * {@link WindowContext} オブジェクト | |
40 | */ | |
41 | public static void setupEnableDependingListeners(final WindowContext context) { | |
42 | 112 | for (EnablesDependingDef def : context.getEnablesDependingDefList()) { |
43 | 40 | String targetId = def.getTargetId(); |
44 | 40 | Set<WidgetHandle> handles = context.findWidgetHandles(targetId); |
45 | 40 | if (handles.size() > 0) { |
46 | 40 | for (WidgetHandle handle : handles) { |
47 | 40 | EnablesDependingListener listener = EnablesDependingListenerFactory |
48 | .getListener(handle, def.getWidgetHandle(), def | |
49 | .getType()); | |
50 | 40 | listener.setupListener(); |
51 | 40 | listener.updateEnableState(); |
52 | 40 | } |
53 | } else { | |
54 | 0 | throw new NotFoundException( |
55 | UrumaMessageCodes.ENABLES_DEPENDING_TARGET_NOT_FOUND, | |
56 | targetId); | |
57 | } | |
58 | 40 | } |
59 | 112 | } |
60 | } |