From 082365513bbf73d143f2b796d8c23cf5ff4446dc Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 29 May 2008 18:09:50 +0200 Subject: [PATCH] work on new project file backend --- src/net/pterodactylus/jsite/gui/FileManager.java | 12 ++++ src/net/pterodactylus/jsite/i18n/jSite.properties | 3 + .../pterodactylus/jsite/i18n/jSite_de.properties | 3 + src/net/pterodactylus/jsite/project/Project.java | 71 +++++++++++++++++++ .../pterodactylus/jsite/project/ProjectFile.java | 81 ++++++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 src/net/pterodactylus/jsite/project/ProjectFile.java diff --git a/src/net/pterodactylus/jsite/gui/FileManager.java b/src/net/pterodactylus/jsite/gui/FileManager.java index cb33c11..c961280 100644 --- a/src/net/pterodactylus/jsite/gui/FileManager.java +++ b/src/net/pterodactylus/jsite/gui/FileManager.java @@ -119,6 +119,12 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr /** The “file name” textfield. */ private JTextField fileNameTextField; + /** The “file size” label. */ + private I18nLabel fileSizeLabel; + + /** The “file size” text field. */ + private JTextField fileSizeTextField; + /** * Creates a new file manager. * @@ -247,6 +253,12 @@ public class FileManager extends JDialog implements I18nable, ActionListener, Tr propertiesPanel.add(fileNameLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0)); propertiesPanel.add(fileNameTextField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0)); + fileSizeLabel = new I18nLabel("fileManager.label.fileSize"); + fileSizeTextField = new JTextField(); + fileSizeTextField.setEditable(false); + propertiesPanel.add(fileSizeLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 24, 0, 0), 0, 0)); + propertiesPanel.add(fileSizeTextField, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(12, 12, 0, 0), 0, 0)); + /* glue panel. */ propertiesPanel.add(new JPanel(), new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); diff --git a/src/net/pterodactylus/jsite/i18n/jSite.properties b/src/net/pterodactylus/jsite/i18n/jSite.properties index 3d84880..1f8b7ee 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite.properties @@ -352,6 +352,9 @@ fileManager.label.filePath.mnemonic: VK_UNDEFINED fileManager.label.fileName.name: File name fileManager.label.fileName.mnemonic: VK_UNDEFINED +fileManager.label.fileName.name: File size +fileManager.label.fileName.mnemonic: VK_UNDEFINED + fileManager.checkbox.insertFile.name: Insert file fileManager.checkbox.insertFile.mnemonic: VK_I fileManager.checkbox.insertFile.accelerator: Ctrl-VK_I diff --git a/src/net/pterodactylus/jsite/i18n/jSite_de.properties b/src/net/pterodactylus/jsite/i18n/jSite_de.properties index 361fe72..4ab7f36 100644 --- a/src/net/pterodactylus/jsite/i18n/jSite_de.properties +++ b/src/net/pterodactylus/jsite/i18n/jSite_de.properties @@ -352,6 +352,9 @@ fileManager.label.filePath.mnemonic: VK_UNDEFINED fileManager.label.fileName.name: Dateiname fileManager.label.fileName.mnemonic: VK_UNDEFINED +fileManager.label.fileName.name: Dateigr\u00f6\u00dfe +fileManager.label.fileName.mnemonic: VK_UNDEFINED + fileManager.checkbox.insertFile.name: Datei einf\u00fcgen fileManager.checkbox.insertFile.mnemonic: VK_E fileManager.checkbox.insertFile.accelerator: Ctrl-VK_E diff --git a/src/net/pterodactylus/jsite/project/Project.java b/src/net/pterodactylus/jsite/project/Project.java index e6f732b..44ffaff 100644 --- a/src/net/pterodactylus/jsite/project/Project.java +++ b/src/net/pterodactylus/jsite/project/Project.java @@ -21,6 +21,7 @@ package net.pterodactylus.jsite.project; import java.beans.PropertyChangeListener; import java.util.HashMap; +import java.util.List; import java.util.Map; import net.pterodactylus.util.beans.AbstractBean; @@ -271,4 +272,74 @@ public class Project extends AbstractBean { return overrides; } + /** + * Scans the base path for files and returns the {@link ProjectFile} for the + * base path. From this file it is possible to reach all files in the base + * path. + * + * This method is disk-intensive and may take some time on larger + * directories! + * + * @return The file for the base path + */ + public ProjectFile getBaseFile() { + + } + + /** + * Implementation of a {@link ProjectFile}. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ + private static class ProjectFileImpl implements ProjectFile { + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#getName() + */ + public String getName() { + // TODO Auto-generated method stub + return null; + } + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#getParents() + */ + public List getParents() { + // TODO Auto-generated method stub + return null; + } + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#isFile() + */ + public boolean isFile() { + // TODO Auto-generated method stub + return false; + } + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#isDirectory() + */ + public boolean isDirectory() { + // TODO Auto-generated method stub + return false; + } + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#isHidden() + */ + public boolean isHidden() { + // TODO Auto-generated method stub + return false; + } + + /** + * @see net.pterodactylus.jsite.project.ProjectFile#getFiles() + */ + public List getFiles() { + // TODO Auto-generated method stub + return null; + } + } + } diff --git a/src/net/pterodactylus/jsite/project/ProjectFile.java b/src/net/pterodactylus/jsite/project/ProjectFile.java new file mode 100644 index 0000000..3e170fd --- /dev/null +++ b/src/net/pterodactylus/jsite/project/ProjectFile.java @@ -0,0 +1,81 @@ +/* + * jSite2 - ProjectFile.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +package net.pterodactylus.jsite.project; + +import java.util.List; + +import net.pterodactylus.jsite.core.Core; + +/** + * Abstraction for a that exists on the machine {@link Core} is being run on. + * This abstraction layer exists to make it possible to run jSite as a daemon + * and only connect to it via network. + * + * @author David ‘Bombe’ Roden <bombe@freenetproject.org> + */ +public interface ProjectFile { + + /** + * Returns the name of the file. + * + * @return The name of the file + */ + public String getName(); + + /** + * Returns all parent files of this file. This file is the last file in the + * returned list. + * + * @return A list of all parents of this file and this file itself + */ + public List getParents(); + + /** + * Returns whether this file is a directory. + * + * @return true if this file is a directory, + * false otherwise + */ + public boolean isDirectory(); + + /** + * Returns whether this file is a file (as opposed to being a directory). + * + * @return true if this file is a file, false + * otherwise + */ + public boolean isFile(); + + /** + * Returns whether this file is hidden. + * + * @return true if this file is hidden + */ + public boolean isHidden(); + + /** + * If this file is a directory, returns all files in this directory. + * + * @see #isDirectory() + * @return All files in this directory if this file is a directory, or + * null if this file is not a directory + */ + public List getFiles(); + +} -- 2.7.4