implement project deletion
[jSite2.git] / src / net / pterodactylus / jsite / gui / MainWindow.java
index 654f548..1d536c8 100644 (file)
@@ -41,6 +41,7 @@ import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
 import javax.swing.JToolBar;
@@ -137,6 +138,7 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                SwingUtils.center(this);
                I18n.registerI18nable(this);
                addWindowListener(this);
+               setIconImage(IconLoader.loadImage("/jSite-frame-icon.png"));
        }
 
        //
@@ -299,10 +301,25 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                project.addPropertyChangeListener(this);
                if (switchToProject) {
                        projectPane.setSelectedIndex(newTabIndex);
+                       while (project.getBasePath().length() == 0) {
+                               JOptionPane.showMessageDialog(this, I18n.get("mainWindow.information.changeProjectBasePath.message"), I18n.get("mainWindow.information.changeProjectBasePath.title"), JOptionPane.INFORMATION_MESSAGE);
+                               projectPanel.changeBasePath();
+                       }
                }
        }
 
        /**
+        * 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) {
@@ -472,8 +489,6 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                swingInterface.getQuitAction().updateI18n();
                swingInterface.getAddNodeAction().updateI18n();
                swingInterface.getAddProjectAction().updateI18n();
-               swingInterface.getCloneProjectAction().updateI18n();
-               swingInterface.getDeleteProjectAction().updateI18n();
                swingInterface.getHelpAboutAction().updateI18n();
                jSiteMenu.updateI18n();
                nodeMenu.updateI18n();
@@ -484,6 +499,10 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                        swingInterface.getNodeEditAction(node).updateI18n();
                        swingInterface.getNodeDeleteAction(node).updateI18n();
                }
+               for (Project project: swingInterface.getProjects()) {
+                       swingInterface.getCloneProjectAction(project).updateI18n();
+                       swingInterface.getDeleteProjectAction(project).updateI18n();
+               }
                for (I18nAction languageAction: swingInterface.getLanguageActions()) {
                        languageAction.updateI18n();
                }
@@ -496,7 +515,6 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
                                ((ProjectPanel) tabComponent).updateI18n();
                        }
                }
-               SwingUtils.repackCentered(this);
        }
 
        //
@@ -566,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) {