work in progress
[jSite.git] / src / de / todesbaum / jsite / main / Main.java
index b00e020..abe9b73 100644 (file)
@@ -61,7 +61,7 @@ import de.todesbaum.util.swing.WizardListener;
 
 /**
  * The main class that ties together everything.
- * 
+ *
  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
  */
 public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener {
@@ -69,6 +69,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;
 
@@ -80,7 +83,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Enumeration for all possible pages.
-        * 
+        *
         * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
         */
        private static enum PageType {
@@ -108,6 +111,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;
 
@@ -132,7 +138,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Creates a new core with the given configuration from the given file.
-        * 
+        *
         * @param configFilename
         *            The name of the configuration file
         */
@@ -145,8 +151,11 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                Locale.setDefault(configuration.getLocale());
                I18n.setLocale(configuration.getLocale());
                if (!configuration.createLockFile()) {
-                       JOptionPane.showMessageDialog(null, I18n.getMessage("jsite.main.already-running"), null, JOptionPane.ERROR_MESSAGE);
-                       return;
+                       int option = JOptionPane.showOptionDialog(null, I18n.getMessage("jsite.main.already-running"), "", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { I18n.getMessage("jsite.main.already-running.override"), I18n.getMessage("jsite.wizard.quit") }, I18n.getMessage("jsite.wizard.quit"));
+                       if (option != 0) {
+                               return;
+                       }
+                       configuration.removeLockfileOnExit();
                }
                wizard = new TWizard();
                createActions();
@@ -184,6 +193,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")
@@ -204,7 +223,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Creates the menu bar.
-        * 
+        *
         * @return The menu bar
         */
        private JMenuBar createMenuBar() {
@@ -282,7 +301,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Shows the page with the given type.
-        * 
+        *
         * @param pageType
         *            The page type to show
         */
@@ -295,7 +314,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Saves the configuration.
-        * 
+        *
         * @return <code>true</code> if the configuration could be saved,
         *         <code>false</code> otherwise
         */
@@ -314,7 +333,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Finds a supported locale for the given locale.
-        * 
+        *
         * @param forLocale
         *            The locale to find a supported locale for
         * @return The supported locale that was found, or the default locale if no
@@ -345,7 +364,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Switches the language of the interface to the given locale.
-        * 
+        *
         * @param locale
         *            The locale to switch to
         */
@@ -366,6 +385,13 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
                configuration.setLocale(supportedLocale);
        }
 
+       /**
+        * Checks for updates of jSite.
+        */
+       private void checkForUpdates() {
+
+       }
+
        //
        // INTERFACE ListSelectionListener
        //
@@ -538,7 +564,7 @@ public class Main implements ActionListener, ListSelectionListener, WizardListen
 
        /**
         * Main method that is called by the VM.
-        * 
+        *
         * @param args
         *            The command-line arguments
         */