1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-01-11 13:58:16 -05:00

Run sysinfo script on startup whenever GroovyPad is displayed

This commit is contained in:
Reinhard Pointner 2016-10-19 19:52:30 +08:00
parent 3c3d06543a
commit 26e89117a7
2 changed files with 28 additions and 25 deletions

View File

@ -11,7 +11,6 @@ import static net.filebot.Settings.*;
import static net.filebot.util.ui.SwingUI.*; import static net.filebot.util.ui.SwingUI.*;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dialog.ModalExclusionType; import java.awt.Dialog.ModalExclusionType;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.dnd.DropTarget; import java.awt.dnd.DropTarget;
@ -21,7 +20,6 @@ import java.awt.dnd.DropTargetDropEvent;
import java.awt.dnd.DropTargetEvent; import java.awt.dnd.DropTargetEvent;
import java.awt.event.WindowAdapter; import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent; import java.awt.event.WindowEvent;
import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -99,14 +97,14 @@ public class MainFrame extends JFrame {
setSize(1050, 650); setSize(1050, 650);
// KEYBOARD SHORTCUTS // KEYBOARD SHORTCUTS
installAction(this.getRootPane(), getKeyStroke(VK_DELETE, CTRL_MASK | SHIFT_MASK), newAction("Clear Cache", evt -> { installAction(getRootPane(), getKeyStroke(VK_DELETE, CTRL_MASK | SHIFT_MASK), newAction("Clear Cache", evt -> {
CacheManager.getInstance().clearAll(); CacheManager.getInstance().clearAll();
log.info("Cache has been cleared"); log.info("Cache has been cleared");
})); }));
installAction(this.getRootPane(), getKeyStroke(VK_F5, 0), newAction("Run", evt -> { installAction(getRootPane(), getKeyStroke(VK_F5, 0), newAction("Run", evt -> {
try { try {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // loading Groovy might take a while withWaitCursor(getRootPane(), () -> {
GroovyPad pad = new GroovyPad(); GroovyPad pad = new GroovyPad();
pad.addWindowListener(new WindowAdapter() { pad.addWindowListener(new WindowAdapter() {
@ -128,10 +126,9 @@ public class MainFrame extends JFrame {
pad.setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE); pad.setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE);
pad.setLocationByPlatform(true); pad.setLocationByPlatform(true);
pad.setVisible(true); pad.setVisible(true);
} catch (IOException e) { });
} catch (Exception e) {
debug.log(Level.WARNING, e.getMessage(), e); debug.log(Level.WARNING, e.getMessage(), e);
} finally {
setCursor(Cursor.getDefaultCursor());
} }
})); }));

View File

@ -313,6 +313,12 @@ public final class SwingUI {
public static void withWaitCursor(Object source, BackgroundRunnable runnable) throws Exception { public static void withWaitCursor(Object source, BackgroundRunnable runnable) throws Exception {
Window window = getWindow(source); Window window = getWindow(source);
if (window == null) {
runnable.run();
return;
}
try { try {
window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
runnable.run(); runnable.run();