OSDN Git Service

srcディレクトリとdocディレクトリを作成
[xdf/git-repos.git] / src / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / mappers / JButtonMapper.java
1 package jp.ac.aiit.xdf.component.swing.mappers;
2
3 import java.util.Map;
4
5 import javax.swing.Icon;
6 import javax.swing.ImageIcon;
7 import javax.swing.JButton;
8
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.IconProcessor;
13 import jp.ac.aiit.xdf.component.swing.attribute.ObjectModelAttributeGetProcessor;
14 import jp.ac.aiit.xdf.component.swing.attribute.SetterAttributeProcessor;
15 import jp.ac.aiit.xdf.component.swing.event.ActionEventHandler;
16 import jp.ac.aiit.xdf.component.swing.event.SwingEventHandler;
17 import jp.ac.aiit.xdf.component.swing.event.SwingEventType;
18 import jp.ac.aiit.xdf.core.action.EventHandler;
19 import jp.ac.aiit.xdf.core.typeconvert.StringConverter;
20
21
22 /**
23  * buttonタグをSwingのJButtonにマッピングするクラス
24  * 
25  * @author Shunichi Takagi
26  */
27 public class JButtonMapper extends SwingComponentMapperTemplate {
28
29         @Override
30         protected Map<String, AttributeProcessingUnit> initProcessingUnits() {
31                 Map<String, AttributeProcessingUnit> result = CommonAttributeStore.commonAttributes(model);
32                 result.put("text", new AttributeProcessingUnit(new SetterAttributeProcessor("setText", false), new GetterAttributeProcessor("getText"), new StringConverter()));
33                 result.put("img", new AttributeProcessingUnit(new IconProcessor(), new ObjectModelAttributeGetProcessor(model), new StringConverter()));
34                 
35                 return result;
36         }
37
38         @Override
39         protected Map<String, EventHandler> intiProcessingAction() {
40                 Map<String, EventHandler> action = SwingEventHandler.commonEvent();
41                 action.put("click", new ActionEventHandler(SwingEventType.CLICK));
42                 return action;
43         }
44
45         @SuppressWarnings("serial")
46         @Override
47         protected Object newComponent() {
48                 return new JButton(){
49                         @SuppressWarnings("unused")
50                         public void setIcon(ImageIcon defaultIcon){setIcon((Icon)defaultIcon);}
51                 };
52         }
53
54         @Override
55         protected void processingChildComponents() { }
56
57
58 }