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 c45c6d0..743b215 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java @@ -18,6 +18,7 @@ package eu.omp.irap.vespa.epntapclient; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; import eu.omp.irap.vespa.epntapclient.service.Queries; @@ -25,6 +26,7 @@ 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; +import eu.omp.irap.vespa.votable.votabledata.VOTableData; /** * The main controller which manage views and controllers. @@ -52,8 +54,22 @@ public class EpnTapController { * Method constructor, which initialize servicesController, resultsController and mainView. */ public EpnTapController() { - String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); + String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, + ServiceCore.EPNCORE); servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); + VOTableData data = servicesCtrl.getVOTableData(); + } + + public void readServices() { + try { + servicesCtrl.readTable(); + } catch (CantGetVOTableException e) { + displayError(e); + } + } + + public void displayError(Exception e) { + logger.log(Level.SEVERE, "Can not get services.", e); } public String sendQuery(String query, String tableServiceURL) 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 9cf1c71..cd9931e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java @@ -55,8 +55,9 @@ public class EpnTapMainApp { return; } - GUIController ctrl = new GUIController(); - SwingUtilities.invokeLater(EpnTapMainApp.run(ctrl.getView(), "EPN-TAP client")); + GUIController guiCtrl = new GUIController(); + guiCtrl.readServices(); + SwingUtilities.invokeLater(EpnTapMainApp.run(guiCtrl.getView(), "EPN-TAP client")); } private static Runnable run(final EpnTapMainView voTableView, final String title) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java index 1b942d7..82879d0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java @@ -23,6 +23,8 @@ 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; @@ -49,6 +51,15 @@ public class GUIController extends EpnTapController implements ViewListener { public GUIController() { super(); mainView = new EpnTapMainView(this); + } + + @Override + public void readServices() { + try { + servicesCtrl.readTable(); + } catch (CantGetVOTableException e) { + displayError(e); + } mainView.getServicesPanel().fillTable(servicesCtrl.getVOTableData()); } @@ -59,8 +70,9 @@ public class GUIController extends EpnTapController implements ViewListener { /** Update the row selected by the user on the Services Panel. */ @Override public void onServiceSelected(int selectedServiceRow) { - mainView.getServicesPanel().getServiceURL(selectedServiceRow); - mainView.getServicesPanel().getTableName(selectedServiceRow); + String url = mainView.getServicesPanel().getServiceURL(selectedServiceRow); + String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow); + updateService(url, tableName); } /** Send the specified query on selectedTableServiceURL */ @@ -76,6 +88,12 @@ public class GUIController extends EpnTapController implements ViewListener { } } + @Override + public void displayError(Exception e) { + JOptionPane.showMessageDialog(mainView, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE, + null); + } + /** Copy the VOTable to a specified location. */ @Override public void onDownloadButtonClicked(File outputFile) { @@ -92,7 +110,7 @@ public class GUIController extends EpnTapController implements ViewListener { /** Update a query parameter in the parameter list. */ @Override public void onParameterChanged(String paramName, Object paramValue) { - updateParameter(paramName, paramName); + updateParameter(paramName, paramValue); updateQueryArea(); GUIController.logger.info("uploaded " + paramName + ": " + paramValue); } -- libgit2 0.21.2