From d393913eb760e32f3c4de647b5fd60b3004f1379 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Thu, 9 Jun 2016 12:18:19 +0200 Subject: [PATCH] Move the Runnable inside the MainPanelCtrl in order to load the GUI before the data. --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java | 35 ++++------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 31 deletions(-) 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 ddea224..df8be4c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapMainApp.java @@ -18,9 +18,6 @@ package eu.omp.irap.vespa.epntapclient; import java.util.logging.Logger; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; - import com.google.gson.Gson; import eu.omp.irap.vespa.epntapclient.gui.mainpanel.MainPanelCtrl; @@ -49,36 +46,12 @@ public class EpnTapMainApp { * @param args The program arguments (not used). */ public static void main(final String[] args) { - EpnTapMainApp.LOGGER.info("Lauching EPNTAP app with arguments: " + new Gson().toJson(args)); + LOGGER.info("Lauching EPNTAP app with arguments: " + new Gson().toJson(args)); if (args.length != 0) { - System.console().writer().println(EpnTapMainApp.WRONG_COMMAND); + System.console().writer().println(WRONG_COMMAND); return; } - - SwingUtilities.invokeLater(run("EPN-TAP client")); + MainPanelCtrl guiCtrl = new MainPanelCtrl(); + guiCtrl.readServices(); } - - /** - * Creates runnable used to run the application GUI. - * - * @param title The title of the application window. - * @return The runnable. - */ - private static Runnable run(final String title) { - return new Runnable() { - - @Override - public void run() { - MainPanelCtrl guiCtrl = new MainPanelCtrl(); - guiCtrl.readServices(); - JFrame frame = new JFrame(title); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - frame.setContentPane(guiCtrl.getView()); - frame.setVisible(true); - frame.pack(); - frame.setLocationRelativeTo(null); - } - }; - } - } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java index 9dcba35..1d8ac78 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java @@ -20,7 +20,9 @@ import java.awt.Cursor; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.JFrame; import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import eu.omp.irap.vespa.epntapclient.epntap.EpnTapController; @@ -61,6 +63,29 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener resultsPanelCtrl = new ResultPanelCtrl(this); requestPanelCtrl = new RequestPanelCtrl(this); view = new MainPanelView(this); + SwingUtilities.invokeLater(run("EPN-TAP client", view)); + } + + /** + * Creates runnable used to run the application GUI. + * + * @param title The title of the application window. + * @param view The view of the VOTable, created by the VOTableController. + * @return The runnable. + */ + private static Runnable run(final String title, final MainPanelView view) { + return new Runnable() { + + @Override + public void run() { + JFrame frame = new JFrame(title); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setContentPane(view); + frame.setVisible(true); + frame.pack(); + frame.setLocationRelativeTo(null); + } + }; } @Override -- libgit2 0.21.2