From: David ‘Bombe’ Roden Date: Mon, 30 Jun 2008 21:34:42 +0000 (+0200) Subject: use JOptionPane for busy dialog X-Git-Tag: 0.7~26 X-Git-Url: https://git.pterodactylus.net/?p=jSite.git;a=commitdiff_plain;h=ad548a5cd100faf20905658ea389ad1f680807f8 use JOptionPane for busy dialog --- 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 */ + } + }); + } }