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 affd41a..622b0b6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java @@ -108,7 +108,7 @@ public class EpnTapController { return servicesCtrl; } - public RequestCtrl getRequestPanelCtrl() { + public RequestCtrl getRequestCtrl() { return requestCtrl; } 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 ed946db..0ee3bda 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 @@ -27,9 +27,7 @@ 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.epntapclient.gui.servicespanel.ServicesPanelCtrl; import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; import eu.omp.irap.vespa.votable.controller.VOTableController; @@ -43,7 +41,7 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { private RequestPanelCtrl requestPanelCtrl; - private VOTableController servicesPanelCtrl; + private ServicesPanelCtrl servicesPanelCtrl; private VOTableController resultPanelCtrl; @@ -53,19 +51,11 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { // 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); + servicesPanelCtrl = new ServicesPanelCtrl(this); resultPanelCtrl = new VOTableController(); requestPanelCtrl = new RequestPanelCtrl(this); mainView = new MainPanelView(this); @@ -82,9 +72,10 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { } public void sendQuery(String query) { - logger.info("Sending query: " + query + " on " + selectedServiceURL); + String serviceURL = servicesPanelCtrl.getSelectedServiceURL(); + logger.info("Sending query: " + query + " on " + serviceURL); try { - resultPanelCtrl.updateVOTable(selectedServiceURL, query); + resultPanelCtrl.updateVOTable(serviceURL, query); voTablePath = resultPanelCtrl.getVOTablePath(); mainView.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData()); } catch (CantGetVOTableException e) { @@ -93,29 +84,16 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { } } - @Override public RequestPanelCtrl getRequestPanelCtrl() { return requestPanelCtrl; } - public MainPanelView getView() { - return mainView; - } - - public String getSelectedTableName() { - return selectedTableName; + public ServicesPanelCtrl getServicePanelCtrl() { + return servicesPanelCtrl; } - 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); + public MainPanelView getView() { + return mainView; } @Override @@ -151,14 +129,4 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { 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 987a129..b0d1ca1 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 @@ -55,7 +55,7 @@ public class MainPanelView extends JPanel { */ public MainPanelView(MainPanelCtrl mainPanelCtrl) { - servicesPanel = new ServicesPanelView(mainPanelCtrl); + servicesPanel = mainPanelCtrl.getServicePanelCtrl().getView(); resultPanel = new ResultPanelView(mainPanelCtrl); requestPanel = mainPanelCtrl.getRequestPanelCtrl().getView(); buildMainView(); 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 e5b23a3..9e7befa 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 @@ -27,13 +27,6 @@ import java.io.File; public interface ViewListener { /** - * When a service is selected on the service panel. - * - * @param selectedService The row number selected in the service panel. - */ - void onServiceSelected(int selectedService); - - /** * When the `Download VOTable` button is clicked. * * @param outputFile The file to copy the VOTable. 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 5ad745c..12f6ed3 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 @@ -68,8 +68,8 @@ public class RequestPanelCtrl extends RequestCtrl implements RequestPanelListene * 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()); + String query = Queries.getQuery(mainPanelCtrl.getServicePanelCtrl().getSelectedTableName(), + paramValues, mainPanelCtrl.getNbMaxResult()); view.updateQueryArea(query); } 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 586edc8..e264b9d 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 @@ -18,11 +18,62 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; import java.util.logging.Logger; +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelCtrl; +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.VOTableController; + /** * @author N. Jourdane */ -public class ServicesPanelCtrl { +public class ServicesPanelCtrl extends VOTableController implements ServicesPanelListener { /** The logger for the class ServicesPanelCtrl. */ private static final Logger logger = Logger.getLogger(ServicesPanelCtrl.class.getName()); + + /** 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 MainPanelCtrl mainPanelCtrl; + + private ServicesPanelView view; + + + public ServicesPanelCtrl(MainPanelCtrl mainPanelCtrl) { + this.mainPanelCtrl = mainPanelCtrl; + targetURL = Consts.DEFAULT_REGISTRY_URL; + query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); + view = new ServicesPanelView(this); + } + + public ServicesPanelView getView() { + return view; + } + + 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 serviceURL = view.getServiceURL(selectedServiceRow); + String tableName = view.getTableName(selectedServiceRow); + if (!tableName.equals(selectedTableName)) { + selectedServiceURL = serviceURL; + selectedTableName = tableName; + mainPanelCtrl.getRequestPanelCtrl().updateQueryArea(); + logger.info( + "Selected table: " + selectedTableName + " - service: " + selectedServiceURL); + } + } + } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java index acb1149..c3757bc 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java @@ -21,5 +21,10 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; */ public interface ServicesPanelListener { - public void onServiceSelected(int selectedServiceRow); + /** + * When a service is selected on the service panel. + * + * @param selectedService The row number selected in the service panel. + */ + void onServiceSelected(int selectedService); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java index 10b0cdf..5f80431 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java @@ -27,7 +27,6 @@ import javax.swing.JTextField; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; import eu.omp.irap.vespa.votable.view.VOTableView; /** @@ -38,7 +37,7 @@ public class ServicesPanelView extends VOTableView { /** The serial version UID. */ private static final long serialVersionUID = 1L; - private ViewListener viewListener; + private ServicesPanelListener viewListener; private JButton serviceButton; @@ -54,7 +53,7 @@ public class ServicesPanelView extends VOTableView { * @param mainView The main view of the application. * @param voTableView The generic view of the VOTable panel. */ - public ServicesPanelView(final ViewListener viewListener) { + public ServicesPanelView(final ServicesPanelListener viewListener) { super(); this.viewListener = viewListener; buildServicesPanel(); -- libgit2 0.21.2