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 2445ad6..bfc15cb 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 @@ -30,6 +30,8 @@ import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException; /** + * The main controller which manage views and controllers. + * * @author N. Jourdane */ public class EpnTapController implements MainViewListener { @@ -57,7 +59,7 @@ public class EpnTapController implements MainViewListener { private Map paramValues = new HashMap<>(); /** - * Method constructor + * Method constructor, which initialize servicesController, resultsController and mainView. */ public EpnTapController() { servicesController = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL", @@ -70,27 +72,29 @@ public class EpnTapController implements MainViewListener { } /** - * @return the EPN-TAP view. + * @return the EPN-TAP main view. */ public EpnTapMainView getView() { return mainView; } /** - * @return The controller of the VOTable displaying the query results. + * @return The controller of the VOTable which displays the result of the query. */ public VOTableController getResultsController() { return resultsController; } /** - * @return The controller of the VOTable displaying the list of services. + * @return The controller of the VOTable which displays the list of services. */ public VOTableController getServicesController() { return servicesController; } /** + * Update the row selected by the user on the Services Panel. + * * @param row The row selected by the user on the Jtable. */ public void updateSelected(int row) { @@ -105,24 +109,40 @@ public class EpnTapController implements MainViewListener { } } + /** + * Remove a query parameter from the parameters list. + * + * @param paramName The name of the parameter as described in REG-TAP specifications. + */ public void removeParameter(String paramName) { paramValues.remove(paramName); updateQueryArea(); logger.info("removed " + paramName); } + /** + * Update a query parameter in the parameter list. + * + * @param paramName The name of the parameter as described in REG-TAP specifications. + * @param value The value of the parameter to update. + */ public void updateParameter(String paramName, Object value) { paramValues.put(paramName, value); updateQueryArea(); logger.info("uploaded " + paramName + ": " + value); } + /** + * Update the query area with a working ADQL query, based on the parameters list. + */ private void updateQueryArea() { String query = Queries.getQuery(selectedTableName, paramValues, 10); mainView.getRequestPanel().updateQueryArea(query); } /** + * Send a query to the selected service on the services panel. + * * @param query The query to send to the selected service. * @throws VOTableException Can not fill the Table */ @@ -132,8 +152,10 @@ public class EpnTapController implements MainViewListener { } /** - * @param event - * @param args + * This methods is called each time a graphical event is detected from a view. + * + * @param event The type of the detected event. @see Event + * @param args The possible arguments which comes with the event (ie. a row column). */ @Override public void event(Event event, Object... args) { @@ -145,7 +167,7 @@ public class EpnTapController implements MainViewListener { case serviceSelected: updateSelected(((Integer) args[0]).intValue()); break; - case btnSearchClicked: + case btnSendClicked: sendQuery((String) object); break; case paramChanged: 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 ae894e4..088b8db 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 @@ -24,6 +24,8 @@ import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.votable.Utils.StringJoiner; /** + * Defines the queries and the query patterns usually used in the application. + * * @author N. Jourdane */ public final class Queries { 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 3ca48be..aaffe62 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 @@ -30,6 +30,8 @@ import eu.omp.irap.vespa.epntapclient.view.panels.ServicesPanel; import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; /** + * The main view of the application, which manage all the other views. + * * @author N. Jourdane */ public class EpnTapMainView extends JPanel { @@ -46,22 +48,35 @@ public class EpnTapMainView extends JPanel { /** The JPanel where the list of services is displayed. */ private ServicesPanel servicesPanel; - /** The JPanel where the user put requests. */ + /** The JPanel where the user build the query. */ private RequestPanel requestPanel; - /** The JPanel where the user put requests. */ + /** The status bar. */ private BottomBarPanel bottomBarPanel; + /** The listener of the EpnTapMainView (usually the main controller) */ private MainViewListener mainViewListener; + /** + * The interface for the main view listener, which listen for events. + * + * @author N. Jourdane + */ public interface MainViewListener { + /** + * When an event is detected on the main view. + * + * @param event The event type. @see Event + * @param args The possible arguments which comes with the event (ie. a row number). + */ void event(Event event, Object... args); } /** - * The constructor of the view. TODO: controlleur = écouteur de la vue + * The main view constructor, which create all the panels. * - * @param controller The EPN-TAP controller, allowing the EPN-TAP view to send events. + * @param voTableServicesView The view to put in the services panel, built by ServicesController + * @param voTableResultsView The view to put in the results panel, built by ResultsController. */ public EpnTapMainView(VOTableView voTableServicesView, VOTableView voTableResultsView) { @@ -69,23 +84,27 @@ public class EpnTapMainView extends JPanel { this.resultsPanel = new ResultsPanel(this, voTableResultsView); this.requestPanel = new RequestPanel(this); this.bottomBarPanel = new BottomBarPanel(this); - setLayout(new BorderLayout()); buildWindow(); } + /** + * Add a listener for the main view. + * + * @param listener A MainViewListener. + */ public void addMainViewListener(MainViewListener listener) { mainViewListener = listener; } /** - * @return The JPanel where the VOTable results is displayed. + * @return The JPanel where the VOTable result is displayed. */ public ResultsPanel getResultsPanel() { return resultsPanel; } /** - * @return The JPanel where the GUI elements to make the request are displayed. + * @return The JPanel containing the GUI elements to build the query. */ public RequestPanel getRequestPanel() { return requestPanel; @@ -99,7 +118,7 @@ public class EpnTapMainView extends JPanel { } /** - * @return The JPanel where the list of services is displayed. + * @return The status bar. */ public BottomBarPanel getBottomBarPanel() { return bottomBarPanel; @@ -109,18 +128,18 @@ public class EpnTapMainView extends JPanel { * Build and fill the GUI. */ public void buildWindow() { + setLayout(new BorderLayout()); + JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel, requestPanel); - // TODO: put requestView inside a JScrollPane. - JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel); add(mainPanel, BorderLayout.CENTER); add(bottomBarPanel, BorderLayout.SOUTH); } /** - * Display an error. + * Display an error message. Usually used each time an error happens. * * @param title The title of the error. * @param message The message of the error. @@ -130,6 +149,12 @@ public class EpnTapMainView extends JPanel { JOptionPane.ERROR_MESSAGE); } + /** + * Get an event and send it to the listener of the main view. + * + * @param event The event type. @see Event + * @param args The possible arguments which comes with the event (ie. a row number). + */ public void event(Event event, Object... args) { mainViewListener.event(event, args); } 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 945be06..54eaddc 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 @@ -20,5 +20,12 @@ package eu.omp.irap.vespa.epntapclient.view; * @author N. Jourdane */ public enum Event { - serviceSelected, btnSearchClicked, paramRemoved, paramChanged; + /** When a service is selected on the service panel. */ + serviceSelected, + /** When the `Send query` button is clicked. */ + btnSendClicked, + /** When a parameter is removed on the parameter panel. */ + paramRemoved, + /** When a parameter is updated to a valid value on the parameter panel. */ + paramChanged; } 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 843c3b2..2f4b832 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 @@ -45,6 +45,11 @@ import com.google.gson.JsonParser; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableConnection; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.SendQueryException; +/** + * A field used to set a service parameter to build the query (in the parameter panel). + * + * @author N. Jourdane + */ public abstract class ParamField extends JPanel { /** */ private static final long serialVersionUID = 6025994164004985362L; @@ -52,18 +57,29 @@ public abstract class ParamField extends JPanel { /** The logger for the class ParamField. */ static final Logger logger = Logger.getLogger(ParamField.class.getName()); + /** The minimum width of the field. */ private static final int MIN_FIELD_WIDTH = 30; + /** The preferred field height. */ private static final int FIELD_HEIGHT = 20; + /** The maximum width of the field. */ private static final int MAX_FIELD_WIDTH = 400; + /** The preferred label width. */ private static final int LABEL_WIDTH = 140; + /** The URL of the resolver used for the `target name` field. */ private static final String RESOLVER_URL = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete"; + /** The date format used in the DateRange field */ private static final String DATE_FORMAT = "dd/MM/yyyy"; + /** The regex used to validate the Date fields */ private static final String DATE_REGEX = "(^(((0[1-9]|1[0-9]|2[0-8])[\\/](0[1-9]|1[012]))|((29|30|31)[\\/](0[13578]|1[02]))|((29|30)[\\/](0[4,6,9]|11)))[\\/](19|[2-9][0-9])\\d\\d$)|(^29[\\/]02[\\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)"; + /** The suffix used in REG-TAP parameters names, indicating that it's a beginning of a range. */ private static final String MIN_SUFFIX = "min"; + /** The suffix used in REG-TAP parameters names, indicating that it is a end of a range. */ private static final String MAX_SUFFIX = "max"; + /** The main view of the application. */ protected EpnTapMainView mainView; + /** The parameter name of the field */ protected String paramName; public ParamField(EpnTapMainView mainView, String paramName) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java index 3a37057..349ef5f 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/BottomBarPanel.java @@ -29,18 +29,25 @@ import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView; * @author N. Jourdane */ public class BottomBarPanel extends JPanel { - /** */ + /** The serial version UID (affected with a random number). */ private static final long serialVersionUID = 8083897308526492902L; /** The logger for the class BottomBar. */ @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(BottomBarPanel.class.getName()); + /** The main view of the application. */ @SuppressWarnings("unused") private EpnTapMainView mainView; + /** A label to display several informations (aka. status bar). */ private JLabel infoLabel; + /** + * Method constructor for the bottom bar panel. + * + * @param mainView The main view of the application. + */ public BottomBarPanel(EpnTapMainView mainView) { this.mainView = mainView; setLayout(new BorderLayout()); @@ -49,6 +56,9 @@ public class BottomBarPanel extends JPanel { this.add(new JButton("Get File"), BorderLayout.EAST); } + /** + * @param infoText The text to display in the status-bar, which will override the old one. + */ public void setInfoText(String infoText) { infoLabel.setText(infoText); } 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 2d7efa4..f7dc181 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 @@ -40,6 +40,8 @@ import eu.omp.irap.vespa.epntapclient.view.ParamField.FloatRangeField; import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField; /** + * The view of the panel where the user builds the query. + * * @author N. Jourdane */ public class RequestPanel extends JPanel implements ActionListener { @@ -50,16 +52,15 @@ public class RequestPanel extends JPanel implements ActionListener { /** The serial version UID (affected with a random number). */ private static final long serialVersionUID = 1262856496809315405L; + /** The name of the button to send the query. */ private static final String BTN_NAME = "btnSend"; - /** The EPN-TAP main view. */ + /** The main view of the application. */ private EpnTapMainView mainView; - /** The text area where the user put the query. */ + /** The text area where the user write the query. */ private JTextArea queryArea; - // TODO: Use one map for paramFields, paramValues, paramTypes. - /** * The parameters fields for the request. */ @@ -79,6 +80,7 @@ public class RequestPanel extends JPanel implements ActionListener { setPreferredSize(new Dimension(Dim.RIGHT_PANEL_WIDTH, Dim.TOP_PANEL_HEIGHT)); setMinimumSize(new Dimension(Dim.RIGHT_PANEL_MIN_WIDTH, Dim.TOP_PANEL_MIN_HEIGHT)); + // TODO: Use a JScrollPane. // TODO: Get max row number from the GUI this.add(buildParamPanel(), this); @@ -86,17 +88,23 @@ public class RequestPanel extends JPanel implements ActionListener { this.add(buildButtonPanel(), this); } + /** + * @return The main view of the application. + */ public EpnTapMainView getMainView() { return mainView; } /** - * @return A JPanel containing graphical elements for the service parameters. + * Build a JPanel containing graphical elements to build the query user-friendly. + * + * @return The JPanel. */ private JPanel buildParamPanel() { // 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 <, <=, =, =>, >. + // TODO use enums for the parameters names paramFields = new ArrayList<>(); paramFields.add(new TargetNameField(mainView, "target_name")); paramFields.add(new DateRangeField(mainView, "time_")); @@ -114,7 +122,9 @@ public class RequestPanel extends JPanel implements ActionListener { } /** - * @return A JPanel containing graphical elements for the query. + * Build a JPanel containing a text-area where the query is displayed. + * + * @return The JPanel. */ private JPanel buildQueryPanel() { JPanel queryPanel = new JPanel(); @@ -129,14 +139,18 @@ public class RequestPanel extends JPanel implements ActionListener { } /** - * Update the query JTextArea according to the parameters values. + * Update the query JTextArea. + * + * @param query The string literal to put in the text-area, which will override the old content. */ public void updateQueryArea(String query) { queryArea.setText(query); } /** - * @return A JPanel containing the button(s). + * Build a JPanel containing the button(s), particularly the `Send` button. + * + * @return The JPanel . */ private JPanel buildButtonPanel() { JPanel buttonPanel = new JPanel(); @@ -149,10 +163,13 @@ public class RequestPanel extends JPanel implements ActionListener { return buttonPanel; } + /** + * This method is called when the user click on the `Send` button. + */ @Override public void actionPerformed(ActionEvent evt) { if (((JButton) evt.getSource()).getName() == BTN_NAME) { - this.mainView.event(Event.btnSearchClicked, queryArea.getText()); + this.mainView.event(Event.btnSendClicked, queryArea.getText()); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java index ee09a82..c2ab818 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/view/panels/ResultsPanel.java @@ -34,13 +34,24 @@ public class ResultsPanel extends JPanel { private static final long serialVersionUID = -3387526562625069156L; /** The logger for the class ResultPanel. */ + @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(ResultsPanel.class.getName()); + /** The main view of the application. */ @SuppressWarnings("unused") private EpnTapMainView mainView; + /** The generic view of the VOTable panel. */ + @SuppressWarnings("unused") private VOTableView voTableView; + /** + * Method constructor which customize the result panel, but don't build it from scratch since + * VOTableView is already created by ResultController. + * + * @param mainView The main view of the application. + * @param voTableView The generic view of the VOTable panel. + */ public ResultsPanel(EpnTapMainView mainView, VOTableView voTableView) { super(); @@ -54,6 +65,5 @@ public class ResultsPanel extends JPanel { Dim.BOTTOM_PANEL_HEIGHT)); setMinimumSize(new Dimension(Dim.LEFT_PANEL_MIN_WIDTH + Dim.RIGHT_PANEL_MIN_WIDTH, Dim.BOTTOM_PANEL_MIN_HEIGHT)); - } } 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 d231ec7..fc56a38 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 @@ -33,17 +33,27 @@ import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; * @author N. Jourdane */ public class ServicesPanel extends JPanel { - /** */ + /** The serial version UID (affected with a random number). */ private static final long serialVersionUID = 7850369546415832758L; /** The logger for the class ServicesView. */ @SuppressWarnings("unused") private static final Logger logger = Logger.getLogger(ServicesPanel.class.getName()); + /** The main view of the application. */ + @SuppressWarnings("unused") private EpnTapMainView mainView; + /** The generic view of the VOTable panel. */ private VOTableView voTableView; + /** + * Method constructor which customize the services panel, but don't build it from scratch since + * VOTableView is already created by ServicesController. Add also the JTable listener. + * + * @param mainView The main view of the application. + * @param voTableView The generic view of the VOTable panel. + */ public ServicesPanel(final EpnTapMainView mainView, final VOTableView voTableView) { super(); this.mainView = mainView; @@ -63,13 +73,20 @@ public class ServicesPanel extends JPanel { voTableView.getTable().getSelectedRow()); } }); - } + /** + * @param row The row index in the JTable element. + * @return The URL of the service corresponding to the row. + */ public String getServiceURL(int row) { return (String) this.voTableView.getValueAt(5, row); } + /** + * @param row The row index in the JTable element. + * @return The table name of the service corresponding to the row. + */ public String getTableName(int row) { return (String) this.voTableView.getValueAt(2, row); } 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 6b62a3e..9a440d8 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 @@ -31,7 +31,6 @@ import java.util.Date; import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.utils.Const; -import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.BadRequestException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.SendQueryException; /** diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java index 3ddea7c..6f03795 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/controller/VOTableDataParser.java @@ -92,7 +92,7 @@ public class VOTableDataParser { parseFITSStream(table.getDATA().getFITS().getSTREAM(), fields); } - String logPath = Utils.printObject("voTableData", data); + Utils.printObject("voTableData", data); } /** 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 53dc4a1..75185b0 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 @@ -17,7 +17,6 @@ package eu.omp.irap.vespa.epntapclient.votable.controller; import java.io.IOException; -import java.util.logging.Logger; /** * VOTable Exception class. @@ -26,9 +25,6 @@ import java.util.logging.Logger; */ @SuppressWarnings({ "javadoc", "serial" }) public abstract class VOTableException extends Exception { - /** The logger for the class VOTableException. */ - private static final Logger logger = Logger.getLogger(VOTableException.class.getName()); - public VOTableException(String message) { super(message); } @@ -73,7 +69,6 @@ public abstract class VOTableException extends Exception { } } - // The query is not valid. public static class ErrorInVOTableException extends VOTableException { public ErrorInVOTableException(String errorInfo) { super("There is an error in the VOTable:\n" + errorInfo @@ -81,10 +76,4 @@ public abstract class VOTableException extends Exception { } } - public static class BadRequestException extends VOTableException { - public BadRequestException(String message, String info) { - super(message); - } - } - } -- libgit2 0.21.2