From b185db9445322aca4df3f68a14522d45fa9d5f90 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 24 Dec 2008 11:46:22 +0100 Subject: [PATCH] Implement UpdateListener and show dialog if a newer version was found. --- src/de/todesbaum/jsite/main/Main.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/de/todesbaum/jsite/main/Main.java b/src/de/todesbaum/jsite/main/Main.java index 005b50e..5601329 100644 --- a/src/de/todesbaum/jsite/main/Main.java +++ b/src/de/todesbaum/jsite/main/Main.java @@ -24,6 +24,7 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.IOException; import java.text.MessageFormat; +import java.util.Date; import java.util.HashMap; import java.util.Locale; import java.util.Map; @@ -53,6 +54,7 @@ import de.todesbaum.jsite.gui.ProjectFilesPage; import de.todesbaum.jsite.gui.ProjectInsertPage; import de.todesbaum.jsite.gui.ProjectPage; import de.todesbaum.jsite.gui.UpdateChecker; +import de.todesbaum.jsite.gui.UpdateListener; import de.todesbaum.jsite.i18n.I18n; import de.todesbaum.jsite.i18n.I18nContainer; import de.todesbaum.util.image.IconLoader; @@ -65,7 +67,7 @@ import de.todesbaum.util.swing.WizardListener; * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener { +public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener, UpdateListener { /** Whether the debug mode is activated. */ private static boolean debug = false; @@ -172,6 +174,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen wizard.setIcon(jSiteIcon); updateChecker = new UpdateChecker(wizard, freenetInterface); + updateChecker.addUpdateListener(this); updateChecker.start(); initPages(); @@ -568,6 +571,19 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen } // + // INTERFACE UpdateListener + // + + /** + * {@inheritDoc} + */ + public void foundUpdateData(Version foundVersion, long versionTimestamp) { + if (foundVersion.compareTo(VERSION) > 0) { + JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.update-checker.found-version.message"), foundVersion.toString(), new Date(versionTimestamp)), I18n.getMessage("jsite.update-checker.found-version.title"), JOptionPane.INFORMATION_MESSAGE); + } + } + + // // MAIN METHOD // -- 2.7.4