diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/RequestView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/RequestView.java index 8d26f1a..0913d1c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/RequestView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/RequestView.java @@ -18,24 +18,27 @@ package eu.omp.irap.vespa.epntapclient.view; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.JButton; -import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextArea; -import javax.swing.JTextField; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import eu.omp.irap.vespa.epntapclient.utils.Queries; +import eu.omp.irap.vespa.epntapclient.view.ParamField.DataProductTypeField; +import eu.omp.irap.vespa.epntapclient.view.ParamField.DateRangeField; +import eu.omp.irap.vespa.epntapclient.view.ParamField.FloatRangeField; +import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException; /** @@ -56,18 +59,17 @@ public class RequestView extends JPanel implements ActionListener { private JTextArea queryArea; // TODO: Use one map for paramFields, paramValues, paramTypes. + /** * The parameters fields for the request. */ - private Map paramFields; + private List paramFields; /** * The parameters fields for the request. */ private Map paramValues; - private Map paramTypes; - /** The height of the buttons panel. */ private static final int BUTTON_PANEL_HEIGHT = 15; @@ -81,15 +83,6 @@ public class RequestView extends JPanel implements ActionListener { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // TODO: Get max row number from the GUI - // TODO: auto-building range field by checking *_min / *_max attribute names - - paramTypes = new HashMap<>(); - paramTypes.put("target_name", String.class); - paramTypes.put("dataproduct_type", String.class); - paramTypes.put("minTime", Float.class); - paramTypes.put("maxTime", Float.class); - paramTypes.put("spectral_range_min", Float.class); - paramTypes.put("spectral_range_max", Float.class); paramValues = new HashMap<>(); @@ -102,26 +95,21 @@ public class RequestView extends JPanel implements ActionListener { * @return A JPanel containing graphical elements for the service parameters. */ private JPanel buildParamPanel() { - paramFields = new HashMap(); - - // TODO: Find a way to set numerical value to "" by default. // TODO: new GUI field column to allow the user to select the comparison operator: // - if the field is a String: listbox with 'xx', '%xx', 'xx%', and '%xx%'. // - if the field is a numeric value: listbox with <, <=, =, =>, >. - for (Map.Entry paramType : paramTypes.entrySet()) { - paramFields.put(paramType.getKey(), - new ParamField(this, paramType.getKey(), paramType.getValue())); - } - - JPanel paramPanel = new JPanel(new GridLayout(0, 2)); + paramFields = new ArrayList(); + paramFields.add(new TargetNameField(this, "target_name")); + paramFields.add(new DateRangeField(this, "time_")); + paramFields.add(new FloatRangeField(this, "spectral_range_")); + paramFields.add(new DataProductTypeField(this, "dataproduct_type")); + + JPanel paramPanel = new JPanel(); + paramPanel.setLayout(new BoxLayout(paramPanel, BoxLayout.Y_AXIS)); paramPanel.setBorder(BorderFactory.createTitledBorder("Query parameters")); - for (Map.Entry e : paramFields.entrySet()) { - JLabel label = new JLabel(e.getKey()); - paramPanel.add(label); - - // TODO: Add tooltip text based on rr.table_column.column_description - paramPanel.add(e.getValue()); + for (ParamField field : paramFields) { + paramPanel.add(field); } return paramPanel; @@ -145,6 +133,7 @@ public class RequestView extends JPanel implements ActionListener { public void updateParam(String paramName, Object value) { logger.info("uploading " + paramName + ": " + value); paramValues.put(paramName, value); + updateQueryArea(); } /** -- libgit2 0.21.2