mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
Refactor FAIL
This commit is contained in:
parent
8b95798a2d
commit
9209349f0c
@ -1,5 +1,6 @@
|
|||||||
package net.filebot.cli;
|
package net.filebot.cli;
|
||||||
|
|
||||||
|
import static net.filebot.Logging.*;
|
||||||
import static net.filebot.util.ui.SwingUI.*;
|
import static net.filebot.util.ui.SwingUI.*;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
@ -15,6 +16,8 @@ import java.io.IOException;
|
|||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
@ -188,28 +191,17 @@ public class GroovyPad extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
protected void cancelScript(ActionEvent evt) {
|
protected void cancelScript(ActionEvent evt) {
|
||||||
// persist script file and clear output
|
if (currentRunner != null && !currentRunner.isDone()) {
|
||||||
try {
|
currentRunner.cancel(true);
|
||||||
editor.save();
|
currentRunner.getExecutionThread().stop();
|
||||||
} catch (IOException e) {
|
|
||||||
// won't happen
|
|
||||||
}
|
|
||||||
output.setText("");
|
|
||||||
|
|
||||||
if (currentRunner == null || currentRunner.isDone()) {
|
try {
|
||||||
currentRunner = new Runner(editor.getText()) {
|
currentRunner.get(2, TimeUnit.SECONDS);
|
||||||
|
} catch (Exception e) {
|
||||||
@Override
|
log.log(Level.WARNING, e, e::getMessage);
|
||||||
protected void done() {
|
}
|
||||||
run.setEnabled(true);
|
|
||||||
cancel.setEnabled(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
run.setEnabled(false);
|
|
||||||
cancel.setEnabled(true);
|
|
||||||
currentRunner.execute();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user