From ecf74feba089fac5fc952219ba864306bfdd2220 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 23 May 2008 17:39:45 +0000 Subject: [PATCH] add progress updates to project tab titles git-svn-id: http://trooper/svn/projects/jSite/trunk@942 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/jsite/gui/MainWindow.java | 30 ++++++++++++++-------- src/net/pterodactylus/jsite/i18n/jSite.properties | 3 +++ .../pterodactylus/jsite/i18n/jSite_de.properties | 3 +++ 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 9731ec5..f582bb2 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -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 -1 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; } /** diff --git a/src/net/pterodactylus/jsite/i18n/jSite.properties b/src/net/pterodactylus/jsite/i18n/jSite.properties index 02e72fd..e9b8faa 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite.properties @@ -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 diff --git a/src/net/pterodactylus/jsite/i18n/jSite_de.properties b/src/net/pterodactylus/jsite/i18n/jSite_de.properties index f6085bf..16c467a 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite_de.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite_de.properties @@ -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 -- 2.7.4