Пример #1
0
  private String getPrevOrNextFile(View view, String path, Direction direction) {
    if (files == null) files = _getFiles(view);

    if (files == null || files.length == 0) return null;

    if (path == null) {
      path = view.getBuffer().getSymlinkPath();
      VFS vfs = VFSManager.getVFSForPath(path);
      boolean ignoreCase = ((vfs.getCapabilities() & VFS.CASE_INSENSITIVE_CAP) != 0);

      for (int i = 0; i < files.length; i++) {
        if (StandardUtilities.compareStrings(files[i], path, ignoreCase) == 0) {
          return path;
        }
      }

      if (direction == Direction.NEXT) {
        return getFirstFile(view);
      } else {
        return getLastFile(view);
      }
    } else {
      // -1 so that the last isn't checked
      VFS vfs = VFSManager.getVFSForPath(path);
      boolean ignoreCase = ((vfs.getCapabilities() & VFS.CASE_INSENSITIVE_CAP) != 0);

      if (direction == Direction.NEXT
          && StandardUtilities.compareStrings(files[files.length - 1], path, ignoreCase) == 0) {
        // Going forward and already at the last file
        return null;
      } else if (direction == Direction.PREV
          && StandardUtilities.compareStrings(files[0], path, ignoreCase) == 0) {
        // Going backward and already at the first file
        return null;
      }

      for (int i = 0; i < files.length - 1; i++) {
        if (StandardUtilities.compareStrings(files[i], path, ignoreCase) == 0) {
          if (direction == Direction.NEXT) return files[i + 1];
          else {
            if (i == 0) return files[files.length - 1];
            return files[i - 1];
          }
        }
      }

      return null;
    }
  } // }}}
Пример #2
0
 // {{{ DirectoryEntry constructor
 public DirectoryEntry(
     String name, String path, String deletePath, int type, long length, boolean hidden) {
   this.name = name;
   this.path = path;
   this.deletePath = deletePath;
   this.symlinkPath = path;
   this.type = type;
   this.length = length;
   this.hidden = hidden;
   if (path != null) {
     // maintain backwards compatibility
     VFS vfs = VFSManager.getVFSForPath(path);
     canRead = ((vfs.getCapabilities() & READ_CAP) != 0);
     canWrite = ((vfs.getCapabilities() & WRITE_CAP) != 0);
   }
 } // }}}
Пример #3
0
 public static Buffer createFeatureBuffer() {
   View view = jEdit.getActiveView();
   String parent = null;
   if (view != null) {
     Buffer buffer = view.getBuffer();
     parent = buffer.getDirectory();
   }
   if (parent == null) {
     parent = System.getProperty("user.home");
   }
   VFS vfs = VFSManager.getVFSForPath(parent);
   if ((vfs.getCapabilities() & VFS.WRITE_CAP) == 0) {
     // cannot write on that VFS, creating untitled buffer in home directory
     parent = System.getProperty("user.home");
   }
   Buffer buffer = jEdit.openTemporary(view, tempPath(), getNextFeatureTemp(), true, null);
   jEdit.commitTemporary(buffer);
   return buffer;
 }