From 321a7a1d782260f91d1cdbe8eece1c20909b83ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 9 Jun 2011 21:22:38 +0200 Subject: [PATCH] Only allow files in the root directory to be selected as index files. This fixes #116. --- src/de/todesbaum/jsite/gui/ProjectFilesPage.java | 11 +++++++++-- src/de/todesbaum/jsite/i18n/jSite.properties | 1 + src/de/todesbaum/jsite/i18n/jSite_de.properties | 1 + src/de/todesbaum/jsite/main/Configuration.java | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java index fd9ae2f..ff4a6fb 100644 --- a/src/de/todesbaum/jsite/gui/ProjectFilesPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectFilesPage.java @@ -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(); diff --git a/src/de/todesbaum/jsite/i18n/jSite.properties b/src/de/todesbaum/jsite/i18n/jSite.properties index 5b1dc7f..e28e221 100644 --- a/src/de/todesbaum/jsite/i18n/jSite.properties +++ b/src/de/todesbaum/jsite/i18n/jSite.properties @@ -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=Error scanning files

Either the directory of the project does not exist
or some files/directories in it are not accessible.
Please go back and select the correct directory. 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=A new version was found.

Version {0} (released {1,date}) diff --git a/src/de/todesbaum/jsite/i18n/jSite_de.properties b/src/de/todesbaum/jsite/i18n/jSite_de.properties index d499982..6ed4544 100644 --- a/src/de/todesbaum/jsite/i18n/jSite_de.properties +++ b/src/de/todesbaum/jsite/i18n/jSite_de.properties @@ -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=Fehler beim Einlesen der Dateien

Entweder existiert das Projektverzeichnis nicht,
oder einige Dateien und/oder Verzeichnisse sind nicht lesbar!
Bitte gehen Sie zur\u00fcck und beheben Sie den Fehler! 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=Eine neue Version wurde gefunden.

Version {0} (ver\u00f6ffentlicht {1,date}) diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index e98a18d..d03d70a 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -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("")); -- 2.7.4