From 56349bdea7dccf58df154fa44867c08049c9a7cc Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Thu, 16 Jun 2016 20:36:57 +0200 Subject: [PATCH] Add ResultsPanelCtrl and ResultsPanelsListeners, and fix #21. --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java | 25 +++++++++---------------- src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServiceCtrl.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServicesList.java | 5 +++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java | 37 ++++++++++++++++++++++++------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java | 7 +++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java | 6 +++--- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java | 85 ------------------------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java | 26 -------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java | 96 ------------------------------------------------------------------------------------------------ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabCtrl.java | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabListener.java | 26 ++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelCtrl.java | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelListener.java | 26 ++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelView.java | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java | 14 +++++--------- 16 files changed, 356 insertions(+), 252 deletions(-) delete mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java delete mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java delete mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabCtrl.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabListener.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelCtrl.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelListener.java create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelView.java diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java index 0b35fd8..9ff93df 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java @@ -125,7 +125,7 @@ public class EpnTapConnection implements EpnTapInterface { @Override public List sendADQLQuery(String tapURL, String adqlQuery) throws VOTableException { VOTableCtrl voTableCtrl = new VOTableCtrl(); - voTableCtrl.acquireVOTable(tapURL, adqlQuery, false); + voTableCtrl.acquireVOTable(tapURL, adqlQuery); VOTableData data = voTableCtrl.getVOTableData(); List granules; @@ -139,7 +139,7 @@ public class EpnTapConnection implements EpnTapInterface { throws VOTableException { String query = String.format(enumeratedQuery.toString(), schemaName); VOTableCtrl voTableCtrl = new VOTableCtrl(); - voTableCtrl.acquireVOTable(tapURL, query, false); + voTableCtrl.acquireVOTable(tapURL, query); VOTableData data = voTableCtrl.getVOTableData(); Debug.writeObject("data", data); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java index 154d1b4..0329cf3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java @@ -17,14 +17,12 @@ package eu.omp.irap.vespa.epntapclient.epntap; import java.util.List; -import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.epntap.request.RequestCtrl; import eu.omp.irap.vespa.epntapclient.epntap.service.Queries; import eu.omp.irap.vespa.epntapclient.epntap.service.ServiceCore; import eu.omp.irap.vespa.epntapclient.epntap.service.ServicesList; import eu.omp.irap.vespa.votable.Consts; -import eu.omp.irap.vespa.votable.utils.StringJoiner; import eu.omp.irap.vespa.votable.votable.VOTableCtrl; import eu.omp.irap.vespa.votable.votable.VOTableException; @@ -35,14 +33,11 @@ import eu.omp.irap.vespa.votable.votable.VOTableException; */ public abstract class EpnTapController { - /** The logger for the class EpnTapController. */ - private static final Logger LOGGER = Logger.getLogger(EpnTapController.class.getName()); - /** The request controller, to manage requests. */ private RequestCtrl requestCtrl; /** The controller of the VOTable displaying the result. */ - private VOTableCtrl resultsCtrl; + private List resultsCtrls; /** The controller of the VOTable displaying the list of services. */ private VOTableCtrl servicesCtrl; @@ -62,7 +57,7 @@ public abstract class EpnTapController { public void acquireServices() throws VOTableException { String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); - getServicesCtrl().acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query, true); + getServicesCtrl().acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query); } /** @@ -75,8 +70,8 @@ public abstract class EpnTapController { /** * @return The controller of the VOTable which displays the result of the query. */ - public VOTableCtrl getResultsCtrl() { - return resultsCtrl; + public List getResultsCtrls() { + return resultsCtrls; } /** @@ -94,17 +89,15 @@ public abstract class EpnTapController { } /** - * Send all the queries. + * Send the query to all services. * * @param services The services to send the queries. */ public void sendQueries(ServicesList services) { - List servicesUrls = services.getTargetUrls(); - LOGGER.info("Sending query(ies) at " + StringJoiner.join(servicesUrls)); - for (int i = 0; i < servicesUrls.size(); i++) { - String query = getRequestCtrl().getQuery(services.getTableNames().get(i)); - getResultsCtrl().acquireVOTable(servicesUrls.get(i), query, i != 0); + for (int i = 0; i < services.getNbServices(); i++) { + VOTableCtrl resultCtrl = new VOTableCtrl(); + String query = requestCtrl.getQuery(services.getTableNames().get(i)); + resultCtrl.acquireVOTable(services.getTargetUrls().get(i), query); } - } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServiceCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServiceCtrl.java index 9e3cfd6..a5f9324 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServiceCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServiceCtrl.java @@ -152,7 +152,7 @@ public class ServiceCtrl { */ public static VOTABLE getVoTable(String query) throws VOTableException { VOTableCtrl voTableCtrl = new VOTableCtrl(); - voTableCtrl.acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query, false); + voTableCtrl.acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query); return voTableCtrl.getVOTable(); } @@ -174,7 +174,7 @@ public class ServiceCtrl { */ public static VOTableData getVoTableData(VOTABLE voTable) throws VOTableException { VOTableCtrl ctrl = new VOTableCtrl(); - ctrl.acquireVOTable(voTable, false); + ctrl.acquireVOTable(voTable); Table table = (Table) voTable.getRESOURCE().get(0).getLINKAndTABLEOrRESOURCE().get(0); VOTableDataParser dataParser = new VOTableDataParser("Services list", table); dataParser.parseData(); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServicesList.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServicesList.java index dc645df..8516c71 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServicesList.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epntap/service/ServicesList.java @@ -53,6 +53,11 @@ public class ServicesList { selectedTargetUrls = new ArrayList<>(); } + /** @return The numbers of services (custom + selected) */ + public int getNbServices() { + return customTargetUrls.size() + selectedTargetUrls.size(); + } + /** * @return the tableName */ 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 index d3b98a9..a034b56 100644 --- 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 @@ -16,18 +16,22 @@ package eu.omp.irap.vespa.epntapclient.gui.mainpanel; +import java.awt.Cursor; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import eu.omp.irap.vespa.epntapclient.epntap.EpnTapController; +import eu.omp.irap.vespa.epntapclient.epntap.service.ServicesList; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; -import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelCtrl; +import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultsPanelCtrl; import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl; /** @@ -42,7 +46,7 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener RequestPanelCtrl requestPanelCtrl; /** The controller of the result panel. */ - ResultPanelCtrl resultsPanelCtrl; + ResultsPanelCtrl resultsPanelCtrl; /** The controller of the services panel. */ ServicesPanelCtrl servicesPanelCtrl; @@ -56,8 +60,8 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener */ public MainPanelCtrl() { servicesPanelCtrl = new ServicesPanelCtrl(this); - resultsPanelCtrl = new ResultPanelCtrl(this); requestPanelCtrl = new RequestPanelCtrl(this); + resultsPanelCtrl = new ResultsPanelCtrl(this); view = new MainPanelView(this); } @@ -82,19 +86,14 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener view.getStatusBarPanelView().setStatusBarText(shortMessage); } - /** - * @return The controller of the request panel. - */ + /** @return The controller of the request panel. */ @Override public RequestPanelCtrl getRequestCtrl() { return requestPanelCtrl; } - /** - * @return The controller of the result panel. - */ - @Override - public ResultPanelCtrl getResultsCtrl() { + /** @return The controller of the result panel. */ + public ResultsPanelCtrl getResultsCtrl() { return resultsPanelCtrl; } @@ -116,7 +115,7 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener @Override public void saveCurrentVOTable(File file) { try { - Files.copy(Paths.get(resultsPanelCtrl.getVOTablePath()), + Files.copy(Paths.get(resultsPanelCtrl.getFocusedVOTablePath()), Paths.get(file.getAbsolutePath())); } catch (IOException e) { displayError("Can not save the VOTable file.", e); @@ -125,7 +124,19 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener @Override public void sendQueries() { - sendQueries(servicesPanelCtrl.getServices()); + ServicesList services = getServicesCtrl().getServices(); + List queries = new ArrayList<>(); + for (String tableName : services.getTableNames()) { + queries.add(requestPanelCtrl.getQuery(tableName)); + } + resultsPanelCtrl.sendQueries(services, queries); + } + + /* @see MainPanelListener */ + @Override + public void setWaitMode(boolean enableWaitMode) { + int cursor = enableWaitMode ? Cursor.WAIT_CURSOR : Cursor.DEFAULT_CURSOR; + view.setCursor(Cursor.getPredefinedCursor(cursor)); } @Override diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java index 8d5385d..69f72c5 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java @@ -49,6 +49,13 @@ public interface MainPanelListener { /** Ask the main panel to send the query. */ void sendQueries(); + /** + * Set the cursor in the VOTable view. + * + * @param enableWaitMode True to set the Wait cursor, false to set the default cursor. + */ + void setWaitMode(boolean enableWaitMode); + /** Ask the main panel to update the query. */ void updateQuery(); } 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 96907ee..c544165 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 @@ -24,7 +24,7 @@ import javax.swing.JPanel; import javax.swing.JSplitPane; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelView; -import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelView; +import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultsPanelView; import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelView; import eu.omp.irap.vespa.epntapclient.gui.statusbarpanel.StatusBarPanelView; @@ -42,7 +42,7 @@ public class MainPanelView extends JPanel { private RequestPanelView requestPanel; /** The JPanel where the VOTable results is displayed. */ - private ResultPanelView resultPanel; + private ResultsPanelView resultPanel; /** The JPanel where the list of services is displayed. */ private ServicesPanelView servicesPanel; @@ -85,7 +85,7 @@ public class MainPanelView extends JPanel { /** * @return The JPanel where the VOTable result is displayed. */ - public ResultPanelView getResultsPanel() { + public ResultsPanelView getResultsPanel() { return resultPanel; } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java deleted file mode 100644 index 61d91bb..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java +++ /dev/null @@ -1,85 +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.resultpanel; - -import java.awt.Cursor; -import java.util.logging.Logger; - -import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelListener; -import eu.omp.irap.vespa.votable.utils.StringJoiner; -import eu.omp.irap.vespa.votable.votable.VOTableCtrl; - -/** - * @author N. Jourdane - */ -public class ResultPanelCtrl extends VOTableCtrl implements ResultPanelListener { - - /** The logger for the class ResultPanelCtrl. */ - private static final Logger LOGGER = Logger.getLogger(ResultPanelCtrl.class.getName()); - - /** The listener of the main panel. */ - private MainPanelListener listener; - - /** The result panel view. */ - private ResultPanelView view; - - - /** - * Constructor of ResultPanelCtrl. - * - * @param listener The listener of the main panel. - */ - public ResultPanelCtrl(MainPanelListener listener) { - this.listener = listener; - view = new ResultPanelView(this); - } - - @Override - public void displayError(String message, Exception error) { - listener.displayError(message, error); - } - - @Override - public void displayInfo(String shortMessage, String detailledMessage) { - listener.displayInfo(shortMessage, detailledMessage); - } - - @Override - public void fillTable() { - view.addTable(voTableData); - } - - /** - * @return The result panel view. - */ - public ResultPanelView getView() { - return view; - } - - @Override - public void onRowsSelected() { - if (view.getSelectedIndex() != -1) { - LOGGER.info("Selected row(s): " + StringJoiner.join(view.getSelectedRows())); - } - } - - @Override - public void setWaitCursor(boolean enableWaitcursor) { - int cursor = enableWaitcursor ? Cursor.WAIT_CURSOR : Cursor.DEFAULT_CURSOR; - view.setCursor(Cursor.getPredefinedCursor(cursor)); - } -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java deleted file mode 100644 index d1ff61b..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java +++ /dev/null @@ -1,26 +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.resultpanel; - -import eu.omp.irap.vespa.votable.gui.VOTablePanelListener; - -/** - * @author N. Jourdane - */ -public interface ResultPanelListener extends VOTablePanelListener { - -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java deleted file mode 100644 index 2de2b93..0000000 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java +++ /dev/null @@ -1,96 +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.resultpanel; - -import java.util.List; - -import javax.swing.JTabbedPane; - -import eu.omp.irap.vespa.votable.gui.VOTablePanelView; -import eu.omp.irap.vespa.votable.votabledata.VOTableData; - -/** - * @author N. Jourdane - */ -public class ResultPanelView extends JTabbedPane { - - /** The default serial version UID. */ - private static final long serialVersionUID = 1L; - - /** The listener of the result panel. */ - ResultPanelListener listener; - - - /** - * Method constructor which customize the result panel, but don't build it from scratch since - * VOTableView is already created by ResultController. - * - * @param listener The listener of the result view. - */ - public ResultPanelView(ResultPanelListener listener) { - this.listener = listener; - buildResultPanel(); - } - - /** - * Create a new tab and add a new VOTable into it. - * - * @param voTableData The VOTable data to add in a new tab. - */ - public void addTable(VOTableData voTableData) { - VOTablePanelView voTablePanel = new VOTablePanelView(listener); - voTablePanel.fillTable(voTableData); - addTab(voTableData.getTitle(), voTablePanel); - } - - /** - * Build the panel and add graphical elements to it. - */ - public void buildResultPanel() { - // setLayout(new BorderLayout()); - } - - /** - * @return The panel inside the current active tab. - */ - public VOTablePanelView getCurrentTablePanel() { - return (VOTablePanelView) getComponentAt(getSelectedTab()); - } - - /** - * @return The index of the selected tab. - */ - public List getSelectedRows() { - return getCurrentTablePanel().getSelectedRows(); - } - - /** - * @return The index of the selected tab. - */ - public int getSelectedTab() { - return getSelectedIndex(); - } - - /** - * Append data to the current tab. - * - * @param voTableData The VOTable data to add in the current tab. - */ - public void updateTable(VOTableData voTableData) { - getCurrentTablePanel().fillTable(voTableData); - } -} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabCtrl.java new file mode 100644 index 0000000..e86ed35 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabCtrl.java @@ -0,0 +1,95 @@ +/* + * 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.resultpanel; + +import java.util.logging.Logger; + +import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelListener; +import eu.omp.irap.vespa.votable.gui.VOTablePanelView; +import eu.omp.irap.vespa.votable.utils.StringJoiner; +import eu.omp.irap.vespa.votable.votable.VOTableCtrl; + +/** + * @author N. Jourdane + */ +public class ResultTabCtrl extends VOTableCtrl implements ResultTabListener { + + /** The logger for the class ResultPanelCtrl. */ + private static final Logger LOGGER = Logger.getLogger(ResultTabCtrl.class.getName()); + + /** The listener of the main panel. */ + private MainPanelListener listener; + + /** The result panel view, used to add the new tab into it. */ + private ResultsPanelView resultsPanelView; + + /** The title of the tab (ie. The name of the service). */ + private String title; + + /** The result panel view. */ + private VOTablePanelView view; + + + /** + * Constructor of ResultPanelCtrl. + * + * @param listener The listener of the main panel. + * @param resultsPanelView The result panel view, used to add the new tab into it. + * @param title The title of the tab (ie. The name of the service). + */ + public ResultTabCtrl(MainPanelListener listener, ResultsPanelView resultsPanelView, + String title) { + this.listener = listener; + this.resultsPanelView = resultsPanelView; + view = new VOTablePanelView(this); + this.title = title; + } + + @Override + public void displayError(String message, Exception error) { + listener.displayError(message, error); + } + + @Override + public void displayInfo(String shortMessage, String detailledMessage) { + listener.displayInfo(shortMessage, detailledMessage); + } + + @Override + public void displayTable() { + view.fillTable(voTableData); + resultsPanelView.addTab(title, view); + } + + /** + * @return The result panel view. + */ + public VOTablePanelView getView() { + return view; + } + + @Override + public void onRowsSelected() { + LOGGER.info("Selected row(s): " + StringJoiner.join(view.getSelectedRows())); + } + + @Override + public void setWaitMode(boolean enableWaitMode) { + listener.setWaitMode(enableWaitMode); + } + +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabListener.java new file mode 100644 index 0000000..10a0bc3 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultTabListener.java @@ -0,0 +1,26 @@ +/* + * 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.resultpanel; + +import eu.omp.irap.vespa.votable.gui.VOTablePanelListener; + +/** + * @author N. Jourdane + */ +public interface ResultTabListener extends VOTablePanelListener { + +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelCtrl.java new file mode 100644 index 0000000..40978e5 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelCtrl.java @@ -0,0 +1,70 @@ +/* + * 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.resultpanel; + +import java.util.List; + +import eu.omp.irap.vespa.epntapclient.epntap.service.ServicesList; +import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelListener; +import eu.omp.irap.vespa.votable.gui.VOTablePanelView; + +/** + * @author N. Jourdane + */ +public class ResultsPanelCtrl implements ResultsPanelListener { + + /** The listener of the main panel. */ + private MainPanelListener listener; + + /** The result panel view. */ + private ResultsPanelView view; + + + /** + * Constructor of ResultsPanelCtrl. + * + * @param listener The listener of the main panel. + */ + public ResultsPanelCtrl(MainPanelListener listener) { + this.listener = listener; + view = new ResultsPanelView(this); + } + + /** @return The path of the VOTable related to the focused table. */ + public String getFocusedVOTablePath() { + return ((VOTablePanelView) view.getSelectedComponent()).getVOTablePath(); + } + + /** @return The view of the results panel. */ + public ResultsPanelView getView() { + return view; + } + + /** + * Send a list of queries to the corresponding services. + * + * @param services The services targeted to send the queries + * @param queries The queries to send, in the same order that the list of services. + */ + public void sendQueries(ServicesList services, List queries) { + for (int i = 0; i < queries.size(); i++) { + String title = services.getTableNames().get(i).split("\\.")[0]; + ResultTabCtrl resultCtrl = new ResultTabCtrl(listener, view, title); + resultCtrl.acquireVOTable(services.getTargetUrls().get(i), queries.get(i)); + } + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelListener.java new file mode 100644 index 0000000..311ce14 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelListener.java @@ -0,0 +1,26 @@ +/* + * 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.resultpanel; + + +/** + * + * @author N. Jourdane + */ +public interface ResultsPanelListener { + +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelView.java new file mode 100644 index 0000000..71e92ee --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultsPanelView.java @@ -0,0 +1,82 @@ +/* + * 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.resultpanel; + +import java.util.List; + +import javax.swing.JTabbedPane; + +import eu.omp.irap.vespa.votable.gui.VOTablePanelView; +import eu.omp.irap.vespa.votable.votabledata.VOTableData; + +/** + * @author N. Jourdane + */ +public class ResultsPanelView extends JTabbedPane { + + /** The default serial version UID. */ + private static final long serialVersionUID = 1L; + + /** The listener of the result panel. */ + ResultsPanelListener listener; + + + /** + * Method constructor which customize the result panel, but don't build it from scratch since + * VOTableView is already created by ResultController. + * + * @param listener The listener of the result view. + */ + public ResultsPanelView(ResultsPanelListener listener) { + this.listener = listener; + } + + /** + * @return The panel inside the current active tab. + */ + public VOTablePanelView getCurrentTablePanel() { + return (VOTablePanelView) getComponentAt(getSelectedTab()); + } + + /** @return the VOTable view of each tab in the result panel. */ + public VOTablePanelView[] getPanels() { + return (VOTablePanelView[]) getComponents(); + } + + /** + * @return The index of the selected tab. + */ + public List getSelectedRows() { + return getCurrentTablePanel().getSelectedRows(); + } + + /** + * @return The index of the selected tab. + */ + public int getSelectedTab() { + return getSelectedIndex(); + } + + /** + * Append data to the current tab. + * + * @param voTableData The VOTable data to add in the current tab. + */ + public void updateTable(VOTableData voTableData) { + getCurrentTablePanel().fillTable(voTableData); + } +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java index a9d4be5..b65c4c0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java @@ -16,7 +16,6 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; -import java.awt.Cursor; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -57,13 +56,11 @@ public class ServicesPanelCtrl extends VOTableCtrl implements ServicesPanelListe view = new ServicesPanelView(this); } - /** - * Download and parse the list of services. - */ + /** Download and parse the list of services. */ public void acquire() { String getServicesQuery = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); - acquireVOTable(Consts.DEFAULT_REGISTRY_URL, getServicesQuery, false); + acquireVOTable(Consts.DEFAULT_REGISTRY_URL, getServicesQuery); } @Override @@ -77,7 +74,7 @@ public class ServicesPanelCtrl extends VOTableCtrl implements ServicesPanelListe } @Override - public void fillTable() { + public void displayTable() { view.fillTable(voTableData); } @@ -129,8 +126,7 @@ public class ServicesPanelCtrl extends VOTableCtrl implements ServicesPanelListe } @Override - public void setWaitCursor(boolean enableWaitcursor) { - int cursor = enableWaitcursor ? Cursor.WAIT_CURSOR : Cursor.DEFAULT_CURSOR; - view.setCursor(Cursor.getPredefinedCursor(cursor)); + public void setWaitMode(boolean enableWaitMode) { + listener.setWaitMode(enableWaitMode); } } -- libgit2 0.21.2