001 package nl.cwi.sen1.gui.plugin;
002
003 import java.io.File;
004 import java.util.Arrays;
005 import java.util.List;
006
007 import javax.swing.filechooser.FileSystemView;
008
009 import nl.cwi.sen1.configapi.types.Property;
010 import nl.cwi.sen1.configapi.types.PropertyList;
011
012 public class DialogFileSystemView extends FileSystemView {
013 File[] roots;
014 String[] labels;
015
016 public DialogFileSystemView(PropertyList props) {
017 roots = new File[props.getLength()];
018 labels = new String[props.getLength()];
019
020 for (int i = 0; !props.isEmpty(); i++) {
021 Property root = props.getHead();
022
023 roots[i] = new File(root.getPath());
024 labels[i] = root.getLabel();
025
026 props = props.getTail();
027 }
028 }
029
030 public File createNewFolder(File containingDir) {
031 return null;
032 }
033
034 public File[] getRoots() {
035 return roots;
036 }
037
038 public String getRootLabel(File root) {
039 List<File> rootList = Arrays.asList(roots);
040 return labels[rootList.indexOf(root)];
041 }
042
043 public File getHomeDirectory() {
044 if (roots.length > 0) {
045 return roots[0];
046 }
047 return null;
048 }
049
050 public File getDefaultDirectory() {
051 return getHomeDirectory();
052 }
053 }