// {{{ getEntry() method
  public static Entry getEntry(String path) {
    historyLock.readLock().lock();
    try {
      for (Entry entry : history) {
        if (MiscUtilities.pathsEqual(entry.path, path)) return entry;
      }
    } finally {
      historyLock.readLock().unlock();
    }

    return null;
  } // }}}
示例#2
0
  /**
   * Rebuild the parent view after a directory has been loaded.
   *
   * @param node
   * @param path
   * @param directory
   */
  public void directoryLoaded(Object node, String path, java.util.List<VFSFile> directory) {
    // {{{ If reloading root, update parent directory list
    if (node == null) {
      DefaultListModel parentList = new DefaultListModel();

      String parent = path;

      for (; ; ) {
        VFS _vfs = VFSManager.getVFSForPath(parent);
        VFSFile file = null;
        if (_vfs instanceof FileVFS) {
          Object session = _vfs.createVFSSession(path, browser);
          try {
            file = _vfs._getFile(session, parent, browser);
            if (file != null) {
              file.setName(_vfs.getFileName(parent));
            }
          } catch (IOException e) {
            Log.log(Log.ERROR, this, e, e);
          }
        }
        if (file == null) {
          // create a DirectoryEntry manually
          // instead of using _vfs._getFile()
          // since so many VFS's have broken
          // implementations of this method
          file =
              new VFSFile(_vfs.getFileName(parent), parent, parent, VFSFile.DIRECTORY, 0L, false);
        }

        /*parentList.insertElementAt(new VFSFile(
        _vfs.getFileName(parent),
        parent,parent,
        VFSFile.DIRECTORY,
        0L,false),0);*/
        parentList.insertElementAt(file, 0);
        String newParent = _vfs.getParentOfPath(parent);

        if (newParent == null || MiscUtilities.pathsEqual(parent, newParent)) break;
        else parent = newParent;
      }

      parentDirectories.setModel(parentList);
      int index = parentList.getSize() - 1;
      parentDirectories.setSelectedIndex(index);
      parentDirectories.ensureIndexIsVisible(index);
    } // }}}

    table.setDirectory(VFSManager.getVFSForPath(path), node, directory, tmpExpanded);
  } // }}}
 // {{{ removeEntry() method
 private static void removeEntry(String path) {
   historyLock.writeLock().lock();
   try {
     Iterator<Entry> iter = history.iterator();
     while (iter.hasNext()) {
       Entry entry = iter.next();
       if (MiscUtilities.pathsEqual(path, entry.path)) {
         iter.remove();
         return;
       }
     }
   } finally {
     historyLock.writeLock().unlock();
   }
 } // }}}
示例#4
0
  // {{{ maybeReloadDirectory() method
  public void maybeReloadDirectory(String path) {
    String browserDir = browser.getDirectory();
    String symlinkBrowserDir;
    if (MiscUtilities.isURL(browserDir)) {
      symlinkBrowserDir = browserDir;
    } else {
      symlinkBrowserDir = MiscUtilities.resolveSymlinks(browserDir);
    }

    if (MiscUtilities.pathsEqual(path, symlinkBrowserDir)) {
      saveExpansionState();
      loadDirectory(null, browserDir, false);
    }

    // because this method is called for *every* VFS update,
    // we don't want to scan the tree all the time. So we
    // use the following algorithm to determine if the path
    // might be part of the tree:
    // - if the path starts with the browser's current directory,
    //   we do the tree scan
    // - if the browser's directory is 'favorites:' -- we have to
    //   do the tree scan, as every path can appear under the
    //   favorites list
    // - if the browser's directory is 'roots:' and path is on
    //   the local filesystem, do a tree scan

    if (!browserDir.startsWith(FavoritesVFS.PROTOCOL)
        && !browserDir.startsWith(FileRootsVFS.PROTOCOL)
        && !path.startsWith(symlinkBrowserDir)) return;

    if (browserDir.startsWith(FileRootsVFS.PROTOCOL)
        && MiscUtilities.isURL(path)
        && !"file".equals(MiscUtilities.getProtocolOfURL(path))) return;

    table.maybeReloadDirectory(path);
  } // }}}