Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
EnablesDependingListener |
|
| 1.0;1 |
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 org.seasar.framework.beans.BeanDesc; | |
19 | import org.seasar.framework.beans.PropertyDesc; | |
20 | import org.seasar.framework.beans.factory.BeanDescFactory; | |
21 | import org.seasar.uruma.context.WidgetHandle; | |
22 | ||
23 | /** | |
24 | * 自ウィジットの選択状態によってターゲットのイネーブル状態を変更するためのリスナーインターフェースです。<br /> | |
25 | * | |
26 | * @author y-komori | |
27 | */ | |
28 | public abstract class EnablesDependingListener { | |
29 | protected WidgetHandle target; | |
30 | ||
31 | protected WidgetHandle enabled; | |
32 | ||
33 | protected EnablesForType type; | |
34 | ||
35 | protected PropertyDesc enabledProperty; | |
36 | ||
37 | protected static final String ENABLED_PROPERTY_NAME = "enabled"; | |
38 | ||
39 | /** | |
40 | * {@link EnablesDependingListener} を構築します。<br /> | |
41 | * | |
42 | * @param target | |
43 | * ターゲットの {@link WidgetHandle} | |
44 | * @param enabled | |
45 | * イネーブル状態を変更するウィジットの {@link WidgetHandle} | |
46 | * @param type | |
47 | * 選択条件を表す {@link EnablesForType} | |
48 | */ | |
49 | protected EnablesDependingListener(final WidgetHandle target, | |
50 | 40 | final WidgetHandle enabled, final EnablesForType type) { |
51 | 40 | this.target = target; |
52 | 40 | this.enabled = enabled; |
53 | 40 | this.type = type; |
54 | 40 | BeanDesc desc = BeanDescFactory.getBeanDesc(enabled.getWidgetClass()); |
55 | 40 | this.enabledProperty = desc.getPropertyDesc(ENABLED_PROPERTY_NAME); |
56 | 40 | } |
57 | ||
58 | /** | |
59 | * コンストラクタで設定されたターゲットに対してリスナーを生成します。<br /> | |
60 | * 本メソッドはサブクラスで実装してください。<br /> | |
61 | */ | |
62 | protected abstract void setupListener(); | |
63 | ||
64 | /** | |
65 | * イネーブル状態を最新にします。<br /> | |
66 | */ | |
67 | protected abstract void updateEnableState(); | |
68 | } |