本文整理匯總了Java中com.intellij.util.ui.UIUtil.pump方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.pump方法的具體用法?Java UIUtil.pump怎麽用?Java UIUtil.pump使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.util.ui.UIUtil
的用法示例。
在下文中一共展示了UIUtil.pump方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replaceIdeEventQueueSafely
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public static void replaceIdeEventQueueSafely() {
if (Toolkit.getDefaultToolkit().getSystemEventQueue() instanceof IdeEventQueue) {
return;
}
if (SwingUtilities.isEventDispatchThread()) {
throw new RuntimeException("must not call under EDT");
}
AWTAutoShutdown.getInstance().notifyThreadBusy(Thread.currentThread());
UIUtil.pump();
// in JDK 1.6 java.awt.EventQueue.push() causes slow painful death of current EDT
// so we have to wait through its agony to termination
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
IdeEventQueue.getInstance();
}
});
SwingUtilities.invokeAndWait(EmptyRunnable.getInstance());
SwingUtilities.invokeAndWait(EmptyRunnable.getInstance());
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: checkLeak
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/**
* Checks if there is a memory leak if an object of type {@code suspectClass} is strongly accessible via references from the {@code root} object.
*/
@TestOnly
public static <T> void checkLeak(@NotNull Collection<Object> roots, @NotNull Class<T> suspectClass, @Nullable final Processor<? super T> isReallyLeak) throws AssertionError {
if (SwingUtilities.isEventDispatchThread()) {
UIUtil.dispatchAllInvocationEvents();
}
else {
UIUtil.pump();
}
PersistentEnumeratorBase.clearCacheForTests();
walkObjects(suspectClass, roots, new Processor<BackLink>() {
@Override
public boolean process(BackLink backLink) {
UserDataHolder leaked = (UserDataHolder)backLink.value;
if (((UserDataHolderBase)leaked).replace(REPORTED_LEAKED, null, Boolean.TRUE) &&
(isReallyLeak == null || isReallyLeak.process((T)leaked))) {
String place = leaked instanceof Project ? PlatformTestCase.getCreationPlace((Project)leaked) : "";
System.out.println("Leaked object found:" + leaked +
"; hash: " + System.identityHashCode(leaked) + "; place: " + place);
while (backLink != null) {
String valueStr;
try {
valueStr = backLink.value instanceof FList ? "FList" : backLink.value instanceof Collection ? "Collection" : String.valueOf(backLink.value);
}
catch (Throwable e) {
valueStr = "(" + e.getMessage() + " while computing .toString())";
}
System.out.println("-->" + backLink.field + "; Value: " + valueStr + "; " + backLink.value.getClass());
backLink = backLink.backLink;
}
System.out.println(";-----");
throw new AssertionError();
}
return true;
}
});
}
示例3: flushSwingQueue
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private static void flushSwingQueue() {
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (SwingUtilities.isEventDispatchThread()) {
UIUtil.dispatchAllInvocationEvents();
}
else {
UIUtil.pump();
}
/*
final AtomicBoolean hasEventsInQueue = new AtomicBoolean(true);
while (hasEventsInQueue.get()) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
hasEventsInQueue.set(Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent() != null);
}
});
}
*/
//some weird things like MyFireIdleRequest may still sneak in
//assertEquals(null, Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent());
}