diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java index a081b06..0d909fb 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java @@ -164,16 +164,16 @@ public class EpnTapController implements MainViewListener { try { Object object = args[0]; switch (event) { - case serviceSelected: + case SERVICE_SELECTED: updateSelected(((Integer) args[0]).intValue()); break; - case btnSendClicked: + case SEND_BUTTON_CLICKED: sendQuery((String) object); break; - case paramChanged: + case PARAMETER_CHANGED: updateParameter((String) object, args[1]); break; - case paramRemoved: + case PARAMETER_REMOVED: removeParameter((String) object); break; default: @@ -182,7 +182,7 @@ public class EpnTapController implements MainViewListener { } catch (Exception e) { mainView.displayError("Error", e.getMessage()); logger.log(Level.WARNING, - "Exception thrown when " + event.toString() + ": " + e.getMessage()); + "Exception thrown when " + event.toString() + ": " + e.getMessage(), e); } } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java index 088b8db..2d9e620 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/utils/Queries.java @@ -47,6 +47,10 @@ public final class Queries { + "1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/EpnCore%') " + "ORDER BY short_name, table_name"; + /** Constructor to hide the implicit public one. */ + private Queries() { + } + /** * The default query, with these parameters, respectively: max_rows, target_name, time_min, * time_max, dataproduct_type, spectral_range_min, spectral_range_max. @@ -76,8 +80,4 @@ public final class Queries { return "SELECT TOP " + nbRow + " target_name, target_class FROM " + tableName + where; } - /** Constructor to hide the implicit public one. */ - private Queries() { - } - } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java index ad8d499..2cd74c7 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Dim.java @@ -39,4 +39,8 @@ public class Dim { public static final int BOTTOM_PANEL_HEIGHT = 150; /** The minimum height of the bottom panel (result view). */ public static final int BOTTOM_PANEL_MIN_HEIGHT = 100; + + /** Private constructor to hide the implicit public one. */ + private Dim() { + } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java index aaffe62..6c40f02 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java @@ -63,6 +63,7 @@ public class EpnTapMainView extends JPanel { * @author N. Jourdane */ public interface MainViewListener { + /** * When an event is detected on the main view. * diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java index 54eaddc..ec4bc39 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/Event.java @@ -21,11 +21,11 @@ package eu.omp.irap.vespa.epntapclient.view; */ public enum Event { /** When a service is selected on the service panel. */ - serviceSelected, + SERVICE_SELECTED, /** When the `Send query` button is clicked. */ - btnSendClicked, + SEND_BUTTON_CLICKED, /** When a parameter is removed on the parameter panel. */ - paramRemoved, + PARAMETER_REMOVED, /** When a parameter is updated to a valid value on the parameter panel. */ - paramChanged; + PARAMETER_CHANGED; } 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 e6e4b8e..250a929 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 @@ -138,9 +138,9 @@ public abstract class ParamField extends JPanel { @Override public void update(JTextField textField) { if ("".equals(textField.getText())) { - mainView.event(Event.paramChanged, paramName, null); + mainView.event(Event.PARAMETER_CHANGED, paramName, null); } else { - mainView.event(Event.paramChanged, paramName, textField.getText()); + mainView.event(Event.PARAMETER_CHANGED, paramName, textField.getText()); } } } @@ -178,11 +178,11 @@ public abstract class ParamField extends JPanel { public void update(JTextField textField) { if ("".equals(textField.getText())) { textField.setBackground(Color.WHITE); - mainView.event(Event.paramRemoved, paramName); + mainView.event(Event.PARAMETER_REMOVED, paramName); } else { try { float value = Float.parseFloat(textField.getText()); - mainView.event(Event.paramChanged, paramName, value); + mainView.event(Event.PARAMETER_CHANGED, paramName, value); textField.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") NumberFormatException e) { textField.setBackground(Color.PINK); @@ -238,12 +238,12 @@ public abstract class ParamField extends JPanel { DateFormat df = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); if ("".equals(field.getText())) { field.setBackground(Color.WHITE); - mainView.event(Event.paramRemoved, paramName + field.getName()); + mainView.event(Event.PARAMETER_REMOVED, paramName + field.getName()); } else if (field.getText().matches(DATE_REGEX)) { try { long date = df.parse(field.getText()).getTime(); date = Math.round((date / 86400000.0) + 2440587.5); // to JD - mainView.event(Event.paramChanged, paramName + field.getName(), date); + mainView.event(Event.PARAMETER_CHANGED, paramName + field.getName(), date); field.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") ParseException e) { field.setBackground(Color.PINK); @@ -296,10 +296,10 @@ public abstract class ParamField extends JPanel { public void update(JTextField field) { if ("".equals(field.getText())) { field.setBackground(Color.WHITE); - mainView.event(Event.paramRemoved, paramName + field.getName()); + mainView.event(Event.PARAMETER_REMOVED, paramName + field.getName()); } else { try { - mainView.event(Event.paramChanged, paramName + field.getName(), + mainView.event(Event.PARAMETER_CHANGED, paramName + field.getName(), Float.parseFloat(field.getText())); field.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") NumberFormatException e) { @@ -332,6 +332,36 @@ public abstract class ParamField extends JPanel { String lastContent; /** + * This method is called each time the field is modified. A Runnable is used it is + * impossible to modify the comboBox from a DocumentEvent. + */ + Runnable updateComboBox = new Runnable() { + @Override + public void run() { + String content = field.getText(); + if (!content.equals(lastContent)) { + if (content.length() >= 2) { + lastContent = content; + comboBox.removeAllItems(); + try { + for (String s : getItems(content)) { + comboBox.addItem(s); + } + } catch (CantSendQueryException e) { + logger.log(Level.WARNING, "Can't get table names for the resolver", e); + } + comboBox.getEditor().setItem(content); + } + if ("".equals(content)) { + mainView.event(Event.PARAMETER_REMOVED, paramName); + } else { + mainView.event(Event.PARAMETER_CHANGED, paramName, content); + } + } + } + }; + + /** * Method constructor * * @param mainView The main view of the application. @@ -356,7 +386,7 @@ public abstract class ParamField extends JPanel { * @throws CantSendQueryException If the resolver do not work. */ static String[] getItems(String begining) throws CantSendQueryException { - StringBuilder resolverResult = null; + StringBuilder resolverResult; resolverResult = VOTableConnection.sendGet(RESOLVER_URL, "q=\"" + begining + "\""); JsonObject root = new JsonParser().parse(resolverResult.toString()).getAsJsonObject(); int count = Integer.parseInt(root.get("count").toString()); @@ -371,36 +401,6 @@ public abstract class ParamField extends JPanel { } /** - * This method is called each time the field is modified. A Runnable is used it is - * impossible to modify the comboBox from a DocumentEvent. - */ - Runnable updateComboBox = new Runnable() { - @Override - public void run() { - String content = field.getText(); - if (!content.equals(lastContent)) { - if (content.length() >= 2) { - lastContent = content; - comboBox.removeAllItems(); - try { - for (String s : getItems(content)) { - comboBox.addItem(s); - } - } catch (CantSendQueryException e) { - logger.log(Level.WARNING, "Can't get table names for the resolver", e); - } - comboBox.getEditor().setItem(content); - } - if ("".equals(content)) { - mainView.event(Event.paramRemoved, paramName); - } else { - mainView.event(Event.paramChanged, paramName, content); - } - } - } - }; - - /** * This method is called each time the field is modified. */ @Override @@ -500,9 +500,9 @@ public abstract class ParamField extends JPanel { void update() { DataProductType item = (DataProductType) comboBox.getSelectedItem(); if (DataProductType.ALL.equals(item)) { - mainView.event(Event.paramRemoved, paramName); + mainView.event(Event.PARAMETER_REMOVED, paramName); } else { - mainView.event(Event.paramChanged, paramName, item.query()); + mainView.event(Event.PARAMETER_CHANGED, paramName, item.query()); } } } @@ -581,9 +581,9 @@ public abstract class ParamField extends JPanel { void update() { TargetClass value = (TargetClass) comboBox.getSelectedItem(); if (TargetClass.ALL.equals(value)) { - mainView.event(Event.paramRemoved, paramName); + mainView.event(Event.PARAMETER_REMOVED, paramName); } else { - mainView.event(Event.paramChanged, paramName, value.query()); + mainView.event(Event.PARAMETER_CHANGED, paramName, value.query()); } } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java index f7dc181..78e9ba3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/RequestPanel.java @@ -169,7 +169,7 @@ public class RequestPanel extends JPanel implements ActionListener { @Override public void actionPerformed(ActionEvent evt) { if (((JButton) evt.getSource()).getName() == BTN_NAME) { - this.mainView.event(Event.btnSendClicked, queryArea.getText()); + this.mainView.event(Event.SEND_BUTTON_CLICKED, queryArea.getText()); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java index fc56a38..41020e2 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ServicesPanel.java @@ -69,7 +69,7 @@ public class ServicesPanel extends JPanel { .addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { - mainView.event(Event.serviceSelected, + mainView.event(Event.SERVICE_SELECTED, voTableView.getTable().getSelectedRow()); } }); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java index 3ad8fe1..fbf69e7 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/Utils.java @@ -34,6 +34,10 @@ public class Utils { /** The logger for the class Utils. */ private static final Logger logger = Logger.getLogger(Utils.class.getName()); + /** Private constructor to hide the implicit public one. */ + private Utils() { + } + /** * StringJoiner has the same purpose of Java 8 StringJoiner, it has been rewritten for Java7 * compatibility. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java index 438a2c2..3e67d9a 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/VOTableApp.java @@ -16,6 +16,7 @@ package eu.omp.irap.vespa.epntapclient.votable; +import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JFrame; @@ -35,6 +36,10 @@ public class VOTableApp { /** The logger for the class VOTableApp. */ static final Logger logger = Logger.getLogger(VOTableApp.class.getName()); + /** Private constructor to hide the implicit public one. */ + private VOTableApp() { + } + /** * Main function to start the application as standalone. * @@ -57,13 +62,14 @@ public class VOTableApp { @Override public void run() { // TODO: Add option to export to CSV and HTML in CLI. - VOTableController voTableControl = null; + VOTableController voTableControl; logger.info("Lauching VOTable app with arguments:\n " + new Gson().toJson(args)); if (args.length == 1) { try { voTableControl = new VOTableController(args[0]); } catch (VOTableException e) { System.console().writer().println("Error: " + e.getMessage()); + logger.log(Level.WARNING, e.getMessage(), e); return; } } else if (args.length == 3) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java index 923638d..fb9fc46 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableConnection.java @@ -27,6 +27,7 @@ import java.net.URL; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.logging.Level; import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.utils.Const; @@ -132,7 +133,8 @@ public final class VOTableConnection { response.append(inputLine); } in.close(); - } catch (@SuppressWarnings("unused") IOException e1) { + } catch (IOException e1) { + logger.log(Level.WARNING, "Can not get input stream", e1); try (BufferedReader in = new BufferedReader( new InputStreamReader(con.getErrorStream()))) { while ((inputLine = in.readLine()) != null) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java index d0503c4..3148d21 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableController.java @@ -82,8 +82,7 @@ public class VOTableController { * @param queryLanguage The language used for the queries (ie. "ADQL"). * @param query The query to ask to the registry. * @throws CantSendQueryException If the query can not be sent. - * @throws CantDisplayVOTableException If the table can not be filled. @see - * CantFillTableException + * @throws CantDisplayVOTableException If the table can not be filled. */ public void fillTable(String targetURL, String queryLanguage, String query) throws CantDisplayVOTableException, CantSendQueryException { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java index cf8901c..e29fca0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableException.java @@ -132,7 +132,7 @@ public abstract class VOTableException extends Exception { */ public CantGetErrorStream(String uri, IOException e) { super("Can not get the input stream of the result, neither the error stream " - + "for the request " + uri); + + "for the request " + uri, e); } } -- libgit2 0.21.2