OSDN Git Service

srcディレクトリとdocディレクトリを作成
[xdf/git-repos.git] / src / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / mappers / JCheckboxMapper.java
1 package jp.ac.aiit.xdf.component.swing.mappers;
2
3 import java.util.Map;
4
5 import javax.swing.JCheckBox;
6
7 import jp.ac.aiit.xdf.component.swing.attribute.AttributeProcessingUnit;
8 import jp.ac.aiit.xdf.component.swing.attribute.CommonAttributeStore;
9 import jp.ac.aiit.xdf.component.swing.attribute.DoNothingAttributeProcessor;
10 import jp.ac.aiit.xdf.component.swing.attribute.GetterAttributeProcessor;
11 import jp.ac.aiit.xdf.component.swing.attribute.ObjectModelAttributeGetProcessor;
12 import jp.ac.aiit.xdf.component.swing.attribute.SetterAttributeProcessor;
13 import jp.ac.aiit.xdf.component.swing.event.ActionEventHandler;
14 import jp.ac.aiit.xdf.component.swing.event.SwingEventHandler;
15 import jp.ac.aiit.xdf.component.swing.event.SwingEventType;
16 import jp.ac.aiit.xdf.core.action.EventHandler;
17 import jp.ac.aiit.xdf.core.typeconvert.BooleanConverter;
18 import jp.ac.aiit.xdf.core.typeconvert.StringConverter;
19
20 /**
21  * checkboxタグをSwingのJCheckBoxにマッピングする
22  * @author Shunichi Takagi
23  */
24 public class JCheckboxMapper extends SwingComponentMapperTemplate {
25
26
27         @Override
28         protected Map<String, AttributeProcessingUnit> initProcessingUnits() {
29                 Map<String, AttributeProcessingUnit> result = CommonAttributeStore.commonAttributes(model);
30                 result.put("text", new AttributeProcessingUnit(new SetterAttributeProcessor("setText", false), new GetterAttributeProcessor("getText"), new StringConverter()));
31                 result.put("value", new AttributeProcessingUnit(new DoNothingAttributeProcessor(), new ObjectModelAttributeGetProcessor(model), new StringConverter()));
32                 result.put("checked", new AttributeProcessingUnit(new SetterAttributeProcessor("setSelected", true), new GetterAttributeProcessor("isSelected"), new BooleanConverter()));
33                 
34                 return result;
35         }
36         
37         @Override
38         protected Object newComponent() {
39                 return new JCheckBox();
40         }
41
42         @Override
43         protected void processingChildComponents() { }
44
45         @Override
46         protected Map<String, EventHandler> intiProcessingAction() {
47                 Map<String, EventHandler> action = SwingEventHandler.commonEvent();
48                 action.put("check", new ActionEventHandler(SwingEventType.CHECK));
49                 action.put("uncheck", new ActionEventHandler(SwingEventType.UNCHECK));
50                 return action;
51         }
52 }