implement project deletion
[jSite2.git] / src / net / pterodactylus / jsite / gui / MainWindow.java
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) {