add actions for "jsite" and "about" menus
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Apr 2008 07:01:43 +0000 (07:01 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Apr 2008 07:01:43 +0000 (07:01 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@625 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/SwingInterface.java

index 1210a49..54dec0d 100644 (file)
@@ -24,6 +24,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import javax.swing.JOptionPane;
+
 import net.pterodactylus.jsite.core.Core;
 import net.pterodactylus.jsite.core.CoreListener;
 import net.pterodactylus.jsite.core.Node;
@@ -44,6 +46,15 @@ public class SwingInterface implements CoreListener {
        /** The main window. */
        private MainWindow mainWindow;
 
+       /** The “configure” action. */
+       private I18nAction configureAction;
+
+       /** The “import config” action. */
+       private I18nAction importConfigAction;
+
+       /** The “quit” action. */
+       private I18nAction quitAction;
+
        /** The “manage nodes” action. */
        private I18nAction manageNodesAction;
 
@@ -59,6 +70,12 @@ public class SwingInterface implements CoreListener {
        /** All lanugage menu items. */
        private List<I18nAction> languageActions = new ArrayList<I18nAction>();
 
+       /** The “about” action. */
+       private I18nAction helpAboutAction;
+
+       /** The “add project” action. */
+       private I18nAction addProjectAction;
+
        /** The list of all defined nodes. */
        private List<Node> nodeList;
 
@@ -98,6 +115,33 @@ public class SwingInterface implements CoreListener {
        }
 
        /**
+        * Returns the “configure” action.
+        * 
+        * @return The “configure” action
+        */
+       I18nAction getConfigureAction() {
+               return configureAction;
+       }
+
+       /**
+        * Returns the “import config” action.
+        * 
+        * @return The “import config” action
+        */
+       I18nAction getImportConfigAction() {
+               return importConfigAction;
+       }
+
+       /**
+        * Returns the “quit” action.
+        * 
+        * @return The “quit” action
+        */
+       I18nAction getQuitAction() {
+               return quitAction;
+       }
+
+       /**
         * Returns the “manage nodes” action.
         * 
         * @return The “manage nodes” action
@@ -133,6 +177,24 @@ public class SwingInterface implements CoreListener {
                return languageActions;
        }
 
+       /**
+        * Returns the “about” action.
+        * 
+        * @return The “about” action
+        */
+       I18nAction getHelpAboutAction() {
+               return helpAboutAction;
+       }
+
+       /**
+        * Returns the “add project” action.
+        * 
+        * @return The “add project” action
+        */
+       I18nAction getAddProjectAction() {
+               return addProjectAction;
+       }
+
        //
        // ACTIONS
        //
@@ -156,20 +218,50 @@ public class SwingInterface implements CoreListener {
         * Initializes all actions.
         */
        private void initActions() {
+               configureAction = new I18nAction("mainWindow.menu.jSite.configure") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               configure();
+                       }
+               };
+               importConfigAction = new I18nAction("mainWindow.menu.jSite.importConfig") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               importConfig();
+                       }
+               };
+               quitAction = new I18nAction("mainWindow.menu.jSite.quit") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               quit();
+                       }
+               };
                manageNodesAction = new I18nAction("mainWindow.menu.node.item.manageNodes") {
 
                        /**
                         * {@inheritDoc}
                         */
                        @SuppressWarnings("synthetic-access")
-                       public void actionPerformed(ActionEvent e) {
+                       public void actionPerformed(ActionEvent actionEvent) {
                                manageNodes();
                        }
                };
                nodeConnectAction = new I18nAction("mainWindow.menu.node.item.connect", false) {
 
                        @SuppressWarnings("synthetic-access")
-                       public void actionPerformed(ActionEvent e) {
+                       public void actionPerformed(ActionEvent actionEvent) {
                                nodeConnect();
                        }
 
@@ -199,7 +291,26 @@ public class SwingInterface implements CoreListener {
                        }
                        languageActions.add(languageAction);
                }
+               helpAboutAction = new I18nAction("mainWindow.menu.help.item.about") {
 
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               helpAbout();
+                       }
+               };
+               addProjectAction = new I18nAction("mainWindow.button.addProject") {
+
+                       /**
+                        * {@inheritDoc}
+                        */
+                       @SuppressWarnings("synthetic-access")
+                       public void actionPerformed(ActionEvent actionEvent) {
+                               addProject();
+                       }
+               };
        }
 
        /**
@@ -214,6 +325,25 @@ public class SwingInterface implements CoreListener {
        //
 
        /**
+        * Shows the configuration dialog.
+        */
+       private void configure() {
+       }
+
+       /**
+        * Imports old jSite configuration.
+        */
+       private void importConfig() {
+       }
+
+       /**
+        * Quits jSite.
+        */
+       private void quit() {
+               System.exit(0);
+       }
+
+       /**
         * Pops up the “manage nodes” dialog.
         */
        private void manageNodes() {
@@ -250,6 +380,18 @@ public class SwingInterface implements CoreListener {
                I18n.setLocale(newLocale);
        }
 
+       /**
+        * Shows the “about” dialog.
+        */
+       private void helpAbout() {
+       }
+
+       /**
+        * Adds a project.
+        */
+       private void addProject() {
+       }
+
        //
        // INTERFACE CoreListener
        //
@@ -257,6 +399,13 @@ public class SwingInterface implements CoreListener {
        /**
         * {@inheritDoc}
         */
+       public void loadingProjectsFailed(String directory) {
+               JOptionPane.showMessageDialog(mainWindow, I18n.get("mainWindow.error.projectLoadingFailed.message", directory), I18n.get("mainWindow.error.projectLoadingFailed.title"), JOptionPane.ERROR_MESSAGE);
+       }
+
+       /**
+        * {@inheritDoc}
+        */
        public void coreLoaded() {
                this.nodeList = core.getNodes();
                manageNodesDialog.setNodeList(nodeList);