本文整理匯總了Java中com.intellij.openapi.application.Application.isDispatchThread方法的典型用法代碼示例。如果您正苦於以下問題:Java Application.isDispatchThread方法的具體用法?Java Application.isDispatchThread怎麽用?Java Application.isDispatchThread使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.application.Application
的用法示例。
在下文中一共展示了Application.isDispatchThread方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hierarchyChanged
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public void hierarchyChanged(@NotNull HierarchyEvent e) {
if (isDisposed()) return;
if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) > 0) {
final Runnable runnable = new DumbAwareRunnable() {
public void run() {
final Component c = myComponent.get();
if (isDisposed() || c == null) return;
if (c.isShowing()) {
showNotify();
}
else {
hideNotify();
}
}
};
final Application app = ApplicationManager.getApplication();
if (app != null && app.isDispatchThread()) {
app.invokeLater(runnable, ModalityState.current());
} else {
//noinspection SSBasedInspection
SwingUtilities.invokeLater(runnable);
}
}
}
示例2: notifyIncomingChangesUpdated
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private void notifyIncomingChangesUpdated(@Nullable final Collection<CommittedChangeList> receivedChanges) {
final Collection<CommittedChangeList> changes = receivedChanges == null ? myCachedIncomingChangeLists : receivedChanges;
if (changes == null) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
@Override
public void run() {
final List<CommittedChangeList> lists = loadIncomingChanges(true);
fireIncomingChangesUpdated(lists);
}
};
if (application.isDispatchThread()) {
myTaskQueue.run(runnable);
} else {
runnable.run();
}
return;
}
final ArrayList<CommittedChangeList> listCopy = new ArrayList<CommittedChangeList>(changes);
fireIncomingChangesUpdated(listCopy);
}
示例3: waitForTheFile
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static VirtualFile waitForTheFile(final String path) {
final VirtualFile[] file = new VirtualFile[1];
final Application app = ApplicationManager.getApplication();
Runnable action = new Runnable() {
@Override
public void run() {
app.runWriteAction(new Runnable() {
@Override
public void run() {
file[0] = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
}
});
}
};
if (app.isDispatchThread()) {
action.run();
}
else {
app.invokeAndWait(action, ModalityState.defaultModalityState());
}
return file[0];
}
示例4: clear
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public void clear() {
final List<MyNotification> notifications;
synchronized (myLock) {
notifications = new ArrayList<MyNotification>(myState.values());
myState.clear();
}
final Application application = ApplicationManager.getApplication();
final Runnable runnable = new Runnable() {
public void run() {
for (MyNotification notification : notifications) {
notification.expire();
}
}
};
if (application.isDispatchThread()) {
runnable.run();
} else {
application.invokeLater(runnable, ModalityState.NON_MODAL, myProject.getDisposed());
}
}
示例5: doSetPresentation
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private static void doSetPresentation(@Nullable final Icon icon,
@NotNull final XValuePresentation presentation,
final boolean hasChildren,
final ConfigurableXValueNode node) {
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
node.applyPresentation(icon, presentation, hasChildren);
}
else {
Runnable updater = new Runnable() {
@Override
public void run() {
node.applyPresentation(icon, presentation, hasChildren);
}
};
if (node instanceof XDebuggerTreeNode) {
((XDebuggerTreeNode)node).invokeNodeUpdate(updater);
}
else {
application.invokeLater(updater);
}
}
}
示例6: sortModules
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static void sortModules(final Project project, final List<Module> modules) {
final Application application = ApplicationManager.getApplication();
Runnable sort = new Runnable() {
public void run() {
Comparator<Module> comparator = ModuleManager.getInstance(project).moduleDependencyComparator();
Collections.sort(modules, comparator);
}
};
if (application.isDispatchThread()) {
sort.run();
}
else {
application.runReadAction(sort);
}
}
示例7: runInDispatchedThread
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private static void runInDispatchedThread(@NotNull Runnable r, boolean blocking) {
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
r.run();
}
else if (blocking) {
application.invokeAndWait(r, ModalityState.defaultModalityState());
}
else {
application.invokeLater(r);
}
}
示例8: executeOnEdt
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static <T> T executeOnEdt(@NotNull final Computable<T> task) {
final Application app = ApplicationManager.getApplication();
if (app.isDispatchThread()) {
return task.compute();
}
final Ref<T> result = Ref.create();
app.invokeAndWait(new Runnable() {
@Override
public void run() {
result.set(task.compute());
}
}, ModalityState.defaultModalityState());
return result.get();
}
示例9: dispatchPendingEvent
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public void dispatchPendingEvent(final T listener) {
Boolean dispatched = myListenersState.get(listener);
//if (!LOG.assertTrue(dispatched != null, "dispathPendingEvents() should not be invoked for listener which was not registered")) return;
if (dispatched == null) return;
if (!dispatched.booleanValue()) {
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
invoke(listener);
}
else {
// We do not dispatch events in non swing thread. A potential deadlock otherwise.
return;
/*
ModalityState state = ProgressManager.getInstance().getProgressIndicator().getModalityState();
application.invokeAndWait(new Runnable() {
public void run() {
invoke(listener);
}
}, state);
*/
}
}
/* Seems like this assertion is incorrect and there's nothing wrong with just skipping in this situation.
else {
if (myDispatchingListeners.size() > 0 && listener != myDispatchingListeners.peek() && myDispatchingListeners.contains(listener)){
LOG.error("Cyclic dispatching is prohibited");
}
}
*/
}
示例10: promptUserForSdkCreation
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Nullable
private static Sdk promptUserForSdkCreation(@Nullable final IAndroidTarget target,
@Nullable final String androidSdkPath,
@Nullable final String jdkPath) {
final Ref<Sdk> sdkRef = new Ref<Sdk>();
Runnable task = new Runnable() {
@Override
public void run() {
SelectSdkDialog dlg = new SelectSdkDialog(jdkPath, androidSdkPath);
dlg.setModal(true);
if (dlg.showAndGet()) {
Sdk sdk = createNewAndroidPlatform(target, dlg.getAndroidHome(), dlg.getJdkHome());
sdkRef.set(sdk);
if (sdk != null) {
RunAndroidSdkManagerAction.updateInWelcomePage(dlg.getContentPanel());
}
}
}
};
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
task.run();
return sdkRef.get();
}
application.invokeAndWait(task, ModalityState.any());
return sdkRef.get();
}
示例11: runOnSyncPublisher
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public static <T> void runOnSyncPublisher(final Project project, final Topic<T> topic, final Consumer<T> listener) {
final Application application = ApplicationManager.getApplication();
final Runnable runnable = createPublisherRunnable(project, topic, listener);
if (application.isDispatchThread()) {
runnable.run();
} else {
application.runReadAction(runnable);
}
}
示例12: runAboveAll
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private static void runAboveAll(@NotNull final Runnable runnable) {
ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
if (progressIndicator != null && progressIndicator.isModal()) {
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(runnable);
}
else {
Application app = ApplicationManager.getApplication();
if (app.isDispatchThread()) {
runnable.run();
}
else {
app.invokeAndWait(runnable, ModalityState.any());
}
}
}
示例13: queueLater
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
private static void queueLater(final Task task) {
final Application app = ApplicationManager.getApplication();
if (app.isDispatchThread()) {
task.queue();
} else {
app.invokeLater(new Runnable() {
public void run() {
task.queue();
}
});
}
}
示例14: showBalloon
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
public void showBalloon(@NotNull String title,
@NotNull String text,
@NotNull NotificationType type,
@NotNull NotificationGroup group,
@Nullable NotificationListener listener) {
final Notification notification = group.createNotification(title, text, type, listener);
Runnable notificationTask = new Runnable() {
@Override
public void run() {
if (!myProject.isDisposed() && myProject.isOpen()) {
Notification old = myNotification;
if (old != null) {
boolean similar = Objects.equal(notification.getContent(), old.getContent());
if (similar) {
old.expire();
}
}
myNotification = notification;
notification.notify(myProject);
}
}
};
Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
notificationTask.run();
}
else {
application.invokeLater(notificationTask);
}
}
示例15: runInDispatchThread
import com.intellij.openapi.application.Application; //導入方法依賴的package包/類
@Override
public void runInDispatchThread(@NotNull Runnable action, Project project) {
Application application = ApplicationManager.getApplication();
if (application.isUnitTestMode() || application.isDispatchThread()) {
action.run();
}
else {
WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(action, getCurrentModalityState());
}
}