Skip to content

Commit

Permalink
remote dev + cwm: enabling more actions in the prject view popup
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 4d393e00eb71b14c5789d0617219f96da9fe99b5
  • Loading branch information
jubi20 authored and intellij-monorepo-bot committed Jun 23, 2021
1 parent cc14b27 commit 63a6953
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
@@ -1,6 +1,7 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.actionSystem.impl;

import com.intellij.codeWithMe.ClientId;
import com.intellij.ide.IdeEventQueue;
import com.intellij.ide.ProhibitAWTEvents;
import com.intellij.openapi.Disposable;
Expand Down Expand Up @@ -278,18 +279,21 @@ else if (myContextMenuAction) {
});
};
ourPromises.add(promise);
ClientId clientId = ClientId.getCurrent();
ourExecutor.execute(() -> {
boolean[] success = {false};
try {
ApplicationEx applicationEx = ApplicationManagerEx.getApplicationEx();
BackgroundTaskUtil.runUnderDisposeAwareIndicator(disposableParent, () ->
success[0] = ProgressIndicatorUtils.runActionAndCancelBeforeWrite(
applicationEx,
() -> cancelPromise(promise, "write-action requested"),
() -> applicationEx.tryRunReadAction(runnable)), indicator);
if (!success[0] && !promise.isDone()) {
cancelPromise(promise, "read-action unavailable");
}
ClientId.withClientId(clientId, () -> {
ApplicationEx applicationEx = ApplicationManagerEx.getApplicationEx();
BackgroundTaskUtil.runUnderDisposeAwareIndicator(disposableParent, () ->
success[0] = ProgressIndicatorUtils.runActionAndCancelBeforeWrite(
applicationEx,
() -> cancelPromise(promise, "write-action requested"),
() -> applicationEx.tryRunReadAction(runnable)), indicator);
if (!success[0] && !promise.isDone()) {
cancelPromise(promise, "read-action unavailable");
}
});
}
catch (Throwable e) {
if (!promise.isDone()) {
Expand Down
@@ -0,0 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.actionSystem.impl

interface AsyncDataContext
Expand Up @@ -37,7 +37,7 @@
/**
* @author gregsh
*/
class PreCachedDataContext implements DataContext, UserDataHolder, AnActionEvent.InjectedDataContextSupplier {
class PreCachedDataContext implements DataContext, UserDataHolder, AnActionEvent.InjectedDataContextSupplier, AsyncDataContext {

private static int ourPrevMapEventCount;
private static final Map<Component, Map<String, Object>> ourPrevMaps = ContainerUtil.createWeakKeySoftValueMap();
Expand Down
Expand Up @@ -86,7 +86,7 @@ else if (dataContext instanceof SimpleDataContext && component != null) {
}

public static boolean isAsyncDataContext(@NotNull DataContext dataContext) {
return dataContext instanceof PreCachedDataContext;
return dataContext instanceof AsyncDataContext;
}

@ApiStatus.Internal
Expand Down

0 comments on commit 63a6953

Please sign in to comment.