1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.uruma.binding.method; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | |
import org.seasar.uruma.annotation.EventListenerType; |
22 | |
import org.seasar.uruma.binding.method.impl.GenericActionListenerBinder; |
23 | |
import org.seasar.uruma.binding.method.impl.GenericHandlerListenerBinder; |
24 | |
import org.seasar.uruma.binding.method.impl.StructuredViewerListenerBinder; |
25 | |
import org.seasar.uruma.binding.method.impl.UrumaApplicationWindowListenerBinder; |
26 | |
import org.seasar.uruma.binding.method.impl.ViewerListenerBinder; |
27 | |
import org.seasar.uruma.binding.method.impl.WidgetListenerBinder; |
28 | |
import org.seasar.uruma.context.WidgetHandle; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
public class ListenerBinderFactory { |
36 | |
private static ListenerBinder[] binders; |
37 | |
|
38 | |
static { |
39 | 4 | List<ListenerBinder> binderList = new ArrayList<ListenerBinder>(); |
40 | |
|
41 | 4 | binderList.add(new StructuredViewerListenerBinder()); |
42 | 4 | binderList.add(new ViewerListenerBinder()); |
43 | 4 | binderList.add(new UrumaApplicationWindowListenerBinder()); |
44 | 4 | binderList.add(new WidgetListenerBinder()); |
45 | 4 | binderList.add(new GenericActionListenerBinder()); |
46 | 4 | binderList.add(new GenericHandlerListenerBinder()); |
47 | |
|
48 | 4 | binders = binderList.toArray(new ListenerBinder[binderList.size()]); |
49 | 4 | } |
50 | |
|
51 | 0 | private ListenerBinderFactory() { |
52 | |
|
53 | 0 | } |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
public static ListenerBinder getListenerBinder(final WidgetHandle handle, |
63 | |
final EventListenerType type) { |
64 | 1692 | for (int i = 0; i < binders.length; i++) { |
65 | 1692 | Class<?> clazz = binders[i].getTargetCLass(); |
66 | 1692 | if (clazz.isAssignableFrom(handle.getWidgetClass())) { |
67 | 428 | EventListenerType[] types = binders[i].getEventTypes(); |
68 | 428 | if (types == null) { |
69 | 416 | return binders[i]; |
70 | |
} else { |
71 | 12 | for (int j = 0; j < types.length; j++) { |
72 | 12 | if (types[j] == type) { |
73 | 12 | return binders[i]; |
74 | |
} |
75 | |
} |
76 | |
} |
77 | |
} |
78 | |
} |
79 | 0 | return null; |
80 | |
} |
81 | |
} |