/** Name of the “private key” property. */
public static final String PROPERTY_PRIVATE_KEY = "privateKey";
- /** Name of the “local path” property. */
+ /** Name of the “base path” property. */
public static final String PROPERTY_BASE_PATH = "basePath";
+ /** Name of the “base path entries” property. */
+ public static final String PROPERTY_BASE_PATH_ENTRIES = "basePathEntries";
+
/** Internal ID. */
private String id;
/** The base path of the project. */
private String basePath;
- /** The list of files from the base path. */
- private List<Entry> basePathEntries = new ArrayList<Entry>();
+ /** The list of files from the base path. */
+ private List<Entry> basePathEntries = new ArrayList<Entry>();
/**
* Returns the internal ID.
}
/**
- * Rescans the base path for new or changed files.
- */
- public void rescanBasePath() {
- List<Entry> entries = new ArrayList<Entry>();
- scanPath("", entries);
- }
-
- /**
- * Returns the list of files from the base path.
- *
- * @return The list of files from the base path
- */
- public List<Entry> getBasePathEntries() {
- return basePathEntries;
- }
-
- //
- // PRIVATE METHODS
- //
-
- /**
- * Scans the given path relative to {@link #basePath} for files and adds
- * them to the given list of entries.
- *
- * @param currentPath
- * The current path, relative to the base path
- * @param entries
- * The list of entries
- */
- private void scanPath(String currentPath, List<Entry> entries) {
- File currentDirectory = new File(basePath + File.separatorChar + currentPath);
- if (!currentDirectory.isDirectory()) {
- return;
+ * Rescans the base path for new or changed files.
+ */
+ public void rescanBasePath() {
+ List<Entry> entries = new ArrayList<Entry>();
+ scanPath("", entries);
+ basePathEntries.clear();
+ basePathEntries.addAll(entries);
+ firePropertyChange(PROPERTY_BASE_PATH_ENTRIES, null, null);
+ }
+
+ /**
+ * Returns the list of files from the base path.
+ *
+ * @return The list of files from the base path
+ */
+ public List<Entry> getBasePathEntries() {
+ return basePathEntries;
+ }
+
+ //
+ // PRIVATE METHODS
+ //
+
+ /**
+ * Scans the given path relative to {@link #basePath} for files and adds
+ * them to the given list of entries.
+ *
+ * @param currentPath
+ * The current path, relative to the base path
+ * @param entries
+ * The list of entries
+ */
+ private void scanPath(String currentPath, List<Entry> entries) {
+ File currentDirectory = new File(basePath + File.separatorChar + currentPath);
+ if (!currentDirectory.isDirectory()) {
+ return;
+ }
+ for (File file: currentDirectory.listFiles()) {
+ String fileName = currentPath + file.getName();
+ if (file.isDirectory()) {
+ scanPath(fileName + File.separatorChar, entries);
+ continue;
+ }
+ PhysicalEntry entry = new PhysicalEntry();
+ entry.setName(fileName);
+ entry.setPath(file.getPath());
+ entry.setInsert(!file.isHidden());
+ entries.add(entry);
}
- for (File file: currentDirectory.listFiles()) {
- String fileName = currentPath + file.getName();
- if (file.isDirectory()) {
- scanPath(fileName + File.separatorChar, entries);
- continue;
- }
- PhysicalEntry entry = new PhysicalEntry();
- entry.setName(fileName);
- entry.setPath(file.getPath());
- entry.setInsert(!file.isHidden());
- entries.add(entry);
- }
}
}