WIP: progress dialog
[jSite.git] / src / de / todesbaum / jsite / main / Main.java
index 8c9a15d..dfae154 100644 (file)
@@ -19,6 +19,7 @@
 
 package de.todesbaum.jsite.main;
 
+import java.awt.BorderLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.io.File;
@@ -34,11 +35,14 @@ import javax.swing.AbstractAction;
 import javax.swing.Action;
 import javax.swing.ButtonGroup;
 import javax.swing.Icon;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
 import javax.swing.JList;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
+import javax.swing.JProgressBar;
 import javax.swing.JRadioButtonMenuItem;
 import javax.swing.event.ListSelectionEvent;
 import javax.swing.event.ListSelectionListener;
@@ -69,6 +73,9 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
        /** Whether the debug mode is activated. */
        private static boolean debug = false;
 
+       /** The URL for update checks. */
+       private static final String UPDATE_KEY = "USK@e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U,QvbWT0ImE0TwLODTl7EoJx2NBnwDxTbLTE6zkB-eGPs,AQACAAE/jSite/0/currentVersion.txt";
+
        /** The configuration. */
        private Configuration configuration;
 
@@ -108,6 +115,9 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
        /** The “manage nodes” action. */
        private Action manageNodeAction;
 
+       /** The “check for updates” action. */
+       private Action checkForUpdatesAction;
+
        /** The “about jSite” action. */
        private Action aboutAction;
 
@@ -187,6 +197,16 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                                wizard.setNextName(I18n.getMessage("jsite.wizard.next"));
                        }
                };
+               checkForUpdatesAction = new AbstractAction(I18n.getMessage("jsite.menu.help.check-for-updates")) {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               checkForUpdates();
+                       }
+               };
                aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
 
                        @SuppressWarnings("synthetic-access")
@@ -237,6 +257,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
                final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
                menuBar.add(helpMenu);
+               helpMenu.add(checkForUpdatesAction);
                helpMenu.add(aboutAction);
 
                I18nContainer.getInstance().registerRunnable(new Runnable() {
@@ -369,6 +390,24 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                configuration.setLocale(supportedLocale);
        }
 
+       /**
+        * Checks for updates of jSite.
+        */
+       private void checkForUpdates() {
+               System.out.println("checkForUpdates()");
+               /* construct a small panel for the dialog. */
+               JPanel waitingDialogPanel = new JPanel(new BorderLayout(12, 12));
+               waitingDialogPanel.add(new JLabel(I18n.getMessage("")), BorderLayout.PAGE_START);
+               JProgressBar progressBar = new JProgressBar();
+               progressBar.setIndeterminate(true);
+               waitingDialogPanel.add(progressBar, BorderLayout.PAGE_END);
+               JOptionPane waitingDialog = new JOptionPane(waitingDialogPanel, JOptionPane.INFORMATION_MESSAGE, 0, null, new Object[] { "Cancel" });
+               JDialog dialog = new JDialog(wizard, true);
+               dialog.getContentPane().add(waitingDialog, BorderLayout.CENTER);
+               dialog.pack();
+               dialog.setVisible(true);
+       }
+
        //
        // INTERFACE ListSelectionListener
        //