Esempio n. 1
0
  @Override
  public void mouseMoved(MouseEvent e) {
    if (e.getSource() == browseTree) {
      browseTreeRenderer.setMousePointInTree(e.getPoint());

      TreePath path = browseTree.getPathForLocation(e.getX(), e.getY());
      if (path != null) {
        if (!(path.getLastPathComponent() instanceof ListableEntry)) return;

        ListableEntry fse = (ListableEntry) path.getLastPathComponent();
        if (fse != lastInspectedFSE || lastOnIcon != browseTreeRenderer.pointOnIcon(e.getPoint())) {
          long size = fse.getSize();
          frame.setStatusHint(fse.getName() + ": " + Util.niceSize(size));
          if (lastInspectedFSE != null)
            browseTree.repaint(browseTree.getPathBounds(lastInspectedFSE.getPath()));
          lastInspectedFSE = fse;
          lastOnIcon = browseTreeRenderer.pointOnIcon(e.getPoint());
          browseTree.repaint(browseTree.getPathBounds(path));
        }
      } else {
        if (lastInspectedFSE != null) {
          Rectangle r = browseTree.getPathBounds(lastInspectedFSE.getPath());
          lastInspectedFSE = null;
          browseTree.repaint(r);
        }
      }
    }
  }
Esempio n. 2
0
 @Override
 protected boolean popupDecision(MouseEvent e) {
   if (filesTable.getSelectedRowCount() == 0) return false;
   int[] indices = filesTable.getSelectedRows();
   long size = 0;
   for (int i : indices) {
     size += fs.getEntryForRow(filesTable.convertRowIndexToModel(i)).getSize();
   }
   info.setText(Util.niceSize(size) + " in " + indices.length + " items");
   return true;
 }
Esempio n. 3
0
 /**
  * Called by the queue to notify us that some chunk of the download queue has been erased so this
  * should un-dispatch those items contained within it.
  */
 synchronized void queueItemCancelled(DownloadItem cancelled) {
   for (DownloadWorker w : workers) {
     try {
       if (Util.isWithin(w.info.file.getFile(), cancelled.getFile())) {
         w.cancel();
       }
     } catch (IOException e) {
       Logger.severe("Couldn't determine file locations: " + e);
       Logger.log(e);
     }
   }
 }
Esempio n. 4
0
  void setTableStatusHint() {
    if (browseTree.getSelectionPath() == null) {
      return;
    }

    if (!(browseTree.getSelectionPath().getLastPathComponent() instanceof FileSystemEntry)) return;
    FileSystemEntry fse = ((FileSystemEntry) browseTree.getSelectionPath().getLastPathComponent());

    int[] selected = filesTable.getSelectedRows();
    if (selected == null || selected.length == 0) {
      if (fse.getFiles() != null)
        frame.setStatusHint(
            "Directories: "
                + fse.getChildCount()
                + ", Files: "
                + fse.getFiles().size()
                + ", Total size: "
                + Util.niceSize(fse.getSize()));
    } else {
      long size = 0;
      int dirs = 0;
      int files = 0;
      for (int i : selected) {
        FileSystemEntry current = fs.getEntryForRow(filesTable.convertRowIndexToModel(i));
        size += current.getSize();
        if (current.isDirectory()) dirs++;
        else files++;
      }
      frame.setStatusHint(
          "(selection) Directories: "
              + dirs
              + ", Files: "
              + files
              + ", Total size: "
              + Util.niceSize(size));
    }
  }
Esempio n. 5
0
 private void setPassword() {
   JPasswordField password = new JPasswordField();
   if (JOptionPane.showConfirmDialog(
           null,
           new Object[] {
             new JLabel(
                 "<html><b>Enter this indexnode's password carefully.</b><br>The indexnode may create you an account if you do not already have one.<html>"),
             password
           },
           "Password:",
           JOptionPane.OK_CANCEL_OPTION)
       == JOptionPane.OK_OPTION) {
     comm.getRegisteredIndexNodes()
         .get(nodesTable.convertRowIndexToModel(nodesTable.getSelectedRow()))
         .setPassword(
             Util.md5(FS2Constants.FS2_USER_PASSWORD_SALT + new String(password.getPassword())));
     for (int i = 0; i < password.getPassword().length; i++)
       password.getPassword()[i] = 0; // null out password from memory.
   }
 }
Esempio n. 6
0
    @Override
    protected boolean popupDecision(MouseEvent e) {
      int count = browseTree.getSelectionCount();
      if (count == 0) return false;

      boolean canRemoveSearches = false;
      long totalSize = 0;
      ListableEntry lastSelected = null;
      for (TreePath path : browseTree.getSelectionPaths()) {
        lastSelected = (ListableEntry) path.getLastPathComponent();
        totalSize += lastSelected.getSize();
        canRemoveSearches |=
            ((lastSelected instanceof FileSystemEntry)
                && ((FileSystemEntry) lastSelected).isSearch());
      }
      removeSearch.setEnabled(canRemoveSearches);

      infoItem.setText(
          (count == 1 ? lastSelected.getName() : "Multiple items")
              + ": "
              + Util.niceSize(totalSize));

      return true;
    }
 @Override
 public void run() {
   Util.writeAndSleep(name, messages, 1000, 2000);
   latch.countDown();
 }