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 new file mode 100644 index 0000000..1b398d8 --- /dev/null +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/votable/view/VOTableView.java @@ -0,0 +1,88 @@ +/** + * 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.votable.view; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.util.List; + +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ScrollPaneConstants; + +import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController; + +/** + * The main class of the View of the application. + * + * @author N. Jourdane + */ +public class VOTableView extends JPanel { + + /** The serial version UID (affected with a random number). */ + private static final long serialVersionUID = -1233290271099283814L; + + /** The controller of the VOTable */ + private VOTableController controller; + + /** + * The constructor of the view. + * + * @param controller The Controller of the application. + */ + public VOTableView(VOTableController controller) { + this.controller = controller; + } + + /** + * Build and fill the GUI. + * + * @param keys The name of each column of the VOTable data. + * @param values A list of arrays, representing the rows of the VOTable data. In each row, + * elements are in the same order as `keys`. + */ + public void buildArray(String[] keys, List values) { + setLayout(new BorderLayout()); + + Object valuesArray[][] = values.toArray(new Object[values.size()][]); + JTable table = new JTable(valuesArray, keys); + + setLayout(new BorderLayout()); + + JScrollPane scrollPane = new JScrollPane(table); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + scrollPane.setBounds(50, 30, 300, 50); + + setPreferredSize(new Dimension(500, 400)); + + add(scrollPane, BorderLayout.CENTER); + } + + /** + * Display an error. + * + * @param title The title of the error. + * @param message The message of the error. + */ + public void displayError(String title, String message) { + JOptionPane.showMessageDialog(this, message, title, JOptionPane.ERROR_MESSAGE); + } + +} -- libgit2 0.21.2