ui/src/main/java/org/apache/hop/ui/core/vfs/HopVfsFileDialog.java
private void populateFolder(FileObject folder, TreeItem folderItem) throws FileSystemException {

    FileObject[] children = folder.getChildren();

    Arrays.sort(
        children,
        (child1, child2) -> {
          try {
            int cmp;
            switch (sortIndex) {
              case 0:
                String name1 = child1.getName().getBaseName();
                String name2 = child2.getName().getBaseName();
                cmp = name1.compareToIgnoreCase(name2);
                break;
              case 1:
                long time1 = child1.getContent().getLastModifiedTime();
                long time2 = child2.getContent().getLastModifiedTime();
                cmp = Long.compare(time1, time2);
                break;
              case 2:
                long size1 = child1.getContent().getSize();
                long size2 = child2.getContent().getSize();
                cmp = Long.compare(size1, size2);
                break;

              default:
                cmp = 0;
            }
            if (ascending) {
              return -cmp;
            } else {
              return cmp;
            }
          } catch (Exception e) {
            return 0;
          }
        });

    // First the child folders
    //
    for (FileObject child : children) {
      if (child.isFolder()) {
        String baseFilename = child.getName().getBaseName();
        if (!showingHiddenFiles && baseFilename.startsWith(".")) {
          continue;
        }
        TreeItem childFolderItem = new TreeItem(folderItem, SWT.NONE);
        childFolderItem.setImage(folderImage);
        childFolderItem.setText(child.getName().getBaseName());
        fileObjectsMap.put(getTreeItemPath(childFolderItem), child);
      }
    }
    if (!browsingDirectories) {
      for (final FileObject child : children) {
        if (child.isFile()) {
          String baseFilename = child.getName().getBaseName();
          if (!showingHiddenFiles && baseFilename.startsWith(".")) {
            continue;
          }

          boolean selectFile = false;

          // Check file extension...
          //
          String selectedExtensions = filterExtensions[wFilters.getSelectionIndex()];
          String[] exts = selectedExtensions.split(";");
          for (String ext : exts) {
            if (FilenameUtils.wildcardMatch(baseFilename, ext)) {
              selectFile = true;
            }
          }

          // Hidden file?
          //
          if (selectFile) {
            TreeItem childFileItem = new TreeItem(folderItem, SWT.NONE);
            childFileItem.setImage(getFileImage(child));
            childFileItem.setFont(GuiResource.getInstance().getFontBold());
            childFileItem.setText(0, child.getName().getBaseName());
            childFileItem.setText(1, getFileDate(child));
            childFileItem.setText(2, getFileSize(child));
            fileObjectsMap.put(getTreeItemPath(childFileItem), child);

            // Gray out if the file is not readable
            //
            if (!child.isReadable()) {
              childFileItem.setForeground(GuiResource.getInstance().getColorGray());
            }

            if (child.equals(activeFileObject)) {
              wBrowser.setSelection(childFileItem);
              wBrowser.showSelection();
            }
          }
        }
      }
    }
  }
/**
   * Child folders are always shown at the top. Files below it sorted alphabetically
   *
   * @param folder
   * @param folderItem
   */
Child folders are always shown at the top. Files below it sorted alphabetically
@param folder
@param folderItem
Child folders are always shown at the top . Files below it sorted alphabetically @param folder @param folderItem
private void populateFolder(FileObject folder, TreeItem folderItem) throws FileSystemException {
    FileObject[] children = folder.getChildren();
    Arrays.sort(
        children,
        (child1, child2) -> {
          try {
            int cmp;
            switch (sortIndex) {
              case 0:
                String name1 = child1.getName().getBaseName();
                String name2 = child2.getName().getBaseName();
                cmp = name1.compareToIgnoreCase(name2);
                break;
              case 1:
                long time1 = child1.getContent().getLastModifiedTime();
                long time2 = child2.getContent().getLastModifiedTime();
                cmp = Long.compare(time1, time2);
                break;
              case 2:
                long size1 = child1.getContent().getSize();
                long size2 = child2.getContent().getSize();
                cmp = Long.compare(size1, size2);
                break;
              default:
                cmp = 0;
            }
            if (ascending) {
              return -cmp;
            } else {
              return cmp;
            }
          } catch (Exception e) {
            return 0;
          }
        });
    for (FileObject child : children) {
      if (child.isFolder()) {
        String baseFilename = child.getName().getBaseName();
        if (!showingHiddenFiles && baseFilename.startsWith(".")) {
          continue;
        }
        TreeItem childFolderItem = new TreeItem(folderItem, SWT.NONE);
        childFolderItem.setImage(folderImage);
        childFolderItem.setText(child.getName().getBaseName());
        fileObjectsMap.put(getTreeItemPath(childFolderItem), child);
      }
    }
    if (!browsingDirectories) {
      for (final FileObject child : children) {
        if (child.isFile()) {
          String baseFilename = child.getName().getBaseName();
          if (!showingHiddenFiles && baseFilename.startsWith(".")) {
            continue;
          }
          boolean selectFile = false;
           Check file extension...
          String selectedExtensions = filterExtensions[wFilters.getSelectionIndex()];
          String[] exts = selectedExtensions.split(";");
          for (String ext : exts) {
            if (FilenameUtils.wildcardMatch(baseFilename, ext)) {
              selectFile = true;
            }
          }
           Hidden file?
          if (selectFile) {
            TreeItem childFileItem = new TreeItem(folderItem, SWT.NONE);
            childFileItem.setImage(getFileImage(child));
            childFileItem.setFont(GuiResource.getInstance().getFontBold());
            childFileItem.setText(0, child.getName().getBaseName());
            childFileItem.setText(1, getFileDate(child));
            childFileItem.setText(2, getFileSize(child));
            fileObjectsMap.put(getTreeItemPath(childFileItem), child);
             Gray out if the file is not readable
            if (!child.isReadable()) {
              childFileItem.setForeground(GuiResource.getInstance().getColorGray());
            }
            if (child.equals(activeFileObject)) {
              wBrowser.setSelection(childFileItem);
              wBrowser.showSelection();
            }
          }
        }
      }
    }
  }
private void populateFolder ( FileObject folder , TreeItem folderItem ) throws FileSystemException { FileObject [ ] children = folder . getChildren ( ) ; Arrays . sort ( children , ( child1 , child2 ) -> { try { int cmp ; switch ( sortIndex ) { case 0 : String name1 = child1 . getName ( ) . getBaseName ( ) ; String name2 = child2 . getName ( ) . getBaseName ( ) ; cmp = name1 . compareToIgnoreCase ( name2 ) ; break ; case 1 : long time1 = child1 . getContent ( ) . getLastModifiedTime ( ) ; long time2 = child2 . getContent ( ) . getLastModifiedTime ( ) ; cmp = Long . compare ( time1 , time2 ) ; break ; case 2 : long size1 = child1 . getContent ( ) . getSize ( ) ; long size2 = child2 . getContent ( ) . getSize ( ) ; cmp = Long . compare ( size1 , size2 ) ; break ; default : cmp = 0 ; } if ( ascending ) { return - cmp ; } else { return cmp ; } } catch ( Exception e ) { return 0 ; } } ) ; for ( FileObject child : children ) { if ( child . isFolder ( ) ) { String baseFilename = child . getName ( ) . getBaseName ( ) ; if ( ! showingHiddenFiles && baseFilename . startsWith ( "." ) ) { continue ; } TreeItem childFolderItem = new TreeItem ( folderItem , SWT . NONE ) ; childFolderItem . setImage ( folderImage ) ; childFolderItem . setText ( child . getName ( ) . getBaseName ( ) ) ; fileObjectsMap . put ( getTreeItemPath ( childFolderItem ) , child ) ; } } if ( ! browsingDirectories ) { for ( final FileObject child : children ) { if ( child . isFile ( ) ) { String baseFilename = child . getName ( ) . getBaseName ( ) ; if ( ! showingHiddenFiles && baseFilename . startsWith ( "." ) ) { continue ; } boolean selectFile = false ; String selectedExtensions = filterExtensions [ wFilters . getSelectionIndex ( ) ] ; String [ ] exts = selectedExtensions . split ( ";" ) ; for ( String ext : exts ) { if ( FilenameUtils . wildcardMatch ( baseFilename , ext ) ) { selectFile = true ; } } if ( selectFile ) { TreeItem childFileItem = new TreeItem ( folderItem , SWT . NONE ) ; childFileItem . setImage ( getFileImage ( child ) ) ; childFileItem . setFont ( GuiResource . getInstance ( ) . getFontBold ( ) ) ; childFileItem . setText ( 0 , child . getName ( ) . getBaseName ( ) ) ; childFileItem . setText ( 1 , getFileDate ( child ) ) ; childFileItem . setText ( 2 , getFileSize ( child ) ) ; fileObjectsMap . put ( getTreeItemPath ( childFileItem ) , child ) ; if ( ! child . isReadable ( ) ) { childFileItem . setForeground ( GuiResource . getInstance ( ) . getColorGray ( ) ) ; } if ( child . equals ( activeFileObject ) ) { wBrowser . setSelection ( childFileItem ) ; wBrowser . showSelection ( ) ; } } } } } }
Child folders are always shown at the top.
Child folders are always shown at the top .
// First the child folders // // Check file extension... // // Hidden file? // // Gray out if the file is not readable //