⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 triggerrunner.java

📁 基于Junit的 功能和单元测试的的测试工具。只支持Swing.
💻 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 + -