Commit 4a9845fdf91af4d7c3b946d95a9e836f227f5483

Authored by Nathanael Jourdane
1 parent fc9c97aa
Exists in master

Add controllers for each panel and organize packages.

Showing 12 changed files with 139 additions and 54 deletions   Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java
... ... @@ -23,8 +23,8 @@ import javax.swing.SwingUtilities;
23 23  
24 24 import com.google.gson.Gson;
25 25  
26   -import eu.omp.irap.vespa.epntapclient.gui.EpnTapMainView;
27   -import eu.omp.irap.vespa.epntapclient.gui.GUIController;
  26 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelView;
  27 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.MainPanelController;
28 28  
29 29 /**
30 30 * Simple class to have a main function to launch the EPNTap client.
... ... @@ -55,12 +55,12 @@ public class EpnTapMainApp {
55 55 return;
56 56 }
57 57  
58   - GUIController guiCtrl = new GUIController();
  58 + MainPanelController guiCtrl = new MainPanelController();
59 59 guiCtrl.readServices();
60 60 SwingUtilities.invokeLater(EpnTapMainApp.run(guiCtrl.getView(), "EPN-TAP client"));
61 61 }
62 62  
63   - private static Runnable run(final EpnTapMainView voTableView, final String title) {
  63 + private static Runnable run(final MainPanelView voTableView, final String title) {
64 64 return new Runnable() {
65 65  
66 66 @Override
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/GUIDim.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui;
  17 +package eu.omp.irap.vespa.epntapclient.gui.mainPanel;
18 18  
19 19 /**
20 20 * A simple class containing GUI panel and elements dimensions.
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelController.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui;
  17 +package eu.omp.irap.vespa.epntapclient.gui.mainPanel;
18 18  
19 19 import java.io.File;
20 20 import java.io.IOException;
... ... @@ -32,12 +32,12 @@ import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
32 32 /**
33 33 * @author N. Jourdane
34 34 */
35   -public class GUIController extends EpnTapController implements ViewListener {
  35 +public class MainPanelController extends EpnTapController implements ViewListener {
36 36  
37 37 /** The logger for the class GUIController. */
38   - private static final Logger logger = Logger.getLogger(GUIController.class.getName());
  38 + private static final Logger logger = Logger.getLogger(MainPanelController.class.getName());
39 39  
40   - private EpnTapMainView mainView;
  40 + private MainPanelView mainView;
41 41  
42 42 private String voTablePath;
43 43  
... ... @@ -48,9 +48,9 @@ public class GUIController extends EpnTapController implements ViewListener {
48 48 private String selectedTableServiceURL;
49 49  
50 50  
51   - public GUIController() {
  51 + public MainPanelController() {
52 52 super();
53   - mainView = new EpnTapMainView(this);
  53 + mainView = new MainPanelView(this);
54 54 }
55 55  
56 56 @Override
... ... @@ -63,7 +63,7 @@ public class GUIController extends EpnTapController implements ViewListener {
63 63 mainView.getServicesPanel().fillTable(servicesCtrl.getVOTableData());
64 64 }
65 65  
66   - public EpnTapMainView getView() {
  66 + public MainPanelView getView() {
67 67 return mainView;
68 68 }
69 69  
... ... @@ -78,12 +78,12 @@ public class GUIController extends EpnTapController implements ViewListener {
78 78 /** Send the specified query on selectedTableServiceURL */
79 79 @Override
80 80 public void onSendButtonClicked(String query) {
81   - GUIController.logger.info("Sending query: " + query + " on " + selectedTableServiceURL);
  81 + MainPanelController.logger.info("Sending query: " + query + " on " + selectedTableServiceURL);
82 82 try {
83 83 voTablePath = sendQuery(query, selectedTableServiceURL);
84 84 } catch (CantGetVOTableException e) {
85 85 displayError("Can not send the query.", e);
86   - GUIController.logger.log(Level.WARNING, "Can not send query.", e);
  86 + MainPanelController.logger.log(Level.WARNING, "Can not send query.", e);
87 87 }
88 88  
89 89 mainView.getResultsPanel().fillTable(resultsCtrl.getVOTableData());
... ... @@ -104,7 +104,7 @@ public class GUIController extends EpnTapController implements ViewListener {
104 104 // TODO create exception
105 105 mainView.displayError("Can not save the file.",
106 106 "Check that you can write on the specified directory.");
107   - GUIController.logger.log(Level.WARNING, "Can not save the file.", e);
  107 + MainPanelController.logger.log(Level.WARNING, "Can not save the file.", e);
108 108 }
109 109 }
110 110  
... ... @@ -113,7 +113,7 @@ public class GUIController extends EpnTapController implements ViewListener {
113 113 public void onParameterChanged(String paramName, Object paramValue) {
114 114 updateParameter(paramName, paramValue);
115 115 updateQueryArea();
116   - GUIController.logger.info("uploaded " + paramName + ": " + paramValue);
  116 + MainPanelController.logger.info("uploaded " + paramName + ": " + paramValue);
117 117 }
118 118  
119 119 /** Remove a query parameter from the parameters list. */
... ... @@ -121,7 +121,7 @@ public class GUIController extends EpnTapController implements ViewListener {
121 121 public void onParameterRemoved(String paramName) {
122 122 removeParameter(paramName);
123 123 updateQueryArea();
124   - GUIController.logger.info("removed " + paramName);
  124 + MainPanelController.logger.info("removed " + paramName);
125 125 }
126 126  
127 127 /**
... ... @@ -137,7 +137,7 @@ public class GUIController extends EpnTapController implements ViewListener {
137 137 selectedTableServiceURL = serviceURL;
138 138 selectedTableName = tableName;
139 139 updateQueryArea();
140   - GUIController.logger.info("Selected table: " + selectedTableName + " - service: "
  140 + MainPanelController.logger.info("Selected table: " + selectedTableName + " - service: "
141 141 + selectedTableServiceURL);
142 142 }
143 143 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/MainPanelView.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui;
  17 +package eu.omp.irap.vespa.epntapclient.gui.mainPanel;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.Dimension;
... ... @@ -23,28 +23,28 @@ import javax.swing.JOptionPane;
23 23 import javax.swing.JPanel;
24 24 import javax.swing.JSplitPane;
25 25  
26   -import eu.omp.irap.vespa.epntapclient.gui.panels.RequestPanel;
27   -import eu.omp.irap.vespa.epntapclient.gui.panels.ResultsPanel;
28   -import eu.omp.irap.vespa.epntapclient.gui.panels.ServicesPanel;
  26 +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelView;
  27 +import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelView;
  28 +import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelView;
29 29  
30 30 /**
31 31 * The main view of the application, which manage all the other views.
32 32 *
33 33 * @author N. Jourdane
34 34 */
35   -public class EpnTapMainView extends JPanel {
  35 +public class MainPanelView extends JPanel {
36 36  
37 37 /** The serial version UID. */
38 38 private static final long serialVersionUID = 1L;
39 39  
40 40 /** The JPanel where the VOTable results is displayed. */
41   - private ResultsPanel resultsPanel;
  41 + private ResultPanelView resultsPanel;
42 42  
43 43 /** The JPanel where the list of services is displayed. */
44   - private ServicesPanel servicesPanel;
  44 + private ServicesPanelView servicesPanel;
45 45  
46 46 /** The JPanel where the user build the query. */
47   - private RequestPanel requestPanel;
  47 + private RequestPanelView requestPanel;
48 48  
49 49  
50 50 /**
... ... @@ -54,10 +54,10 @@ public class EpnTapMainView extends JPanel {
54 54 * @param voTableResultsView The view to put in the results panel, built by ResultsController.
55 55 */
56 56  
57   - public EpnTapMainView(ViewListener viewListener) {
58   - servicesPanel = new ServicesPanel(viewListener);
59   - resultsPanel = new ResultsPanel(viewListener);
60   - requestPanel = new RequestPanel(viewListener);
  57 + public MainPanelView(ViewListener viewListener) {
  58 + servicesPanel = new ServicesPanelView(viewListener);
  59 + resultsPanel = new ResultPanelView(viewListener);
  60 + requestPanel = new RequestPanelView(viewListener);
61 61 buildMainView();
62 62 }
63 63  
... ... @@ -73,6 +73,7 @@ public class EpnTapMainView extends JPanel {
73 73  
74 74 add(mainPanel, BorderLayout.CENTER);
75 75  
  76 + revalidate();
76 77 setSizes();
77 78 }
78 79  
... ... @@ -98,21 +99,21 @@ public class EpnTapMainView extends JPanel {
98 99 /**
99 100 * @return The JPanel where the VOTable result is displayed.
100 101 */
101   - public ResultsPanel getResultsPanel() {
  102 + public ResultPanelView getResultsPanel() {
102 103 return resultsPanel;
103 104 }
104 105  
105 106 /**
106 107 * @return The JPanel containing the GUI elements to build the query.
107 108 */
108   - public RequestPanel getRequestPanel() {
  109 + public RequestPanelView getRequestPanel() {
109 110 return requestPanel;
110 111 }
111 112  
112 113 /**
113 114 * @return The JPanel where the list of services is displayed.
114 115 */
115   - public ServicesPanel getServicesPanel() {
  116 + public ServicesPanelView getServicesPanel() {
116 117 return servicesPanel;
117 118 }
118 119  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainPanel/ViewListener.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui;
  17 +package eu.omp.irap.vespa.epntapclient.gui.mainPanel;
18 18  
19 19 import java.io.File;
20 20  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/ParamField.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui;
  17 +package eu.omp.irap.vespa.epntapclient.gui.requestpanel;
18 18  
19 19 import java.awt.Color;
20 20 import java.awt.Dimension;
... ... @@ -39,6 +39,7 @@ import javax.swing.event.DocumentEvent;
39 39 import javax.swing.event.DocumentListener;
40 40  
41 41 import eu.omp.irap.vespa.epntapclient.EpnTapGet;
  42 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener;
42 43 import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
43 44  
44 45 /**
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +/*
  2 + * This file is a part of EpnTAPClient.
  3 + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
  4 + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
  5 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
  6 + *
  7 + * This program is free software: you can
  8 + * redistribute it and/or modify it under the terms of the GNU General Public License as published
  9 + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
  10 + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  11 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12 + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
  13 + * the GNU General Public License along with this program. If not, see
  14 + * <http://www.gnu.org/licenses/>.
  15 + */
  16 +
  17 +package eu.omp.irap.vespa.epntapclient.gui.requestpanel;
  18 +
  19 +import java.util.logging.Logger;
  20 +
  21 +/**
  22 + * @author N. Jourdane
  23 + */
  24 +public class RequestPanelCtrl {
  25 +
  26 + /** The logger for the class RequestPanelCtrl. */
  27 + private static final Logger logger = Logger.getLogger(RequestPanelCtrl.class.getName());
  28 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.requestpanel;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.Dimension;
... ... @@ -29,19 +29,18 @@ import javax.swing.JButton;
29 29 import javax.swing.JPanel;
30 30 import javax.swing.JTextArea;
31 31  
32   -import eu.omp.irap.vespa.epntapclient.gui.ParamField;
33   -import eu.omp.irap.vespa.epntapclient.gui.ParamField.DataProductTypeField;
34   -import eu.omp.irap.vespa.epntapclient.gui.ParamField.DateRangeField;
35   -import eu.omp.irap.vespa.epntapclient.gui.ParamField.FloatRangeField;
36   -import eu.omp.irap.vespa.epntapclient.gui.ParamField.TargetNameField;
37   -import eu.omp.irap.vespa.epntapclient.gui.ViewListener;
  32 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener;
  33 +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.ParamField.DataProductTypeField;
  34 +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.ParamField.DateRangeField;
  35 +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.ParamField.FloatRangeField;
  36 +import eu.omp.irap.vespa.epntapclient.gui.requestpanel.ParamField.TargetNameField;
38 37  
39 38 /**
40 39 * The view of the panel where the user builds the query.
41 40 *
42 41 * @author N. Jourdane
43 42 */
44   -public class RequestPanel extends JPanel {
  43 +public class RequestPanelView extends JPanel {
45 44  
46 45 /** The serial version UID. */
47 46 private static final long serialVersionUID = 1L;
... ... @@ -66,7 +65,7 @@ public class RequestPanel extends JPanel {
66 65 *
67 66 * @param mainView The EPN-TAP main view.
68 67 */
69   - public RequestPanel(ViewListener viewListener) {
  68 + public RequestPanelView(ViewListener viewListener) {
70 69 this.viewListener = viewListener;
71 70 buildRequestPanel();
72 71 }
... ... @@ -143,7 +142,7 @@ public class RequestPanel extends JPanel {
143 142 }
144 143 });
145 144 buttonPanel.add(btnSend);
146   - buttonPanel.setMaximumSize(new Dimension(1000, RequestPanel.BUTTON_PANEL_HEIGHT));
  145 + buttonPanel.setMaximumSize(new Dimension(1000, RequestPanelView.BUTTON_PANEL_HEIGHT));
147 146  
148 147 return buttonPanel;
149 148 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +/*
  2 + * This file is a part of EpnTAPClient.
  3 + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
  4 + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
  5 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
  6 + *
  7 + * This program is free software: you can
  8 + * redistribute it and/or modify it under the terms of the GNU General Public License as published
  9 + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
  10 + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  11 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12 + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
  13 + * the GNU General Public License along with this program. If not, see
  14 + * <http://www.gnu.org/licenses/>.
  15 + */
  16 +
  17 +package eu.omp.irap.vespa.epntapclient.gui.resultpanel;
  18 +
  19 +import java.util.logging.Logger;
  20 +
  21 +/**
  22 + * @author N. Jourdane
  23 + */
  24 +public class ResultPanelCtrl {
  25 +
  26 + /** The logger for the class ResultPanelCtrl. */
  27 + private static final Logger logger = Logger.getLogger(ResultPanelCtrl.class.getName());
  28 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.resultpanel;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.event.ActionEvent;
... ... @@ -25,13 +25,13 @@ import javax.swing.JFileChooser;
25 25 import javax.swing.JLabel;
26 26 import javax.swing.JPanel;
27 27  
28   -import eu.omp.irap.vespa.epntapclient.gui.ViewListener;
  28 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener;
29 29 import eu.omp.irap.vespa.votable.view.VOTableView;
30 30  
31 31 /**
32 32 * @author N. Jourdane
33 33 */
34   -public class ResultsPanel extends VOTableView {
  34 +public class ResultPanelView extends VOTableView {
35 35  
36 36 /** The serial version UID. */
37 37 private static final long serialVersionUID = 1L;
... ... @@ -51,7 +51,7 @@ public class ResultsPanel extends VOTableView {
51 51 * @param mainView The main view of the application.
52 52 * @param voTableView The generic view of the VOTable panel.
53 53 */
54   - public ResultsPanel(ViewListener viewListener) {
  54 + public ResultPanelView(ViewListener viewListener) {
55 55 super();
56 56 this.viewListener = viewListener;
57 57 buildResultPanel();
... ... @@ -89,7 +89,7 @@ public class ResultsPanel extends VOTableView {
89 89 @Override
90 90 public void actionPerformed(ActionEvent e) {
91 91 final JFileChooser fc = new JFileChooser();
92   - fc.showOpenDialog(ResultsPanel.this);
  92 + fc.showOpenDialog(ResultPanelView.this);
93 93 viewListener.onDownloadButtonClicked(fc.getSelectedFile());
94 94 }
95 95 });
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +/*
  2 + * This file is a part of EpnTAPClient.
  3 + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
  4 + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
  5 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
  6 + *
  7 + * This program is free software: you can
  8 + * redistribute it and/or modify it under the terms of the GNU General Public License as published
  9 + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
  10 + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
  11 + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12 + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
  13 + * the GNU General Public License along with this program. If not, see
  14 + * <http://www.gnu.org/licenses/>.
  15 + */
  16 +
  17 +package eu.omp.irap.vespa.epntapclient.gui.servicespanel;
  18 +
  19 +import java.util.logging.Logger;
  20 +
  21 +/**
  22 + * @author N. Jourdane
  23 + */
  24 +public class ServicesPanelCtrl {
  25 +
  26 + /** The logger for the class ServicesPanelCtrl. */
  27 + private static final Logger logger = Logger.getLogger(ServicesPanelCtrl.class.getName());
  28 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java renamed to src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.gui.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.servicespanel;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.event.ActionEvent;
... ... @@ -27,13 +27,13 @@ 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.ViewListener;
  30 +import eu.omp.irap.vespa.epntapclient.gui.mainPanel.ViewListener;
31 31 import eu.omp.irap.vespa.votable.view.VOTableView;
32 32  
33 33 /**
34 34 * @author N. Jourdane
35 35 */
36   -public class ServicesPanel extends VOTableView {
  36 +public class ServicesPanelView extends VOTableView {
37 37  
38 38 /** The serial version UID. */
39 39 private static final long serialVersionUID = 1L;
... ... @@ -54,7 +54,7 @@ public class ServicesPanel extends VOTableView {
54 54 * @param mainView The main view of the application.
55 55 * @param voTableView The generic view of the VOTable panel.
56 56 */
57   - public ServicesPanel(final ViewListener viewListener) {
  57 + public ServicesPanelView(final ViewListener viewListener) {
58 58 super();
59 59 this.viewListener = viewListener;
60 60 buildServicesPanel();
... ...