diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java index 8630d3a..affd41a 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java @@ -16,8 +16,6 @@ package eu.omp.irap.vespa.epntapclient; -import java.util.HashMap; -import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -38,15 +36,14 @@ public class EpnTapController { private static final Logger logger = Logger.getLogger(EpnTapController.class.getName()); /** The controller of the VOTable displaying the list of services. */ - protected VOTableController servicesCtrl; + private VOTableController servicesCtrl; /** The controller of the VOTable displaying the result. */ - protected VOTableController resultsCtrl; + private VOTableController resultsCtrl; - /** - * The parameters fields for the request. - */ - protected Map paramValues = new HashMap<>(); + private RequestCtrl requestCtrl; + + private String voTablePath; /** @@ -56,6 +53,7 @@ public class EpnTapController { String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); + requestCtrl = new RequestCtrl(this); } /** @@ -89,11 +87,11 @@ public class EpnTapController { * path. * @throws CantGetVOTableException Can not get the VOTable. */ - public String sendQuery(String query, String tableServiceURL) + public void sendQuery(String query, String tableServiceURL) throws CantGetVOTableException { resultsCtrl = new VOTableController(tableServiceURL, query); resultsCtrl.readTable(); - return resultsCtrl.getVOTablePath(); + voTablePath = resultsCtrl.getVOTablePath(); } /** @@ -110,31 +108,8 @@ public class EpnTapController { return servicesCtrl; } - /** - * Update a specified parameter - * - * @param paramName The name of the parameter. - * @param paramValue The new value of the parameter - */ - public void updateParameter(String paramName, Object paramValue) { - paramValues.put(paramName, paramValue); + public RequestCtrl getRequestPanelCtrl() { + return requestCtrl; } - /** - * Remove a specified parameter. - * - * @param paramName the name of the parameter. - */ - public void removeParameter(String paramName) { - paramValues.remove(paramName); - } - - /** - * Get the values of all the parameters. - * - * @return A map containing all the values, as couples . - */ - public Map getParamValues() { - return paramValues; - } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java index 9acee99..76fe0b1 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java @@ -23,7 +23,7 @@ import javax.swing.SwingUtilities; import com.google.gson.Gson; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelController; +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelCtrl; import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelView; /** @@ -56,7 +56,7 @@ public class EpnTapMainApp { return; } - MainPanelController guiCtrl = new MainPanelController(); + MainPanelCtrl guiCtrl = new MainPanelCtrl(); guiCtrl.readServices(); SwingUtilities.invokeLater(EpnTapMainApp.run(guiCtrl.getView(), "EPN-TAP client")); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java index 987392d..530d2db 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java @@ -40,14 +40,17 @@ public class RequestCtrl { /** 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 parameters fields for the request. - */ + /** The parameters fields for the request. */ protected Map paramValues = new HashMap<>(); + private EpnTapController epnTapCtrl; + public RequestCtrl() { + } + public RequestCtrl(EpnTapController epnTapCtrl) { + this.epnTapCtrl = epnTapCtrl; } /** diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelController.java deleted file mode 100644 index 0d872f8..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelController.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * This file is a part of EpnTAPClient. - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. - * - * This program is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of - * the GNU General Public License along with this program. If not, see - * . - */ - -package eu.omp.irap.vespa.epntapclient.gui.mainPanel; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.JOptionPane; - -import eu.omp.irap.vespa.epntapclient.EpnTapController; -import eu.omp.irap.vespa.epntapclient.service.Queries; -import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; - -/** - * @author N. Jourdane - */ -public class MainPanelController extends EpnTapController implements ViewListener { - - /** The logger for the class GUIController. */ - private static final Logger logger = Logger.getLogger(MainPanelController.class.getName()); - - private MainPanelView mainView; - - private String voTablePath; - - /** The name of the table selected by the user on the table list panel. */ - private String selectedTableName; - - /** The URL of the service corresponding to the selected table. */ - private String selectedTableServiceURL; - - private int nbMaxResult = 10; - - - public MainPanelController() { - super(); - mainView = new MainPanelView(this); - } - - @Override - public void readServices() { - try { - servicesCtrl.readTable(); - } catch (CantGetVOTableException e) { - displayError("Can not get services.", e); - } - mainView.getServicesPanel().fillTable(servicesCtrl.getVOTableData()); - } - - public MainPanelView getView() { - return mainView; - } - - /** Update the row selected by the user on the Services Panel. */ - @Override - public void onServiceSelected(int selectedServiceRow) { - String url = mainView.getServicesPanel().getServiceURL(selectedServiceRow); - String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow); - updateService(url, tableName); - } - - /** Send the specified query on selectedTableServiceURL */ - @Override - public void onSendButtonClicked(String query) { - MainPanelController.logger.info("Sending query: " + query + " on " + selectedTableServiceURL); - try { - voTablePath = sendQuery(query, selectedTableServiceURL); - } catch (CantGetVOTableException e) { - displayError("Can not send the query.", e); - MainPanelController.logger.log(Level.WARNING, "Can not send query.", e); - } - - mainView.getResultsPanel().fillTable(resultsCtrl.getVOTableData()); - } - - @Override - public void displayError(String message, Exception e) { - logger.log(Level.SEVERE, message, e); - JOptionPane.showMessageDialog(mainView, e.getMessage(), message, JOptionPane.ERROR_MESSAGE); - } - - /** Copy the VOTable to a specified location. */ - @Override - public void onDownloadButtonClicked(File outputFile) { - try { - Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath())); - } catch (IOException e) { - // TODO create exception - mainView.displayError("Can not save the file.", - "Check that you can write on the specified directory."); - MainPanelController.logger.log(Level.WARNING, "Can not save the file.", e); - } - } - - /** Update a query parameter in the parameter list. */ - @Override - public void onParameterChanged(String paramName, Object paramValue) { - updateParameter(paramName, paramValue); - updateQueryArea(); - MainPanelController.logger.info("uploaded " + paramName + ": " + paramValue); - } - - /** Remove a query parameter from the parameters list. */ - @Override - public void onParameterRemoved(String paramName) { - removeParameter(paramName); - updateQueryArea(); - MainPanelController.logger.info("removed " + paramName); - } - - /** - * Update the query area with a working ADQL query, based on the parameters list. - */ - private void updateQueryArea() { - String query = Queries.getQuery(selectedTableName, paramValues, getNbMaxResult()); - mainView.getRequestPanel().updateQueryArea(query); - } - - /** - * @return the nb max of result - */ - public int getNbMaxResult() { - return nbMaxResult; - } - - /** - * set the nb max of result for a query - */ - public void setNbMaxResult(int nb) { - nbMaxResult = nb; - } - - public void updateService(String serviceURL, String tableName) { - if (!tableName.equals(selectedTableName)) { - selectedTableServiceURL = serviceURL; - selectedTableName = tableName; - updateQueryArea(); - MainPanelController.logger.info("Selected table: " + selectedTableName + " - service: " - + selectedTableServiceURL); - } - } - -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelCtrl.java new file mode 100644 index 0000000..ed946db --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelCtrl.java @@ -0,0 +1,164 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.gui.mainPanel; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.JOptionPane; + +import eu.omp.irap.vespa.epntapclient.EpnTapController; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; +import eu.omp.irap.vespa.epntapclient.service.Queries; +import eu.omp.irap.vespa.epntapclient.service.ServiceCore; +import eu.omp.irap.vespa.votable.Consts; +import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; +import eu.omp.irap.vespa.votable.controller.VOTableController; + +/** + * @author N. Jourdane + */ +public class MainPanelCtrl extends EpnTapController implements ViewListener { + + /** The logger for the class GUIController. */ + private static final Logger logger = Logger.getLogger(MainPanelCtrl.class.getName()); + + private RequestPanelCtrl requestPanelCtrl; + + private VOTableController servicesPanelCtrl; + + private VOTableController resultPanelCtrl; + + private MainPanelView mainView; + + private String voTablePath; + + // TODO: à déplacer dans ServicePanelCtrl + + /** The name of the table selected by the user on the table list panel. */ + private String selectedTableName; + + /** The URL of the service corresponding to the selected table. */ + private String selectedServiceURL; + + private int nbMaxResult = 10; + + + public MainPanelCtrl() { + String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, + ServiceCore.EPNCORE); + servicesPanelCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); + resultPanelCtrl = new VOTableController(); + requestPanelCtrl = new RequestPanelCtrl(this); + mainView = new MainPanelView(this); + } + + @Override + public void readServices() { + try { + servicesPanelCtrl.readTable(); + } catch (CantGetVOTableException e) { + displayError("Can not get services.", e); + } + mainView.getServicesPanel().fillTable(servicesPanelCtrl.getVOTableData()); + } + + public void sendQuery(String query) { + logger.info("Sending query: " + query + " on " + selectedServiceURL); + try { + resultPanelCtrl.updateVOTable(selectedServiceURL, query); + voTablePath = resultPanelCtrl.getVOTablePath(); + mainView.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData()); + } catch (CantGetVOTableException e) { + displayError("Can not send the query.", e); + MainPanelCtrl.logger.log(Level.WARNING, "Can not send query.", e); + } + } + + @Override + public RequestPanelCtrl getRequestPanelCtrl() { + return requestPanelCtrl; + } + + public MainPanelView getView() { + return mainView; + } + + public String getSelectedTableName() { + return selectedTableName; + } + + public String getSelectedServiceURL() { + return selectedServiceURL; + } + + /** Update the row selected by the user on the Services Panel. */ + @Override + public void onServiceSelected(int selectedServiceRow) { + String url = mainView.getServicesPanel().getServiceURL(selectedServiceRow); + String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow); + updateService(url, tableName); + } + + @Override + public void displayError(String message, Exception e) { + logger.log(Level.SEVERE, message, e); + JOptionPane.showMessageDialog(mainView, e.getMessage(), message, JOptionPane.ERROR_MESSAGE); + } + + /** Copy the VOTable to a specified location. */ + @Override + public void onDownloadButtonClicked(File outputFile) { + try { + Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath())); + } catch (IOException e) { + // TODO create exception + mainView.displayError("Can not save the file.", + "Check that you can write on the specified directory."); + MainPanelCtrl.logger.log(Level.WARNING, "Can not save the file.", e); + } + } + + /** + * @return the nb max of result + */ + public int getNbMaxResult() { + return nbMaxResult; + } + + /** + * set the nb max of result for a query + */ + public void setNbMaxResult(int nb) { + nbMaxResult = nb; + } + + public void updateService(String serviceURL, String tableName) { + if (!tableName.equals(selectedTableName)) { + selectedServiceURL = serviceURL; + selectedTableName = tableName; + requestPanelCtrl.updateQueryArea(); + MainPanelCtrl.logger.info("Selected table: " + selectedTableName + " - service: " + + selectedServiceURL); + } + } + +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java index ecd8ff6..987a129 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java @@ -38,7 +38,7 @@ public class MainPanelView extends JPanel { private static final long serialVersionUID = 1L; /** The JPanel where the VOTable results is displayed. */ - private ResultPanelView resultsPanel; + private ResultPanelView resultPanel; /** The JPanel where the list of services is displayed. */ private ServicesPanelView servicesPanel; @@ -54,10 +54,10 @@ public class MainPanelView extends JPanel { * @param voTableResultsView The view to put in the results panel, built by ResultsController. */ - public MainPanelView(ViewListener viewListener) { - servicesPanel = new ServicesPanelView(viewListener); - resultsPanel = new ResultPanelView(viewListener); - requestPanel = new RequestPanelView(viewListener); + public MainPanelView(MainPanelCtrl mainPanelCtrl) { + servicesPanel = new ServicesPanelView(mainPanelCtrl); + resultPanel = new ResultPanelView(mainPanelCtrl); + requestPanel = mainPanelCtrl.getRequestPanelCtrl().getView(); buildMainView(); } @@ -69,7 +69,7 @@ public class MainPanelView extends JPanel { JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel, requestPanel); - JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel); + JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultPanel); add(mainPanel, BorderLayout.CENTER); @@ -88,10 +88,10 @@ public class MainPanelView extends JPanel { requestPanel.setMinimumSize( new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); - resultsPanel.setPreferredSize( + resultPanel.setPreferredSize( new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.BOTTOM_PANEL_HEIGHT)); - resultsPanel.setMinimumSize( + resultPanel.setMinimumSize( new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.BOTTOM_PANEL_MIN_HEIGHT)); } @@ -100,7 +100,7 @@ public class MainPanelView extends JPanel { * @return The JPanel where the VOTable result is displayed. */ public ResultPanelView getResultsPanel() { - return resultsPanel; + return resultPanel; } /** diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java index 6222ca2..e5b23a3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java @@ -34,31 +34,10 @@ public interface ViewListener { void onServiceSelected(int selectedService); /** - * When the `Send query` button is clicked. - * - * @param query The query to send. - */ - void onSendButtonClicked(String query); - - /** * When the `Download VOTable` button is clicked. * * @param outputFile The file to copy the VOTable. */ void onDownloadButtonClicked(File outputFile); - /** - * When a parameter is removed on the parameter panel. - * - * @param paramName The name of the parameter as described in REG-TAP specifications. - * @param paramValue The value of the parameter to update. - */ - void onParameterChanged(String paramName, Object paramValue); - - /** - * When a parameter is updated to a valid value on the parameter panel. - * - * @param paramName The name of the parameter as described in REG-TAP specifications. - */ - void onParameterRemoved(String paramName); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java index 05ad91b..5ad745c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java @@ -18,11 +18,89 @@ package eu.omp.irap.vespa.epntapclient.gui.requestpanel; import java.util.logging.Logger; +import eu.omp.irap.vespa.epntapclient.RequestCtrl; +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelCtrl; +import eu.omp.irap.vespa.epntapclient.service.Queries; + /** * @author N. Jourdane */ -public class RequestPanelCtrl { +public class RequestPanelCtrl extends RequestCtrl implements RequestPanelListener { /** The logger for the class RequestPanelCtrl. */ private static final Logger logger = Logger.getLogger(RequestPanelCtrl.class.getName()); + + MainPanelCtrl mainPanelCtrl; + + RequestPanelView view; + + + /** + * Constructor of RequestPanelCtrl + * + * @param epnTapCtrl + */ + public RequestPanelCtrl(MainPanelCtrl mainPanelCtrl) { + this.mainPanelCtrl = mainPanelCtrl; + view = new RequestPanelView(this); + } + + public void setMainPanelCtrl(MainPanelCtrl mainPanelCtrl) { + this.mainPanelCtrl = mainPanelCtrl; + view = new RequestPanelView(this); + } + + public RequestPanelView getView() { + return view; + } + + /* + * @see + * eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener#onSendButtonClicked(java + * .lang.String) + */ + @Override + public void onSendButtonClicked(String query) { + mainPanelCtrl.sendQuery(query); + } + + /** + * Update the query area with a working ADQL query, based on the parameters list. + */ + public void updateQueryArea() { + String query = Queries.getQuery(mainPanelCtrl.getSelectedTableName(), paramValues, + mainPanelCtrl.getNbMaxResult()); + view.updateQueryArea(query); + } + + /** + * Update the query area with a working ADQL query, based on the parameters list. + */ + // private void updateQueryArea() { + // mainPanelCtrl.updateQueryArea(); + // } + + /* + * @see + * eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener#onParameterRemoved(java. + * lang.String) + */ + @Override + public void onParameterRemoved(String paramName) { + removeParameter(paramName); + updateQueryArea(); + logger.info("removed " + paramName); + } + + /* + * @see + * eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener#onParameterChanged(java. + * lang.String, java.lang.Object) + */ + @Override + public void onParameterChanged(String paramName, Object paramValue) { + updateParameter(paramName, paramValue); + updateQueryArea(); + logger.info("uploaded " + paramName + ": " + paramValue); + } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java index 4ca0813..c570ab9 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java @@ -29,7 +29,6 @@ import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextArea; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield.DataProductTypeField; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield.DateRangeField; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield.FloatRangeField; @@ -46,9 +45,6 @@ public class RequestPanelView extends JPanel { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The main view of the application. */ - protected ViewListener viewListener; - /** The text area where the user write the query. */ protected JTextArea queryArea; @@ -68,14 +64,16 @@ public class RequestPanelView extends JPanel { /** The height of the buttons panel. */ private static final int BUTTON_PANEL_HEIGHT = 20; + private RequestPanelListener requestPanelListener; + /** * Method constructor * * @param mainView The EPN-TAP main view. */ - public RequestPanelView(ViewListener viewListener) { - this.viewListener = viewListener; + public RequestPanelView(RequestPanelListener requestPanelListener) { + this.requestPanelListener = requestPanelListener; buildRequestPanel(); } @@ -113,10 +111,11 @@ public class RequestPanelView extends JPanel { * @return the data product field */ public DataProductTypeField getDataProductTypeField() { - if(dataProductTypeField == null){ - dataProductTypeField = new DataProductTypeField(viewListener, "dataproduct_type"); + if (dataProductTypeField == null) { + dataProductTypeField = new DataProductTypeField(requestPanelListener, + "dataproduct_type"); } - + return dataProductTypeField; } @@ -124,10 +123,10 @@ public class RequestPanelView extends JPanel { * @return the spectral range field */ public FloatRangeField getSpectralRangeField() { - if (spectralRangeField == null){ - spectralRangeField = new FloatRangeField(viewListener, "spectral_range_"); + if (spectralRangeField == null) { + spectralRangeField = new FloatRangeField(requestPanelListener, "spectral_range_"); } - + return spectralRangeField; } @@ -135,10 +134,10 @@ public class RequestPanelView extends JPanel { * @return the time range field */ public DateRangeField getTimeRangeField() { - if (timeRangeField == null){ - timeRangeField = new DateRangeField(viewListener, "time_"); + if (timeRangeField == null) { + timeRangeField = new DateRangeField(requestPanelListener, "time_"); } - + return timeRangeField; } @@ -146,10 +145,10 @@ public class RequestPanelView extends JPanel { * @return the target name field */ public TargetNameField getTargetNameField() { - if(targetNameField == null){ - targetNameField = new TargetNameField(viewListener, "target_name"); + if (targetNameField == null) { + targetNameField = new TargetNameField(requestPanelListener, "target_name"); } - + return targetNameField; } @@ -191,7 +190,7 @@ public class RequestPanelView extends JPanel { @Override public void actionPerformed(ActionEvent e) { - viewListener.onSendButtonClicked(queryArea.getText()); + requestPanelListener.onSendButtonClicked(queryArea.getText()); } }); buttonPanel.add(btnSend); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java index 7fd4e5c..061f98b 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java @@ -24,7 +24,7 @@ import java.util.List; import javax.swing.JComboBox; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The data product type field is used only for the `dataproduct_type` parameter. It is a ComboBox @@ -50,8 +50,8 @@ public class DataProductTypeField extends ParamField { * @param viewListener The main listener of the application. * @param paramName The name of the parameter. */ - public DataProductTypeField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public DataProductTypeField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); comboBox = new JComboBox<>(DataProductType.values()); comboBox.setSelectedItem(DataProductType.ALL); comboBox.setPreferredSize( @@ -74,9 +74,9 @@ public class DataProductTypeField extends ParamField { public void update() { DataProductType item = (DataProductType) comboBox.getSelectedItem(); if (DataProductType.ALL.equals(item)) { - viewListener.onParameterRemoved(paramName); + requestPanelListener.onParameterRemoved(paramName); } else { - viewListener.onParameterChanged(paramName, item.query()); + requestPanelListener.onParameterChanged(paramName, item.query()); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java index a50512d..1bad3af 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java @@ -26,7 +26,7 @@ import java.util.Locale; import javax.swing.JLabel; import javax.swing.JTextField; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The date range field is used for couples of parameter with both a `Date` type (actually only @@ -60,8 +60,8 @@ public class DateRangeField extends ParamField implements TextFieldListener { * @param viewListener The main view listener of the application. * @param paramName The name of the parameter. */ - public DateRangeField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public DateRangeField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); this.add(new JLabel("min ")); fieldMin = new JTextField(); fieldMin.setName(MIN_SUFFIX); @@ -87,12 +87,12 @@ public class DateRangeField extends ParamField implements TextFieldListener { DateFormat df = new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH); if (field.getText().isEmpty()) { field.setBackground(Color.WHITE); - viewListener.onParameterRemoved(paramName + field.getName()); + requestPanelListener.onParameterRemoved(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 - viewListener.onParameterChanged(paramName + field.getName(), + requestPanelListener.onParameterChanged(paramName + field.getName(), date); field.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") ParseException e) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatField.java index 40cb66f..8605ed0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatField.java @@ -20,7 +20,7 @@ import java.awt.Color; import javax.swing.JTextField; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The float field is used for parameter with a `Float` class. It is a JTextField which checks if @@ -44,8 +44,8 @@ public class FloatField extends ParamField implements TextFieldListener { * @param viewListener The main view listener of the application. * @param paramName The name of the parameter. */ - public FloatField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public FloatField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); field = new JTextField(); ParamField.addChangeListener(this, field); this.add(field); @@ -58,11 +58,11 @@ public class FloatField extends ParamField implements TextFieldListener { public void update(JTextField textField) { if (textField.getText().isEmpty()) { textField.setBackground(Color.WHITE); - viewListener.onParameterRemoved(paramName); + requestPanelListener.onParameterRemoved(paramName); } else { try { float value = Float.parseFloat(textField.getText()); - viewListener.onParameterChanged(paramName, value); + requestPanelListener.onParameterChanged(paramName, value); textField.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") NumberFormatException e) { textField.setBackground(Color.PINK); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java index 32954cc..edc9178 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java @@ -20,7 +20,7 @@ import java.awt.Color; import javax.swing.JTextField; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The float range field is used for couples of parameter with both a `Float` class. These are @@ -47,8 +47,8 @@ public class FloatRangeField extends ParamField implements TextFieldListener { * @param viewListener The main view listener of the application. * @param paramName The name of the parameter. */ - public FloatRangeField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public FloatRangeField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); fieldMin = new JTextField(); fieldMin.setName(ParamField.MIN_SUFFIX); ParamField.addChangeListener(this, fieldMin); @@ -67,10 +67,10 @@ public class FloatRangeField extends ParamField implements TextFieldListener { public void update(JTextField field) { if (field.getText().isEmpty()) { field.setBackground(Color.WHITE); - viewListener.onParameterRemoved(paramName + field.getName()); + requestPanelListener.onParameterRemoved(paramName + field.getName()); } else { try { - viewListener.onParameterChanged(paramName + field.getName(), + requestPanelListener.onParameterChanged(paramName + field.getName(), Float.parseFloat(field.getText())); field.setBackground(Color.WHITE); } catch (@SuppressWarnings("unused") NumberFormatException e) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java index 02b4197..513d9e7 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java @@ -26,7 +26,7 @@ import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * A field used to set a service parameter to build the query (in the parameter panel). ParamField @@ -63,7 +63,7 @@ public abstract class ParamField extends JPanel { static final String MAX_SUFFIX = "max"; /** The main view of the application. */ - ViewListener viewListener; + RequestPanelListener requestPanelListener; /** The parameter name of the field */ String paramName; @@ -76,10 +76,10 @@ public abstract class ParamField extends JPanel { * @param mainView The main view of the application. * @param paramName The name of the parameter. */ - public ParamField(ViewListener viewListener, String paramName) { + public ParamField(RequestPanelListener requestPanelListener, String paramName) { super(); - this.viewListener = viewListener; + this.requestPanelListener = requestPanelListener; this.paramName = paramName; buildParamField(); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/StringField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/StringField.java index f7b5a8c..d072bd3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/StringField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/StringField.java @@ -18,7 +18,7 @@ package eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield; import javax.swing.JTextField; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The string field is used for parameter with a `String` class. It is a simple JTextField with no @@ -41,8 +41,8 @@ public class StringField extends ParamField implements TextFieldListener { * @param mainView The main view of the application. * @param paramName The name of the parameter. */ - public StringField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public StringField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); field = new JTextField(); ParamField.addChangeListener(this, field); this.add(field); @@ -54,9 +54,9 @@ public class StringField extends ParamField implements TextFieldListener { @Override public void update(JTextField textField) { if (textField.getText().isEmpty()) { - viewListener.onParameterChanged(paramName, null); + requestPanelListener.onParameterChanged(paramName, null); } else { - viewListener.onParameterChanged(paramName, textField.getText()); + requestPanelListener.onParameterChanged(paramName, textField.getText()); } } } \ No newline at end of file diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java index 8d4aab9..f3cc4fd 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java @@ -22,7 +22,7 @@ import java.awt.event.ActionListener; import javax.swing.JComboBox; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; /** * The target class field is used only for the `target_class` parameter. It is a ComboBox filled @@ -48,8 +48,8 @@ public class TargetClassField extends ParamField { * @param mainView The main view of the application. * @param paramName The name of the parameter. */ - public TargetClassField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public TargetClassField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); comboBox = new JComboBox<>(TargetClass.values()); comboBox.setPreferredSize( new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); @@ -69,9 +69,9 @@ public class TargetClassField extends ParamField { public void update() { TargetClass value = (TargetClass) comboBox.getSelectedItem(); if (TargetClass.ALL.equals(value)) { - viewListener.onParameterRemoved(paramName); + requestPanelListener.onParameterRemoved(paramName); } else { - viewListener.onParameterChanged(paramName, value.query()); + requestPanelListener.onParameterChanged(paramName, value.query()); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java index 8bbdf9a..0c39e94 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java @@ -24,7 +24,7 @@ import javax.swing.JTextField; import javax.swing.SwingUtilities; import eu.omp.irap.vespa.epntapclient.EpnTapGet; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; import eu.omp.irap.vespa.votable.utils.CantSendQueryException; /** @@ -60,8 +60,8 @@ public class TargetNameField extends ParamField implements TextFieldListener { * @param mainView The main view of the application. * @param paramName The name of the parameter. */ - public TargetNameField(ViewListener viewListener, String paramName) { - super(viewListener, paramName); + public TargetNameField(RequestPanelListener requestPanelListener, String paramName) { + super(requestPanelListener, paramName); comboBox = new JComboBox<>(); comboBox.setPreferredSize( new Dimension(ParamField.MIN_FIELD_WIDTH, ParamField.FIELD_HEIGHT)); @@ -106,9 +106,9 @@ public class TargetNameField extends ParamField implements TextFieldListener { comboBox.showPopup(); } if (content.isEmpty()) { - viewListener.onParameterRemoved(paramName); + requestPanelListener.onParameterRemoved(paramName); } else { - viewListener.onParameterChanged(paramName, content); + requestPanelListener.onParameterChanged(paramName, content); } } } diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java index 26388eb..c860b58 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -140,7 +140,6 @@ public class EpnTapConnectionTest { Resource amda = null; for (Resource resource : resources) { - System.out.println(resource.getIdentifier()); if (AMDA_IVOID.equals(resource.getIdentifier())) { amda = resource; } -- libgit2 0.21.2