| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.seasar.uruma.binding.value; |
| 17 | |
|
| 18 | |
import java.util.List; |
| 19 | |
|
| 20 | |
import org.seasar.framework.beans.PropertyDesc; |
| 21 | |
import org.seasar.uruma.binding.value.command.ExportSelectionCommand; |
| 22 | |
import org.seasar.uruma.binding.value.command.ExportValueCommand; |
| 23 | |
import org.seasar.uruma.binding.value.command.ImportSelectionCommand; |
| 24 | |
import org.seasar.uruma.binding.value.command.ImportValueCommand; |
| 25 | |
import org.seasar.uruma.context.PartContext; |
| 26 | |
import org.seasar.uruma.context.WidgetHandle; |
| 27 | |
import org.seasar.uruma.core.UrumaMessageCodes; |
| 28 | |
import org.seasar.uruma.desc.FormDesc; |
| 29 | |
import org.seasar.uruma.exception.BindingException; |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | 0 | public class ValueBindingSupport { |
| 37 | 4 | private static final ImportValueCommand IMPORT_VALUE_COMMAND = new ImportValueCommand(); |
| 38 | |
|
| 39 | 4 | private static final ExportValueCommand EXPORT_VALUE_COMMAND = new ExportValueCommand(); |
| 40 | |
|
| 41 | 4 | private static final ImportSelectionCommand IMPORT_SELECTION_COMMAND = new ImportSelectionCommand(); |
| 42 | |
|
| 43 | 4 | private static final ExportSelectionCommand EXPORT_SELECTION_COMMAND = new ExportSelectionCommand(); |
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
public static void importValue(final PartContext context) { |
| 52 | 44 | dealFields(context, IMPORT_VALUE_COMMAND); |
| 53 | 44 | } |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
public static void exportValue(final PartContext context) { |
| 62 | 148 | dealFields(context, EXPORT_VALUE_COMMAND); |
| 63 | 148 | } |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
public static void importSelection(final PartContext context) { |
| 72 | 44 | dealFields(context, IMPORT_SELECTION_COMMAND); |
| 73 | 44 | } |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
public static void exportSelection(final PartContext context) { |
| 82 | 148 | dealFields(context, EXPORT_SELECTION_COMMAND); |
| 83 | 148 | } |
| 84 | |
|
| 85 | |
private static void dealFields(final PartContext context, |
| 86 | |
final BindingCommand command) { |
| 87 | 384 | Object form = context.getFormObject(); |
| 88 | 384 | FormDesc formDesc = context.getFormDesc(); |
| 89 | 384 | if (form == null || formDesc == null) { |
| 90 | 0 | return; |
| 91 | |
} |
| 92 | |
|
| 93 | 384 | List<PropertyDesc> targetProperties = command |
| 94 | |
.getTargetPropertyDescs(formDesc); |
| 95 | 384 | for (PropertyDesc pd : targetProperties) { |
| 96 | 36 | String id = command.getId(pd.getField()); |
| 97 | |
|
| 98 | 36 | WidgetHandle handle = context.getWidgetHandle(id); |
| 99 | 36 | if (handle != null) { |
| 100 | 36 | Object widget = handle.getWidget(); |
| 101 | 36 | command.doBind(widget, form, pd, handle.getUiComponent()); |
| 102 | 36 | } else { |
| 103 | 0 | throw new BindingException(UrumaMessageCodes.WIDGET_NOT_FOUND, |
| 104 | |
id, form.getClass(), pd.getField()); |
| 105 | |
} |
| 106 | 36 | } |
| 107 | 384 | } |
| 108 | |
} |