From ad548a5cd100faf20905658ea389ad1f680807f8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 30 Jun 2008 23:34:42 +0200 Subject: [PATCH] use JOptionPane for busy dialog --- src/de/todesbaum/jsite/gui/UpdateChecker.java | 67 ++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 6 deletions(-) diff --git a/src/de/todesbaum/jsite/gui/UpdateChecker.java b/src/de/todesbaum/jsite/gui/UpdateChecker.java index 46b16c9..9f5ebf4 100644 --- a/src/de/todesbaum/jsite/gui/UpdateChecker.java +++ b/src/de/todesbaum/jsite/gui/UpdateChecker.java @@ -19,28 +19,37 @@ package de.todesbaum.jsite.gui; +import java.awt.BorderLayout; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.Action; -import javax.swing.JDialog; +import javax.swing.JButton; import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.JProgressBar; import de.todesbaum.jsite.application.Freenet7Interface; import de.todesbaum.jsite.i18n.I18n; +import de.todesbaum.jsite.i18n.I18nContainer; /** * Checks for newer versions of jSite. * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class UpdateChecker extends JDialog { +public class UpdateChecker { /** The URL for update checks. */ @SuppressWarnings("unused") private static final String UPDATE_KEY = "USK@e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U,QvbWT0ImE0TwLODTl7EoJx2NBnwDxTbLTE6zkB-eGPs,AQACAAE/jSite/0/currentVersion.txt"; + /** The parent of the dialog. */ + @SuppressWarnings("unused") + private final JFrame parent; + /** The freenet interface. */ @SuppressWarnings("unused") private final Freenet7Interface freenetInterface; @@ -59,7 +68,7 @@ public class UpdateChecker extends JDialog { * The freenet interface */ public UpdateChecker(JFrame parent, Freenet7Interface freenetInterface) { - super(parent); + this.parent = parent; this.freenetInterface = freenetInterface; initActions(); } @@ -72,7 +81,7 @@ public class UpdateChecker extends JDialog { * Checks for updates, showing a dialog with an indeterminate progress bar. */ public void checkForUpdates() { - /* TODO */ + showBusyDialog(); } // @@ -95,14 +104,60 @@ public class UpdateChecker extends JDialog { } /** + * Shows a “please wait” dialog. + */ + private void showBusyDialog() { + new Thread(new Runnable() { + + @SuppressWarnings("synthetic-access") + public void run() { + BusyPanel busyPanel = new BusyPanel(); + JButton cancelButton = new JButton(cancelAction); + JOptionPane.showOptionDialog(parent, busyPanel, I18n.getMessage(""), 0, JOptionPane.INFORMATION_MESSAGE, null, new Object[] { cancelButton }, cancelButton); + } + }).start(); + } + + /** * A panel that shows a busy progress bar and a “please wait” message. * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ - @SuppressWarnings("unused") private class BusyPanel extends JPanel { - /* TODO */ + /** + * Creates a new busy panel. + */ + public BusyPanel() { + super(new BorderLayout(12, 12)); + initComponents(); + } + + // + // PRIVATE METHODS + // + + /** + * Initializes all components of this panel. + */ + private void initComponents() { + final JLabel label = new JLabel(I18n.getMessage("")); /* TODO */ + JProgressBar progressBar = new JProgressBar(); + progressBar.setIndeterminate(true); + + add(label, BorderLayout.PAGE_START); + add(progressBar, BorderLayout.PAGE_END); + + I18nContainer.getInstance().registerRunnable(new Runnable() { + + /** + * {@inheritDoc} + */ + public void run() { + label.setText(I18n.getMessage("")); /* TODO */ + } + }); + } } -- 2.7.4