Java Code Examples for javax.swing.filechooser.FileSystemView#getFiles()

The following examples show how to use javax.swing.filechooser.FileSystemView#getFiles() . 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: bug8003399.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
            OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) {
        FileSystemView fsv = FileSystemView.getFileSystemView();
        for (File file : fsv.getFiles(fsv.getHomeDirectory(), false)) {
            if(file.isDirectory()) {
                for (File file1 : fsv.getFiles(file, false)) {
                    if(file1.isDirectory())
                    {
                        String path = file1.getPath();
                        if(path.startsWith("::{") &&
                                path.toLowerCase().endsWith(".library-ms")) {
                            throw new RuntimeException("Unconverted library link found");
                        }
                    }
                }
            }
        }
    }
    System.out.println("ok");
}
 
Example 2
Source File: JarTool.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used by removeDirectory (File)
 * @param directory File
 * @param fsView FileSystemView
 */
static private boolean recursiveClearDirectory(File directory, FileSystemView fsView) {
  File files[] = fsView.getFiles(directory, false);
  for(int i = 0; i<files.length; i++) {
    if(files[i].isDirectory()) {
      if(!recursiveClearDirectory(files[i], fsView)) {
        return false;
      }
    } else if(!files[i].delete()) {
      return false;
    }
  }
  return directory.delete();
}
 
Example 3
Source File: JarTool.java    From osp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used by getFilesUnderDirectory (File)
 * @param directory File
 * @param fsView FileSystemView
 */
static private java.util.Collection<File> recursiveGetDirectory(File directory, FileSystemView fsView) {
  File files[] = fsView.getFiles(directory, false);
  java.util.Collection<File> list = new ArrayList<File>();
  for(int i = 0; i<files.length; i++) {
    if(files[i].isDirectory()) {
      list.addAll(recursiveGetDirectory(files[i], fsView));
    } else {
      list.add(files[i]);
    }
  }
  return list;
}
 
Example 4
Source File: AquaFileSystemModel.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 5
Source File: AquaFileSystemModel.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 6
Source File: bug6868611.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 7
Source File: AquaFileSystemModel.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 8
Source File: bug6868611.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 9
Source File: AquaFileSystemModel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 10
Source File: bug6868611.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 11
Source File: AquaFileSystemModel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 12
Source File: bug6868611.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 13
Source File: bug6868611.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 14
Source File: AquaFileSystemModel.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 15
Source File: bug6868611.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 16
Source File: bug6868611.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 17
Source File: AquaFileSystemModel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 18
Source File: bug6868611.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}
 
Example 19
Source File: AquaFileSystemModel.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    final Vector<DoChangeContents> runnables = new Vector<DoChangeContents>(10);
    final FileSystemView fileSystem = filechooser.getFileSystemView();

    final File[] list = fileSystem.getFiles(currentDirectory, filechooser.isFileHidingEnabled());

    final Vector<Object> acceptsList = new Vector<Object>();

    for (final File element : list) {
        // Return all files to the file chooser. The UI will disable or enable
        // the file name if the current filter approves.
        acceptsList.addElement(new SortableFile(element));
    }

    // Sort based on settings.
    sort(acceptsList);

    // Don't separate directories from files
    Vector<SortableFile> chunk = new Vector<SortableFile>(10);
    final int listSize = acceptsList.size();
    // run through list grabbing file/dirs in chunks of ten
    for (int i = 0; i < listSize;) {
        SortableFile f;
        for (int j = 0; j < 10 && i < listSize; j++, i++) {
            f = (SortableFile)acceptsList.elementAt(i);
            chunk.addElement(f);
        }
        final DoChangeContents runnable = new DoChangeContents(chunk, fid);
        runnables.addElement(runnable);
        SwingUtilities.invokeLater(runnable);
        chunk = new Vector<SortableFile>(10);
        if (isInterrupted()) {
            // interrupted, cancel all runnables
            cancelRunnables(runnables);
            return;
        }
    }

    synchronized (fileCacheLock) {
        for (final Runnable r : queuedTasks) {
            SwingUtilities.invokeLater(r);
        }
    }
}
 
Example 20
Source File: bug6868611.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    FileSystemView fileSystemView = FileSystemView.getFileSystemView();

    fileSystemView.getFiles(new File(dir), false);
}