Commit 9c5b73b8f81d34cea71f55c263c0daa1b8b7184f

Authored by Nathanael Jourdane
1 parent a2c89bc1
Exists in master and in 1 other branch b6.0.X

Create a VOTablePanelCtrl and dissociate graphics from processing (#3), this fixes #1.

src/main/java/eu/omp/irap/vespa/votable/VOTableApp.java
... ... @@ -19,13 +19,9 @@ package eu.omp.irap.vespa.votable;
19 19 import java.util.logging.Level;
20 20 import java.util.logging.Logger;
21 21  
22   -import javax.swing.JFrame;
23   -import javax.swing.SwingUtilities;
24   -
25   -import eu.omp.irap.vespa.votable.controller.VOTableController;
26   -import eu.omp.irap.vespa.votable.controller.VOTableException;
  22 +import eu.omp.irap.vespa.votable.gui.VOTablePanelCtrl;
27 23 import eu.omp.irap.vespa.votable.utils.StringJoiner;
28   -import eu.omp.irap.vespa.votable.view.VOTableView;
  24 +import eu.omp.irap.vespa.votable.votable.VOTableException;
29 25  
30 26 /**
31 27 * Simple class to have a main function to display a voTable from a XML file.
... ... @@ -52,11 +48,9 @@ public class VOTableApp {
52 48 * @param args The program arguments
53 49 */
54 50 public static void main(final String[] args) {
55   - VOTableApp.LOGGER
56   - .info("Lauching VOTable app with arguments: " + StringJoiner.join(args));
57   - VOTableController ctrl;
  51 + LOGGER.info("Lauching VOTable app with arguments: " + StringJoiner.join(args));
58 52  
59   - ctrl = new VOTableController();
  53 + VOTablePanelCtrl ctrl = new VOTablePanelCtrl();
60 54 try {
61 55 if (args.length == 1) {
62 56 ctrl.newVOTable(args[0]);
... ... @@ -71,30 +65,6 @@ public class VOTableApp {
71 65 return;
72 66 }
73 67  
74   - VOTableView view = new VOTableView();
75   - view.fillTable(ctrl.getVOTableData());
76   - SwingUtilities.invokeLater(VOTableApp.run(view, args[0]));
77   - }
78   -
79   - /**
80   - * Create the runnable to launch the application.
81   - *
82   - * @param voTableView The view of the VOTable, created by the VOTableController.
83   - * @param title The title of the window displaying the VOTable.
84   - * @return The Runnable.
85   - */
86   - private static Runnable run(final VOTableView voTableView, final String title) {
87   - return new Runnable() {
88   -
89   - @Override
90   - public void run() {
91   - JFrame frame = new JFrame(title);
92   - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
93   - frame.setContentPane(voTableView);
94   - frame.setVisible(true);
95   - frame.setSize(800, 600);
96   - frame.setLocationRelativeTo(null);
97   - }
98   - };
  68 + ctrl.fillTable();
99 69 }
100 70 }
101 71 \ No newline at end of file
... ...
src/main/java/eu/omp/irap/vespa/votable/gui/VOTablePanelCtrl.java 0 → 100644
... ... @@ -0,0 +1,83 @@
  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.votable.gui;
  18 +
  19 +import javax.swing.JFrame;
  20 +import javax.swing.SwingUtilities;
  21 +
  22 +import eu.omp.irap.vespa.votable.votable.VOTableCtrl;
  23 +
  24 +/**
  25 + * @author N. Jourdane
  26 + */
  27 +public class VOTablePanelCtrl extends VOTableCtrl implements VOTablePanelListener {
  28 +
  29 + /** The view of the VOTable panel. */
  30 + private VOTablePanelView view;
  31 +
  32 +
  33 + /**
  34 + * Constructor of VOTablePanelCtrl
  35 + */
  36 + public VOTablePanelCtrl() {
  37 + view = new VOTablePanelView(this);
  38 + SwingUtilities.invokeLater(run("EPN-TAP client", view));
  39 + }
  40 +
  41 + /**
  42 + * Create the runnable to launch the application.
  43 + *
  44 + * @param voTableView The view of the VOTable, created by the VOTableController.
  45 + * @param title The title of the window displaying the VOTable.
  46 + * @return The Runnable.
  47 + */
  48 + private static Runnable run(final String title, final VOTablePanelView voTableView) {
  49 + return new Runnable() {
  50 +
  51 + @Override
  52 + public void run() {
  53 + JFrame frame = new JFrame(title);
  54 + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  55 + frame.setContentPane(voTableView);
  56 + frame.setVisible(true);
  57 + frame.setSize(800, 600);
  58 + frame.setLocationRelativeTo(null);
  59 + }
  60 + };
  61 + }
  62 +
  63 + @Override
  64 + public void displayInfo(String shortMessage, String detailledMessage) {
  65 + super.displayInfo(shortMessage, detailledMessage);
  66 + view.displayInfo(shortMessage, detailledMessage);
  67 + }
  68 +
  69 + /** Put the VOTable data in the JTable. */
  70 + public void fillTable() {
  71 + view.fillTable(getVOTableData());
  72 + }
  73 +
  74 + /** @return The view of the VOTable panel */
  75 + public VOTablePanelView getView() {
  76 + return view;
  77 + }
  78 +
  79 + @Override
  80 + public void onRowsSelected() {
  81 + // Do nothing yet when a column is selected.
  82 + }
  83 +}
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/BinaryStreamParser.java
... ... @@ -28,8 +28,8 @@ import javax.xml.bind.DatatypeConverter;
28 28 import eu.omp.irap.vespa.epntapclient.votable.model.DataType;
29 29 import eu.omp.irap.vespa.epntapclient.votable.model.Field;
30 30 import eu.omp.irap.vespa.epntapclient.votable.model.Stream;
31   -import eu.omp.irap.vespa.votable.controller.VOTableException.CantParseVOTableException;
32 31 import eu.omp.irap.vespa.votable.utils.Debug;
  32 +import eu.omp.irap.vespa.votable.votable.VOTableException.CantParseVOTableException;
33 33  
34 34 /**
35 35 * @author N. Jourdane
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/DataParser.java
... ... @@ -18,7 +18,7 @@ package eu.omp.irap.vespa.votable.votabledata;
18 18  
19 19 import java.util.List;
20 20  
21   -import eu.omp.irap.vespa.votable.controller.VOTableException.CantParseVOTableException;
  21 +import eu.omp.irap.vespa.votable.votable.VOTableException.CantParseVOTableException;
22 22  
23 23 /**
24 24 * @author N. Jourdane
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/VOTableData.java
... ... @@ -21,7 +21,7 @@ import java.util.HashMap;
21 21 import java.util.List;
22 22 import java.util.Map;
23 23  
24   -import eu.omp.irap.vespa.votable.controller.VOTableException.CanNotParseDataException;
  24 +import eu.omp.irap.vespa.votable.votable.VOTableException.CanNotParseDataException;
25 25  
26 26 /**
27 27 * @author N. Jourdane
... ...
src/main/java/eu/omp/irap/vespa/votable/votabledata/VOTableDataParser.java
... ... @@ -23,9 +23,9 @@ import java.util.logging.Logger;
23 23 import eu.omp.irap.vespa.epntapclient.votable.model.Data;
24 24 import eu.omp.irap.vespa.epntapclient.votable.model.Field;
25 25 import eu.omp.irap.vespa.epntapclient.votable.model.Table;
26   -import eu.omp.irap.vespa.votable.controller.VOTableException;
27   -import eu.omp.irap.vespa.votable.controller.VOTableException.VOTableIsNotValidException;
28 26 import eu.omp.irap.vespa.votable.utils.StringJoiner;
  27 +import eu.omp.irap.vespa.votable.votable.VOTableException;
  28 +import eu.omp.irap.vespa.votable.votable.VOTableException.VOTableIsNotValidException;
29 29  
30 30 /**
31 31 * @author N. Jourdane
... ...