diff --git a/plugins/git4idea/src/git4idea/actions/GitInit.java b/plugins/git4idea/src/git4idea/actions/GitInit.java index 42db21f25fb6..b8ff63e95568 100644 --- a/plugins/git4idea/src/git4idea/actions/GitInit.java +++ b/plugins/git4idea/src/git4idea/actions/GitInit.java @@ -1,6 +1,7 @@ -// Copyright 2000-2019 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.actions; +import com.intellij.ide.impl.TrustedProjects; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.fileChooser.FileChooser; @@ -30,6 +31,12 @@ import static git4idea.GitNotificationIdsHolder.INIT_FAILED; public class GitInit extends DumbAwareAction { + @Override + public void update(@NotNull AnActionEvent e) { + Project project = e.getProject(); + e.getPresentation().setEnabledAndVisible(project == null || project.isDefault() || TrustedProjects.isTrusted(project)); + } + @Override public void actionPerformed(@NotNull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java index 8d9e124e5404..3d930a30739d 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgInit.java @@ -1,6 +1,7 @@ -// Copyright 2000-2018 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.zmlx.hg4idea.action; +import com.intellij.ide.impl.TrustedProjects; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.progress.util.BackgroundTaskUtil; @@ -36,6 +37,12 @@ public class HgInit extends DumbAwareAction { private Project myProject; + @Override + public void update(@NotNull AnActionEvent e) { + Project project = e.getProject(); + e.getPresentation().setEnabledAndVisible(project == null || project.isDefault() || TrustedProjects.isTrusted(project)); + } + @Override public void actionPerformed(@NotNull AnActionEvent e) { myProject = notNull(e.getData(CommonDataKeys.PROJECT), ProjectManager.getInstance().getDefaultProject()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ImportToRepositoryAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ImportToRepositoryAction.java index a25df9d64b40..9f2522673b90 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ImportToRepositoryAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ImportToRepositoryAction.java @@ -1,10 +1,10 @@ -// Copyright 2000-2019 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. +// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.idea.svn.actions; +import com.intellij.ide.impl.TrustedProjects; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.Presentation; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectManager; @@ -12,16 +12,14 @@ import com.intellij.openapi.vcs.ProjectLevelVcsManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.dialogs.ImportDialog; -/** - * @author alex - */ public class ImportToRepositoryAction extends AnAction implements DumbAware { @Override - public void update(@NotNull final AnActionEvent e) { - final Project project = e.getData(CommonDataKeys.PROJECT); - final Presentation presentation = e.getPresentation(); - presentation.setEnabled(presentation.isEnabled() && - (project == null || (! ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning()))); + public void update(@NotNull AnActionEvent e) { + Project project = e.getData(CommonDataKeys.PROJECT); + e.getPresentation().setEnabled( + project == null || + TrustedProjects.isTrusted(project) && !ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning() + ); } @Override