2 * Sudokuki - essential sudoku game
\r
3 * Copyright (C) 2007-2016 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
26 import static net.jankenpoi.i18n.I18n.gtxt;
\r
28 @SuppressWarnings("serial")
\r
29 public class CheckUpdateAction extends AbstractAction {
\r
31 private Action openUpdateSiteAction;
\r
33 private JFrame frame;
\r
35 public CheckUpdateAction(JFrame frame, Action openUpdateSiteAction) {
\r
37 this.openUpdateSiteAction = openUpdateSiteAction;
\r
38 performSilentCheck();
\r
42 public void actionPerformed(ActionEvent e) {
\r
43 CheckUpdateDialog dlg = new CheckUpdateDialog(frame, this);
\r
44 dlg.setVisible(true);
\r
45 int upToDateStatus = dlg.getResult();
\r
46 if (upToDateStatus == 0) {
\r
47 JOptionPane.showMessageDialog(frame, "<html>"
\r
48 + "<table border=\"0\">" + "<tr>"
\r
49 + gtxt("This version of Sudokuki is up-to-date.") + "</tr>"
\r
50 + "</html>", "Sudokuki", JOptionPane.PLAIN_MESSAGE);
\r
51 } else if (upToDateStatus == 1) {
\r
52 openUpdateSiteAction.setEnabled(true);
\r
53 NewVersionFoundDialog nvDlg = new NewVersionFoundDialog(frame);
\r
54 nvDlg.setVisible(true);
\r
55 } else if (upToDateStatus == -1) {
\r
56 JOptionPane.showMessageDialog(frame, "<html>"
\r
57 + "<table border=\"0\">" + "<tr>"
\r
58 + gtxt("Unable to retrieve update information.<br/><br/>Please check on the following website<br/>if a new version of Sudokuki is available:<br/><br/>")
\r
59 + "http://sourceforge.net/projects/sudokuki/files/sudokuki"
\r
60 + "</tr>" + "</html>", "Sudokuki",
\r
61 JOptionPane.WARNING_MESSAGE);
\r
64 * CheckUpdateAction.actionPerformed() CANCELLED");
\r
69 public void performSilentCheck() {
\r
70 CheckUpdateDialog dlg = new CheckUpdateDialog(frame, this);
\r
71 dlg.setVisible(false);
\r
72 // Here I'm supposing that the SwingWorker created by the
\r
73 // CheckUpdateDialog will live on and from its done() method will notify
\r
74 // this CheckUpdateAction when ready.
\r
77 void notifyNewVersionFound() {
\r
78 openUpdateSiteAction.setEnabled(true);
\r