OSDN Git Service

srcディレクトリとdocディレクトリを作成
[xdf/git-repos.git] / src / xdf-swing / src / main / java / jp / ac / aiit / xdf / component / swing / mappers / JTextFieldMapper.java
1 package jp.ac.aiit.xdf.component.swing.mappers;
2
3 import java.util.Map;
4
5 import javax.swing.JTextField;
6 import javax.swing.border.Border;
7
8 import jp.ac.aiit.xdf.component.swing.attribute.AttributeProcessingUnit;
9 import jp.ac.aiit.xdf.component.swing.attribute.CommonAttributeStore;
10 import jp.ac.aiit.xdf.component.swing.attribute.GetterAttributeProcessor;
11 import jp.ac.aiit.xdf.component.swing.attribute.SetterAttributeProcessor;
12 import jp.ac.aiit.xdf.component.swing.event.KeyEventHandler;
13 import jp.ac.aiit.xdf.component.swing.event.SwingEventHandler;
14 import jp.ac.aiit.xdf.component.swing.event.SwingEventType;
15 import jp.ac.aiit.xdf.component.swing.typeconvert.BorderConverter;
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  * textfieldタグをSwingのJTextFieldとしてマッピングするクラス
22  * 
23  * @author Shunichi Takagi
24  */
25 public class JTextFieldMapper extends SwingComponentMapperTemplate {
26
27         @Override
28         protected Map<String, AttributeProcessingUnit> initProcessingUnits() {
29                 Map<String, AttributeProcessingUnit> result = CommonAttributeStore.commonAttributes(model);
30                 result.put("value", new AttributeProcessingUnit(new SetterAttributeProcessor("setText", false), new GetterAttributeProcessor("getText"), new StringConverter()));
31                 result.put("border", new AttributeProcessingUnit(new SetterAttributeProcessor("setBorder", Border.class), new GetterAttributeProcessor("getBorder"), new BorderConverter()));
32                 result.put("editable", new AttributeProcessingUnit(new SetterAttributeProcessor("setEditable", true), new GetterAttributeProcessor("isEditable"), new BooleanConverter()));
33
34                 return result;
35         }
36
37         @Override
38         protected Object newComponent() {
39                 return new JTextField();
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("edit", new KeyEventHandler(SwingEventType.EDIT));
49                 action.put("press-enter", new KeyEventHandler(SwingEventType.PRESSENTER));
50                 return action;
51         }
52
53 }