Only allow files in the root directory to be selected as index files.
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 9 Jun 2011 19:22:38 +0000 (21:22 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Thu, 3 Nov 2011 07:45:18 +0000 (08:45 +0100)
This fixes #116.

src/de/todesbaum/jsite/gui/ProjectFilesPage.java
src/de/todesbaum/jsite/i18n/jSite.properties
src/de/todesbaum/jsite/i18n/jSite_de.properties
src/de/todesbaum/jsite/main/Configuration.java

index fd9ae2f..ff4a6fb 100644 (file)
@@ -634,9 +634,16 @@ public class ProjectFilesPage extends TWizardPage implements ActionListener, Lis
                        JCheckBox checkBox = (JCheckBox) source;
                        if ("default-file".equals(checkBox.getName())) {
                                if (checkBox.isSelected()) {
-                                       project.setIndexFile(filename);
+                                       if (filename.indexOf('/') > -1) {
+                                               JOptionPane.showMessageDialog(wizard, I18n.getMessage("jsite.project-files.invalid-default-file"), null, JOptionPane.ERROR_MESSAGE);
+                                               checkBox.setSelected(false);
+                                       } else {
+                                               project.setIndexFile(filename);
+                                       }
                                } else {
-                                       project.setIndexFile(null);
+                                       if (filename.equals(project.getIndexFile())) {
+                                               project.setIndexFile(null);
+                                       }
                                }
                        } else if ("insert".equals(checkBox.getName())) {
                                boolean isInsert = checkBox.isSelected();
index 5b1dc7f..e28e221 100644 (file)
@@ -166,6 +166,7 @@ jsite.project-files.replacement.edition-range=Range
 jsite.project-files.replacement.edition-range.tooltip=Also replace $[EDITION+1], $[EDITION+2]\u2026
 jsite.project-files.scan-error=<html><b>Error scanning files</b><br><br>Either the directory of the project does not exist<br>or some files/directories in it are not accessible.<br>Please go back and select the correct directory.</html>
 jsite.project-files.insert-now=Insert now
+jsite.project-files.invalid-default-file=Only files in the root directory may be selected as default files.
 
 jsite.update-checker.found-version.title=Found New Version
 jsite.update-checker.found-version.message=<html>A new version was found.<br><br>Version {0} (released {1,date})</html>
index d499982..6ed4544 100644 (file)
@@ -166,6 +166,7 @@ jsite.project-files.replacement.edition-range=Reichweite
 jsite.project-files.replacement.edition-range.tooltip=Ersetzt auch $[EDITION+1], $[EDITION+2], usw.
 jsite.project-files.scan-error=<html><b>Fehler beim Einlesen der Dateien</b><br><br>Entweder existiert das Projektverzeichnis nicht,<br>oder einige Dateien und/oder Verzeichnisse sind nicht lesbar!<br>Bitte gehen Sie zur\u00fcck und beheben Sie den Fehler!</html>
 jsite.project-files.insert-now=Jetzt einf\u00fcgen
+jsite.project-files.invalid-default-file=Nur Dateien im obersten Verzeichnis d\u00fcrfen als Index-Dateien ausgew\u00e4hlt werden.
 
 jsite.update-checker.found-version.title=Neue Version gefunden
 jsite.update-checker.found-version.message=<html>Eine neue Version wurde gefunden.<br><br>Version {0} (ver\u00f6ffentlicht {1,date})</html>
index e98a18d..d03d70a 100644 (file)
@@ -332,7 +332,11 @@ public class Configuration {
                                        Project project = new Project();
                                        projects.add(project);
                                        project.setDescription(projectNode.getNode("description").getValue(""));
-                                       project.setIndexFile(projectNode.getNode("index-file").getValue(""));
+                                       String indexFile = projectNode.getNode("index-file").getValue("");
+                                       if (indexFile.indexOf('/') > -1) {
+                                               indexFile = "";
+                                       }
+                                       project.setIndexFile(indexFile);
                                        project.setLastInsertionTime(Long.parseLong(projectNode.getNode("last-insertion-time").getValue("0")));
                                        project.setLocalPath(projectNode.getNode("local-path").getValue(""));
                                        project.setName(projectNode.getNode("name").getValue(""));