Пример #1
0
 public void fileDataCreated(FileEvent fe) {
   FileObject fo = fe.getFile();
   if (FileUtil.isParentOf(root, fo) && isVisible(root, fo)) {
     FileObject parent = fo.getParent();
     if (!VisibilityQuery.getDefault().isVisible(parent)) {
       return; // Adding file into ignored directory
     }
     PackageNode n = get(parent);
     if (n == null && !contains(parent)) {
       add(parent, false);
       refreshKeys();
     } else if (n != null) {
       n.updateChildren();
     }
   }
 }
Пример #2
0
  public void fileDeleted(FileEvent fe) {
    FileObject fo = fe.getFile();
    if (FileUtil.isParentOf(root, fo) && isVisible(root, fo)) {
      if (fo.isFolder() || get(fo) != null) {
        removeSubTree(fo);
        // Now add the parent if necessary
        FileObject parent = fo.getParent();
        if ((FileUtil.isParentOf(root, parent) || root.equals(parent))
            && get(parent) == null
            && parent.isValid()) {
          // Candidate for adding
          if (!toBeRemoved(parent)) {
            add(parent, true);
          }
        }
        refreshKeysAsync();
      } else {
        FileObject parent = fo.getParent();
        final PackageNode n = get(parent);
        if (n != null) {
          // #61027: workaround to a deadlock when the package is being changed from non-leaf to
          // leaf:
          boolean leaf = n.isLeaf();
          DataFolder df = n.getDataFolder();
          boolean empty = n.isEmpty(df);

          if (leaf != empty) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    n.updateChildren();
                  }
                });
          } else {
            n.updateChildren();
          }
        }
        // If the parent folder only contains folders remove it
        if (toBeRemoved(parent)) {
          remove(parent);
          refreshKeysAsync();
        }
      }
    }
  }