}
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() {
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
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...
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
<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>
+++ /dev/null
-// 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);
- }
- }
- }
-}
--- /dev/null
+// 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
<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>
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
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
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 {
}
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
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)