Example #1
0
  @Override
  public void actionPerformed(ActionEvent e) {

    String suggest = null;
    if (group.source == Group.GroupSource.ROBOT_STREAM) {
      String rname = null;
      boolean same = true;

      for (LogReference ref : group.logs) {
        if (rname == null) {
          rname = ref.host_name;
        } else {
          if (!rname.equals(ref.host_name)) {
            same = false;
            break;
          }
        }
      }

      suggest = (same && rname != null) ? PathChooser.suggestion(rname) : null;
    }

    Path path = PathChooser.chooseDirPath(this, suggest);

    if (path != null) {
      for (LogReference ref : group.logs) {
        Debug.info("writing log r%d to %s", ref.thisID, path);
        ref.copyLogToPath(path);
      }
    }
  }
Example #2
0
 /* this method takes ownership of the logrefs.  if you do not wish this, access logs directly */
 public void add(List<LogReference> logReferences) {
   synchronized (logs) {
     for (LogReference lr : logReferences) {
       logs.add(lr);
       lr.container = this;
     }
   }
 }
Example #3
0
 public void remove(List<LogReference> logReferences) {
   synchronized (logs) {
     for (LogReference lr : logReferences) {
       if (logs.remove(lr)) {
         lr.container = null;
       }
     }
   }
 }
    @Override
    public Log[] supplyLogsForDrag() {
      ArrayList<Log> refs = new ArrayList<>();
      for (TreePath tp : display.logTree.getSelectionPaths()) {
        if (tp.getPathCount() == 3) {
          LogReference reference = (LogReference) tp.getLastPathComponent();
          refs.add(reference.get());
        }
      }

      return refs.toArray(new Log[0]);
    }
  @Override
  public void ioReceived(IOInstance inst, int ret, Log... out) {
    if (inst == robot) {

      // Deal with streaming...
      LogSearching.Criteria criteria =
          LogSearching.criteriaAt(display.streamComboBox.getSelectedIndex());

      if (criteria != null) {
        Log pass = null;

        for (Log l : out) {
          if (criteria.fits(l.getFullDescription())) pass = l;
        }

        if (pass != null) displayLog(pass);
      }

      // Deal with adding to groups (i.e. keeping)...
      assert (lastGroup != null);
      for (Log l : out) {
        if (shouldKeep(l.jvm_unique_id)) lastGroup.add(LogReference.referenceFromLog(l));
      }

      Events.GLogsFound.generate(this, out);
    } else {
      Debug.error("%s got %d surprising logs from %s", this, out.length, inst);
    }
  }
    @Override
    public void valueChanged(TreeSelectionEvent e) {
      if (!e.isAddedPath()) {
        // path unselected, ignore
        return;
      }

      TreePath[] selected = display.logTree.getSelectionPaths();
      switch (selected[0].getPathCount()) {
        case 0:
          Debug.error("null selection!");
          break;
        case 1:
          Debug.error("root selected!");
          break;
        case 2:
          {
            Group group = (Group) selected[0].getLastPathComponent();
            displayGroup(group);
            Events.GGroupSelected.generate(this, group);
          }
          return;
        case 3:
          {
            List<Log> all = new LinkedList<>();
            for (TreePath path : selected) {
              if (path.getPathCount() != 3) continue; // it isn't a Log selection

              LogReference ref = (LogReference) path.getLastPathComponent();
              all.add(ref.get());
            }

            Log first = all.remove(0);
            displayLog(first, all);
            Events.GLogSelected.generate(outerClassThis, first, all);
          }
          return;
        default:
          Debug.error(
              "selection count %d %s",
              selected[0].getPathCount(), selected[0].getLastPathComponent());
      }
    }
    @Override
    public Component getTreeCellRendererComponent(
        JTree tree,
        Object value,
        boolean selected,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      JLabel rendered =
          (JLabel)
              renderer.getTreeCellRendererComponent(
                  tree, value, selected, expanded, leaf, row, hasFocus);

      if (value instanceof Group) {
        Group group = (Group) value;
        rendered.setText(group.guiString());
      } else if (value instanceof LogReference) {
        LogReference reference = (LogReference) value;

        if (!reference.temporary()) {

          //					rendered.setText(reference.loadPath().getFileName().toString());
          //					rendered.setText("" + reference.loadPath().getFileName().toString().length());

          Path lp = reference.loadPath();
          String last = lp.getFileName().toString();

          if (last.length() < 20 || !resemblesGeneratedFilename(last, reference)) {
            rendered.setText(last);
          } else {
            rendered.setText(reference.guiString());
          }

        } else {
          rendered.setText(reference.guiString());
        }
      }

      return rendered;
    }