new toolbar - fix perforce - fix #RIDER-67208 fix #RIDER-67189
authorElena.Korotkova <elena.korotkova@jetbrains.com>
Fri, 7 Jan 2022 16:56:08 +0000 (19:56 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sat, 8 Jan 2022 00:57:42 +0000 (00:57 +0000)
GitOrigin-RevId: c7f54b895b7ed5fb860ec8f84f24a83b9291c2b5

platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/NewToolbarRootPaneExtension.kt
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/vcs-api/vcs-api-core/resources/messages/VcsBundle.properties
platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.java [deleted file]
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.kt [new file with mode: 0644]
plugins/git4idea/resources/META-INF/plugin.xml
plugins/git4idea/resources/messages/GitBundle.properties
plugins/git4idea/src/git4idea/actions/GitQuickActionsToolbarPopup.kt

index 87177f6e4847159716569b1390984dc5120c0f9a..a31fe16895a1d97482b6ec1b43535483c0f18124 100644 (file)
@@ -55,13 +55,12 @@ class NewToolbarRootPaneManager(private val project: Project) : SimpleModificati
   }
 
   init {
-    RunWidgetAvailabilityManager.getInstance(project).addListener(this, RunWidgetAvailabilityManager.RunWidgetAvailabilityListener {
+    RunWidgetAvailabilityManager.getInstance(project).addListener(this) {
       logger.info("New toolbar: run widget availability changed $it")
-
       IdeRootPaneNorthExtension.EP_NAME.findExtension(NewToolbarRootPaneExtension::class.java, project)?.let { extension ->
         startUpdateActionGroups(extension)
       }
-    })
+    }
   }
 
   override fun dispose() {
index de804722727ca6d2e1f6022bf48748a20d161c8f..9dd4f8af7b35eff06cd56386abac4886c2db05f7 100644 (file)
@@ -28,7 +28,7 @@ action.Vcs.ShowHistoryForRevision.text=History Up to Here
 action.Vcs.ShowHistoryForRevision.description=Show history for file until the selected revision
 action.Vcs.ShowTabbedFileHistory.text=Show _History
 action.Vcs.ShowTabbedFileHistory.description=Show history of file
-action.SegmentedVcsControlAction.text=Version Control
+action.SegmentedVcsControlAction.text=VCS Widget
 action.AddToFavoritesPopup.text=Add to Favorites
 action.AddToFavoritesPopup.description=Add selected node to favorites
 group.AddToFavorites.text=Add to F_avorites
@@ -2537,7 +2537,7 @@ action.RunConfigurationTemplatesForNewProjects.MainMenu.text=Run Configuration T
 action.TemplateProjectStructure.MainMenu.text=Structure...
 action.ClickLink.text=Click Link
 
-action.RunToolbarWidgetAction.text=Run Widget Component
+action.RunToolbarWidgetAction.text=Run/Debug Widget
 action.RunToolbarProcessStartedAction.text=Active Process
 action.RunToolbarMainSlotInfoAction.text=Active Processes
 action.RunToolbarRunConfigurationsAction.text=Add Configuration...
index 37e15df9202a4e12108b31d1adfb71d1ae1f8ed9..d846d11401e71abdd7849d392e45863db19feeed 100644 (file)
@@ -1214,4 +1214,5 @@ status.text.vcs.toolwindow.help=Version control integration
 status.text.commit.toolwindow.create.repository.prefix=To commit changes,
 status.text.commit.toolwindow.create.repository=Create Git repository\u2026
 status.text.commit.toolwindow.local.history.prefix=For recent changes, see
-status.text.commit.toolwindow.local.history=Local History\u2026
\ No newline at end of file
+status.text.commit.toolwindow.local.history=Local History\u2026
+action.Vcs.Toolbar.ShowMoreActions.text=Version Control
\ No newline at end of file
index 1bb11f2ff188f2e7088c34614cab32a6b55dbd02..d981d0af93ad36697b8e77f52c37f0fd3863211c 100644 (file)
@@ -42,6 +42,9 @@
       <keyboard-shortcut first-keystroke="control T" keymap="$default"/>
       <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
     </action>
+    <action id="Vcs.Toolbar.ShowMoreActions"  class="com.intellij.openapi.vcs.actions.VcsQuickActionsToolbarPopup">
+      <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="last"/>
+    </action>
     <group class="com.intellij.openapi.vcs.actions.VcsGroupsWrapper" id="VcsFileGroupPopup" popup="true">
       <add-to-group group-id="VersionControlsGroup" />
     </group>
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.java
deleted file mode 100644 (file)
index 7851510..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2000-2020 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.vcs.actions;
-
-import com.intellij.ide.DataManager;
-import com.intellij.ide.ui.customization.CustomActionsSchema;
-import com.intellij.idea.ActionsBundle;
-import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
-import com.intellij.openapi.actionSystem.impl.ActionButtonWithText;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.ListPopup;
-import com.intellij.openapi.vcs.VcsActions;
-import com.intellij.openapi.vcs.VcsBundle;
-import com.intellij.util.ui.JBInsets;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.FocusManager;
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.InputEvent;
-import java.awt.event.MouseEvent;
-import java.util.Objects;
-
-/**
- * Vcs quick popup action which is shown in the new toolbar and has two different presentations
- * depending on vcs repo availability
- */
-public class VcsQuickActionsToolbarPopup extends IconWithTextAction implements CustomComponentAction, DumbAware {
-
-  public VcsQuickActionsToolbarPopup() {
-    getTemplatePresentation().setText(VcsBundle.messagePointer("vcs.quicklist.popup.title"));
-  }
-
-  @NotNull
-  @Override
-  public JComponent createCustomComponent(@NotNull Presentation presentation, @NotNull String place) {
-    return new ActionButtonWithText(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
-      @Override
-      public Color getInactiveTextColor() {
-        return getForeground();
-      }
-
-      @Override
-      public Insets getInsets() {
-        return new JBInsets(0, 0, 0, 0);
-      }
-    };
-  }
-
-  @Override
-  public void actionPerformed(@NotNull AnActionEvent e) {
-    DefaultActionGroup group = new DefaultActionGroup();
-    group.add(Objects.requireNonNull(
-      CustomActionsSchema.getInstance().getCorrectedAction(VcsActions.VCS_OPERATIONS_POPUP)));
-
-    if (group.getChildrenCount() == 0) return;
-
-    var dataContext = DataManager.getInstance().getDataContext(FocusManager.getCurrentManager().getFocusOwner());
-    ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
-      VcsBundle.message("action.Vcs.Toolbar.QuickListPopupAction.text"),
-      group, dataContext, JBPopupFactory.ActionSelectionAid.NUMBERING, true, null, -1,
-      action -> true, ActionPlaces.RUN_TOOLBAR_LEFT_SIDE);
-
-    var component = e.getInputEvent().getComponent();
-    popup.showUnderneathOf(component);
-
-  }
-
-  @Override
-  public void update(@NotNull AnActionEvent e) {
-    if (e.getPlace() != ActionPlaces.MAIN_TOOLBAR) {
-      e.getPresentation().setEnabledAndVisible(false);
-      return;
-    }
-  }
-
-  private static void showPopup(@NotNull AnActionEvent e, @NotNull ListPopup popup) {
-    InputEvent mouseEvent = e.getInputEvent();
-    if (mouseEvent instanceof MouseEvent) {
-      Object source = mouseEvent.getSource();
-      if (source instanceof JComponent) {
-        Point topLeftCorner = ((JComponent)source).getLocationOnScreen();
-        Point bottomLeftCorner = new Point(topLeftCorner.x, topLeftCorner.y + ((JComponent)source).getHeight());
-        popup.setLocation(bottomLeftCorner);
-        popup.show((JComponent)source);
-      }
-    }
-  }
-}
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.kt b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.kt
new file mode 100644 (file)
index 0000000..6291af9
--- /dev/null
@@ -0,0 +1,110 @@
+// Copyright 2000-2020 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.vcs.actions
+
+import com.intellij.icons.AllIcons
+import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction
+import com.intellij.openapi.actionSystem.ex.CustomComponentAction
+import com.intellij.openapi.vcs.VcsBundle
+import javax.swing.JComponent
+import com.intellij.openapi.actionSystem.impl.ActionButtonWithText
+import com.intellij.util.ui.JBInsets
+import com.intellij.ide.ui.customization.CustomActionsSchema
+import com.intellij.openapi.vcs.VcsActions
+import com.intellij.ide.DataManager
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.project.DumbAware
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.ui.popup.JBPopupFactory
+import com.intellij.openapi.ui.popup.ListPopup
+import com.intellij.openapi.vcs.ProjectLevelVcsManager
+import java.awt.Color
+import java.awt.Insets
+import java.awt.Point
+import java.awt.event.MouseEvent
+import java.util.*
+import javax.swing.FocusManager
+
+/**
+ * Vcs quick popup action which is shown in the new toolbar and has two different presentations
+ * depending on vcs repo availability
+ */
+open class VcsQuickActionsToolbarPopup : IconWithTextAction(), CustomComponentAction, DumbAware {
+  inner class MyActionButtonWithText(
+    action: AnAction,
+    presentation: Presentation,
+    place: String,
+  ) : ActionButtonWithText(action, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
+
+    override fun getInactiveTextColor(): Color = foreground
+
+    override fun getInsets(): Insets = JBInsets(0, 0, 0, 0)
+  }
+
+  open fun getName(project: Project): String? {
+    return null
+  }
+
+  protected fun updateVcs(project: Project?, e: AnActionEvent): Boolean {
+    if (project == null || e.place !== ActionPlaces.MAIN_TOOLBAR || getName(project) == null ||
+        !ProjectLevelVcsManager.getInstance(project).checkVcsIsActive(getName(project))) {
+      e.presentation.isEnabledAndVisible = false
+      return false
+    }
+    return true
+  }
+
+  override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
+    return object : ActionButtonWithText(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
+      override fun getInactiveTextColor(): Color {
+        return foreground
+      }
+
+      override fun getInsets(): Insets {
+        return JBInsets(0, 0, 0, 0)
+      }
+    }
+  }
+
+  override fun actionPerformed(e: AnActionEvent) {
+    val group = DefaultActionGroup()
+    CustomActionsSchema.getInstance().getCorrectedAction(VcsActions.VCS_OPERATIONS_POPUP)?.let {
+      group.add(
+        it)
+    }
+    if (group.childrenCount == 0) return
+    val dataContext = DataManager.getInstance().getDataContext(FocusManager.getCurrentManager().focusOwner)
+    val popup = JBPopupFactory.getInstance().createActionGroupPopup(
+      VcsBundle.message("action.Vcs.Toolbar.QuickListPopupAction.text"),
+      group, dataContext, JBPopupFactory.ActionSelectionAid.NUMBERING, true, null, -1,
+      { action: AnAction? -> true }, ActionPlaces.RUN_TOOLBAR_LEFT_SIDE)
+    val component = e.inputEvent.component
+    popup.showUnderneathOf(component)
+  }
+
+  override fun update(e: AnActionEvent) {
+    val presentation = e.presentation
+    if (e.project == null ||
+        e.place !== ActionPlaces.MAIN_TOOLBAR || ProjectLevelVcsManager.getInstance(e.project!!).hasActiveVcss()) {
+      presentation.isEnabledAndVisible = false
+      return
+    }
+    presentation.isEnabledAndVisible = true
+    presentation.icon = AllIcons.Vcs.BranchNode
+    presentation.text = VcsBundle.message("action.Vcs.Toolbar.ShowMoreActions.text") + " "
+  }
+
+  companion object {
+    private fun showPopup(e: AnActionEvent, popup: ListPopup) {
+      val mouseEvent = e.inputEvent
+      if (mouseEvent is MouseEvent) {
+        val source = mouseEvent.getSource()
+        if (source is JComponent) {
+          val topLeftCorner = source.locationOnScreen
+          val bottomLeftCorner = Point(topLeftCorner.x, topLeftCorner.y + source.height)
+          popup.setLocation(bottomLeftCorner)
+          popup.show(source)
+        }
+      }
+    }
+  }
+}
\ No newline at end of file
index 2fe31e5f4e71cfe824fcc553a57a90137e05c261..0fd17152709de74c41e52e45534ef1b96cd55e20 100644 (file)
       <add-to-group group-id="VcsGroup" anchor="last"/>
     </group>
 
-    <action id="Vcs.ShowBranches" class="git4idea.actions.GitBranchesComboBoxAction" icon="AllIcons.Vcs.Branch">
+    <action id="Git.ShowBranches" class="git4idea.actions.GitBranchesComboBoxAction" icon="AllIcons.Vcs.Branch">
       <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
     </action>
 
-    <action id="Vcs.Toolbar.ShowMoreActions" class="git4idea.actions.GitQuickActionsToolbarPopup">
+    <action id="Git.Toolbar.ShowMoreActions" class="git4idea.actions.GitQuickActionsToolbarPopup">
       <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="last"/>
     </action>
 
index 76a4a1cd9a9e2b355aeae786c77ab58767a36a19..289bf8e969a536b2d3f894765be5abfef4108a6e 100644 (file)
@@ -1411,7 +1411,7 @@ notification.content.updating.root.failed.with.error=Update {0} failed with an e
 git.update.operation=Update
 progress.update.destination.remote=Remote
 action.Vcs.ShowBranches.text=Show Branches
-action.Vcs.Toolbar.ShowMoreActions.text=Version Control
+action.Git.Toolbar.ShowMoreActions.text=Version Control
 no.revisions.available=No revisions
 search.everywhere.group.name=Git
 search.everywhere.group.full.name=Git Refs
index e6ab90b7cdd3a4f54f3409affa541feb60b50191..a9051c27e05a9bf9a174affe2049148c10e4206f 100644 (file)
@@ -4,17 +4,14 @@ package git4idea.actions
 import com.intellij.dvcs.repo.VcsRepositoryMappingListener
 import com.intellij.icons.AllIcons
 import com.intellij.openapi.actionSystem.*
-import com.intellij.openapi.actionSystem.impl.ActionButtonWithText
 import com.intellij.openapi.components.Service
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.vcs.actions.VcsQuickActionsToolbarPopup
 import com.intellij.util.IconUtil
-import com.intellij.util.ui.JBInsets
+import git4idea.GitVcs
 import git4idea.i18n.GitBundle
 import git4idea.repo.GitRepositoryManager
-import java.awt.Color
 import java.awt.Dimension
-import java.awt.Insets
 import javax.swing.Icon
 import javax.swing.JComponent
 
@@ -36,15 +33,8 @@ class GitQuickActionsToolbarService {
 
 internal class GitQuickActionsToolbarPopup : VcsQuickActionsToolbarPopup() {
 
-  private inner class MyActionButtonWithText(
-    action: AnAction,
-    presentation: Presentation,
-    place: String,
-  ) : ActionButtonWithText(action, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
-
-    override fun getInactiveTextColor(): Color = foreground
-
-    override fun getInsets(): Insets = JBInsets(0, 0, 0, 0)
+  override fun getName(project: Project): String {
+    return GitVcs.getInstance(project).name
   }
 
   override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
@@ -52,13 +42,11 @@ internal class GitQuickActionsToolbarPopup : VcsQuickActionsToolbarPopup() {
   }
 
   override fun update(e: AnActionEvent) {
-    if (e.place !== ActionPlaces.MAIN_TOOLBAR) {
-      e.presentation.isEnabledAndVisible = false
-      return
-    }
-    e.project ?: return
+    val project = e.project
     val presentation = e.presentation
-    val instance = GitQuickActionsToolbarService.getInstance(e.project!!)
+
+    if (!updateVcs(project, e)) return
+    val instance = GitQuickActionsToolbarService.getInstance(project!!)
     if (!instance.gitMappingInitialized) {
       presentation.isEnabledAndVisible = false
       return
@@ -67,7 +55,7 @@ internal class GitQuickActionsToolbarPopup : VcsQuickActionsToolbarPopup() {
       presentation.isEnabledAndVisible = true
     }
 
-    val repo = GitRepositoryManager.getInstance(e.project!!).repositories.isNotEmpty()
+    val repo = GitRepositoryManager.getInstance(project).repositories.isNotEmpty()
 
     presentation.icon = if (repo) {
       AllIcons.Actions.More.toSize(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE)