Commit 667dd80c7a45cc8a44cd2aa37ef717bc9bd8d966

Authored by Nathanael Jourdane
1 parent 41133475
Exists in master

JTextField as ParamField attribute.

src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java
... ... @@ -51,14 +51,16 @@ public abstract class ParamField extends JPanel {
51 51 }
52 52  
53 53 public static class StringField extends ParamField {
  54 + JTextField field;
  55 +
54 56 StringField(RequestView requestView, String paramName) {
55 57 super(requestView, paramName);
56   - JTextField field = new JTextField();
57   - addChangeListener(field, e -> onUpdate(field));
  58 + field = new JTextField();
  59 + addChangeListener(field, e -> onUpdate());
58 60 this.add(field);
59 61 }
60 62  
61   - private void onUpdate(JTextField field) {
  63 + private void onUpdate() {
62 64 if ("".equals(field.getText())) {
63 65 requestView.updateParam(paramName, null);
64 66 } else {
... ... @@ -68,14 +70,16 @@ public abstract class ParamField extends JPanel {
68 70 }
69 71  
70 72 public static class FloatField extends ParamField {
  73 + JTextField field;
  74 +
71 75 FloatField(RequestView requestView, String paramName) {
72 76 super(requestView, paramName);
73   - JTextField field = new JTextField();
74   - addChangeListener(field, e -> onUpdate(field));
  77 + field = new JTextField();
  78 + addChangeListener(field, e -> onUpdate());
75 79 this.add(field);
76 80 }
77 81  
78   - private void onUpdate(JTextField field) {
  82 + private void onUpdate() {
79 83 if ("".equals(field.getText())) {
80 84 field.setBackground(Color.WHITE);
81 85 requestView.updateParam(paramName, null);
... ... @@ -91,13 +95,16 @@ public abstract class ParamField extends JPanel {
91 95 }
92 96  
93 97 public static class DateRangeField extends ParamField {
  98 + JTextField fieldMin;
  99 + JTextField fieldMax;
  100 +
94 101 DateRangeField(RequestView requestView, String paramName) {
95 102 super(requestView, paramName);
96   - JTextField fieldMin = new JTextField();
  103 + fieldMin = new JTextField();
97 104 addChangeListener(fieldMin, e -> onUpdate(fieldMin, MIN_SUFFIX));
98 105 this.add(fieldMin);
99 106  
100   - JTextField fieldMax = new JTextField();
  107 + fieldMax = new JTextField();
101 108 addChangeListener(fieldMax, e -> onUpdate(fieldMax, MAX_SUFFIX));
102 109 this.add(fieldMax);
103 110 }
... ... @@ -154,14 +161,17 @@ public abstract class ParamField extends JPanel {
154 161 }
155 162  
156 163 public static class TargetNameField extends ParamField {
  164 + JTextField field;
  165 +
157 166 TargetNameField(RequestView requestView, String paramName) {
158 167 super(requestView, paramName);
159   - JTextField field = new JTextField();
160   - addChangeListener(field, e -> onUpdate(field));
  168 + field = new JTextField();
  169 + addChangeListener(field, e -> onUpdate());
  170 + field.setEditable(true);
161 171 this.add(field);
162 172 }
163 173  
164   - private void onUpdate(JTextField field) {
  174 + private void onUpdate() {
165 175 // TODO: add resolver
166 176 if ("".equals(field.getText())) {
167 177 requestView.updateParam(paramName, null);
... ... @@ -172,15 +182,17 @@ public abstract class ParamField extends JPanel {
172 182 }
173 183  
174 184 public static class DataProductTypeField extends ParamField {
  185 + JTextField field;
  186 +
175 187 DataProductTypeField(RequestView requestView, String paramName) {
176 188 super(requestView, paramName);
177   - JTextField field = new JTextField();
  189 + field = new JTextField();
178 190 // TODO: listbox with enumerated values instead of JTextField
179   - addChangeListener(field, e -> onUpdate(field));
  191 + addChangeListener(field, e -> onUpdate());
180 192 this.add(field);
181 193 }
182 194  
183   - private void onUpdate(JTextField field) {
  195 + private void onUpdate() {
184 196 if ("".equals(field.getText())) {
185 197 requestView.updateParam(paramName, null);
186 198 } else {
... ... @@ -190,15 +202,17 @@ public abstract class ParamField extends JPanel {
190 202 }
191 203  
192 204 public static class TargetClassField extends ParamField {
  205 + JTextField field;
  206 +
193 207 TargetClassField(RequestView requestView, String paramName) {
194 208 super(requestView, paramName);
195 209 JTextField field = new JTextField();
196 210 // TODO: listbox with enumerated values instead of JTextField
197   - addChangeListener(field, e -> onUpdate(field));
  211 + addChangeListener(field, e -> onUpdate());
198 212 this.add(field);
199 213 }
200 214  
201   - private void onUpdate(JTextField field) {
  215 + private void onUpdate() {
202 216 if ("".equals(field.getText())) {
203 217 requestView.updateParam(paramName, null);
204 218 } else {
... ...