Commit 1353e182277de278877c9959bb874e4e49bfc3a2

Authored by Nathanael Jourdane
1 parent 8de486be
Exists in master

Add minimal elements for the EPN-TAP client GUI: app, controller and view.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java 0 → 100644
... ... @@ -0,0 +1,57 @@
  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;
  18 +
  19 +import javax.swing.JFrame;
  20 +import javax.swing.SwingUtilities;
  21 +
  22 +import eu.omp.irap.vespa.epntapclient.controller.EpnTapController;
  23 +import eu.omp.irap.vespa.epntapclient.utils.Log;
  24 +
  25 +/**
  26 + * Simple class to have a main function to launch the EPNTap client.
  27 + *
  28 + * @author N. Jourdane
  29 + */
  30 +public class EpnTapMainApp {
  31 + /**
  32 + * Main function to start the application as standalone.
  33 + *
  34 + * @param args The program arguments (not used).
  35 + */
  36 + public static void main(String[] args) {
  37 + SwingUtilities.invokeLater(new Runnable() {
  38 + @Override
  39 + public void run() {
  40 + EpnTapController epnTapControl = new EpnTapController();
  41 + Log.LOGGER.info("Lauching EPN-TAP application...");
  42 + if (args.length != 0) {
  43 + System.out.println("Usage: EpnTapMainApp");
  44 + return;
  45 + }
  46 +
  47 + JFrame frame = new JFrame("EPN-TAP client");
  48 + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  49 + frame.setContentPane(epnTapControl.getView());
  50 + frame.setVisible(true);
  51 + // frame.pack();
  52 + frame.setSize(800, 600);
  53 + frame.setLocationRelativeTo(null);
  54 + }
  55 + });
  56 + }
  57 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java 0 → 100644
... ... @@ -0,0 +1,62 @@
  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.controller;
  18 +
  19 +import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView;
  20 +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController;
  21 +
  22 +/**
  23 + * @author N. Jourdane
  24 + */
  25 +public class EpnTapController {
  26 + /** The view of EPN-TAP application. */
  27 + EpnTapMainView view;
  28 +
  29 + /** The controller of the VOTable displaying the query results. */
  30 + VOTableController resultsController;
  31 +
  32 + /** The controller of the VOTable displaying the list of services. */
  33 + VOTableController servicesController;
  34 +
  35 + /**
  36 + * Method constructor
  37 + */
  38 + public EpnTapController() {
  39 + view = new EpnTapMainView();
  40 + }
  41 +
  42 + /**
  43 + * @return the EPN-TAP view.
  44 + */
  45 + public EpnTapMainView getView() {
  46 + return view;
  47 + }
  48 +
  49 + /**
  50 + * @return The controller of the VOTable displaying the query results.
  51 + */
  52 + public VOTableController getResultsController() {
  53 + return resultsController;
  54 + }
  55 +
  56 + /**
  57 + * @return The controller of the VOTable displaying the list of services.
  58 + */
  59 + public VOTableController getServicesController() {
  60 + return servicesController;
  61 + }
  62 +}
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/view/EpnTapMainView.java 0 → 100644
... ... @@ -0,0 +1,100 @@
  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.view;
  18 +
  19 +import java.awt.BorderLayout;
  20 +
  21 +import javax.swing.JOptionPane;
  22 +import javax.swing.JPanel;
  23 +import javax.swing.JTextArea;
  24 +
  25 +import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
  26 +
  27 +/**
  28 + * @author N. Jourdane
  29 + */
  30 +public class EpnTapMainView extends JPanel {
  31 +
  32 + /** The serial version UID (affected with a random number). */
  33 + private static final long serialVersionUID = -1233290271099283814L;
  34 +
  35 + /** The JPanel where the VOTable results is displayed. */
  36 + private VOTableView results;
  37 +
  38 + /** The JPanel where the list of services is displayed. */
  39 + private VOTableView services;
  40 +
  41 + /** The text area where the user put its requests. */
  42 + private JTextArea queryArea;
  43 +
  44 + /**
  45 + * The constructor of the view.
  46 + */
  47 + public EpnTapMainView() {
  48 + services = new VOTableView();
  49 + results = new VOTableView();
  50 + queryArea = new JTextArea("");
  51 +
  52 + String[] sColumns = { "service name", "service value" };
  53 + String[][] sValues = { { "s1", "s2" }, { "789", "357" } };
  54 + services.buildArray(sColumns, sValues);
  55 +
  56 + String[] rColumns = { "result name", "result value" };
  57 + String[][] rValues = { { "r1", "r2" }, { "123", "456" } };
  58 + results.buildArray(rColumns, rValues);
  59 +
  60 + buildWindow();
  61 + }
  62 +
  63 + /**
  64 + * @return The JPanel where the VOTable results is displayed.
  65 + */
  66 + public VOTableView getResults() {
  67 + return results;
  68 + }
  69 +
  70 + /**
  71 + * @return The JPanel where the list of services is displayed.
  72 + */
  73 + public VOTableView getServices() {
  74 + return services;
  75 + }
  76 +
  77 + /**
  78 + * Build and fill the GUI.
  79 + */
  80 + public void buildWindow() {
  81 + JPanel northPanel = new JPanel(new BorderLayout());
  82 + northPanel.add(services, BorderLayout.WEST);
  83 + northPanel.add(queryArea, BorderLayout.CENTER);
  84 +
  85 + setLayout(new BorderLayout());
  86 + add(northPanel, BorderLayout.NORTH);
  87 + add(results, BorderLayout.CENTER);
  88 + }
  89 +
  90 + /**
  91 + * Display an error.
  92 + *
  93 + * @param title The title of the error.
  94 + * @param message The message of the error.
  95 + */
  96 + public void displayError(String title, String message) {
  97 + JOptionPane.showMessageDialog(this, message, title, JOptionPane.ERROR_MESSAGE);
  98 + }
  99 +
  100 +}
... ...