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

The following examples show how to use sun.awt.shell.ShellFolder#get() . 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: bug6840086.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test was skipped because it is sensible only for Windows.");

        return;
    }

    for (String key : KEYS) {
        Image image = (Image) ShellFolder.get(key);

        if (image == null) {
            throw new RuntimeException("The image '" + key + "' not found.");
        }

        if (image != ShellFolder.get(key)) {
            throw new RuntimeException("The image '" + key + "' is not cached.");
        }
    }

    System.out.println("The test passed.");
}
 
Example 2
Source File: bug6840086.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test was skipped because it is sensible only for Windows.");

        return;
    }

    for (String key : KEYS) {
        Image image = (Image) ShellFolder.get(key);

        if (image == null) {
            throw new RuntimeException("The image '" + key + "' not found.");
        }

        if (image != ShellFolder.get(key)) {
            throw new RuntimeException("The image '" + key + "' is not cached.");
        }
    }

    System.out.println("The test passed.");
}
 
Example 3
Source File: bug6840086.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test was skipped because it is sensible only for Windows.");

        return;
    }

    for (String key : KEYS) {
        Image image = (Image) ShellFolder.get(key);

        if (image == null) {
            throw new RuntimeException("The image '" + key + "' not found.");
        }

        if (image != ShellFolder.get(key)) {
            throw new RuntimeException("The image '" + key + "' is not cached.");
        }
    }

    System.out.println("The test passed.");
}
 
Example 4
Source File: bug6840086.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
        System.out.println("The test was skipped because it is sensible only for Windows.");

        return;
    }

    for (String key : KEYS) {
        Image image = (Image) ShellFolder.get(key);

        if (image == null) {
            throw new RuntimeException("The image '" + key + "' not found.");
        }

        if (image != ShellFolder.get(key)) {
            throw new RuntimeException("The image '" + key + "' is not cached.");
        }
    }

    System.out.println("The test passed.");
}
 
Example 5
Source File: WindowsLookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object createValue(UIDefaults table) {
    if (icon == null) {
        Image image = (Image)ShellFolder.get(nativeImageName);
        if (image != null) {
            icon = new ImageIconUIResource(image);
        }
    }
    if (icon == null && fallbackName != null) {
        UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
                SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
                    BasicLookAndFeel.class, fallbackName);
        icon = (Icon) fallback.createValue(table);
    }
    return icon;
}
 
Example 6
Source File: WindowsLookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object createValue(UIDefaults table) {
    if (icon == null) {
        Image image = (Image)ShellFolder.get(nativeImageName);
        if (image != null) {
            icon = new ImageIconUIResource(image);
        }
    }
    if (icon == null && fallbackName != null) {
        UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
                SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
                    BasicLookAndFeel.class, fallbackName);
        icon = (Icon) fallback.createValue(table);
    }
    return icon;
}
 
Example 7
Source File: WindowsLookAndFeel.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public Object createValue(UIDefaults table) {
    if (nativeImage != null) {
        Image image = (Image)ShellFolder.get(nativeImage);
        if (image != null) {
            return new ImageIcon(image);
        }
    }
    return SwingUtilities2.makeIcon(getClass(),
                                    WindowsLookAndFeel.class,
                                    resource);
}
 
Example 8
Source File: bug6945316.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 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 suitable only for Windows OS. Skipped.");

        return;
    }

    // Init toolkit because it shouldn't be interrupted while initialization
    Toolkit.getDefaultToolkit();

    // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
    ShellFolder.get("fileChooserComboBoxFolders");

    // To get NPE the path must obey the following rules:
    // path.length() == 3 && path.charAt(1) == ':'
    final File tempFile = new File("c:\\");

    for (int i = 0; i < 10000; i++) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final Thread thread = new Thread() {
            public void run() {
                countDownLatch.countDown();

                ShellFolder.isFileSystemRoot(tempFile);
            }
        };

        thread.start();

        countDownLatch.await();

        thread.interrupt();
    }
}
 
Example 9
Source File: WindowsLookAndFeel.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Object createValue(UIDefaults table) {
    if (nativeImage != null) {
        Image image = (Image)ShellFolder.get(nativeImage);
        if (image != null) {
            return new ImageIcon(image);
        }
    }
    return SwingUtilities2.makeIcon(getClass(),
                                    WindowsLookAndFeel.class,
                                    resource);
}
 
Example 10
Source File: bug6945316.java    From hottub with GNU General Public License v2.0 5 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 suitable only for Windows OS. Skipped.");

        return;
    }

    // Init toolkit because it shouldn't be interrupted while initialization
    Toolkit.getDefaultToolkit();

    // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
    ShellFolder.get("fileChooserComboBoxFolders");

    // To get NPE the path must obey the following rules:
    // path.length() == 3 && path.charAt(1) == ':'
    final File tempFile = new File("c:\\");

    for (int i = 0; i < 10000; i++) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final Thread thread = new Thread() {
            public void run() {
                countDownLatch.countDown();

                ShellFolder.isFileSystemRoot(tempFile);
            }
        };

        thread.start();

        countDownLatch.await();

        thread.interrupt();
    }
}
 
Example 11
Source File: bug6945316.java    From dragonwell8_jdk with GNU General Public License v2.0 5 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 suitable only for Windows OS. Skipped.");

        return;
    }

    // Init toolkit because it shouldn't be interrupted while initialization
    Toolkit.getDefaultToolkit();

    // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
    ShellFolder.get("fileChooserComboBoxFolders");

    // To get NPE the path must obey the following rules:
    // path.length() == 3 && path.charAt(1) == ':'
    final File tempFile = new File("c:\\");

    for (int i = 0; i < 10000; i++) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final Thread thread = new Thread() {
            public void run() {
                countDownLatch.countDown();

                ShellFolder.isFileSystemRoot(tempFile);
            }
        };

        thread.start();

        countDownLatch.await();

        thread.interrupt();
    }
}
 
Example 12
Source File: FileSystemView.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Return the user's default starting directory for the file chooser.
 *
 * @return a <code>File</code> object representing the default
 *         starting folder
 * @since 1.4
 */
public File getDefaultDirectory() {
    File f = (File)ShellFolder.get("fileChooserDefaultFolder");
    if (isFileSystemRoot(f)) {
        f = createFileSystemRoot(f);
    }
    return f;
}
 
Example 13
Source File: bug6945316.java    From jdk8u-jdk with GNU General Public License v2.0 5 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 suitable only for Windows OS. Skipped.");

        return;
    }

    // Init toolkit because it shouldn't be interrupted while initialization
    Toolkit.getDefaultToolkit();

    // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
    ShellFolder.get("fileChooserComboBoxFolders");

    // To get NPE the path must obey the following rules:
    // path.length() == 3 && path.charAt(1) == ':'
    final File tempFile = new File("c:\\");

    for (int i = 0; i < 10000; i++) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final Thread thread = new Thread() {
            public void run() {
                countDownLatch.countDown();

                ShellFolder.isFileSystemRoot(tempFile);
            }
        };

        thread.start();

        countDownLatch.await();

        thread.interrupt();
    }
}
 
Example 14
Source File: bug6945316.java    From TencentKona-8 with GNU General Public License v2.0 5 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 suitable only for Windows OS. Skipped.");

        return;
    }

    // Init toolkit because it shouldn't be interrupted while initialization
    Toolkit.getDefaultToolkit();

    // Init the sun.awt.shell.Win32ShellFolderManager2.drives field
    ShellFolder.get("fileChooserComboBoxFolders");

    // To get NPE the path must obey the following rules:
    // path.length() == 3 && path.charAt(1) == ':'
    final File tempFile = new File("c:\\");

    for (int i = 0; i < 10000; i++) {
        final CountDownLatch countDownLatch = new CountDownLatch(1);

        final Thread thread = new Thread() {
            public void run() {
                countDownLatch.countDown();

                ShellFolder.isFileSystemRoot(tempFile);
            }
        };

        thread.start();

        countDownLatch.await();

        thread.interrupt();
    }
}
 
Example 15
Source File: WindowsLookAndFeel.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public Object createValue(UIDefaults table) {
    if (nativeImage != null) {
        Image image = (Image)ShellFolder.get(nativeImage);
        if (image != null) {
            return new ImageIcon(image);
        }
    }
    return SwingUtilities2.makeIcon(getClass(),
                                    WindowsLookAndFeel.class,
                                    resource);
}
 
Example 16
Source File: SynthFileChooserUIImpl.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.
 */
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 17
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 18
Source File: SynthFileChooserUIImpl.java    From openjdk-jdk9 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 19
Source File: SynthFileChooserUIImpl.java    From jdk8u-dev-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 20
Source File: WindowsFileChooserUI.java    From jdk8u60 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();
    }
}