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.i18n.I18n;
import de.todesbaum.jsite.i18n.I18nContainer;
import de.todesbaum.util.image.IconLoader;
/**
* The main class that ties together everything.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
public class Main implements ActionListener, ListSelectionListener, WizardListener, NodeManagerListener {
/** Whether the debug mode is activated. */
private static boolean debug = false;
+ /** The version. */
+ private static final Version VERSION = new Version(0, 6, 2);
+
/** The configuration. */
private Configuration configuration;
/** The freenet interface. */
private Freenet7Interface freenetInterface = new Freenet7Interface();
+ /** The update checker. */
+ private final UpdateChecker updateChecker;
+
/** The jSite icon. */
private Icon jSiteIcon;
/**
* Enumeration for all possible pages.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
*/
private static enum PageType {
/** The “manage nodes” action. */
private Action manageNodeAction;
+ /** The “check for updates” action. */
+ private Action checkForUpdatesAction;
+
/** The “about jSite” action. */
private Action aboutAction;
/**
* Creates a new core with the given configuration from the given file.
- *
+ *
* @param configFilename
* The name of the configuration file
*/
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) {
+ throw new IllegalStateException("Lockfile override not active, refusing start.");
+ }
+ configuration.removeLockfileOnExit();
}
wizard = new TWizard();
createActions();
jSiteIcon = IconLoader.loadIcon("/jsite-icon.png");
wizard.setIcon(jSiteIcon);
+ updateChecker = new UpdateChecker(wizard, freenetInterface);
+
initPages();
showPage(PageType.PAGE_PROJECTS);
}
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) {
+ updateChecker.checkForUpdates();
+ }
+ };
aboutAction = new AbstractAction(I18n.getMessage("jsite.menu.help.about")) {
@SuppressWarnings("synthetic-access")
public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), Version.getVersion()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
+ JOptionPane.showMessageDialog(wizard, MessageFormat.format(I18n.getMessage("jsite.about.message"), getVersion().toString()), null, JOptionPane.INFORMATION_MESSAGE, jSiteIcon);
}
};
/**
* Creates the menu bar.
- *
+ *
* @return The menu bar
*/
private JMenuBar createMenuBar() {
final JMenu helpMenu = new JMenu(I18n.getMessage("jsite.menu.help"));
menuBar.add(helpMenu);
+ helpMenu.add(checkForUpdatesAction);
helpMenu.add(aboutAction);
I18nContainer.getInstance().registerRunnable(new Runnable() {
/**
* Shows the page with the given type.
- *
+ *
* @param pageType
* The page type to show
*/
/**
* Saves the configuration.
- *
+ *
* @return <code>true</code> if the configuration could be saved,
* <code>false</code> otherwise
*/
/**
* 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
return SUPPORTED_LOCALES[0];
}
+ /**
+ * Returns the version.
+ *
+ * @return The version
+ */
+ public static final Version getVersion() {
+ return VERSION;
+ }
+
//
// ACTIONS
//
/**
* Switches the language of the interface to the given locale.
- *
+ *
* @param locale
* The locale to switch to
*/
/**
* Main method that is called by the VM.
- *
+ *
* @param args
* The command-line arguments
*/