2 * jSite-remote - UpdateChecker.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package de.todesbaum.jsite.gui;
22 import java.awt.BorderLayout;
23 import java.awt.event.ActionEvent;
25 import javax.swing.AbstractAction;
26 import javax.swing.Action;
27 import javax.swing.JButton;
28 import javax.swing.JFrame;
29 import javax.swing.JLabel;
30 import javax.swing.JOptionPane;
31 import javax.swing.JPanel;
32 import javax.swing.JProgressBar;
34 import de.todesbaum.jsite.application.Freenet7Interface;
35 import de.todesbaum.jsite.i18n.I18n;
36 import de.todesbaum.jsite.i18n.I18nContainer;
39 * Checks for newer versions of jSite.
41 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
43 public class UpdateChecker {
45 /** The URL for update checks. */
46 @SuppressWarnings("unused")
47 private static final String UPDATE_KEY = "USK@e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U,QvbWT0ImE0TwLODTl7EoJx2NBnwDxTbLTE6zkB-eGPs,AQACAAE/jSite/0/currentVersion.txt";
49 /** The parent of the dialog. */
50 @SuppressWarnings("unused")
51 private final JFrame parent;
53 /** The freenet interface. */
54 @SuppressWarnings("unused")
55 private final Freenet7Interface freenetInterface;
57 /** The cancel action. */
58 @SuppressWarnings("unused")
59 private Action cancelAction;
62 * Creates a new update checker that uses the given frame as its parent and
63 * communications via the given freenet interface.
66 * The parent of the dialog
67 * @param freenetInterface
68 * The freenet interface
70 public UpdateChecker(JFrame parent, Freenet7Interface freenetInterface) {
72 this.freenetInterface = freenetInterface;
81 * Checks for updates, showing a dialog with an indeterminate progress bar.
83 public void checkForUpdates() {
92 * Initializes all actions.
94 private void initActions() {
95 cancelAction = new AbstractAction(I18n.getMessage("")) {
100 public void actionPerformed(ActionEvent actionEvent) {
107 * Shows a “please wait” dialog.
109 private void showBusyDialog() {
110 new Thread(new Runnable() {
112 @SuppressWarnings("synthetic-access")
114 BusyPanel busyPanel = new BusyPanel();
115 JButton cancelButton = new JButton(cancelAction);
116 JOptionPane.showOptionDialog(parent, busyPanel, I18n.getMessage(""), 0, JOptionPane.INFORMATION_MESSAGE, null, new Object[] { cancelButton }, cancelButton);
122 * A panel that shows a busy progress bar and a “please wait” message.
124 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
126 private class BusyPanel extends JPanel {
129 * Creates a new busy panel.
132 super(new BorderLayout(12, 12));
141 * Initializes all components of this panel.
143 private void initComponents() {
144 final JLabel label = new JLabel(I18n.getMessage("")); /* TODO */
145 JProgressBar progressBar = new JProgressBar();
146 progressBar.setIndeterminate(true);
148 add(label, BorderLayout.PAGE_START);
149 add(progressBar, BorderLayout.PAGE_END);
151 I18nContainer.getInstance().registerRunnable(new Runnable() {
157 label.setText(I18n.getMessage("")); /* TODO */