Exemplo n.º 1
0
  public void fileRenamed(FileRenameEvent fe) {
    FileObject fo = fe.getFile();
    if (FileUtil.isParentOf(root, fo) && fo.isFolder()) {
      String rp = FileUtil.getRelativePath(root, fo.getParent());
      String oldPath = rp + (rp.length() == 0 ? "" : "/") + fe.getName() + fe.getExt(); // NOI18N

      boolean visible = VisibilityQuery.getDefault().isVisible(fo);
      boolean doUpdate = false;

      // Find all entries which have to be updated
      ArrayList needsUpdate = new ArrayList();
      for (Iterator it = names2nodes.keySet().iterator(); it.hasNext(); ) {
        String p = (String) it.next();
        if (p.startsWith(oldPath)) {
          if (visible) {
            needsUpdate.add(p);
          } else {
            names2nodes.remove(p);
            doUpdate = true;
          }
        }
      }

      // If the node does not exists then there might have been update
      // from ignored to non ignored
      if (get(fo) == null && visible) {
        cleanEmptyKeys(fo);
        findNonExcludedPackages(fo);
        doUpdate = true; // force refresh
      }

      int oldPathLen = oldPath.length();
      String newPath = FileUtil.getRelativePath(root, fo);
      for (Iterator it = needsUpdate.iterator(); it.hasNext(); ) {
        String p = (String) it.next();
        StringBuffer np = new StringBuffer(p);
        np.replace(0, oldPathLen, newPath);
        PackageNode n = updatePath(p, np.toString()); // Replace entries in cache
        if (n != null) {
          n.updateDisplayName(); // Update nodes
        }
      }

      if (needsUpdate.size() > 1 || doUpdate) {
        // Sorting might change
        refreshKeys();
      }
    }
    /*
    else if ( FileUtil.isParentOf( root, fo ) && fo.isFolder() ) {
        FileObject parent = fo.getParent();
        PackageNode n = get( parent );
        if ( n != null && VisibilityQuery.getDefault().isVisible( parent ) ) {
            n.updateChildren();
        }

    }
    */

  }
Exemplo n.º 2
0
 public void fileRenamed(FileRenameEvent fe) {
   try {
     this.setURL(((FileObject) fe.getSource()).getURL().toString());
   } catch (FileStateInvalidException ex) {
     ErrorManager.getDefault().notify(ex);
   }
 }