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:
parent
3c3d06543a
commit
26e89117a7
@ -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,39 +97,38 @@ 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() {
|
||||||
@Override
|
@Override
|
||||||
public void windowOpened(WindowEvent e) {
|
public void windowOpened(WindowEvent e) {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
|
||||||
// run default script on startup
|
// run default script on startup
|
||||||
pad.runScript(GroovyPad.DEFAULT_SCRIPT);
|
pad.runScript(GroovyPad.DEFAULT_SCRIPT);
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
};
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
pad.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
pad.setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE);
|
||||||
|
pad.setLocationByPlatform(true);
|
||||||
|
pad.setVisible(true);
|
||||||
});
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
pad.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
|
||||||
pad.setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE);
|
|
||||||
pad.setLocationByPlatform(true);
|
|
||||||
pad.setVisible(true);
|
|
||||||
} catch (IOException e) {
|
|
||||||
debug.log(Level.WARNING, e.getMessage(), e);
|
debug.log(Level.WARNING, e.getMessage(), e);
|
||||||
} finally {
|
|
||||||
setCursor(Cursor.getDefaultCursor());
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
Loading…
Reference in New Issue
Block a user