Java Code Examples for sun.awt.shell.ShellFolder#getShellFolder()

The following examples show how to use sun.awt.shell.ShellFolder#getShellFolder() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicFileChooserUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null && FilePane.usesShellFolder(fc)) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);

            if (shellFolder.isLink()) {
                File linkedTo = shellFolder.getLinkLocation();

                // If linkedTo is null we try to use dir
                if (linkedTo != null) {
                    if (fc.isTraversable(linkedTo)) {
                        dir = linkedTo;
                    } else {
                        return;
                    }
                } else {
                    dir = shellFolder;
                }
            }
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
        fc.getFileSystemView().isFileSystem(dir)) {

        setFileName(dir.getAbsolutePath());
    }
}
 
Example 2
Source File: BasicFileChooserUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null && FilePane.usesShellFolder(fc)) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);

            if (shellFolder.isLink()) {
                File linkedTo = shellFolder.getLinkLocation();

                // If linkedTo is null we try to use dir
                if (linkedTo != null) {
                    if (fc.isTraversable(linkedTo)) {
                        dir = linkedTo;
                    } else {
                        return;
                    }
                } else {
                    dir = shellFolder;
                }
            }
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
        fc.getFileSystemView().isFileSystem(dir)) {

        setFileName(dir.getAbsolutePath());
    }
}
 
Example 3
Source File: bug6798062.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private MyThread(int delay, String link) {
    this.delay = delay;

    ShellFolder linkFolder;

    try {
        linkFolder = ShellFolder.getShellFolder(new File(link));
    } catch (FileNotFoundException e) {
        e.printStackTrace();

        linkFolder = null;
    }

    this.link = linkFolder;
}
 
Example 4
Source File: BasicFileChooserUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null && FilePane.usesShellFolder(fc)) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);

            if (shellFolder.isLink()) {
                File linkedTo = shellFolder.getLinkLocation();

                // If linkedTo is null we try to use dir
                if (linkedTo != null) {
                    if (fc.isTraversable(linkedTo)) {
                        dir = linkedTo;
                    } else {
                        return;
                    }
                } else {
                    dir = shellFolder;
                }
            }
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
        fc.getFileSystemView().isFileSystem(dir)) {

        setFileName(dir.getAbsolutePath());
    }
}
 
Example 5
Source File: bug6798062.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private MyThread(int delay, String link) {
    this.delay = delay;

    ShellFolder linkFolder;

    try {
        linkFolder = ShellFolder.getShellFolder(new File(link));
    } catch (FileNotFoundException e) {
        e.printStackTrace();

        linkFolder = null;
    }

    this.link = linkFolder;
}
 
Example 6
Source File: bug6798062.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private MyThread(int delay, String link) {
    this.delay = delay;

    ShellFolder linkFolder;

    try {
        linkFolder = ShellFolder.getShellFolder(new File(link));
    } catch (FileNotFoundException e) {
        e.printStackTrace();

        linkFolder = null;
    }

    this.link = linkFolder;
}
 
Example 7
Source File: FileList.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private ShellFolder getShellFolder(File f) {
	try {
		return ShellFolder.getShellFolder(f);
	} catch (FileNotFoundException | InternalError e) {
		return null;
	}
}
 
Example 8
Source File: BasicFileChooserUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null && FilePane.usesShellFolder(fc)) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);

            if (shellFolder.isLink()) {
                File linkedTo = shellFolder.getLinkLocation();

                // If linkedTo is null we try to use dir
                if (linkedTo != null) {
                    if (fc.isTraversable(linkedTo)) {
                        dir = linkedTo;
                    } else {
                        return;
                    }
                } else {
                    dir = shellFolder;
                }
            }
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    if (fc.getFileSelectionMode() == JFileChooser.FILES_AND_DIRECTORIES &&
        fc.getFileSystemView().isFileSystem(dir)) {

        setFileName(dir.getAbsolutePath());
    }
}
 
Example 9
Source File: bug6798062.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private MyThread(int delay, String link) {
    this.delay = delay;

    ShellFolder linkFolder;

    try {
        linkFolder = ShellFolder.getShellFolder(new File(link));
    } catch (FileNotFoundException e) {
        e.printStackTrace();

        linkFolder = null;
    }

    this.link = linkFolder;
}
 
Example 10
Source File: MetalFileChooserUI.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 11
Source File: WindowsFileChooserUI.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = directory.getCanonicalFile();
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 12
Source File: FileChooserUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addItem(File directory) {
	if (directory == null) {
		return;
	}

	this.directories.clear();

	File[] baseFolders = this.fileSystemView.getRoots();
	this.directories.addAll(Arrays.asList(baseFolders));

	File canonical;
	try {
		canonical = directory.getCanonicalFile();
	} catch (IOException e) {
		canonical = directory;
	}
	File sf;
	if (!(this.fileSystemView instanceof RemoteFileSystemView)) {
		try {
			sf = ShellFolder.getShellFolder(canonical);
		} catch (FileNotFoundException ex) {
			sf = canonical;
		}
	} else {
		sf = canonical;
	}
	File f = sf;
	Vector<File> path = new Vector<>(10);
	do {
		path.addElement(f);
	} while ((f = fileSystemView.getParentDirectory(f)) != null);

	int pathCount = path.size();
	for (int i = 0; i < pathCount; i++) {
		f = path.get(i);
		if (this.directories.contains(f)) {
			int topIndex = this.directories.indexOf(f);
			for (int j = i - 1; j >= 0; j--) {
				this.directories.insertElementAt(path.get(j), topIndex + i - j);
			}
			break;
		}
	}
	calculateDepths();
	setSelectedItem(sf);
}
 
Example 13
Source File: MetalFileChooserUI.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 14
Source File: MetalFileChooserUI.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 15
Source File: SynthFileChooserUIImpl.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
public void addItem(File directory) {

    if (directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    int oldSize = directories.size();
    directories.clear();
    if (oldSize > 0) {
        fireIntervalRemoved(this, 0, oldSize);
    }

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 16
Source File: bug6741890.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test is applicable only for Windows. Skipped.");

        return;
    }

    String tmpDir = System.getProperty("java.io.tmpdir");

    if (tmpDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
        tmpDir = System.getProperty("user.home");
    }

    final ShellFolder tmpFile = ShellFolder.getShellFolder(new File(tmpDir));

    System.out.println("Temp directory: " + tmpDir);

    System.out.println("Stress test was run");

    Thread thread = new Thread() {
        public void run() {
            while (!isInterrupted()) {
                ShellFolder.invoke(new Callable<Void>() {
                    public Void call() throws Exception {
                        synchronized (mux) {
                            tmpFile.isFileSystem();
                            tmpFile.isLink();
                        }

                        return null;
                    }
                });
            }
        }
    };

    thread.start();

    for (int i = 0; i < COUNT; i++) {
        synchronized (mux) {
            clearField(tmpFile, "cachedIsLink");
            clearField(tmpFile, "cachedIsFileSystem");
        }

        tmpFile.isFileSystem();
        tmpFile.isLink();
    }

    thread.interrupt();
    thread.join();

    System.out.println("Test passed successfully");
}
 
Example 17
Source File: bug6741890.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test is applicable only for Windows. Skipped.");

        return;
    }

    String tmpDir = System.getProperty("java.io.tmpdir");

    if (tmpDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
        tmpDir = System.getProperty("user.home");
    }

    final ShellFolder tmpFile = ShellFolder.getShellFolder(new File(tmpDir));

    System.out.println("Temp directory: " + tmpDir);

    System.out.println("Stress test was run");

    Thread thread = new Thread() {
        public void run() {
            while (!isInterrupted()) {
                ShellFolder.invoke(new Callable<Void>() {
                    public Void call() throws Exception {
                        synchronized (mux) {
                            tmpFile.isFileSystem();
                            tmpFile.isLink();
                        }

                        return null;
                    }
                });
            }
        }
    };

    thread.start();

    for (int i = 0; i < COUNT; i++) {
        synchronized (mux) {
            clearField(tmpFile, "cachedIsLink");
            clearField(tmpFile, "cachedIsFileSystem");
        }

        tmpFile.isFileSystem();
        tmpFile.isLink();
    }

    thread.interrupt();
    thread.join();

    System.out.println("Test passed successfully");
}
 
Example 18
Source File: MetalFileChooserUI.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 19
Source File: DarkFileChooserUIBridge.java    From darklaf with MIT License 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected, additionally clears out the previous selected
 * directory and the paths leading up to it, if any.
 *
 * @param directory the directory
 */
protected void addItem(final File directory) {

    if (directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                : canonical;
        File f = sf;
        Vector<File> path = new Vector<>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i - 1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex + i - j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}
 
Example 20
Source File: MetalFileChooserUI.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Adds the directory to the model and sets it to be selected,
 * additionally clears out the previous selected directory and
 * the paths leading up to it, if any.
 */
private void addItem(File directory) {

    if(directory == null) {
        return;
    }

    boolean useShellFolder = FilePane.usesShellFolder(chooser);

    directories.clear();

    File[] baseFolders = (useShellFolder)
            ? (File[]) ShellFolder.get("fileChooserComboBoxFolders")
            : fsv.getRoots();
    directories.addAll(Arrays.asList(baseFolders));

    // Get the canonical (full) path. This has the side
    // benefit of removing extraneous chars from the path,
    // for example /foo/bar/ becomes /foo/bar
    File canonical;
    try {
        canonical = ShellFolder.getNormalizedFile(directory);
    } catch (IOException e) {
        // Maybe drive is not ready. Can't abort here.
        canonical = directory;
    }

    // create File instances of each directory leading up to the top
    try {
        File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
                                 : canonical;
        File f = sf;
        Vector<File> path = new Vector<File>(10);
        do {
            path.addElement(f);
        } while ((f = f.getParentFile()) != null);

        int pathCount = path.size();
        // Insert chain at appropriate place in vector
        for (int i = 0; i < pathCount; i++) {
            f = path.get(i);
            if (directories.contains(f)) {
                int topIndex = directories.indexOf(f);
                for (int j = i-1; j >= 0; j--) {
                    directories.insertElementAt(path.get(j), topIndex+i-j);
                }
                break;
            }
        }
        calculateDepths();
        setSelectedItem(sf);
    } catch (FileNotFoundException ex) {
        calculateDepths();
    }
}