diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java index 1917476..1ed8098 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/ParamField.java @@ -51,14 +51,16 @@ public abstract class ParamField extends JPanel { } public static class StringField extends ParamField { + JTextField field; + StringField(RequestView requestView, String paramName) { super(requestView, paramName); - JTextField field = new JTextField(); - addChangeListener(field, e -> onUpdate(field)); + field = new JTextField(); + addChangeListener(field, e -> onUpdate()); this.add(field); } - private void onUpdate(JTextField field) { + private void onUpdate() { if ("".equals(field.getText())) { requestView.updateParam(paramName, null); } else { @@ -68,14 +70,16 @@ public abstract class ParamField extends JPanel { } public static class FloatField extends ParamField { + JTextField field; + FloatField(RequestView requestView, String paramName) { super(requestView, paramName); - JTextField field = new JTextField(); - addChangeListener(field, e -> onUpdate(field)); + field = new JTextField(); + addChangeListener(field, e -> onUpdate()); this.add(field); } - private void onUpdate(JTextField field) { + private void onUpdate() { if ("".equals(field.getText())) { field.setBackground(Color.WHITE); requestView.updateParam(paramName, null); @@ -91,13 +95,16 @@ public abstract class ParamField extends JPanel { } public static class DateRangeField extends ParamField { + JTextField fieldMin; + JTextField fieldMax; + DateRangeField(RequestView requestView, String paramName) { super(requestView, paramName); - JTextField fieldMin = new JTextField(); + fieldMin = new JTextField(); addChangeListener(fieldMin, e -> onUpdate(fieldMin, MIN_SUFFIX)); this.add(fieldMin); - JTextField fieldMax = new JTextField(); + fieldMax = new JTextField(); addChangeListener(fieldMax, e -> onUpdate(fieldMax, MAX_SUFFIX)); this.add(fieldMax); } @@ -154,14 +161,17 @@ public abstract class ParamField extends JPanel { } public static class TargetNameField extends ParamField { + JTextField field; + TargetNameField(RequestView requestView, String paramName) { super(requestView, paramName); - JTextField field = new JTextField(); - addChangeListener(field, e -> onUpdate(field)); + field = new JTextField(); + addChangeListener(field, e -> onUpdate()); + field.setEditable(true); this.add(field); } - private void onUpdate(JTextField field) { + private void onUpdate() { // TODO: add resolver if ("".equals(field.getText())) { requestView.updateParam(paramName, null); @@ -172,15 +182,17 @@ public abstract class ParamField extends JPanel { } public static class DataProductTypeField extends ParamField { + JTextField field; + DataProductTypeField(RequestView requestView, String paramName) { super(requestView, paramName); - JTextField field = new JTextField(); + field = new JTextField(); // TODO: listbox with enumerated values instead of JTextField - addChangeListener(field, e -> onUpdate(field)); + addChangeListener(field, e -> onUpdate()); this.add(field); } - private void onUpdate(JTextField field) { + private void onUpdate() { if ("".equals(field.getText())) { requestView.updateParam(paramName, null); } else { @@ -190,15 +202,17 @@ public abstract class ParamField extends JPanel { } public static class TargetClassField extends ParamField { + JTextField field; + TargetClassField(RequestView requestView, String paramName) { super(requestView, paramName); JTextField field = new JTextField(); // TODO: listbox with enumerated values instead of JTextField - addChangeListener(field, e -> onUpdate(field)); + addChangeListener(field, e -> onUpdate()); this.add(field); } - private void onUpdate(JTextField field) { + private void onUpdate() { if ("".equals(field.getText())) { requestView.updateParam(paramName, null); } else { -- libgit2 0.21.2