| 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.lang.reflect.Method; |
| 19 | |
|
| 20 | |
import org.eclipse.jface.viewers.StructuredViewer; |
| 21 | |
import org.seasar.uruma.annotation.AsyncMethod; |
| 22 | |
import org.seasar.uruma.binding.method.impl.OmissionArgumentsFilter; |
| 23 | |
import org.seasar.uruma.binding.method.impl.StructuredSelectionArgumentsFilter; |
| 24 | |
import org.seasar.uruma.binding.method.impl.TypedEventArgumentsFilter; |
| 25 | |
import org.seasar.uruma.context.WidgetHandle; |
| 26 | |
import org.seasar.uruma.rcp.core.UrumaBundleState; |
| 27 | |
import org.seasar.uruma.rcp.core.UrumaBundleState.BundleState; |
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
public class MethodBindingFactory { |
| 35 | 0 | private MethodBindingFactory() { |
| 36 | |
|
| 37 | 0 | } |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
public static MethodBinding createMethodBinding(final Object target, |
| 53 | |
final Method method, final WidgetHandle handle, |
| 54 | |
final AsyncMethod asyncMethod) { |
| 55 | |
MethodBinding binding; |
| 56 | 428 | if (asyncMethod == null |
| 57 | |
|| UrumaBundleState.getInstance().getUrumaBundleState() == BundleState.NOT_AVAILABLE) { |
| 58 | 428 | binding = new MethodBinding(target, method, null); |
| 59 | |
} else { |
| 60 | 0 | binding = new AsyncMethodBinding(target, method, null); |
| 61 | 0 | ((AsyncMethodBinding) binding).setTaskNameProperty(asyncMethod |
| 62 | |
.nameProperty()); |
| 63 | 0 | ((AsyncMethodBinding) binding).setCancelable(asyncMethod |
| 64 | |
.cancelable()); |
| 65 | |
} |
| 66 | |
|
| 67 | 428 | Class<?> widgetClass = handle.getWidgetClass(); |
| 68 | 428 | if (StructuredViewer.class.isAssignableFrom(widgetClass)) { |
| 69 | 8 | binding.addArgumentsFilter(new StructuredSelectionArgumentsFilter( |
| 70 | |
method)); |
| 71 | |
} else { |
| 72 | 420 | binding.addArgumentsFilter(new OmissionArgumentsFilter(method)); |
| 73 | 420 | binding.addArgumentsFilter(new TypedEventArgumentsFilter(method)); |
| 74 | |
} |
| 75 | |
|
| 76 | 428 | return binding; |
| 77 | |
} |
| 78 | |
} |