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

View File

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