1 package jp.ac.aiit.xdf.component.swing.mappers;
3 import java.awt.Component;
6 import javax.swing.JList;
7 import javax.swing.border.Border;
9 import jp.ac.aiit.xdf.component.swing.attribute.AttributeProcessingUnit;
10 import jp.ac.aiit.xdf.component.swing.attribute.CommonAttributeStore;
11 import jp.ac.aiit.xdf.component.swing.attribute.GetterAttributeProcessor;
12 import jp.ac.aiit.xdf.component.swing.attribute.SelectedIndexProcessor;
13 import jp.ac.aiit.xdf.component.swing.attribute.SetterAttributeProcessor;
14 import jp.ac.aiit.xdf.component.swing.event.ActionEventHandler;
15 import jp.ac.aiit.xdf.component.swing.event.SwingEventHandler;
16 import jp.ac.aiit.xdf.component.swing.event.SwingEventType;
17 import jp.ac.aiit.xdf.component.swing.typeconvert.BorderConverter;
18 import jp.ac.aiit.xdf.core.action.EventHandler;
19 import jp.ac.aiit.xdf.core.typeconvert.IntegerConverter;
20 import jp.ac.aiit.xdf.core.typeconvert.StringValuesConverter;
23 * listタグをSwingのJListにマッピングする
27 public class JListMapper extends SwingComponentMapperTemplate {
30 protected Map<String, AttributeProcessingUnit> initProcessingUnits() {
31 Map<String, AttributeProcessingUnit> result = CommonAttributeStore.commonAttributes(model);
32 result.put("values", new AttributeProcessingUnit(new SetterAttributeProcessor("setListData", false), new GetValuesProcessor(), new StringValuesConverter()));
33 result.put("border", new AttributeProcessingUnit(new SetterAttributeProcessor("setBorder", Border.class), new GetterAttributeProcessor("getBorder"), new BorderConverter()));
34 result.put("selected", new AttributeProcessingUnit(new SelectedIndexProcessor(), new GetterAttributeProcessor("getSelectedIndex"), new IntegerConverter()));
40 protected Object newComponent() {
45 protected void processingChildComponents() { }
47 private class GetValuesProcessor extends GetterAttributeProcessor{
48 public GetValuesProcessor(){
52 public Object invokeGet(Object target, String name) {
53 JList list = (JList)getComponent();
54 Component[] components = list.getComponents();
55 String[] values = new String[components.length];
56 System.arraycopy(components, 0, values, 0, components.length);
62 protected Map<String, EventHandler> intiProcessingAction() {
63 Map<String, EventHandler> action = SwingEventHandler.commonEvent();
64 action.put("change", new ActionEventHandler(SwingEventType.CHANGE));