/** * Recursively rebuild the tree nodes. * * @param root The full abstract path to the root saved layout directory. * @param local The current directory relative to root (null if none). * @param tnode The current parent tree node. */ private void rebuildTreeModel(Path root, Path local, DefaultMutableTreeNode tnode) { TreeSet<Path> subdirs = new TreeSet<Path>(); TreeSet<String> layouts = new TreeSet<String>(); { Path current = new Path(root, local); File files[] = current.toFile().listFiles(); if (files != null) { int wk; for (wk = 0; wk < files.length; wk++) { String name = files[wk].getName(); if (files[wk].isDirectory()) subdirs.add(new Path(local, name)); else if (files[wk].isFile()) layouts.add(name); } } } for (Path subdir : subdirs) { TreeData data = new TreeData(subdir); DefaultMutableTreeNode child = new DefaultMutableTreeNode(data, true); tnode.add(child); rebuildTreeModel(root, subdir, child); } for (String lname : layouts) { TreeData data = new TreeData(new Path(local, lname), lname); DefaultMutableTreeNode child = new DefaultMutableTreeNode(data, false); tnode.add(child); } }
public Path dateiAuswählen(Path neuesLaufwerk) { JFileChooser fc1 = new JFileChooser(); fc1.setDialogTitle("SyncOrdner auswählen"); fc1.setCurrentDirectory(neuesLaufwerk.toFile()); fc1.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fc1.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) return fc1.getSelectedFile().toPath(); else return null; }