Commit eae7b5f9038afa300c63dee9f51e88c8e84668cc

Authored by Nathanael Jourdane
1 parent 125adfc1
Exists in master

bugfix #1

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java
@@ -18,6 +18,7 @@ package eu.omp.irap.vespa.epntapclient; @@ -18,6 +18,7 @@ package eu.omp.irap.vespa.epntapclient;
18 18
19 import java.util.HashMap; 19 import java.util.HashMap;
20 import java.util.Map; 20 import java.util.Map;
  21 +import java.util.logging.Level;
21 import java.util.logging.Logger; 22 import java.util.logging.Logger;
22 23
23 import eu.omp.irap.vespa.epntapclient.service.Queries; 24 import eu.omp.irap.vespa.epntapclient.service.Queries;
@@ -25,6 +26,7 @@ import eu.omp.irap.vespa.epntapclient.service.ServiceCore; @@ -25,6 +26,7 @@ import eu.omp.irap.vespa.epntapclient.service.ServiceCore;
25 import eu.omp.irap.vespa.votable.Consts; 26 import eu.omp.irap.vespa.votable.Consts;
26 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; 27 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
27 import eu.omp.irap.vespa.votable.controller.VOTableController; 28 import eu.omp.irap.vespa.votable.controller.VOTableController;
  29 +import eu.omp.irap.vespa.votable.votabledata.VOTableData;
28 30
29 /** 31 /**
30 * The main controller which manage views and controllers. 32 * The main controller which manage views and controllers.
@@ -52,8 +54,22 @@ public class EpnTapController { @@ -52,8 +54,22 @@ public class EpnTapController {
52 * Method constructor, which initialize servicesController, resultsController and mainView. 54 * Method constructor, which initialize servicesController, resultsController and mainView.
53 */ 55 */
54 public EpnTapController() { 56 public EpnTapController() {
55 - String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); 57 + String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE,
  58 + ServiceCore.EPNCORE);
56 servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); 59 servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query);
  60 + VOTableData data = servicesCtrl.getVOTableData();
  61 + }
  62 +
  63 + public void readServices() {
  64 + try {
  65 + servicesCtrl.readTable();
  66 + } catch (CantGetVOTableException e) {
  67 + displayError(e);
  68 + }
  69 + }
  70 +
  71 + public void displayError(Exception e) {
  72 + logger.log(Level.SEVERE, "Can not get services.", e);
57 } 73 }
58 74
59 public String sendQuery(String query, String tableServiceURL) 75 public String sendQuery(String query, String tableServiceURL)
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java
@@ -55,8 +55,9 @@ public class EpnTapMainApp { @@ -55,8 +55,9 @@ public class EpnTapMainApp {
55 return; 55 return;
56 } 56 }
57 57
58 - GUIController ctrl = new GUIController();  
59 - SwingUtilities.invokeLater(EpnTapMainApp.run(ctrl.getView(), "EPN-TAP client")); 58 + GUIController guiCtrl = new GUIController();
  59 + guiCtrl.readServices();
  60 + SwingUtilities.invokeLater(EpnTapMainApp.run(guiCtrl.getView(), "EPN-TAP client"));
60 } 61 }
61 62
62 private static Runnable run(final EpnTapMainView voTableView, final String title) { 63 private static Runnable run(final EpnTapMainView voTableView, final String title) {
src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java
@@ -23,6 +23,8 @@ import java.nio.file.Paths; @@ -23,6 +23,8 @@ import java.nio.file.Paths;
23 import java.util.logging.Level; 23 import java.util.logging.Level;
24 import java.util.logging.Logger; 24 import java.util.logging.Logger;
25 25
  26 +import javax.swing.JOptionPane;
  27 +
26 import eu.omp.irap.vespa.epntapclient.EpnTapController; 28 import eu.omp.irap.vespa.epntapclient.EpnTapController;
27 import eu.omp.irap.vespa.epntapclient.service.Queries; 29 import eu.omp.irap.vespa.epntapclient.service.Queries;
28 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; 30 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
@@ -49,6 +51,15 @@ public class GUIController extends EpnTapController implements ViewListener { @@ -49,6 +51,15 @@ public class GUIController extends EpnTapController implements ViewListener {
49 public GUIController() { 51 public GUIController() {
50 super(); 52 super();
51 mainView = new EpnTapMainView(this); 53 mainView = new EpnTapMainView(this);
  54 + }
  55 +
  56 + @Override
  57 + public void readServices() {
  58 + try {
  59 + servicesCtrl.readTable();
  60 + } catch (CantGetVOTableException e) {
  61 + displayError(e);
  62 + }
52 mainView.getServicesPanel().fillTable(servicesCtrl.getVOTableData()); 63 mainView.getServicesPanel().fillTable(servicesCtrl.getVOTableData());
53 } 64 }
54 65
@@ -59,8 +70,9 @@ public class GUIController extends EpnTapController implements ViewListener { @@ -59,8 +70,9 @@ public class GUIController extends EpnTapController implements ViewListener {
59 /** Update the row selected by the user on the Services Panel. */ 70 /** Update the row selected by the user on the Services Panel. */
60 @Override 71 @Override
61 public void onServiceSelected(int selectedServiceRow) { 72 public void onServiceSelected(int selectedServiceRow) {
62 - mainView.getServicesPanel().getServiceURL(selectedServiceRow);  
63 - mainView.getServicesPanel().getTableName(selectedServiceRow); 73 + String url = mainView.getServicesPanel().getServiceURL(selectedServiceRow);
  74 + String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow);
  75 + updateService(url, tableName);
64 } 76 }
65 77
66 /** Send the specified query on selectedTableServiceURL */ 78 /** Send the specified query on selectedTableServiceURL */
@@ -76,6 +88,12 @@ public class GUIController extends EpnTapController implements ViewListener { @@ -76,6 +88,12 @@ public class GUIController extends EpnTapController implements ViewListener {
76 } 88 }
77 } 89 }
78 90
  91 + @Override
  92 + public void displayError(Exception e) {
  93 + JOptionPane.showMessageDialog(mainView, "Error", e.getMessage(), JOptionPane.ERROR_MESSAGE,
  94 + null);
  95 + }
  96 +
79 /** Copy the VOTable to a specified location. */ 97 /** Copy the VOTable to a specified location. */
80 @Override 98 @Override
81 public void onDownloadButtonClicked(File outputFile) { 99 public void onDownloadButtonClicked(File outputFile) {
@@ -92,7 +110,7 @@ public class GUIController extends EpnTapController implements ViewListener { @@ -92,7 +110,7 @@ public class GUIController extends EpnTapController implements ViewListener {
92 /** Update a query parameter in the parameter list. */ 110 /** Update a query parameter in the parameter list. */
93 @Override 111 @Override
94 public void onParameterChanged(String paramName, Object paramValue) { 112 public void onParameterChanged(String paramName, Object paramValue) {
95 - updateParameter(paramName, paramName); 113 + updateParameter(paramName, paramValue);
96 updateQueryArea(); 114 updateQueryArea();
97 GUIController.logger.info("uploaded " + paramName + ": " + paramValue); 115 GUIController.logger.info("uploaded " + paramName + ": " + paramValue);
98 } 116 }