1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 package org.ximtec.igesture.tool.binding;
27
28 import javax.swing.JTextField;
29
30 import org.ximtec.igesture.configuration.Configuration;
31
32
33 public class MapTextFieldBinding extends DataBinding<JTextField> {
34
35 private JTextField textField;
36 private String algorithm;
37
38
39 public MapTextFieldBinding(JTextField textField, Configuration configuration, String property, String algorithm) {
40 super(configuration, property);
41 this.textField = textField;
42 this.algorithm = algorithm;
43 this.textField.addFocusListener(this);
44 updateView();
45 }
46
47
48 @Override
49 public JTextField getComponent() {
50 return textField;
51 }
52
53
54 @Override
55 protected void updateView() {
56 textField.setText(getValue());
57 }
58
59
60 @Override
61 protected void updateModel() {
62 setValue(textField.getText());
63 }
64
65
66
67
68
69
70 @Override
71 protected String getValue() {
72 return ((Configuration)getObject()).getParameters(algorithm).get(getProperty());
73 }
74
75 @Override
76 protected void setValue(Object value) {
77 if(!getValue().equals(value)){
78 ((Configuration)getObject()).addParameter(algorithm, getProperty(), (String)value);
79 }
80
81 }
82
83
84 }