Skip to content

Commit

Permalink
'#1907: New column with item's processing time in a task.
Browse files Browse the repository at this point in the history
  • Loading branch information
wladimirleite committed Sep 29, 2023
1 parent d71c6c8 commit 7b0dfd4
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions iped-app/src/main/java/iped/app/processing/ui/ProgressFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public class ProgressFrame extends JFrame implements PropertyChangeListener, Act
long secsToEnd;
private Date indexStart;
private Worker[] workers;
private String[] lastWorkerTaskPath;
private long[] lastWorkerTime;
private static final NumberFormat nf = LocalizedFormat.getNumberInstance();
private boolean paused = false;
private String decodingDir = null;
Expand Down Expand Up @@ -240,6 +242,8 @@ public void propertyChange(PropertyChangeEvent evt) {

} else if ("workers".equals(evt.getPropertyName())) { //$NON-NLS-1$
workers = (Worker[]) evt.getNewValue();
lastWorkerTaskPath = new String[workers.length];
lastWorkerTime = new long[workers.length];
}

}
Expand All @@ -249,32 +253,57 @@ private String getItemList() {
return "";
StringBuilder msg = new StringBuilder();
startTable(msg);
addTitle(msg, 3, Messages.getString("ProgressFrame.CurrentItems"));
addTitle(msg, 4, Messages.getString("ProgressFrame.CurrentItems"));

long now = System.currentTimeMillis();
boolean hasWorkerAlive = false;
for (Worker worker : workers) {
for (int i = 0; i < workers.length; i++) {
Worker worker = workers[i];
if (!worker.isAlive())
continue;
hasWorkerAlive = true;
startRow(msg, worker.getName(), worker.state != STATE.PAUSED);

AbstractTask task = worker.runningTask;
String taskName = task == null ? null : task.getName();

IItem evidence = worker.evidence;
String evidencePath = evidence == null ? null : evidence.getPath();

String wt = "-";
int pct = -1;
if (taskName != null && evidencePath != null) {
String taskPath = taskName + evidencePath;
if (!taskPath.equals(lastWorkerTaskPath[i])) {
lastWorkerTime[i] = now;
lastWorkerTaskPath[i] = taskPath;
} else if (worker.state != STATE.PAUSED) {
long t = (now - lastWorkerTime[i]) / 1000;
wt = t < 60 ? t + "s" : t / 60 + "m";
pct = (int) Math.min(t / 30, 60);
}
} else {
lastWorkerTaskPath[i] = null;
}

startRow(msg, worker.getName(), worker.state != STATE.PAUSED, pct);

if (worker.state == STATE.PAUSED) {
addCell(msg, Messages.getString("ProgressFrame.Paused"), Align.CENTER);
} else if (worker.state == STATE.PAUSING) {
addCell(msg, Messages.getString("ProgressFrame.Pausing"), Align.CENTER);
} else if (task != null) {
addCell(msg, task.getName());
addCell(msg, taskName);
} else {
addCell(msg, "-", Align.CENTER);
}

IItem evidence = worker.evidence;
addCell(msg, wt, wt.equals("-") ? Align.CENTER : Align.RIGHT);

if (evidence != null) {
String len = "";
if (evidence.getLength() != null && evidence.getLength() > 0)
len = " (" + nf.format(evidence.getLength()) + " bytes)";
finishRow(msg, evidence.getPath() + len);
finishRow(msg, evidencePath + len);
} else {
finishRow(msg, Messages.getString("ProgressFrame.WaitingItem"));
}
Expand Down Expand Up @@ -638,7 +667,7 @@ private void updateTaskBar() {
}
}
}

private static String formatMB(long value) {
return nf.format(value >>> 20) + " MB";
}
Expand Down

0 comments on commit 7b0dfd4

Please sign in to comment.