Commit 6f25e39e85ed902196b9faf921ba052c267d8595
1 parent
02d6e914
Exists in
master
Use ServicePanelCtrl to manage the service view.
Showing
8 changed files
with
74 additions
and
58 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelCtrl.java
... | ... | @@ -27,9 +27,7 @@ import javax.swing.JOptionPane; |
27 | 27 | |
28 | 28 | import eu.omp.irap.vespa.epntapclient.EpnTapController; |
29 | 29 | import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; |
30 | -import eu.omp.irap.vespa.epntapclient.service.Queries; | |
31 | -import eu.omp.irap.vespa.epntapclient.service.ServiceCore; | |
32 | -import eu.omp.irap.vespa.votable.Consts; | |
30 | +import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl; | |
33 | 31 | import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; |
34 | 32 | import eu.omp.irap.vespa.votable.controller.VOTableController; |
35 | 33 | |
... | ... | @@ -43,7 +41,7 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
43 | 41 | |
44 | 42 | private RequestPanelCtrl requestPanelCtrl; |
45 | 43 | |
46 | - private VOTableController servicesPanelCtrl; | |
44 | + private ServicesPanelCtrl servicesPanelCtrl; | |
47 | 45 | |
48 | 46 | private VOTableController resultPanelCtrl; |
49 | 47 | |
... | ... | @@ -53,19 +51,11 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
53 | 51 | |
54 | 52 | // TODO: à déplacer dans ServicePanelCtrl |
55 | 53 | |
56 | - /** The name of the table selected by the user on the table list panel. */ | |
57 | - private String selectedTableName; | |
58 | - | |
59 | - /** The URL of the service corresponding to the selected table. */ | |
60 | - private String selectedServiceURL; | |
61 | - | |
62 | 54 | private int nbMaxResult = 10; |
63 | 55 | |
64 | 56 | |
65 | 57 | public MainPanelCtrl() { |
66 | - String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, | |
67 | - ServiceCore.EPNCORE); | |
68 | - servicesPanelCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); | |
58 | + servicesPanelCtrl = new ServicesPanelCtrl(this); | |
69 | 59 | resultPanelCtrl = new VOTableController(); |
70 | 60 | requestPanelCtrl = new RequestPanelCtrl(this); |
71 | 61 | mainView = new MainPanelView(this); |
... | ... | @@ -82,9 +72,10 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
82 | 72 | } |
83 | 73 | |
84 | 74 | public void sendQuery(String query) { |
85 | - logger.info("Sending query: " + query + " on " + selectedServiceURL); | |
75 | + String serviceURL = servicesPanelCtrl.getSelectedServiceURL(); | |
76 | + logger.info("Sending query: " + query + " on " + serviceURL); | |
86 | 77 | try { |
87 | - resultPanelCtrl.updateVOTable(selectedServiceURL, query); | |
78 | + resultPanelCtrl.updateVOTable(serviceURL, query); | |
88 | 79 | voTablePath = resultPanelCtrl.getVOTablePath(); |
89 | 80 | mainView.getResultsPanel().fillTable(resultPanelCtrl.getVOTableData()); |
90 | 81 | } catch (CantGetVOTableException e) { |
... | ... | @@ -93,29 +84,16 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
93 | 84 | } |
94 | 85 | } |
95 | 86 | |
96 | - @Override | |
97 | 87 | public RequestPanelCtrl getRequestPanelCtrl() { |
98 | 88 | return requestPanelCtrl; |
99 | 89 | } |
100 | 90 | |
101 | - public MainPanelView getView() { | |
102 | - return mainView; | |
103 | - } | |
104 | - | |
105 | - public String getSelectedTableName() { | |
106 | - return selectedTableName; | |
91 | + public ServicesPanelCtrl getServicePanelCtrl() { | |
92 | + return servicesPanelCtrl; | |
107 | 93 | } |
108 | 94 | |
109 | - public String getSelectedServiceURL() { | |
110 | - return selectedServiceURL; | |
111 | - } | |
112 | - | |
113 | - /** Update the row selected by the user on the Services Panel. */ | |
114 | - @Override | |
115 | - public void onServiceSelected(int selectedServiceRow) { | |
116 | - String url = mainView.getServicesPanel().getServiceURL(selectedServiceRow); | |
117 | - String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow); | |
118 | - updateService(url, tableName); | |
95 | + public MainPanelView getView() { | |
96 | + return mainView; | |
119 | 97 | } |
120 | 98 | |
121 | 99 | @Override |
... | ... | @@ -151,14 +129,4 @@ public class MainPanelCtrl extends EpnTapController implements ViewListener { |
151 | 129 | nbMaxResult = nb; |
152 | 130 | } |
153 | 131 | |
154 | - public void updateService(String serviceURL, String tableName) { | |
155 | - if (!tableName.equals(selectedTableName)) { | |
156 | - selectedServiceURL = serviceURL; | |
157 | - selectedTableName = tableName; | |
158 | - requestPanelCtrl.updateQueryArea(); | |
159 | - MainPanelCtrl.logger.info("Selected table: " + selectedTableName + " - service: " | |
160 | - + selectedServiceURL); | |
161 | - } | |
162 | - } | |
163 | - | |
164 | 132 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java
... | ... | @@ -55,7 +55,7 @@ public class MainPanelView extends JPanel { |
55 | 55 | */ |
56 | 56 | |
57 | 57 | public MainPanelView(MainPanelCtrl mainPanelCtrl) { |
58 | - servicesPanel = new ServicesPanelView(mainPanelCtrl); | |
58 | + servicesPanel = mainPanelCtrl.getServicePanelCtrl().getView(); | |
59 | 59 | resultPanel = new ResultPanelView(mainPanelCtrl); |
60 | 60 | requestPanel = mainPanelCtrl.getRequestPanelCtrl().getView(); |
61 | 61 | buildMainView(); | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java
... | ... | @@ -27,13 +27,6 @@ import java.io.File; |
27 | 27 | public interface ViewListener { |
28 | 28 | |
29 | 29 | /** |
30 | - * When a service is selected on the service panel. | |
31 | - * | |
32 | - * @param selectedService The row number selected in the service panel. | |
33 | - */ | |
34 | - void onServiceSelected(int selectedService); | |
35 | - | |
36 | - /** | |
37 | 30 | * When the `Download VOTable` button is clicked. |
38 | 31 | * |
39 | 32 | * @param outputFile The file to copy the VOTable. | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java
... | ... | @@ -68,8 +68,8 @@ public class RequestPanelCtrl extends RequestCtrl implements RequestPanelListene |
68 | 68 | * Update the query area with a working ADQL query, based on the parameters list. |
69 | 69 | */ |
70 | 70 | public void updateQueryArea() { |
71 | - String query = Queries.getQuery(mainPanelCtrl.getSelectedTableName(), paramValues, | |
72 | - mainPanelCtrl.getNbMaxResult()); | |
71 | + String query = Queries.getQuery(mainPanelCtrl.getServicePanelCtrl().getSelectedTableName(), | |
72 | + paramValues, mainPanelCtrl.getNbMaxResult()); | |
73 | 73 | view.updateQueryArea(query); |
74 | 74 | } |
75 | 75 | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java
... | ... | @@ -18,11 +18,62 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; |
18 | 18 | |
19 | 19 | import java.util.logging.Logger; |
20 | 20 | |
21 | +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelCtrl; | |
22 | +import eu.omp.irap.vespa.epntapclient.service.Queries; | |
23 | +import eu.omp.irap.vespa.epntapclient.service.ServiceCore; | |
24 | +import eu.omp.irap.vespa.votable.Consts; | |
25 | +import eu.omp.irap.vespa.votable.controller.VOTableController; | |
26 | + | |
21 | 27 | /** |
22 | 28 | * @author N. Jourdane |
23 | 29 | */ |
24 | -public class ServicesPanelCtrl { | |
30 | +public class ServicesPanelCtrl extends VOTableController implements ServicesPanelListener { | |
25 | 31 | |
26 | 32 | /** The logger for the class ServicesPanelCtrl. */ |
27 | 33 | private static final Logger logger = Logger.getLogger(ServicesPanelCtrl.class.getName()); |
34 | + | |
35 | + /** The name of the table selected by the user on the table list panel. */ | |
36 | + private String selectedTableName; | |
37 | + | |
38 | + /** The URL of the service corresponding to the selected table. */ | |
39 | + private String selectedServiceURL; | |
40 | + | |
41 | + private MainPanelCtrl mainPanelCtrl; | |
42 | + | |
43 | + private ServicesPanelView view; | |
44 | + | |
45 | + | |
46 | + public ServicesPanelCtrl(MainPanelCtrl mainPanelCtrl) { | |
47 | + this.mainPanelCtrl = mainPanelCtrl; | |
48 | + targetURL = Consts.DEFAULT_REGISTRY_URL; | |
49 | + query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); | |
50 | + view = new ServicesPanelView(this); | |
51 | + } | |
52 | + | |
53 | + public ServicesPanelView getView() { | |
54 | + return view; | |
55 | + } | |
56 | + | |
57 | + public String getSelectedTableName() { | |
58 | + return selectedTableName; | |
59 | + } | |
60 | + | |
61 | + public String getSelectedServiceURL() { | |
62 | + return selectedServiceURL; | |
63 | + } | |
64 | + | |
65 | + /** Update the row selected by the user on the Services Panel. */ | |
66 | + @Override | |
67 | + public void onServiceSelected(int selectedServiceRow) { | |
68 | + String serviceURL = view.getServiceURL(selectedServiceRow); | |
69 | + String tableName = view.getTableName(selectedServiceRow); | |
70 | + if (!tableName.equals(selectedTableName)) { | |
71 | + selectedServiceURL = serviceURL; | |
72 | + selectedTableName = tableName; | |
73 | + mainPanelCtrl.getRequestPanelCtrl().updateQueryArea(); | |
74 | + logger.info( | |
75 | + "Selected table: " + selectedTableName + " - service: " + selectedServiceURL); | |
76 | + } | |
77 | + } | |
78 | + | |
28 | 79 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java
... | ... | @@ -21,5 +21,10 @@ package eu.omp.irap.vespa.epntapclient.gui.servicespanel; |
21 | 21 | */ |
22 | 22 | public interface ServicesPanelListener { |
23 | 23 | |
24 | - public void onServiceSelected(int selectedServiceRow); | |
24 | + /** | |
25 | + * When a service is selected on the service panel. | |
26 | + * | |
27 | + * @param selectedService The row number selected in the service panel. | |
28 | + */ | |
29 | + void onServiceSelected(int selectedService); | |
25 | 30 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java
... | ... | @@ -27,7 +27,6 @@ import javax.swing.JTextField; |
27 | 27 | import javax.swing.event.ListSelectionEvent; |
28 | 28 | import javax.swing.event.ListSelectionListener; |
29 | 29 | |
30 | -import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener; | |
31 | 30 | import eu.omp.irap.vespa.votable.view.VOTableView; |
32 | 31 | |
33 | 32 | /** |
... | ... | @@ -38,7 +37,7 @@ public class ServicesPanelView extends VOTableView { |
38 | 37 | /** The serial version UID. */ |
39 | 38 | private static final long serialVersionUID = 1L; |
40 | 39 | |
41 | - private ViewListener viewListener; | |
40 | + private ServicesPanelListener viewListener; | |
42 | 41 | |
43 | 42 | private JButton serviceButton; |
44 | 43 | |
... | ... | @@ -54,7 +53,7 @@ public class ServicesPanelView extends VOTableView { |
54 | 53 | * @param mainView The main view of the application. |
55 | 54 | * @param voTableView The generic view of the VOTable panel. |
56 | 55 | */ |
57 | - public ServicesPanelView(final ViewListener viewListener) { | |
56 | + public ServicesPanelView(final ServicesPanelListener viewListener) { | |
58 | 57 | super(); |
59 | 58 | this.viewListener = viewListener; |
60 | 59 | buildServicesPanel(); | ... | ... |