📄 triggerrunner.java
字号:
package org.uispec4j.utils;
import org.uispec4j.Trigger;
import org.uispec4j.interception.toolkit.UISpecDisplay;
import javax.swing.*;
import java.lang.reflect.InvocationTargetException;
public class TriggerRunner {
public static void runInCurrentThread(Trigger trigger) {
try {
trigger.run();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void runInSwingThread(final Trigger trigger) {
if (SwingUtilities.isEventDispatchThread()) {
runInCurrentThread(trigger);
}
else {
final ExceptionContainer container = new ExceptionContainer();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
runInCurrentThread(trigger);
}
catch (Throwable e) {
container.set(e);
}
}
});
}
catch (InterruptedException e) {
throw new RuntimeException(e.getCause());
}
catch (InvocationTargetException e) {
throw new RuntimeException(e.getCause());
}
container.rethrowIfNeeded();
}
}
public static void runInUISpecThread(final Trigger trigger) {
UISpecDisplay.instance().runInNewThread(new Runnable() {
public void run() {
try {
trigger.run();
}
catch (Throwable e) {
UISpecDisplay.instance().store(e);
}
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -