From 6dd0d3328afeeed02d50542f57865de3c68530e1 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Mon, 18 Apr 2016 11:21:23 +0200 Subject: [PATCH] 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 | 32 ++++++++++++++++++++------------ src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java | 125 ++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java | 72 +++++++++++++++++++++++++++++++++++++++++++++++------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java | 3 +-- src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java | 18 +++++++----------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java | 23 ++++++----------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java | 44 +++++++++++++++----------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java | 3 +++ 13 files changed, 261 insertions(+), 196 deletions(-) create mode 100644 src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java 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 3366a8d..abc5a7f 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java @@ -23,7 +23,8 @@ import javax.swing.SwingUtilities; import com.google.gson.Gson; -import eu.omp.irap.vespa.epntapclient.controller.EpnTapController; +import eu.omp.irap.vespa.epntapclient.gui.EpnTapMainView; +import eu.omp.irap.vespa.epntapclient.gui.GUIController; /** * Simple class to have a main function to launch the EPNTap client. @@ -35,6 +36,8 @@ public class EpnTapMainApp { /** The logger for the class EpnTapMainApp. */ private static final Logger logger = Logger.getLogger(EpnTapMainApp.class.getName()); + private static final String WRONG_COMMAND = "Usage: EpnTapMainApp"; + /** Constructor to hide the implicit public one. */ private EpnTapMainApp() { @@ -47,23 +50,28 @@ public class EpnTapMainApp { */ public static void main(final String[] args) { EpnTapMainApp.logger.info("Lauching EPNTAP app with arguments: " + new Gson().toJson(args)); - SwingUtilities.invokeLater(new Runnable() { + if (args.length != 0) { + System.console().writer().println(EpnTapMainApp.WRONG_COMMAND); + return; + } + + GUIController ctrl = new GUIController(); + SwingUtilities.invokeLater(EpnTapMainApp.run(ctrl.getView(), "EPN-TAP client")); + } + + private static Runnable run(final EpnTapMainView voTableView, final String title) { + return new Runnable() { @Override public void run() { - EpnTapController epnTapControl = new EpnTapController(); - if (args.length != 0) { - System.console().writer().println("Usage: EpnTapMainApp"); - return; - } - - JFrame frame = new JFrame("EPN-TAP client"); + JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setContentPane(epnTapControl.getView()); + frame.setContentPane(voTableView); frame.setVisible(true); - frame.pack(); + frame.setSize(800, 600); frame.setLocationRelativeTo(null); } - }); + }; } + } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java index 20bf744..8b342bb 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/EpnTapController.java @@ -14,18 +14,12 @@ * . */ -package eu.omp.irap.vespa.epntapclient.controller; +package eu.omp.irap.vespa.epntapclient.epnTapLib; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.logging.Logger; -import eu.omp.irap.vespa.epntapclient.utils.Queries; -import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; @@ -36,129 +30,70 @@ import eu.omp.irap.vespa.epntapclient.votable.utils.Const; * * @author N. Jourdane */ -public class EpnTapController implements ViewListener { +public class EpnTapController { /** The logger for the class EpnTapController. */ - private Logger logger = Logger.getLogger(EpnTapController.class.getName()); - - /** The view of EPN-TAP application. */ - private EpnTapMainView mainView; + private static final Logger logger = Logger.getLogger(EpnTapController.class.getName()); /** The controller of the VOTable displaying the list of services. */ - private VOTableController servicesController; - - /** The controller of the VOTable displaying the query results. */ - private VOTableController resultsController; - - /** The name of the table selected by the user on the table list panel. */ - private String selectedTableName; + protected VOTableController servicesCtrl; - /** The URL of the service corresponding to the selected table. */ - private String selectedTableServiceURL; - - private String voTablePath; + /** The controller of the VOTable displaying the list of services. */ + protected VOTableController resultsCtrl; /** * The parameters fields for the request. */ - private Map paramValues = new HashMap<>(); + protected Map paramValues = new HashMap<>(); /** * Method constructor, which initialize servicesController, resultsController and mainView. */ public EpnTapController() { - servicesController = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL", + servicesCtrl = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL", Queries.GET_EPN_TAP_SERVICES); - resultsController = new VOTableController(); - - mainView = new EpnTapMainView(this, servicesController.getView(), - resultsController.getView()); - // updateSelected(0); + try { + servicesCtrl.readTable(); + } catch (CantDisplayVOTableException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CantSendQueryException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } - /** - * @return the EPN-TAP main view. - */ - public EpnTapMainView getView() { - return mainView; + public String sendQuery(String query, String tableServiceURL) + throws CantDisplayVOTableException, CantSendQueryException { + resultsCtrl = new VOTableController(tableServiceURL, "ADQL", query); + resultsCtrl.readTable(); + return resultsCtrl.getVOTablePath(); } /** * @return The controller of the VOTable which displays the result of the query. */ public VOTableController getResultsController() { - return resultsController; + return resultsCtrl; } /** * @return The controller of the VOTable which displays the list of services. */ public VOTableController getServicesController() { - return servicesController; - } - - /** - * Update the query area with a working ADQL query, based on the parameters list. - */ - private void updateQueryArea() { - String query = Queries.getQuery(selectedTableName, paramValues, 10); - mainView.getRequestPanel().updateQueryArea(query); + return servicesCtrl; } - /** Update the row selected by the user on the Services Panel. */ - @Override - public void onServiceSelected(int selectedServiceRow) { - String serviceURL = mainView.getServicesPanel().getServiceURL(selectedServiceRow); - String tableName = mainView.getServicesPanel().getTableName(selectedServiceRow); - if (!tableName.equals(selectedTableName)) { - selectedTableServiceURL = serviceURL; - selectedTableName = tableName; - updateQueryArea(); - logger.info("Selected table: " + selectedTableName + " - service: " - + selectedTableServiceURL); - } - } - - /** Send the specified query on selectedTableServiceURL */ - @Override - public void onSendButtonClicked(String query) { - logger.info("Sending query: " + query + " on " + selectedTableServiceURL); - try { - voTablePath = resultsController.fillTable(selectedTableServiceURL, "ADQL", query); - } catch (CantDisplayVOTableException e) { - // TODO Create exception - e.printStackTrace(); - } catch (CantSendQueryException e) { - // TODO Create exception - e.printStackTrace(); - } - } - - /** Copy the VOTable to a specified location. */ - @Override - public void onDownloadButtonClicked(File outputFile) { - try { - Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath())); - } catch (IOException e) { - // TODO Create exception - e.printStackTrace(); - } - } - - /** Update a query parameter in the parameter list. */ - @Override - public void onParameterChanged(String paramName, Object paramValue) { + public void updateParameter(String paramName, Object paramValue) { paramValues.put(paramName, paramValue); - updateQueryArea(); - logger.info("uploaded " + paramName + ": " + paramValue); } - /** Remove a query parameter from the parameters list. */ - @Override - public void onParameterRemoved(String paramName) { + public void removeParameter(String paramName) { paramValues.remove(paramName); - updateQueryArea(); - logger.info("removed " + paramName); + } + + public Map getParamValues() { + return paramValues; } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java index d5680a7..14994b3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/epnTapLib/Queries.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.utils; +package eu.omp.irap.vespa.epntapclient.epnTapLib; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java index 8719b8e..d44c818 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/EpnTapMainView.java @@ -14,20 +14,19 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view; +package eu.omp.irap.vespa.epntapclient.gui; import java.awt.BorderLayout; +import java.awt.Dimension; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; -import eu.omp.irap.vespa.epntapclient.view.panels.BottomBarPanel; -import eu.omp.irap.vespa.epntapclient.view.panels.RequestPanel; -import eu.omp.irap.vespa.epntapclient.view.panels.ResultsPanel; -import eu.omp.irap.vespa.epntapclient.view.panels.ServicesPanel; -import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; +import eu.omp.irap.vespa.epntapclient.gui.panels.BottomBarPanel; +import eu.omp.irap.vespa.epntapclient.gui.panels.RequestPanel; +import eu.omp.irap.vespa.epntapclient.gui.panels.ResultsPanel; +import eu.omp.irap.vespa.epntapclient.gui.panels.ServicesPanel; /** * The main view of the application, which manage all the other views. @@ -59,16 +58,53 @@ public class EpnTapMainView extends JPanel { * @param voTableResultsView The view to put in the results panel, built by ResultsController. */ - public EpnTapMainView(ViewListener viewListener, VOTableView voTableServicesView, - VOTableView voTableResultsView) { - servicesPanel = new ServicesPanel(viewListener, voTableServicesView); - resultsPanel = new ResultsPanel(viewListener, voTableResultsView); + public EpnTapMainView(ViewListener viewListener) { + servicesPanel = new ServicesPanel(viewListener); + resultsPanel = new ResultsPanel(viewListener); requestPanel = new RequestPanel(viewListener); bottomBarPanel = new BottomBarPanel(viewListener); buildMainView(); } /** + * Build and fill the GUI. + */ + private void buildMainView() { + setLayout(new BorderLayout()); + + JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel, + requestPanel); + JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel); + + add(mainPanel, BorderLayout.CENTER); + add(bottomBarPanel, BorderLayout.SOUTH); + + setSizes(); + } + + private void setSizes() { + + servicesPanel + .setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); + servicesPanel.setMinimumSize( + new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); + resultsPanel + .setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH, + GUIDim.BOTTOM_PANEL_HEIGHT)); + resultsPanel.setMinimumSize( + new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH, + GUIDim.BOTTOM_PANEL_MIN_HEIGHT)); + + requestPanel + .setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); + requestPanel.setMinimumSize( + new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); + + // bottomBarPanel.setPreferredSize + // bottomBarPanel.setMinimumSize + } + + /** * @return The JPanel where the VOTable result is displayed. */ public ResultsPanel getResultsPanel() { @@ -97,20 +133,6 @@ public class EpnTapMainView extends JPanel { } /** - * Build and fill the GUI. - */ - private void buildMainView() { - setLayout(new BorderLayout()); - - JSplitPane northPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, servicesPanel, - requestPanel); - JSplitPane mainPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, northPanel, resultsPanel); - - add(mainPanel, BorderLayout.CENTER); - add(bottomBarPanel, BorderLayout.SOUTH); - } - - /** * Display an error message. Usually used each time an error happens. * * @param title The title of the error. 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 new file mode 100644 index 0000000..35b1d1e --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIController.java @@ -0,0 +1,127 @@ +/* + * This file is a part of EpnTAPClient. + * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. + * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 + * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. + * + * This program is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, or (at your option) any later + * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. You should have received a copy of + * the GNU General Public License along with this program. If not, see + * . + */ + +package eu.omp.irap.vespa.epntapclient.gui; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.logging.Level; +import java.util.logging.Logger; + +import eu.omp.irap.vespa.epntapclient.epnTapLib.EpnTapController; +import eu.omp.irap.vespa.epntapclient.epnTapLib.Queries; +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException; +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; + +/** + * @author N. Jourdane + */ +public class GUIController extends EpnTapController implements ViewListener { + + /** The logger for the class GUIController. */ + private static final Logger logger = Logger.getLogger(GUIController.class.getName()); + + private EpnTapMainView mainView; + + private String voTablePath; + + /** The name of the table selected by the user on the table list panel. */ + private String selectedTableName; + + /** The URL of the service corresponding to the selected table. */ + private String selectedTableServiceURL; + + + public GUIController() { + super(); + mainView = new EpnTapMainView(this); + mainView.getServicesPanel().fillTable(servicesCtrl.getColumns(), servicesCtrl.getData()); + } + + public EpnTapMainView getView() { + return mainView; + } + + /** 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); + } + + /** Send the specified query on selectedTableServiceURL */ + @Override + public void onSendButtonClicked(String query) { + GUIController.logger.info("Sending query: " + query + " on " + selectedTableServiceURL); + try { + voTablePath = sendQuery(query, selectedTableServiceURL); + } catch (CantDisplayVOTableException | CantSendQueryException e) { + // TODO create exception + mainView.displayError("Can not send query.", e.getMessage()); + GUIController.logger.log(Level.WARNING, "Can not send query.", e); + } + } + + /** Copy the VOTable to a specified location. */ + @Override + public void onDownloadButtonClicked(File outputFile) { + try { + Files.copy(Paths.get(voTablePath), Paths.get(outputFile.getAbsolutePath())); + } catch (IOException e) { + // TODO create exception + mainView.displayError("Can not save the file.", + "Check that you can write on the specified directory."); + GUIController.logger.log(Level.WARNING, "Can not save the file.", e); + } + } + + /** Update a query parameter in the parameter list. */ + @Override + public void onParameterChanged(String paramName, Object paramValue) { + updateParameter(paramName, paramName); + updateQueryArea(); + GUIController.logger.info("uploaded " + paramName + ": " + paramValue); + } + + /** Remove a query parameter from the parameters list. */ + @Override + public void onParameterRemoved(String paramName) { + removeParameter(paramName); + updateQueryArea(); + GUIController.logger.info("removed " + paramName); + } + + /** + * Update the query area with a working ADQL query, based on the parameters list. + */ + private void updateQueryArea() { + String query = Queries.getQuery(selectedTableName, paramValues, 10); + mainView.getRequestPanel().updateQueryArea(query); + } + + public void updateService(String serviceURL, String tableName) { + if (!tableName.equals(selectedTableName)) { + selectedTableServiceURL = serviceURL; + selectedTableName = tableName; + updateQueryArea(); + GUIController.logger.info("Selected table: " + selectedTableName + " - service: " + + selectedTableServiceURL); + } + } + +} diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java index 32dbe93..f95ad42 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/GUIDim.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view; +package eu.omp.irap.vespa.epntapclient.gui; /** * A simple class containing GUI panel and elements dimensions. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java index 7fdc807..1d95e53 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ParamField.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view; +package eu.omp.irap.vespa.epntapclient.gui; import java.awt.Color; import java.awt.Dimension; @@ -42,7 +42,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableConnection; import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java index 912c46e..c4775c8 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/ViewListener.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.controller; +package eu.omp.irap.vespa.epntapclient.gui; import java.io.File; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java index 3eda154..3971b90 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/BottomBarPanel.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view.panels; +package eu.omp.irap.vespa.epntapclient.gui.panels; import java.awt.BorderLayout; import java.awt.event.ActionEvent; @@ -25,7 +25,7 @@ import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JPanel; -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; +import eu.omp.irap.vespa.epntapclient.gui.ViewListener; /** * @author N. Jourdane diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java index cd53a16..73ccbc6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/RequestPanel.java @@ -14,7 +14,7 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view.panels; +package eu.omp.irap.vespa.epntapclient.gui.panels; import java.awt.BorderLayout; import java.awt.Dimension; @@ -29,13 +29,12 @@ import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JTextArea; -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; -import eu.omp.irap.vespa.epntapclient.view.GUIDim; -import eu.omp.irap.vespa.epntapclient.view.ParamField; -import eu.omp.irap.vespa.epntapclient.view.ParamField.DataProductTypeField; -import eu.omp.irap.vespa.epntapclient.view.ParamField.DateRangeField; -import eu.omp.irap.vespa.epntapclient.view.ParamField.FloatRangeField; -import eu.omp.irap.vespa.epntapclient.view.ParamField.TargetNameField; +import eu.omp.irap.vespa.epntapclient.gui.ParamField; +import eu.omp.irap.vespa.epntapclient.gui.ParamField.DataProductTypeField; +import eu.omp.irap.vespa.epntapclient.gui.ParamField.DateRangeField; +import eu.omp.irap.vespa.epntapclient.gui.ParamField.FloatRangeField; +import eu.omp.irap.vespa.epntapclient.gui.ParamField.TargetNameField; +import eu.omp.irap.vespa.epntapclient.gui.ViewListener; /** * The view of the panel where the user builds the query. @@ -75,9 +74,6 @@ public class RequestPanel extends JPanel { private void buildRequestPanel() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - setPreferredSize(new Dimension(GUIDim.RIGHT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); - setMinimumSize(new Dimension(GUIDim.RIGHT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); - this.add(buildParamPanel(), this); this.add(buildQueryPanel(), this); this.add(buildButtonPanel(), this); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java index f9eceb6..d1537d0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ResultsPanel.java @@ -14,21 +14,17 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view.panels; +package eu.omp.irap.vespa.epntapclient.gui.panels; import java.awt.BorderLayout; -import java.awt.Dimension; -import javax.swing.JPanel; - -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; -import eu.omp.irap.vespa.epntapclient.view.GUIDim; +import eu.omp.irap.vespa.epntapclient.gui.ViewListener; import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; /** * @author N. Jourdane */ -public class ResultsPanel extends JPanel { +public class ResultsPanel extends VOTableView { /** The serial version UID. */ private static final long serialVersionUID = 1L; @@ -43,21 +39,14 @@ public class ResultsPanel extends JPanel { * @param mainView The main view of the application. * @param voTableView The generic view of the VOTable panel. */ - public ResultsPanel(ViewListener viewListener, VOTableView voTableView) { + public ResultsPanel(ViewListener viewListener) { super(); this.viewListener = viewListener; - buildResultPanel(voTableView); + buildResultPanel(); } - private void buildResultPanel(VOTableView voTableView) { + private void buildResultPanel() { setLayout(new BorderLayout()); - - setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH + GUIDim.RIGHT_PANEL_WIDTH, - GUIDim.BOTTOM_PANEL_HEIGHT)); - setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH + GUIDim.RIGHT_PANEL_MIN_WIDTH, - GUIDim.BOTTOM_PANEL_MIN_HEIGHT)); - - this.add(voTableView); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java index 38120b1..d2f4c94 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/panels/ServicesPanel.java @@ -14,10 +14,9 @@ * . */ -package eu.omp.irap.vespa.epntapclient.view.panels; +package eu.omp.irap.vespa.epntapclient.gui.panels; import java.awt.BorderLayout; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -28,21 +27,17 @@ import javax.swing.JTextField; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import eu.omp.irap.vespa.epntapclient.controller.ViewListener; -import eu.omp.irap.vespa.epntapclient.view.GUIDim; +import eu.omp.irap.vespa.epntapclient.gui.ViewListener; import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView; /** * @author N. Jourdane */ -public class ServicesPanel extends JPanel { +public class ServicesPanel extends VOTableView { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The generic view of the VOTable panel. */ - private VOTableView voTableView; - private ViewListener viewListener; private JButton serviceButton; @@ -59,31 +54,22 @@ public class ServicesPanel extends JPanel { * @param mainView The main view of the application. * @param voTableView The generic view of the VOTable panel. */ - public ServicesPanel(final ViewListener viewListener, final VOTableView voTableView) { + public ServicesPanel(final ViewListener viewListener) { super(); this.viewListener = viewListener; - this.voTableView = voTableView; - - buildServicesPanel(voTableView); + buildServicesPanel(); } - private void buildServicesPanel(final VOTableView voTableView) { - setLayout(new BorderLayout()); - - setPreferredSize(new Dimension(GUIDim.LEFT_PANEL_WIDTH, GUIDim.TOP_PANEL_HEIGHT)); - setMinimumSize(new Dimension(GUIDim.LEFT_PANEL_MIN_WIDTH, GUIDim.TOP_PANEL_MIN_HEIGHT)); - - voTableView.getTable().getSelectionModel() - .addListSelectionListener(new ListSelectionListener() { + private void buildServicesPanel() { + getTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { - @Override - public void valueChanged(ListSelectionEvent evt) { - viewListener.onServiceSelected(voTableView.getTable().getSelectedRow()); - } - }); + @Override + public void valueChanged(ListSelectionEvent evt) { + viewListener.onServiceSelected(getTable().getSelectedRow()); + } + }); - this.add(buildAddServicePanel(), BorderLayout.CENTER); - this.add(voTableView, BorderLayout.NORTH); + this.add(buildAddServicePanel(), BorderLayout.SOUTH); } private JPanel buildAddServicePanel() { @@ -145,7 +131,7 @@ public class ServicesPanel extends JPanel { if (row == -1) { return serviceUrlTextField.getText(); } - return (String) voTableView.getValueAt(5, row); + return (String) getValueAt(5, row); } /** @@ -156,6 +142,6 @@ public class ServicesPanel extends JPanel { if (row == -1) { return tableNameTextField.getText(); } - return (String) voTableView.getValueAt(2, row); + return (String) getValueAt(2, row); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java index b0cf41f..c2316f0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java @@ -69,6 +69,7 @@ public class VOTableView extends JPanel implements TableModelListener { private void buildVOTableView() { JScrollPane scrollPane = new JScrollPane(table); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); @@ -83,7 +84,9 @@ public class VOTableView extends JPanel implements TableModelListener { * @param data The VoTable data displayed on the JTable */ public void fillTable(String[] columns, List data) { + System.out.println(columns + "\n" + data); Object[][] values = data.toArray(new Object[data.size()][]); + Utils.printObject("tableColumns", columns); Utils.printObject("tableData", values); tableData.setDataVector(values, columns); if (values.length != 0) { -- libgit2 0.21.2