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;
* The freenet interface
*/
public UpdateChecker(JFrame parent, Freenet7Interface freenetInterface) {
- super(parent);
+ this.parent = parent;
this.freenetInterface = freenetInterface;
initActions();
}
* Checks for updates, showing a dialog with an indeterminate progress bar.
*/
public void checkForUpdates() {
- /* TODO */
+ showBusyDialog();
}
//
}
/**
+ * 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 */
+ }
+ });
+ }
}