From d7d24bc3d5dc056b5e63431b06f6aa5f71f4f672 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 21 Jan 2010 10:54:03 +0100 Subject: [PATCH] Notify user when the insert collided with the previous edition. --- src/de/todesbaum/jsite/gui/ProjectInsertPage.java | 24 +++++++++++++++++++++++ src/de/todesbaum/jsite/i18n/jSite.properties | 2 ++ src/de/todesbaum/jsite/i18n/jSite_de.properties | 2 ++ 3 files changed, 28 insertions(+) diff --git a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java index 2cedd5b..a93dd44 100644 --- a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java @@ -34,6 +34,8 @@ import java.awt.event.KeyEvent; import java.text.DateFormat; import java.text.MessageFormat; import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; @@ -62,6 +64,9 @@ import de.todesbaum.util.swing.TWizardPage; */ public class ProjectInsertPage extends TWizardPage implements InsertListener, ClipboardOwner { + /** The logger. */ + private static final Logger logger = Logger.getLogger(ProjectInsertPage.class.getName()); + /** The project inserter. */ private ProjectInserter projectInserter; @@ -300,6 +305,25 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl requestURITextField.setText(uri); } }); + logger.log(Level.FINEST, "Insert generated URI: " + uri); + int slash = uri.indexOf('/'); + slash = uri.indexOf('/', slash + 1); + int secondSlash = uri.indexOf('/', slash + 1); + if (secondSlash == -1) { + secondSlash = uri.length(); + } + String editionNumber = uri.substring(slash + 1, secondSlash); + logger.log(Level.FINEST, "Extracted edition number: " + editionNumber); + int edition = -1; + try { + edition = Integer.valueOf(editionNumber); + } catch (NumberFormatException nfe1) { + /* ignore. */ + } + logger.log(Level.FINEST, "Insert edition: " + edition + ", Project edition: " + project.getEdition()); + if ((edition != -1) && (edition == project.getEdition())) { + JOptionPane.showMessageDialog(this, I18n.getMessage("jsite.insert.reinserted-edition"), I18n.getMessage("jsite.insert.reinserted-edition.title"), JOptionPane.INFORMATION_MESSAGE); + } } /** diff --git a/src/de/todesbaum/jsite/i18n/jSite.properties b/src/de/todesbaum/jsite/i18n/jSite.properties index f7991e3..ff74685 100644 --- a/src/de/todesbaum/jsite/i18n/jSite.properties +++ b/src/de/todesbaum/jsite/i18n/jSite.properties @@ -90,6 +90,8 @@ jsite.insert.insert-failed-with-cause=Insert failed

The inse jsite.insert.inserted=Project inserted

Your project was inserted successfully. jsite.insert.okay=OK jsite.insert.okay-copy-uri=Copy URI to Clipboard +jsite.insert.reinserted-edition=Edition Reinserted

The edition you are just inserting
has already been inserted before. +jsite.insert.reinserted-edition.title=Edition Reinserted jsite.file-scanner.can-not-read-directory=Can not read directory diff --git a/src/de/todesbaum/jsite/i18n/jSite_de.properties b/src/de/todesbaum/jsite/i18n/jSite_de.properties index e9409d2..67dc81c 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_de.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_de.properties @@ -90,6 +90,8 @@ jsite.insert.insert-failed-with-cause=Einf\u00fcgen fehlgeschlagen< jsite.insert.inserted=Projekt eingef\u00fcgt

Ihr Projekt wurde erfolgreich eingef\u00fcgt. jsite.insert.okay=OK jsite.insert.okay-copy-uri=URI kopieren +jsite.insert.reinserted-edition=Edition bereits eingef\u00fcgt

Die Edition, die gerade eingef\u00fcgt wird,
ist schon einmal eingef\u00fcgt worden. +jsite.insert.reinserted-edition.title=Edition bereits eingef\u00fcgt jsite.file-scanner.can-not-read-directory=Kann Verzeichnis nicht lesen -- 2.7.4