Java Code Examples for sun.awt.shell.ShellFolder#isLink()
The following examples show how to use
sun.awt.shell.ShellFolder#isLink() .
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-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 Java8CN with Apache License 2.0 | 5 votes |
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 |
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 openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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: FileSystemView.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Checks if <code>f</code> represents a real directory or file as opposed to a * special folder such as <code>"Desktop"</code>. Used by UI classes to decide if * a folder is selectable when doing directory choosing. * * @param f a <code>File</code> object * @return <code>true</code> if <code>f</code> is a real file or directory. * @since 1.4 */ public boolean isFileSystem(File f) { if (f instanceof ShellFolder) { ShellFolder sf = (ShellFolder)f; // Shortcuts to directories are treated as not being file system objects, // so that they are never returned by JFileChooser. return sf.isFileSystem() && !(sf.isLink() && sf.isDirectory()); } else { return true; } }
Example 7
Source File: BasicFileChooserUI.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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 JDKSourceCode1.8 with MIT License | 5 votes |
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 jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 hottub with GNU General Public License v2.0 | 5 votes |
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 jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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: bug6741890.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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 15
Source File: bug6741890.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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 16
Source File: bug6741890.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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 hottub with GNU General Public License v2.0 | 4 votes |
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: bug6741890.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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 19
Source File: bug6741890.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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 20
Source File: bug6741890.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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"); }