implement project deletion
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 27 May 2008 19:05:05 +0000 (21:05 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 27 May 2008 19:05:05 +0000 (21:05 +0200)
src/net/pterodactylus/jsite/gui/MainWindow.java
src/net/pterodactylus/jsite/gui/SwingInterface.java
src/net/pterodactylus/jsite/i18n/jSite.properties
src/net/pterodactylus/jsite/i18n/jSite_de.properties

index 843eaa1..1d536c8 100644 (file)
@@ -309,6 +309,17 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
        }
 
        /**
+        * Removes the pane containing the given project.
+        * 
+        * @param project
+        *            The project whose pane to remove
+        */
+       void removeProject(Project project) {
+               int projectIndex = getProjectIndex(project);
+               projectPane.remove(projectIndex);
+       }
+
+       /**
         * @param project
         */
        void projectInsertStarted(Project project) {
@@ -504,7 +515,6 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                                ((ProjectPanel) tabComponent).updateI18n();
                        }
                }
-               SwingUtils.repackCentered(this);
        }
 
        //
@@ -574,17 +584,11 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                        /* if a project was changed, update the tab title and tooltip. */
                        if (Project.PROPERTY_NAME.equals(propertyName) || Project.PROPERTY_DESCRIPTION.equals(propertyName)) {
                                Project project = (Project) eventSource;
-                               int tabCount = projectPane.getTabCount();
-                               for (int tabIndex = 0; tabIndex < tabCount; tabIndex++) {
-                                       Component tabComponent = projectPane.getComponentAt(tabIndex);
-                                       if (tabComponent instanceof ProjectPanel) {
-                                               Project tabProject = ((ProjectPanel) tabComponent).getProject();
-                                               if (tabProject.equals(project)) {
-                                                       projectPane.setTitleAt(tabIndex, project.getName());
-                                                       projectPane.setToolTipTextAt(tabIndex, project.getDescription());
-                                                       projectPane.repaint();
-                                               }
-                                       }
+                               int projectIndex = getProjectIndex(project);
+                               if (projectIndex != -1) {
+                                       projectPane.setTitleAt(projectIndex, project.getName());
+                                       projectPane.setToolTipTextAt(projectIndex, project.getDescription());
+                                       projectPane.repaint();
                                }
                        }
                } else if (eventSource instanceof Node) {
index 2c032ea..e5f569c 100644 (file)
@@ -778,7 +778,6 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh
         *            The project to clone
         */
        private void cloneProject(Project project) {
-               System.out.println("clone " + project);
                /* TODO */
        }
 
@@ -789,7 +788,11 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh
         *            The project to delete
         */
        private void deleteProject(Project project) {
-               System.out.println("delete " + project);
+               int choice = JOptionPane.showConfirmDialog(mainWindow, I18n.get("mainWindow.question.deleteProject.message", project.getName()), I18n.get("mainWindow.question.deleteProject.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+               if (choice == JOptionPane.NO_OPTION) {
+                       return;
+               }
+               core.removeProject(project);
        }
 
        //
@@ -831,6 +834,8 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh
         * {@inheritDoc}
         */
        public void projectAdded(Project project) {
+               project.setName(I18n.get("general.newProject.name"));
+               project.setDescription(I18n.get("general.newProject.description", new Date()));
                projectAdded(project, true);
        }
        
@@ -840,8 +845,6 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh
         * @param switchToProject
         */
        private void projectAdded(final Project project, boolean switchToProject) {
-               project.setName(I18n.get("general.newProject.name"));
-               project.setDescription(I18n.get("general.newProject.description", new Date()));
                cloneProjectActions.put(project, new I18nAction("mainWindow.button.cloneProject") {
 
                        /**
@@ -870,7 +873,9 @@ public class SwingInterface implements CoreListener, LoggingListener, PropertyCh
         * {@inheritDoc}
         */
        public void projectRemoved(Project project) {
-               /* TODO - implement */
+               mainWindow.removeProject(project);
+               cloneProjectActions.remove(project);
+               deleteProjectActions.remove(project);
        }
 
        /**
index 1305a77..d9241aa 100644 (file)
@@ -52,7 +52,10 @@ mainWindow.error.hostnameUnresolvable.title: Could Not Resolve Hostname
 mainWindow.error.hostnameUnresolvable.message: The hostname \u201c{0}\u201d can not be resolved!
 
 mainWindow.question.deleteNode.title: Really Remove Node?
-mainWindow.question.deleteNode.message: You are about to remove the node \u201c{0}\u201d! Do you want to continue?
+mainWindow.question.deleteNode.message: <html>You are about to remove the node \u201c{0}\u201d!<br>Do you want to continue?</html>
+
+mainWindow.question.deleteProject.title: Really Delete Project?
+mainWindow.question.deleteProject.message: <html>You are about to remove the project \u201c{0}\u201d!<br>Do you want to continue?</html>
 
 mainWindow.information.changeProjectBasePath.title: Please Enter Base Path!
 mainWindow.information.changeProjectBasePath.message: <html>You have created a new project. Please enter a base path<br>to read the files for the project from in the next dialog!</html>
@@ -111,11 +114,11 @@ mainWindow.menu.node.item.edit.accelerator: VK_UNDEFINED
 mainWindow.menu.node.item.edit.shortDescription: Edits the node
 mainWindow.menu.node.item.edit.longDescription: Edits the node
 
-mainWindow.menu.node.item.remove.name: Remove
-mainWindow.menu.node.item.remove.mnemonic: VK_R
+mainWindow.menu.node.item.remove.name: Delete
+mainWindow.menu.node.item.remove.mnemonic: VK_D
 mainWindow.menu.node.item.remove.accelerator: VK_UNDEFINED
-mainWindow.menu.node.item.remove.shortDescription: Removes the node
-mainWindow.menu.node.item.remove.longDescription: Removes the node
+mainWindow.menu.node.item.remove.shortDescription: Deletes the node
+mainWindow.menu.node.item.remove.longDescription: Deletes the node
 
 #
 # the jSite menu
index a1c9b02..86a1e6b 100644 (file)
@@ -54,6 +54,9 @@ mainWindow.error.hostnameUnresolvable.message: Der Hostname \u201e{0}\u201e kann
 mainWindow.question.deleteNode.title: Node wirklich l\u00f6schen?
 mainWindow.question.deleteNode.message: Den Node \u201e{0}\u201c wirklich l\u00f6schen?
 
+mainWindow.question.deleteProject.title: Projekt wirklich l\u00f6schen?
+mainWindow.question.deleteProject.message: Das Projekt \u201e{0}\u201c wirklich l\u00f6schen?
+
 mainWindow.information.changeProjectBasePath.title: Bitte Basispfad angeben!
 mainWindow.information.changeProjectBasePath.message: <html>Ein neues Projekt wurde erstellt. Bitte im<br>n\u00e4chsten Dialog einen Basispfad f\u00fcr die Dateien angeben!</html>