protected void deleteCurrent() { int num_logs_deleted = 0; Set<Group> groups_changed = new HashSet<>(); for (TreePath tp : display.logTree.getSelectionPaths()) { if (tp.getPathCount() == 3) { Group group = (Group) tp.getPath()[1]; LogReference reference = (LogReference) tp.getLastPathComponent(); Debug.warn("deleting {%s} from {%s}", reference, group); group.remove(reference); ++num_logs_deleted; groups_changed.add(group); } else { Debug.warn("cannot delete {%s}", tp.getLastPathComponent()); } } for (Group group : groups_changed) { TreeModelEvent removeEvent = new TreeModelEvent(this, new Object[] {this, group}); for (TreeModelListener listener : listeners) listener.treeStructureChanged(removeEvent); } ToolMessage.displayAndPrint("deleted %d logs", num_logs_deleted); }
@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); } }
private void controlLoadAction() { if (robot == null) { Path selected = (Path) display.pathBox.getSelectedItem(); if (selected == null) { Debug.error("null path"); ToolMessage.display("load action: null path", Color.RED); return; } if (FileIO.isValidLogFolder(selected)) { updateComboBoxAndSettings(display.pathBox, UserSettings.loadPathes, selected); lastGroup = Group.groupFromPath(selected); LogReference[] added; try { added = FileIO.readAllRefsFromPath(selected, true); } catch (Throwable e) { ToolMessage.displayError( "error {%s} (see below) reading Log refs from %s", e.getMessage(), selected); e.printStackTrace(); return; } lastGroup.add(added); // Log[] addedLogs = new Log[added.length]; // for (int i = 0; i < added.length; ++i) // addedLogs[i] = added[i].get(); ToolMessage.displayInfo("loaded %d logs into %s", added.length, lastGroup); Events.GGroupAdded.generate(this, lastGroup); Events.GLogRefsFound.generate(this, added); // Events.GLogsFound.generate(this, addedLogs); display.leftSideTabs.setSelectedComponent(display.logTab); } else { Debug.error("invalid Log folder: " + selected.toString()); ToolMessage.display("invalid Log folder: " + selected.toString(), Color.RED); return; } } else { Debug.error("cannot load session while streaming (%s)", robot); ToolMessage.display("cannot load session while streaming", Color.ORANGE); } }
@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; }