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