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

The following examples show how to use sun.awt.shell.ShellFolder#getLinkLocation() . 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 openjdk-jdk9 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: 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 4
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 5
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 6
Source File: BasicFileChooserUI.java    From openjdk-8-source 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 7
Source File: BasicFileChooserUI.java    From hottub 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 8
Source File: BasicFileChooserUI.java    From Java8CN 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: 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 10
Source File: BasicFileChooserUI.java    From jdk1.8-source-analysis 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 11
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 12
Source File: BasicFileChooserUI.java    From openjdk-jdk8u-backup 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 13
Source File: BasicFileChooserUI.java    From openjdk-jdk8u 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 14
Source File: BasicFileChooserUI.java    From JDKSourceCode1.8 with MIT License 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 15
Source File: BasicFileChooserUI.java    From jdk8u60 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 16
Source File: BasicFileChooserUI.java    From TencentKona-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 17
Source File: BasicFileChooserUI.java    From dragonwell8_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 18
Source File: FileSystemView.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the regular file referenced by the specified link file if
 * the specified file is a shell interpreted link.
 * Returns {@code null} if the specified file is not
 * a shell interpreted link.
 *
 * @param file a file
 * @return the linked file or {@code null}.
 * @throws FileNotFoundException if the linked file does not exist
 * @throws NullPointerException if {@code file} equals {@code null}
 * @throws SecurityException if the caller does not have necessary
 *                           permissions
 * @since 9
 */
public File getLinkLocation(File file) throws FileNotFoundException {
    if (file == null) {
        throw new NullPointerException("file is null");
    }
    ShellFolder shellFolder;
    try {
        shellFolder = ShellFolder.getShellFolder(file);
    } catch (FileNotFoundException e) {
        return null;
    }
    return shellFolder.isLink() ? shellFolder.getLinkLocation() : null;
}