add progress updates to project tab titles
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 May 2008 17:39:45 +0000 (17:39 +0000)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 23 May 2008 17:39:45 +0000 (17:39 +0000)
git-svn-id: http://trooper/svn/projects/jSite/trunk@942 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/jsite/gui/MainWindow.java
src/net/pterodactylus/jsite/i18n/jSite.properties
src/net/pterodactylus/jsite/i18n/jSite_de.properties

index 9731ec5..f582bb2 100644 (file)
@@ -264,11 +264,11 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
         * @param project
         */
        void projectInsertStarted(Project project) {
-               ProjectPanel projectPanel = findProjectPanel(project);
-               if (projectPanel == null) {
+               int projectIndex = getProjectIndex(project);
+               if (projectIndex == -1) {
                        return;
                }
-               
+               projectPane.setTitleAt(projectIndex, I18n.get("projectPanel.title.starting", project.getName()));
        }
 
        /**
@@ -281,14 +281,18 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
         * @param finalizedTotal
         */
        void projectInsertProgressed(Project project, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal) {
-
+               int projectIndex = getProjectIndex(project);
+               if (projectIndex == -1) {
+                       return;
+               }
+               projectPane.setTitleAt(projectIndex, I18n.get("projectPanel.title.progress", project.getName(), requiredBlocks / (double) successfulBlocks));
        }
 
        /**
         * @param project
         */
        void projectInsertGeneratedURI(Project project) {
-
+               /* TODO - update panel. */
        }
 
        /**
@@ -296,7 +300,11 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
         * @param success
         */
        void projectInsertFinished(Project project, boolean success) {
-
+               int projectIndex = getProjectIndex(project);
+               if (projectIndex == -1) {
+                       return;
+               }
+               projectPane.setTitleAt(projectIndex, project.getName());
        }
 
        //
@@ -304,22 +312,24 @@ public class MainWindow extends JFrame implements WindowListener, I18nable, Prop
        //
 
        /**
-        * Locates the project panel that contains the given project.
+        * Returns the index of the project panel that contains the given project.
         * 
         * @param project
         *            The wanted project
+        * @return The index of {@link #projectPane}’s tab that contains the given
+        *         project, or <code>-1</code> if the project can not be found
         */
-       private ProjectPanel findProjectPanel(Project project) {
+       private int getProjectIndex(Project project) {
                int tabCount = projectPane.getTabCount();
                for (int tabIndex = 1; tabIndex < tabCount; tabIndex++) {
                        Component tabComponent = projectPane.getComponentAt(tabIndex);
                        if (tabComponent instanceof ProjectPanel) {
                                if (((ProjectPanel) tabComponent).getProject() == project) {
-                                       return (ProjectPanel) tabComponent;
+                                       return tabIndex;
                                }
                        }
                }
-               return null;
+               return -1;
        }
 
        /**
index 02e72fd..e9b8faa 100644 (file)
@@ -165,6 +165,9 @@ mainWindow.pane.overview.title: Project Overview
 # the "project" panel
 #
 
+projectPanel.title.starting: (Starting) {0}
+projectPanel.title.progress: ({1,number,0.0%}) {0}
+
 projectPanel.label.name.name: Name
 projectPanel.label.name.mnemonic: VK_N
 
index f6085bf..16c467a 100644 (file)
@@ -165,6 +165,9 @@ mainWindow.pane.overview.title: Projekt\u00fcbersicht
 # the "project" panel
 #
 
+projectPanel.title.starting: (Starte) {0}
+projectPanel.title.progress: ({1,number,0.0%}) {0}
+
 projectPanel.label.name.name: Name
 projectPanel.label.name.mnemonic: VK_N