Commit 6dd0d3328afeeed02d50542f57865de3c68530e1

Authored by Nathanael Jourdane
1 parent 26c7a6bf
Exists in master

The controller do not use the View in order to use the project as a no-GUI library.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java
... ... @@ -23,7 +23,8 @@ import javax.swing.SwingUtilities;
23 23  
24 24 import com.google.gson.Gson;
25 25  
26   -import eu.omp.irap.vespa.epntapclient.controller.EpnTapController;
  26 +import eu.omp.irap.vespa.epntapclient.gui.EpnTapMainView;
  27 +import eu.omp.irap.vespa.epntapclient.gui.GUIController;
27 28  
28 29 /**
29 30 * Simple class to have a main function to launch the EPNTap client.
... ... @@ -35,6 +36,8 @@ public class EpnTapMainApp {
35 36 /** The logger for the class EpnTapMainApp. */
36 37 private static final Logger logger = Logger.getLogger(EpnTapMainApp.class.getName());
37 38  
  39 + private static final String WRONG_COMMAND = "Usage: EpnTapMainApp";
  40 +
38 41  
39 42 /** Constructor to hide the implicit public one. */
40 43 private EpnTapMainApp() {
... ... @@ -47,23 +50,28 @@ public class EpnTapMainApp {
47 50 */
48 51 public static void main(final String[] args) {
49 52 EpnTapMainApp.logger.info("Lauching EPNTAP app with arguments: " + new Gson().toJson(args));
50   - SwingUtilities.invokeLater(new Runnable() {
  53 + if (args.length != 0) {
  54 + System.console().writer().println(EpnTapMainApp.WRONG_COMMAND);
  55 + return;
  56 + }
  57 +
  58 + GUIController ctrl = new GUIController();
  59 + SwingUtilities.invokeLater(EpnTapMainApp.run(ctrl.getView(), "EPN-TAP client"));
  60 + }
  61 +
  62 + private static Runnable run(final EpnTapMainView voTableView, final String title) {
  63 + return new Runnable() {
51 64  
52 65 @Override
53 66 public void run() {
54   - EpnTapController epnTapControl = new EpnTapController();
55   - if (args.length != 0) {
56   - System.console().writer().println("Usage: EpnTapMainApp");
57   - return;
58   - }
59   -
60   - JFrame frame = new JFrame("EPN-TAP client");
  67 + JFrame frame = new JFrame(title);
61 68 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
62   - frame.setContentPane(epnTapControl.getView());
  69 + frame.setContentPane(voTableView);
63 70 frame.setVisible(true);
64   - frame.pack();
  71 + frame.setSize(800, 600);
65 72 frame.setLocationRelativeTo(null);
66 73 }
67   - });
  74 + };
68 75 }
  76 +
69 77 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java
... ... @@ -14,18 +14,12 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.controller;
  17 +package eu.omp.irap.vespa.epntapclient.epnTapLib;
18 18  
19   -import java.io.File;
20   -import java.io.IOException;
21   -import java.nio.file.Files;
22   -import java.nio.file.Paths;
23 19 import java.util.HashMap;
24 20 import java.util.Map;
25 21 import java.util.logging.Logger;
26 22  
27   -import eu.omp.irap.vespa.epntapclient.utils.Queries;
28   -import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView;
29 23 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController;
30 24 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException;
31 25 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
... ... @@ -36,129 +30,70 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Const;
36 30 *
37 31 * @author N. Jourdane
38 32 */
39   -public class EpnTapController implements ViewListener {
  33 +public class EpnTapController {
40 34  
41 35 /** The logger for the class EpnTapController. */
42   - private Logger logger = Logger.getLogger(EpnTapController.class.getName());
43   -
44   - /** The view of EPN-TAP application. */
45   - private EpnTapMainView mainView;
  36 + private static final Logger logger = Logger.getLogger(EpnTapController.class.getName());
46 37  
47 38 /** The controller of the VOTable displaying the list of services. */
48   - private VOTableController servicesController;
49   -
50   - /** The controller of the VOTable displaying the query results. */
51   - private VOTableController resultsController;
52   -
53   - /** The name of the table selected by the user on the table list panel. */
54   - private String selectedTableName;
  39 + protected VOTableController servicesCtrl;
55 40  
56   - /** The URL of the service corresponding to the selected table. */
57   - private String selectedTableServiceURL;
58   -
59   - private String voTablePath;
  41 + /** The controller of the VOTable displaying the list of services. */
  42 + protected VOTableController resultsCtrl;
60 43  
61 44 /**
62 45 * The parameters fields for the request.
63 46 */
64   - private Map<String, Object> paramValues = new HashMap<>();
  47 + protected Map<String, Object> paramValues = new HashMap<>();
65 48  
66 49  
67 50 /**
68 51 * Method constructor, which initialize servicesController, resultsController and mainView.
69 52 */
70 53 public EpnTapController() {
71   - servicesController = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL",
  54 + servicesCtrl = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL",
72 55 Queries.GET_EPN_TAP_SERVICES);
73   - resultsController = new VOTableController();
74   -
75   - mainView = new EpnTapMainView(this, servicesController.getView(),
76   - resultsController.getView());
77   - // updateSelected(0);
  56 + try {
  57 + servicesCtrl.readTable();
  58 + } catch (CantDisplayVOTableException e) {
  59 + // TODO Auto-generated catch block
  60 + e.printStackTrace();
  61 + } catch (CantSendQueryException e) {
  62 + // TODO Auto-generated catch block
  63 + e.printStackTrace();
  64 + }
78 65 }
79 66  
80   - /**
81   - * @return the EPN-TAP main view.
82   - */
83   - public EpnTapMainView getView() {
84   - return mainView;
  67 + public String sendQuery(String query, String tableServiceURL)
  68 + throws CantDisplayVOTableException, CantSendQueryException {
  69 + resultsCtrl = new VOTableController(tableServiceURL, "ADQL", query);
  70 + resultsCtrl.readTable();
  71 + return resultsCtrl.getVOTablePath();
85 72 }
86 73  
87 74 /**
88 75 * @return The controller of the VOTable which displays the result of the query.
89 76 */
90 77 public VOTableController getResultsController() {
91   - return resultsController;
  78 + return resultsCtrl;
92 79 }
93 80  
94 81 /**
95 82 * @return The controller of the VOTable which displays the list of services.
96 83 */
97 84 public VOTableController getServicesController() {
98   - return servicesController;
99   - }
100   -
101   - /**
102   - * Update the query area with a working ADQL query, based on the parameters list.
103   - */
104   - private void updateQueryArea() {
105   - String query = Queries.getQuery(selectedTableName, paramValues, 10);
106   - mainView.getRequestPanel().updateQueryArea(query);
  85 + return servicesCtrl;
107 86 }
108 87  
109   - /** Update the row selected by the user on the Services Panel. */
110   - @Override
111   - public void onServiceSelected(int selectedServiceRow) {
112   - String serviceURL = mainView.getServicesPanel().getServiceURL(selectedServiceRow);
113   - String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow);
114   - if (!tableName.equals(selectedTableName)) {
115   - selectedTableServiceURL = serviceURL;
116   - selectedTableName = tableName;
117   - updateQueryArea();
118   - logger.info("Selected table: " + selectedTableName + " - service: "
119   - + selectedTableServiceURL);
120   - }
121   - }
122   -
123   - /** Send the specified query on selectedTableServiceURL */
124   - @Override
125   - public void onSendButtonClicked(String query) {
126   - logger.info("Sending query: " + query + " on " + selectedTableServiceURL);
127   - try {
128   - voTablePath = resultsController.fillTable(selectedTableServiceURL, "ADQL", query);
129   - } catch (CantDisplayVOTableException e) {
130   - // TODO Create exception
131   - e.printStackTrace();
132   - } catch (CantSendQueryException e) {
133   - // TODO Create exception
134   - e.printStackTrace();
135   - }
136   - }
137   -
138   - /** Copy the VOTable to a specified location. */
139   - @Override
140   - public void onDownloadButtonClicked(File outputFile) {
141   - try {
142   - Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath()));
143   - } catch (IOException e) {
144   - // TODO Create exception
145   - e.printStackTrace();
146   - }
147   - }
148   -
149   - /** Update a query parameter in the parameter list. */
150   - @Override
151   - public void onParameterChanged(String paramName, Object paramValue) {
  88 + public void updateParameter(String paramName, Object paramValue) {
152 89 paramValues.put(paramName, paramValue);
153   - updateQueryArea();
154   - logger.info("uploaded " + paramName + ": " + paramValue);
155 90 }
156 91  
157   - /** Remove a query parameter from the parameters list. */
158   - @Override
159   - public void onParameterRemoved(String paramName) {
  92 + public void removeParameter(String paramName) {
160 93 paramValues.remove(paramName);
161   - updateQueryArea();
162   - logger.info("removed " + paramName);
  94 + }
  95 +
  96 + public Map<String, Object> getParamValues() {
  97 + return paramValues;
163 98 }
164 99 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.utils;
  17 +package eu.omp.irap.vespa.epntapclient.epnTapLib;
18 18  
19 19 import java.util.ArrayList;
20 20 import java.util.List;
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java
... ... @@ -14,20 +14,19 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view;
  17 +package eu.omp.irap.vespa.epntapclient.gui;
18 18  
19 19 import java.awt.BorderLayout;
  20 +import java.awt.Dimension;
20 21  
21 22 import javax.swing.JOptionPane;
22 23 import javax.swing.JPanel;
23 24 import javax.swing.JSplitPane;
24 25  
25   -import eu.omp.irap.vespa.epntapclient.controller.ViewListener;
26   -import eu.omp.irap.vespa.epntapclient.view.panels.BottomBarPanel;
27   -import eu.omp.irap.vespa.epntapclient.view.panels.RequestPanel;
28   -import eu.omp.irap.vespa.epntapclient.view.panels.ResultsPanel;
29   -import eu.omp.irap.vespa.epntapclient.view.panels.ServicesPanel;
30   -import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
  26 +import eu.omp.irap.vespa.epntapclient.gui.panels.BottomBarPanel;
  27 +import eu.omp.irap.vespa.epntapclient.gui.panels.RequestPanel;
  28 +import eu.omp.irap.vespa.epntapclient.gui.panels.ResultsPanel;
  29 +import eu.omp.irap.vespa.epntapclient.gui.panels.ServicesPanel;
31 30  
32 31 /**
33 32 * The main view of the application, which manage all the other views.
... ... @@ -59,16 +58,53 @@ public class EpnTapMainView extends JPanel {
59 58 * @param voTableResultsView The view to put in the results panel, built by ResultsController.
60 59 */
61 60  
62   - public EpnTapMainView(ViewListener viewListener, VOTableView voTableServicesView,
63   - VOTableView voTableResultsView) {
64   - servicesPanel = new ServicesPanel(viewListener, voTableServicesView);
65   - resultsPanel = new ResultsPanel(viewListener, voTableResultsView);
  61 + public EpnTapMainView(ViewListener viewListener) {
  62 + servicesPanel = new ServicesPanel(viewListener);
  63 + resultsPanel = new ResultsPanel(viewListener);
66 64 requestPanel = new RequestPanel(viewListener);
67 65 bottomBarPanel = new BottomBarPanel(viewListener);
68 66 buildMainView();
69 67 }
70 68  
71 69 /**
  70 + * Build and fill the GUI.
  71 + */
  72 + private void buildMainView() {
  73 + setLayout(new BorderLayout());
  74 +
  75 + JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
  76 + requestPanel);
  77 + JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
  78 +
  79 + add(mainPanel, BorderLayout.CENTER);
  80 + add(bottomBarPanel, BorderLayout.SOUTH);
  81 +
  82 + setSizes();
  83 + }
  84 +
  85 + private void setSizes() {
  86 +
  87 + servicesPanel
  88 + .setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
  89 + servicesPanel.setMinimumSize(
  90 + new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
  91 + resultsPanel
  92 + .setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH,
  93 + GUIDim.BOTTOM_PANEL_HEIGHT));
  94 + resultsPanel.setMinimumSize(
  95 + new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
  96 + GUIDim.BOTTOM_PANEL_MIN_HEIGHT));
  97 +
  98 + requestPanel
  99 + .setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
  100 + requestPanel.setMinimumSize(
  101 + new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
  102 +
  103 + // bottomBarPanel.setPreferredSize
  104 + // bottomBarPanel.setMinimumSize
  105 + }
  106 +
  107 + /**
72 108 * @return The JPanel where the VOTable result is displayed.
73 109 */
74 110 public ResultsPanel getResultsPanel() {
... ... @@ -97,20 +133,6 @@ public class EpnTapMainView extends JPanel {
97 133 }
98 134  
99 135 /**
100   - * Build and fill the GUI.
101   - */
102   - private void buildMainView() {
103   - setLayout(new BorderLayout());
104   -
105   - JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel,
106   - requestPanel);
107   - JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel);
108   -
109   - add(mainPanel, BorderLayout.CENTER);
110   - add(bottomBarPanel, BorderLayout.SOUTH);
111   - }
112   -
113   - /**
114 136 * Display an error message. Usually used each time an error happens.
115 137 *
116 138 * @param title The title of the error.
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java 0 โ†’ 100644
... ... @@ -0,0 +1,127 @@
  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;
  18 +
  19 +import java.io.File;
  20 +import java.io.IOException;
  21 +import java.nio.file.Files;
  22 +import java.nio.file.Paths;
  23 +import java.util.logging.Level;
  24 +import java.util.logging.Logger;
  25 +
  26 +import eu.omp.irap.vespa.epntapclient.epnTapLib.EpnTapController;
  27 +import eu.omp.irap.vespa.epntapclient.epnTapLib.Queries;
  28 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException;
  29 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
  30 +
  31 +/**
  32 + * @author N. Jourdane
  33 + */
  34 +public class GUIController extends EpnTapController implements ViewListener {
  35 +
  36 + /** The logger for the class GUIController. */
  37 + private static final Logger logger = Logger.getLogger(GUIController.class.getName());
  38 +
  39 + private EpnTapMainView mainView;
  40 +
  41 + private String voTablePath;
  42 +
  43 + /** The name of the table selected by the user on the table list panel. */
  44 + private String selectedTableName;
  45 +
  46 + /** The URL of the service corresponding to the selected table. */
  47 + private String selectedTableServiceURL;
  48 +
  49 +
  50 + public GUIController() {
  51 + super();
  52 + mainView = new EpnTapMainView(this);
  53 + mainView.getServicesPanel().fillTable(servicesCtrl.getColumns(), servicesCtrl.getData());
  54 + }
  55 +
  56 + public EpnTapMainView getView() {
  57 + return mainView;
  58 + }
  59 +
  60 + /** Update the row selected by the user on the Services Panel. */
  61 + @Override
  62 + public void onServiceSelected(int selectedServiceRow) {
  63 + mainView.getServicesPanel().getServiceURL(selectedServiceRow);
  64 + mainView.getServicesPanel().getTableName(selectedServiceRow);
  65 + }
  66 +
  67 + /** Send the specified query on selectedTableServiceURL */
  68 + @Override
  69 + public void onSendButtonClicked(String query) {
  70 + GUIController.logger.info("Sending query: " + query + " on " + selectedTableServiceURL);
  71 + try {
  72 + voTablePath = sendQuery(query, selectedTableServiceURL);
  73 + } catch (CantDisplayVOTableException | CantSendQueryException e) {
  74 + // TODO create exception
  75 + mainView.displayError("Can not send query.", e.getMessage());
  76 + GUIController.logger.log(Level.WARNING, "Can not send query.", e);
  77 + }
  78 + }
  79 +
  80 + /** Copy the VOTable to a specified location. */
  81 + @Override
  82 + public void onDownloadButtonClicked(File outputFile) {
  83 + try {
  84 + Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath()));
  85 + } catch (IOException e) {
  86 + // TODO create exception
  87 + mainView.displayError("Can not save the file.",
  88 + "Check that you can write on the specified directory.");
  89 + GUIController.logger.log(Level.WARNING, "Can not save the file.", e);
  90 + }
  91 + }
  92 +
  93 + /** Update a query parameter in the parameter list. */
  94 + @Override
  95 + public void onParameterChanged(String paramName, Object paramValue) {
  96 + updateParameter(paramName, paramName);
  97 + updateQueryArea();
  98 + GUIController.logger.info("uploaded " + paramName + ": " + paramValue);
  99 + }
  100 +
  101 + /** Remove a query parameter from the parameters list. */
  102 + @Override
  103 + public void onParameterRemoved(String paramName) {
  104 + removeParameter(paramName);
  105 + updateQueryArea();
  106 + GUIController.logger.info("removed " + paramName);
  107 + }
  108 +
  109 + /**
  110 + * Update the query area with a working ADQL query, based on the parameters list.
  111 + */
  112 + private void updateQueryArea() {
  113 + String query = Queries.getQuery(selectedTableName, paramValues, 10);
  114 + mainView.getRequestPanel().updateQueryArea(query);
  115 + }
  116 +
  117 + public void updateService(String serviceURL, String tableName) {
  118 + if (!tableName.equals(selectedTableName)) {
  119 + selectedTableServiceURL = serviceURL;
  120 + selectedTableName = tableName;
  121 + updateQueryArea();
  122 + GUIController.logger.info("Selected table: " + selectedTableName + " - service: "
  123 + + selectedTableServiceURL);
  124 + }
  125 + }
  126 +
  127 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view;
  17 +package eu.omp.irap.vespa.epntapclient.gui;
18 18  
19 19 /**
20 20 * A simple class containing GUI panel and elements dimensions.
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view;
  17 +package eu.omp.irap.vespa.epntapclient.gui;
18 18  
19 19 import java.awt.Color;
20 20 import java.awt.Dimension;
... ... @@ -42,7 +42,6 @@ import com.google.gson.JsonArray;
42 42 import com.google.gson.JsonObject;
43 43 import com.google.gson.JsonParser;
44 44  
45   -import eu.omp.irap.vespa.epntapclient.controller.ViewListener;
46 45 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableConnection;
47 46 import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
48 47  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.controller;
  17 +package eu.omp.irap.vespa.epntapclient.gui;
18 18  
19 19 import java.io.File;
20 20  
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.panels;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.event.ActionEvent;
... ... @@ -25,7 +25,7 @@ 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.controller.ViewListener;
  28 +import eu.omp.irap.vespa.epntapclient.gui.ViewListener;
29 29  
30 30 /**
31 31 * @author N. Jourdane
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java
... ... @@ -14,7 +14,7 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.panels;
18 18  
19 19 import java.awt.BorderLayout;
20 20 import java.awt.Dimension;
... ... @@ -29,13 +29,12 @@ 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.controller.ViewListener;
33   -import eu.omp.irap.vespa.epntapclient.view.GUIDim;
34   -import eu.omp.irap.vespa.epntapclient.view.ParamField;
35   -import eu.omp.irap.vespa.epntapclient.view.ParamField.DataProductTypeField;
36   -import eu.omp.irap.vespa.epntapclient.view.ParamField.DateRangeField;
37   -import eu.omp.irap.vespa.epntapclient.view.ParamField.FloatRangeField;
38   -import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField;
  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;
39 38  
40 39 /**
41 40 * The view of the panel where the user builds the query.
... ... @@ -75,9 +74,6 @@ public class RequestPanel extends JPanel {
75 74 private void buildRequestPanel() {
76 75 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
77 76  
78   - setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
79   - setMinimumSize(new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
80   -
81 77 this.add(buildParamPanel(), this);
82 78 this.add(buildQueryPanel(), this);
83 79 this.add(buildButtonPanel(), this);
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java
... ... @@ -14,21 +14,17 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.panels;
18 18  
19 19 import java.awt.BorderLayout;
20   -import java.awt.Dimension;
21 20  
22   -import javax.swing.JPanel;
23   -
24   -import eu.omp.irap.vespa.epntapclient.controller.ViewListener;
25   -import eu.omp.irap.vespa.epntapclient.view.GUIDim;
  21 +import eu.omp.irap.vespa.epntapclient.gui.ViewListener;
26 22 import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
27 23  
28 24 /**
29 25 * @author N. Jourdane
30 26 */
31   -public class ResultsPanel extends JPanel {
  27 +public class ResultsPanel extends VOTableView {
32 28  
33 29 /** The serial version UID. */
34 30 private static final long serialVersionUID = 1L;
... ... @@ -43,21 +39,14 @@ public class ResultsPanel extends JPanel {
43 39 * @param mainView The main view of the application.
44 40 * @param voTableView The generic view of the VOTable panel.
45 41 */
46   - public ResultsPanel(ViewListener viewListener, VOTableView voTableView) {
  42 + public ResultsPanel(ViewListener viewListener) {
47 43 super();
48 44 this.viewListener = viewListener;
49 45  
50   - buildResultPanel(voTableView);
  46 + buildResultPanel();
51 47 }
52 48  
53   - private void buildResultPanel(VOTableView voTableView) {
  49 + private void buildResultPanel() {
54 50 setLayout(new BorderLayout());
55   -
56   - setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH,
57   - GUIDim.BOTTOM_PANEL_HEIGHT));
58   - setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH,
59   - GUIDim.BOTTOM_PANEL_MIN_HEIGHT));
60   -
61   - this.add(voTableView);
62 51 }
63 52 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java
... ... @@ -14,10 +14,9 @@
14 14 * <http://www.gnu.org/licenses/>.
15 15 */
16 16  
17   -package eu.omp.irap.vespa.epntapclient.view.panels;
  17 +package eu.omp.irap.vespa.epntapclient.gui.panels;
18 18  
19 19 import java.awt.BorderLayout;
20   -import java.awt.Dimension;
21 20 import java.awt.event.ActionEvent;
22 21 import java.awt.event.ActionListener;
23 22  
... ... @@ -28,21 +27,17 @@ import javax.swing.JTextField;
28 27 import javax.swing.event.ListSelectionEvent;
29 28 import javax.swing.event.ListSelectionListener;
30 29  
31   -import eu.omp.irap.vespa.epntapclient.controller.ViewListener;
32   -import eu.omp.irap.vespa.epntapclient.view.GUIDim;
  30 +import eu.omp.irap.vespa.epntapclient.gui.ViewListener;
33 31 import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
34 32  
35 33 /**
36 34 * @author N. Jourdane
37 35 */
38   -public class ServicesPanel extends JPanel {
  36 +public class ServicesPanel extends VOTableView {
39 37  
40 38 /** The serial version UID. */
41 39 private static final long serialVersionUID = 1L;
42 40  
43   - /** The generic view of the VOTable panel. */
44   - private VOTableView voTableView;
45   -
46 41 private ViewListener viewListener;
47 42  
48 43 private JButton serviceButton;
... ... @@ -59,31 +54,22 @@ public class ServicesPanel extends JPanel {
59 54 * @param mainView The main view of the application.
60 55 * @param voTableView The generic view of the VOTable panel.
61 56 */
62   - public ServicesPanel(final ViewListener viewListener, final VOTableView voTableView) {
  57 + public ServicesPanel(final ViewListener viewListener) {
63 58 super();
64 59 this.viewListener = viewListener;
65   - this.voTableView = voTableView;
66   -
67   - buildServicesPanel(voTableView);
  60 + buildServicesPanel();
68 61 }
69 62  
70   - private void buildServicesPanel(final VOTableView voTableView) {
71   - setLayout(new BorderLayout());
72   -
73   - setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT));
74   - setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT));
75   -
76   - voTableView.getTable().getSelectionModel()
77   - .addListSelectionListener(new ListSelectionListener() {
  63 + private void buildServicesPanel() {
  64 + getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() {
78 65  
79   - @Override
80   - public void valueChanged(ListSelectionEvent evt) {
81   - viewListener.onServiceSelected(voTableView.getTable().getSelectedRow());
82   - }
83   - });
  66 + @Override
  67 + public void valueChanged(ListSelectionEvent evt) {
  68 + viewListener.onServiceSelected(getTable().getSelectedRow());
  69 + }
  70 + });
84 71  
85   - this.add(buildAddServicePanel(), BorderLayout.CENTER);
86   - this.add(voTableView, BorderLayout.NORTH);
  72 + this.add(buildAddServicePanel(), BorderLayout.SOUTH);
87 73 }
88 74  
89 75 private JPanel buildAddServicePanel() {
... ... @@ -145,7 +131,7 @@ public class ServicesPanel extends JPanel {
145 131 if (row == -1) {
146 132 return serviceUrlTextField.getText();
147 133 }
148   - return (String) voTableView.getValueAt(5, row);
  134 + return (String) getValueAt(5, row);
149 135 }
150 136  
151 137 /**
... ... @@ -156,6 +142,6 @@ public class ServicesPanel extends JPanel {
156 142 if (row == -1) {
157 143 return tableNameTextField.getText();
158 144 }
159   - return (String) voTableView.getValueAt(2, row);
  145 + return (String) getValueAt(2, row);
160 146 }
161 147 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java
... ... @@ -69,6 +69,7 @@ public class VOTableView extends JPanel implements TableModelListener {
69 69  
70 70 private void buildVOTableView() {
71 71 JScrollPane scrollPane = new JScrollPane(table);
  72 +
72 73 scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
73 74 scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
74 75  
... ... @@ -83,7 +84,9 @@ public class VOTableView extends JPanel implements TableModelListener {
83 84 * @param data The VoTable data displayed on the JTable
84 85 */
85 86 public void fillTable(String[] columns, List<Object[]> data) {
  87 + System.out.println(columns + "\n" + data);
86 88 Object[][] values = data.toArray(new Object[data.size()][]);
  89 + Utils.printObject("tableColumns", columns);
87 90 Utils.printObject("tableData", values);
88 91 tableData.setDataVector(values, columns);
89 92 if (values.length != 0) {
... ...