forked from j62/ctbrec
1
0
Fork 0

Enable rerun PP for multiple recordings

This commit is contained in:
0xb00bface 2020-07-26 11:07:55 +02:00
parent eaa26fa1bf
commit 64c6b9aa4f
2 changed files with 17 additions and 11 deletions

View File

@ -439,15 +439,13 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
}
MenuItem rerunPostProcessing = new MenuItem("Rerun Post-Processing");
rerunPostProcessing.setOnAction(e -> triggerPostProcessing(first));
if (first.getStatus() == FAILED || first.getStatus() == WAITING || first.getStatus() == FINISHED) {
contextMenu.getItems().add(rerunPostProcessing);
}
rerunPostProcessing.setOnAction(e -> triggerPostProcessing(recordings));
contextMenu.getItems().add(rerunPostProcessing);
rerunPostProcessing.setDisable(!recordings.stream().allMatch(Recording::canBePostProcessed));
if(recordings.size() > 1) {
openInPlayer.setDisable(true);
openDir.setDisable(true);
rerunPostProcessing.setDisable(true);
}
return contextMenu;
@ -567,13 +565,15 @@ public class RecordingsTab extends Tab implements TabSelectionListener {
new Thread(() -> DesktopIntegration.open(tsFile.getParent())).start();
}
private void triggerPostProcessing(JavaFxRecording first) {
private void triggerPostProcessing(List<JavaFxRecording> recs) {
new Thread(() -> {
try {
recorder.rerunPostProcessing(first.getDelegate());
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e1) {
showErrorDialog("Error while starting post-processing", "The post-processing could not be started", e1);
LOG.error("Error while starting post-processing", e1);
for (JavaFxRecording rec : recs) {
try {
recorder.rerunPostProcessing(rec.getDelegate());
} catch (IOException | InvalidKeyException | NoSuchAlgorithmException | IllegalStateException e1) {
showErrorDialog("Error while starting post-processing", "The post-processing could not be started", e1);
LOG.error("Error while starting post-processing", e1);
}
}
}).start();
}

View File

@ -1,5 +1,7 @@
package ctbrec;
import static ctbrec.Recording.State.*;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
@ -272,4 +274,8 @@ public class Recording implements Serializable {
public void refresh() {
sizeInByte = getSize();
}
public boolean canBePostProcessed() {
return getStatus() == FAILED || getStatus() == WAITING || getStatus() == FINISHED;
}
}