void (final Runnable runnable) { final Application application = ApplicationManager.getApplication(); final boolean unitTestMode = application.isUnitTestMode(); if (unitTestMode) { UIUtil.invokeLaterIfNeeded(runnable); } else if (application.isHeadlessEnvironment() || application.isDispatchThread()) { runnable.run(); } else { EdtExecutorService.getInstance().execute(runnable); } }