From 3d68925f513f8e31eb34dcb1fc11e70faee847e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 27 May 2008 21:05:05 +0200 Subject: [PATCH] implement project deletion --- src/net/pterodactylus/jsite/gui/MainWindow.java | 28 ++++++++++++---------- .../pterodactylus/jsite/gui/SwingInterface.java | 15 ++++++++---- src/net/pterodactylus/jsite/i18n/jSite.properties | 13 ++++++---- .../pterodactylus/jsite/i18n/jSite_de.properties | 3 +++ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/net/pterodactylus/jsite/gui/MainWindow.java b/src/net/pterodactylus/jsite/gui/MainWindow.java index 843eaa1..1d536c8 100644 --- a/src/net/pterodactylus/jsite/gui/MainWindow.java +++ b/src/net/pterodactylus/jsite/gui/MainWindow.java @@ -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) { diff --git a/src/net/pterodactylus/jsite/gui/SwingInterface.java b/src/net/pterodactylus/jsite/gui/SwingInterface.java index 2c032ea..e5f569c 100644 --- a/src/net/pterodactylus/jsite/gui/SwingInterface.java +++ b/src/net/pterodactylus/jsite/gui/SwingInterface.java @@ -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); } /** diff --git a/src/net/pterodactylus/jsite/i18n/jSite.properties b/src/net/pterodactylus/jsite/i18n/jSite.properties index 1305a77..d9241aa 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite.properties @@ -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: You are about to remove the node \u201c{0}\u201d!
Do you want to continue? + +mainWindow.question.deleteProject.title: Really Delete Project? +mainWindow.question.deleteProject.message: You are about to remove the project \u201c{0}\u201d!
Do you want to continue? mainWindow.information.changeProjectBasePath.title: Please Enter Base Path! mainWindow.information.changeProjectBasePath.message: You have created a new project. Please enter a base path
to read the files for the project from in the next dialog! @@ -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 diff --git a/src/net/pterodactylus/jsite/i18n/jSite_de.properties b/src/net/pterodactylus/jsite/i18n/jSite_de.properties index a1c9b02..86a1e6b 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite_de.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite_de.properties @@ -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: Ein neues Projekt wurde erstellt. Bitte im
n\u00e4chsten Dialog einen Basispfad f\u00fcr die Dateien angeben! -- 2.7.4