Search in sources :

Example 6 with ApplicationAdapter

use of com.intellij.openapi.application.ApplicationAdapter in project intellij-community by JetBrains.

the class NoSwingUnderWriteAction method watchForEvents.

static void watchForEvents(Application application) {
    AtomicBoolean reported = new AtomicBoolean();
    IdeEventQueue.getInstance().addPostprocessor(e -> {
        if (application.isWriteAccessAllowed() && reported.compareAndSet(false, true)) {
            LOG.error("AWT events are not allowed inside write action: " + e);
        }
        return true;
    }, application);
    application.addApplicationListener(new ApplicationAdapter() {

        @Override
        public void afterWriteActionFinished(@NotNull Object action) {
            reported.set(false);
        }
    });
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ApplicationAdapter(com.intellij.openapi.application.ApplicationAdapter)

Aggregations

ApplicationAdapter (com.intellij.openapi.application.ApplicationAdapter)6 Application (com.intellij.openapi.application.Application)3 NotNull (org.jetbrains.annotations.NotNull)3 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 Ref (com.intellij.openapi.util.Ref)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 PowerSaveMode (com.intellij.ide.PowerSaveMode)1 Disposable (com.intellij.openapi.Disposable)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 ModalityState (com.intellij.openapi.application.ModalityState)1 ApplicationManagerEx (com.intellij.openapi.application.ex.ApplicationManagerEx)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 ProgressIndicatorBase (com.intellij.openapi.progress.util.ProgressIndicatorBase)1 EmptyRunnable (com.intellij.openapi.util.EmptyRunnable)1 BulkFileListener (com.intellij.openapi.vfs.newvfs.BulkFileListener)1 NewVirtualFile (com.intellij.openapi.vfs.newvfs.NewVirtualFile)1 VFileEvent (com.intellij.openapi.vfs.newvfs.events.VFileEvent)1 Function (com.intellij.util.Function)1