2 * Sudokuki - essential sudoku game
\r
3 * Copyright (C) 2007-2011 Sylvain Vedrenne
\r
5 * This program is free software: you can redistribute it and/or modify
\r
6 * it under the terms of the GNU General Public License as published by
\r
7 * the Free Software Foundation, either version 3 of the License, or
\r
8 * (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
18 package net.jankenpoi.sudokuki.ui.swing;
\r
20 import java.awt.event.ActionEvent;
\r
22 import javax.swing.AbstractAction;
\r
23 import javax.swing.Action;
\r
24 import javax.swing.JFrame;
\r
25 import javax.swing.JOptionPane;
\r
27 @SuppressWarnings("serial")
\r
28 public class CheckUpdateAction extends AbstractAction {
\r
30 private Action openUpdateSiteAction;
\r
32 private JFrame frame;
\r
34 public CheckUpdateAction(JFrame frame, Action openUpdateSiteAction) {
\r
36 this.openUpdateSiteAction = openUpdateSiteAction;
\r
37 performSilentCheck();
\r
41 public void actionPerformed(ActionEvent e) {
\r
42 CheckUpdateDialog dlg = new CheckUpdateDialog(frame, this);
\r
43 dlg.setVisible(true);
\r
44 int isNewVersionAvailable = dlg.getResult();
\r
45 if (isNewVersionAvailable == 0) {
\r
46 JOptionPane.showMessageDialog(frame, "<html>"
\r
47 + "<table border=\"0\">" + "<tr>"
\r
48 + "This version of Sudokuki is up-to-date." + "</tr>"
\r
49 + "</html>", "Sudokuki", JOptionPane.PLAIN_MESSAGE);
\r
50 } else if (isNewVersionAvailable == 1) {
\r
51 openUpdateSiteAction.setEnabled(true);
\r
52 NewVersionFoundDialog nvDlg = new NewVersionFoundDialog(frame);
\r
53 nvDlg.setVisible(true);
\r
55 JOptionPane.showMessageDialog(frame, "<html>"
\r
56 + "<table border=\"0\">" + "<tr>"
\r
57 + "Unable to retrieve update information.<br/><br/>"
\r
58 + "Please check on the following website<br/>"
\r
59 + "if a new version of Sudokuki is available:<br/><br/>"
\r
60 + "http://sourceforge.net/projects/sudokuki/files/sudokuki"
\r
61 + "</tr>" + "</html>", "Sudokuki",
\r
62 JOptionPane.WARNING_MESSAGE);
\r
66 public void performSilentCheck() {
\r
67 CheckUpdateDialog dlg = new CheckUpdateDialog(frame, this);
\r
68 dlg.setVisible(false);
\r
69 // Here I'm supposing that the SwingWorker created by the
\r
70 // CheckUpdateDialog will live on and from its done() method will notify
\r
71 // this CheckUpdateAction when ready.
\r
74 void notifyNewVersionFound(boolean isNewVersionFound) {
\r
75 if (isNewVersionFound) {
\r
76 openUpdateSiteAction.setEnabled(true);
\r