Notify user when the insert collided with the previous edition.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 21 Jan 2010 09:54:03 +0000 (10:54 +0100)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 21 Jan 2010 09:54:03 +0000 (10:54 +0100)
src/de/todesbaum/jsite/gui/ProjectInsertPage.java
src/de/todesbaum/jsite/i18n/jSite.properties
src/de/todesbaum/jsite/i18n/jSite_de.properties

index 2cedd5b..a93dd44 100644 (file)
@@ -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);
+               }
        }
 
        /**
index f7991e3..ff74685 100644 (file)
@@ -90,6 +90,8 @@ jsite.insert.insert-failed-with-cause=<html><b>Insert failed</b><br><br>The inse
 jsite.insert.inserted=<html><b>Project inserted</b><br><br>Your project was inserted successfully.</html>
 jsite.insert.okay=OK
 jsite.insert.okay-copy-uri=Copy URI to Clipboard
+jsite.insert.reinserted-edition=<html><b>Edition Reinserted</b><br><br>The edition you are just inserting<br>has already been inserted before.</html>
+jsite.insert.reinserted-edition.title=Edition Reinserted
 
 jsite.file-scanner.can-not-read-directory=Can not read directory
 
index e9409d2..67dc81c 100644 (file)
@@ -90,6 +90,8 @@ jsite.insert.insert-failed-with-cause=<html><b>Einf\u00fcgen fehlgeschlagen</b><
 jsite.insert.inserted=<html><b>Projekt eingef\u00fcgt</b><br><br>Ihr Projekt wurde erfolgreich eingef\u00fcgt.</html>
 jsite.insert.okay=OK
 jsite.insert.okay-copy-uri=URI kopieren
+jsite.insert.reinserted-edition=<html><b>Edition bereits eingef\u00fcgt</b><br><br>Die Edition, die gerade eingef\u00fcgt wird,<br>ist schon einmal eingef\u00fcgt worden.</html>
+jsite.insert.reinserted-edition.title=Edition bereits eingef\u00fcgt
 
 jsite.file-scanner.can-not-read-directory=Kann Verzeichnis nicht lesen