<keyboard-shortcut first-keystroke="control shift K" keymap="$default"/>
<add-to-group group-id="VcsToolbarActions" anchor="after" relative-to-action="ChangesView.ToggleCommitUi"/>
<add-to-group group-id="VcsNavBarToolbarActions" anchor="after" relative-to-action="ChangesView.ToggleCommitUi"/>
- <add-to-group group-id="VcsNavBarToolbarActionsLight" anchor="after" relative-to-action="ChangesView.ToggleCommitUi"/>
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="after" relative-to-action="ChangesView.ToggleCommitUi"/>
</action>
<action id="Vcs.Force.Push" class="com.intellij.dvcs.push.ui.ForcePushAction"/>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceImplementation="com.intellij.ide.ui.UISettings" preload="true"/>
<applicationService serviceImplementation="com.intellij.ide.ui.NotRoamableUiSettings"/>
+ <applicationService serviceInterface="com.intellij.ide.ui.ToolbarSettings"
+ serviceImplementation="com.intellij.ide.ui.CoreToolbarSettings"/>
+
<projectService
serviceInterface="com.intellij.openapi.vcs.FileStatusManager"
serviceImplementation="com.intellij.openapi.vcs.DefaultFileStatusManager" />
--- /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.ide.ui
+
+import com.intellij.openapi.components.*
+
+class CoreToolbarSettings private constructor() : ToolbarSettings{
+
+ private var uiStateSettings: UISettingsState? = null
+
+ override fun isNavBarVisible(): Boolean {
+ return uiSettingsState().showNavigationBar
+ }
+
+ override fun setNavBarVisible(value: Boolean) {
+ uiSettingsState().showNavigationBar = value
+ }
+
+ override fun isToolbarVisible(): Boolean {
+ return uiSettingsState().showMainToolbar
+ }
+
+ override fun setToolbarVisible(b: Boolean) {
+ uiSettingsState().showMainToolbar = b
+ }
+
+ override fun getShowToolbarInNavigationBar(): Boolean {
+ return !uiSettingsState().showMainToolbar && uiSettingsState().showNavigationBar
+ }
+
+ private fun uiSettingsState(): UISettingsState{
+ if(uiStateSettings == null){
+ uiStateSettings = UISettings.instance.state
+ }
+ return uiStateSettings!!
+ }
+
+}
--- /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.ide.ui
+
+import com.intellij.openapi.application.ApplicationManager
+
+interface ToolbarSettings {
+
+ companion object {
+ fun getInstance(): ToolbarSettings {
+ return ApplicationManager.getApplication().getService(ToolbarSettings::class.java)
+ }
+ }
+ fun isNavBarVisible(): Boolean
+
+ fun setNavBarVisible(b: Boolean)
+
+ fun isToolbarVisible(): Boolean
+
+ fun setToolbarVisible(b: Boolean)
+
+ fun getShowToolbarInNavigationBar(): Boolean
+
+}
\ No newline at end of file
var showNavigationBar: Boolean
get() = state.showNavigationBar
- set(value) {
- state.showNavigationBar = value
+ set(b) {
+ ToolbarSettings.getInstance().setNavBarVisible(b)
+ fireUISettingsChanged()
}
+ val showToolbarInNavigationBar: Boolean
+ get() = ToolbarSettings.getInstance().getShowToolbarInNavigationBar()
+
var showMembersInNavigationBar: Boolean
get() = state.showMembersInNavigationBar
set(value) {
}
var showMainToolbar: Boolean
- get() = state.showMainToolbar
+ get() = state.showMainToolbar
set(value) {
- state.showMainToolbar = value
+ ToolbarSettings.getInstance().setToolbarVisible(value)
+ fireUISettingsChanged()
}
var showIconsInMenus: Boolean
state.mergeMainMenuWithWindowTitle = value
}
- val showNewNavbarVcsGroup: Boolean
- get() = Registry.`is`("ide.new.navbar.vcs.group", false)
-
- val showNewToolbar: Boolean
- get() = Registry.`is`("ide.new.navbar", false)
init {
// TODO Remove the registry keys and migration code in 2019.3
}
const val MERGE_MAIN_MENU_WITH_WINDOW_TITLE_PROPERTY = "ide.win.frame.decoration"
+
@JvmStatic
val mergeMainMenuWithWindowTitleOverrideValue = System.getProperty(MERGE_MAIN_MENU_WITH_WINDOW_TITLE_PROPERTY)?.toBoolean()
val isMergeMainMenuWithWindowTitleOverridden = mergeMainMenuWithWindowTitleOverrideValue != null
--- /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.ide.ui.experimental.toolbar
+
+import com.intellij.ide.ui.ToolbarSettings
+import com.intellij.ide.ui.UISettings
+import com.intellij.openapi.components.*
+import com.intellij.openapi.util.registry.Registry
+
+@State(name = "ToolbarSettingsService", storages = [(Storage(StoragePathMacros.NON_ROAMABLE_FILE))])
+class ExperimentalToolbarSettings private constructor() : ToolbarSettings,
+ PersistentStateComponent<ExperimentalToolbarStateWrapper> {
+
+ val newToolbarEnabled: Boolean
+ get() = Registry.`is`("ide.new.navbar", false)
+
+ val showNewNavbarVcsGroup: Boolean
+ get() = Registry.`is`("ide.new.navbar.vcs.group", false)
+
+ val showNewNavbarRunGroup: Boolean
+ get() = Registry.`is`("ide.new.navbar.run.debug", false)
+
+ private var toolbarState = ExperimentalToolbarStateWrapper()
+
+
+ override fun getState(): ExperimentalToolbarStateWrapper {
+ return toolbarState
+ }
+
+ override fun loadState(state: ExperimentalToolbarStateWrapper) {
+ toolbarState = state
+ updateSettingsState()
+ }
+
+ fun getToolbarStateByVisibilityFlags(newToolbarEnabled: Boolean, oldToolbarVisible: Boolean,
+ newToolbarVisible: Boolean, navBarVisible: Boolean): ExperimentalToolbarStateEnum {
+ if (oldToolbarVisible && newToolbarVisible) {
+ throw IllegalStateException()
+ }
+ if (newToolbarEnabled && newToolbarVisible) {
+ if (navBarVisible) {
+ return ExperimentalToolbarStateEnum.NEW_TOOLBAR_WITH_NAVBAR
+ }
+ else {
+ return ExperimentalToolbarStateEnum.NEW_TOOLBAR_WITHOUT_NAVBAR
+ }
+ }
+ else if (oldToolbarVisible) {
+ if (navBarVisible) {
+ return ExperimentalToolbarStateEnum.OLD_TOOLBAR_WITH_NAVBAR_SEPARATE
+ }
+ else {
+ return ExperimentalToolbarStateEnum.OLD_TOOLBAR_WITHOUT_NAVBAR
+ }
+ }
+ else {
+ if (navBarVisible) {
+ return ExperimentalToolbarStateEnum.OLD_NAVBAR
+ }
+ else {
+ return ExperimentalToolbarStateEnum.NO_TOOLBAR_NO_NAVBAR
+ }
+ }
+ }
+
+ override fun isNavBarVisible(): Boolean {
+ return toolbarState.state.navBarVisible
+ }
+
+ override fun setNavBarVisible(value: Boolean) {
+
+ toolbarState.state = getToolbarStateByVisibilityFlags(newToolbarEnabled, toolbarState.state.oldToolbarVisible,
+ toolbarState.state.newToolbarVisible,
+ value)
+ updateSettingsState()
+ UISettings.instance.fireUISettingsChanged()
+ }
+
+ private fun updateSettingsState() {
+ UISettings.instance.state.showNavigationBar = toolbarState.state.navBarVisible
+ UISettings.instance.state.showMainToolbar = toolbarState.state.oldToolbarVisible
+ }
+
+ override fun isToolbarVisible(): Boolean {
+ return toolbarState.state.oldToolbarVisible
+ }
+
+ override fun setToolbarVisible(value: Boolean) {
+ if (value) {
+ toolbarState.state = getToolbarStateByVisibilityFlags(newToolbarEnabled, value, false, toolbarState.state.navBarVisible)
+ }
+ else {
+ toolbarState.state = getToolbarStateByVisibilityFlags(newToolbarEnabled, value, toolbarState.state.newToolbarVisible,
+ toolbarState.state.navBarVisible)
+ }
+ updateSettingsState()
+ UISettings.instance.fireUISettingsChanged()
+ }
+
+ override fun getShowToolbarInNavigationBar(): Boolean {
+ return toolbarState.equals(ExperimentalToolbarStateEnum.OLD_NAVBAR)
+ }
+
+ var showNewToolbar: Boolean
+ get() = toolbarState.state.newToolbarVisible
+ set(value) {
+ if (value) {
+ toolbarState.state = getToolbarStateByVisibilityFlags(newToolbarEnabled, false, value, toolbarState.state.navBarVisible)
+ }
+ else {
+ toolbarState.state = getToolbarStateByVisibilityFlags(newToolbarEnabled, toolbarState.state.oldToolbarVisible, value,
+ toolbarState.state.navBarVisible)
+ }
+ updateSettingsState()
+ UISettings.instance.fireUISettingsChanged()
+ }
+}
+
+
+
--- /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.ide.ui.experimental.toolbar
+
+/**
+ * New toolbar state plus support legacy toolbar
+ */
+enum class ExperimentalToolbarStateEnum(val oldToolbarVisible: Boolean, val newToolbarVisible: Boolean, val navBarVisible: Boolean) {
+ NEW_TOOLBAR_WITH_NAVBAR(false, true, true),
+ NEW_TOOLBAR_WITHOUT_NAVBAR(false, true, false),
+ OLD_NAVBAR(false, false, true), //navbar with old toolbar integrated
+ OLD_TOOLBAR_WITH_NAVBAR_SEPARATE(true, false, true),
+ OLD_TOOLBAR_WITHOUT_NAVBAR(true, false, false),
+ NO_TOOLBAR_NO_NAVBAR(false, false, false)
+ //only navbar option without any toolbar - was not possible
+}
\ No newline at end of file
--- /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.ide.ui.experimental.toolbar
+
+import com.intellij.openapi.components.BaseState
+import com.intellij.util.xmlb.annotations.OptionTag
+
+class ExperimentalToolbarStateWrapper: BaseState() {
+
+ @get:OptionTag("NEW_TOOLBAR_SETTINGS")
+ var state by enum(ExperimentalToolbarStateEnum.NEW_TOOLBAR_WITHOUT_NAVBAR)
+}
\ No newline at end of file
--- /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.execution.segmentedVcsWidget // 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.
+
+import com.intellij.openapi.actionSystem.ActionGroup
+import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.impl.segmentedActionBar.SegmentedBarActionComponent
+import org.jetbrains.annotations.NotNull
+import javax.swing.SwingUtilities
+
+class SegmentedVcsControlAction : SegmentedBarActionComponent() {
+ init {
+ ActionManager.getInstance().getAction("SegmentedVcsActionsBarGroup")?.let {
+ if(it is ActionGroup) {
+ SwingUtilities.invokeLater {
+ actionGroup = it
+ }
+ }
+ }
+ }
+
+ override fun update(e: @NotNull AnActionEvent) {
+ super.update(e)
+ e.presentation.isVisible = actionGroup != null
+ }
+}
\ No newline at end of file
return null;
}
- private static String getShortcut() {
+ protected static String getShortcut() {
Shortcut[] shortcuts = KeymapUtil.getActiveKeymapShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE).getShortcuts();
if (shortcuts.length == 0) {
return "Double" + (SystemInfo.isMac ? FontUtil.thinSpace() + MacKeymapUtil.SHIFT : " Shift"); //NON-NLS
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.util.ui.JBSwingUtilities;
import com.intellij.util.ui.JBUI;
-import kotlin.Unit;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
private JComponent myWrapperPanel;
@NonNls public static final String NAV_BAR = "NavBar";
@SuppressWarnings("StatefulEp")
- private Project myProject;
+ private final Project myProject;
private NavBarPanel myNavigationBar;
private JPanel myRunPanel;
private final boolean myNavToolbarGroupExist;
myProject = project;
myProject.getMessageBus().connect().subscribe(UISettingsListener.TOPIC, uiSettings -> {
- toggleRunPanel(!uiSettings.getShowMainToolbar() && uiSettings.getShowNavigationBar() && !uiSettings.getPresentationMode());
+ toggleRunPanel(isShowToolPanel(uiSettings));
});
myNavToolbarGroupExist = runToolbarExists();
}
+ private static boolean isShowToolPanel(@NotNull UISettings uiSettings) {
+ return uiSettings.getShowToolbarInNavigationBar() && !uiSettings.getPresentationMode();
+ }
+
@Override
public void revalidate() {
final UISettings settings = UISettings.getInstance();
- if (!settings.getShowMainToolbar() && settings.getShowNavigationBar() && !UISettings.getInstance().getPresentationMode()) {
+ if (isShowToolPanel(settings)) {
toggleRunPanel(false);
toggleRunPanel(true);
}
}
public boolean isMainToolbarVisible() {
- return !UISettings.getInstance().getPresentationMode() && (UISettings.getInstance().getShowMainToolbar() || !myNavToolbarGroupExist);
+ return !UISettings.getInstance().getPresentationMode() &&
+ (UISettings.getInstance().getShowMainToolbar() || !myNavToolbarGroupExist);
}
public static boolean runToolbarExists() {
addNavigationBarPanel(myWrapperPanel);
- toggleRunPanel(!UISettings.getInstance().getShowMainToolbar() && !UISettings.getInstance().getPresentationMode());
+ toggleRunPanel(isShowToolPanel(UISettings.getInstance()));
}
return myWrapperPanel;
}
Insets insets = container.getInsets();
Dimension d = c.getPreferredSize();
Rectangle r = container.getBounds();
- c.setBounds(insets.left, (r.height - d.height - insets.top - insets.bottom) / 2 + insets.top, r.width - insets.left - insets.right, d.height);
+ c.setBounds(insets.left, (r.height - d.height - insets.top - insets.bottom) / 2 + insets.top, r.width - insets.left - insets.right,
+ d.height);
}
}
AnAction toolbarRunGroup = CustomActionsSchema.getInstance().getCorrectedAction("NavBarToolBar");
if (toolbarRunGroup instanceof ActionGroup && myWrapperPanel != null) {
- final ActionToolbar actionToolbar = manager.createActionToolbar(ActionPlaces.NAVIGATION_BAR_TOOLBAR, (ActionGroup)toolbarRunGroup, true);
+ final ActionToolbar actionToolbar =
+ manager.createActionToolbar(ActionPlaces.NAVIGATION_BAR_TOOLBAR, (ActionGroup)toolbarRunGroup, true);
final JComponent component = actionToolbar.getComponent();
myRunPanel = new JPanel(new BorderLayout()) {
@Override
Insets insets = getInsets();
Rectangle r = navBar.getBounds();
- Graphics2D g2d = (Graphics2D) g.create();
+ Graphics2D g2d = (Graphics2D)g.create();
g2d.translate(r.x, r.y);
g2d.dispose();
}
--- /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.ide.navigationToolbar.experimental
+
+import com.intellij.openapi.actionSystem.DefaultActionGroup
+
+class CenterToolbarGroup: DefaultActionGroup() {
+}
\ No newline at end of file
--- /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.ide.navigationToolbar.experimental
+
+import com.intellij.openapi.actionSystem.DefaultActionGroup
+
+class LeftToolbarGroup: DefaultActionGroup() {
+}
\ No newline at end of file
--- /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.ide.navigationToolbar.experimental
+
+import com.intellij.ide.ui.ToolbarSettings
+import com.intellij.ide.ui.UISettings
+import com.intellij.ide.ui.UISettings.Companion.instance
+import com.intellij.ide.ui.UISettingsListener
+import com.intellij.ide.ui.experimental.toolbar.ExperimentalToolbarSettings
+import com.intellij.openapi.Disposable
+import com.intellij.openapi.actionSystem.*
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.registry.Registry
+import com.intellij.openapi.util.registry.RegistryValue
+import com.intellij.openapi.util.registry.RegistryValueListener
+import com.intellij.openapi.wm.IdeRootPaneNorthExtension
+import com.intellij.util.containers.stream
+import com.intellij.util.ui.JBSwingUtilities
+import org.jetbrains.annotations.NotNull
+import java.awt.BorderLayout
+import java.awt.Graphics
+import javax.swing.JComponent
+import javax.swing.JPanel
+
+class NewToolbarRootPaneExtension(val myProject: Project) : IdeRootPaneNorthExtension(), @NotNull Disposable {
+
+ companion object {
+ private const val NEW_TOOLBAR_KEY = "NEW_TOOLBAR_KEY"
+ const val navBarKey = "ide.new.navbar"
+ const val runDebugKey = "ide.new.navbar.run.debug"
+ const val vcsKey = "ide.new.navbar.vcs.group"
+ }
+
+ private val myPanel: JPanel = object : JPanel() {
+ override fun getComponentGraphics(graphics: Graphics?): Graphics? {
+ return JBSwingUtilities.runGlobalCGTransform(this, super.getComponentGraphics(graphics))
+ }
+ }
+
+ private val myLeftPanel: JPanel = JPanel(BorderLayout())
+ private val myCenterPanel: JPanel = JPanel(BorderLayout())
+ private val myRightPanel: JPanel = JPanel(BorderLayout())
+
+
+ private val registryListener = object : RegistryValueListener {
+ override fun afterValueChanged(value: RegistryValue) {
+ revalidate()
+ }
+ }
+
+ init {
+ val manager = ActionManager.getInstance()
+
+ Registry.get(navBarKey).addListener(registryListener, this)
+ Registry.get(runDebugKey).addListener(registryListener, this)
+ Registry.get(vcsKey).addListener(registryListener, this)
+
+ myPanel.layout = BorderLayout()
+ myPanel.add(myLeftPanel, BorderLayout.WEST)
+ myPanel.add(myCenterPanel, BorderLayout.CENTER)
+ myPanel.add(myRightPanel, BorderLayout.EAST)
+ myPanel.isOpaque = false
+ myLeftPanel.isOpaque = false
+ myRightPanel.isOpaque = false
+
+ val newToolbarActions = ActionManager.getInstance().getAction("NewToolbarActions")
+
+ val listChildren = (newToolbarActions as ActionGroup).getChildren(null)
+ addGroupComponent<LeftToolbarGroup>(listChildren, myLeftPanel, BorderLayout.EAST)
+ addGroupComponent<CenterToolbarGroup>(listChildren, myCenterPanel, BorderLayout.EAST)
+ addGroupComponent<RightToolbarGroup>(listChildren, myRightPanel, BorderLayout.WEST)
+
+ revalidate()
+ myProject.messageBus.connect().subscribe(UISettingsListener.TOPIC, UISettingsListener { revalidate() })
+
+ }
+
+ private inline fun <reified T : DefaultActionGroup> addGroupComponent(listChildren: Array<AnAction>, panel: JPanel, alignment: String) {
+ val actionsGroup = listChildren.stream().filter { it is T }.findAny()
+ if (actionsGroup.isPresent) {
+ val actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.NAVIGATION_BAR_TOOLBAR,
+ actionsGroup.get() as @NotNull ActionGroup, true)
+ val component = actionToolbar.component
+ panel.add(component, alignment)
+ }
+ }
+
+ override fun getKey(): String {
+ return NEW_TOOLBAR_KEY
+ }
+
+ override fun revalidate() {
+ val toolbarSettingsService = ToolbarSettings.Companion.getInstance()
+ if (toolbarSettingsService is ExperimentalToolbarSettings) {
+ myPanel.isVisible = toolbarSettingsService.showNewToolbar && !instance.presentationMode
+ myLeftPanel.isVisible = toolbarSettingsService.showNewNavbarVcsGroup
+ myRightPanel.isVisible = toolbarSettingsService.showNewNavbarRunGroup
+ }
+ else {
+ myPanel.isVisible = false
+ myLeftPanel.isVisible = false
+ myRightPanel.isVisible = false
+ }
+ }
+
+ override fun getComponent(): JComponent {
+ return myPanel
+ }
+
+ override fun uiSettingsChanged(settings: UISettings) {
+ revalidate()
+ }
+
+ override fun copy(): IdeRootPaneNorthExtension {
+ return NewToolbarRootPaneExtension(myProject)
+ }
+
+ override fun dispose() {
+ }
+
+}
\ No newline at end of file
--- /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.ide.navigationToolbar.experimental
+
+import com.intellij.openapi.actionSystem.DefaultActionGroup
+
+class RightToolbarGroup: DefaultActionGroup() {
+}
\ No newline at end of file
--- /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.ide.navigationToolbar.experimental
+
+import com.intellij.icons.AllIcons
+import com.intellij.ide.DataManager
+import com.intellij.ide.actions.SearchEverywhereAction
+import com.intellij.idea.ActionsBundle
+import com.intellij.openapi.actionSystem.ActionManager
+import com.intellij.openapi.actionSystem.ActionToolbar
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.Presentation
+import com.intellij.openapi.util.text.StringUtil
+import com.intellij.util.ui.JBInsets
+import com.intellij.util.ui.accessibility.ScreenReader
+import java.awt.Dimension
+import java.awt.event.MouseAdapter
+import java.awt.event.MouseEvent
+import javax.swing.JButton
+import javax.swing.JComponent
+
+class SearchEverywhereNewToolbarAction : SearchEverywhereAction() {
+
+ override fun createCustomComponent(presentation: Presentation, place: String): JComponent {
+ return object : JButton() {
+ init {
+ icon = AllIcons.Actions.Search
+ text = ActionsBundle.message("action.SearchEverywhere.text")
+ getModel().isEnabled = false
+ isVisible = presentation.isVisible
+ isFocusable = ScreenReader.isActive()
+
+ addMouseListener(object : MouseAdapter() {
+ override fun mouseClicked(e: MouseEvent?) {
+ DataManager.getInstance().dataContextFromFocusAsync.onSuccess {
+ if (e != null) {
+ val e1 = MouseEvent(e.component, e.id, e.`when`, 0, 0, 0, 0, true, 0)
+ actionPerformed(
+ AnActionEvent(e1, it, "", templatePresentation,
+ ActionManager.getInstance(), 0))
+ }
+ }
+ }
+ })
+ }
+
+ override fun getPreferredSize(): Dimension? {
+ val prefSize = super.getPreferredSize()
+ val i = insets
+ val width = prefSize.width + (if (StringUtil.isNotEmpty(text)) iconTextGap else 0)
+ var height = ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height + i.top + i.bottom
+
+ val size = Dimension(width, height)
+ JBInsets.addTo(size, margin)
+ return size
+ }
+ }
+ }
+}
\ No newline at end of file
--- /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.ide.actions
+
+import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.project.DumbAwareAction
+
+class CustomizeToolbarAction: DumbAwareAction() {
+
+ init {
+ println()
+ }
+
+ override fun actionPerformed(e: AnActionEvent) {
+ TODO("Not yet implemented")
+ }
+}
\ No newline at end of file
DaemonCodeAnalyzerSettings ds = DaemonCodeAnalyzerSettings.getInstance();
if (enter) {
- applyAndSave(p, ui.getState(), eo, ds, BEFORE, AFTER, false);
+ applyAndSave(p, ui, eo, ds, BEFORE, AFTER, false);
TogglePresentationModeAction.storeToolWindows(project);
} else {
- applyAndSave(p, ui.getState(), eo, ds, AFTER, BEFORE, true);
+ applyAndSave(p, ui, eo, ds, AFTER, BEFORE, true);
}
UISettings.getInstance().fireUISettingsChanged();
}
private static void applyAndSave(@NotNull PropertiesComponent p,
- @NotNull UISettingsState ui,
+ @NotNull UISettings uiSettings,
@NotNull EditorSettingsExternalizable.OptionSet eo,
@NotNull DaemonCodeAnalyzerSettings ds,
String before, String after, boolean value) {
+ var ui = uiSettings.getState();
// @formatter:off
p.setValue(before + "SHOW_STATUS_BAR", valueOf(ui.getShowStatusBar())); ui.setShowStatusBar(p.getBoolean(after + "SHOW_STATUS_BAR", value));
- p.setValue(before + "SHOW_MAIN_TOOLBAR", valueOf(ui.getShowMainToolbar())); ui.setShowMainToolbar(p.getBoolean(after + "SHOW_MAIN_TOOLBAR", value));
- p.setValue(before + "SHOW_NAVIGATION_BAR", valueOf(ui.getShowNavigationBar())); ui.setShowNavigationBar(p.getBoolean(after + "SHOW_NAVIGATION_BAR", value));
+
+ p.setValue(before + "SHOW_MAIN_TOOLBAR", valueOf(uiSettings.getShowMainToolbar())); uiSettings.setShowMainToolbar(p.getBoolean(after + "SHOW_MAIN_TOOLBAR", value));
+ p.setValue(before + "SHOW_NAVIGATION_BAR", valueOf(uiSettings.getShowNavigationBar())); uiSettings.setShowNavigationBar(p.getBoolean(after + "SHOW_NAVIGATION_BAR", value));
p.setValue(before + "IS_FOLDING_OUTLINE_SHOWN", valueOf(eo.IS_FOLDING_OUTLINE_SHOWN)); eo.IS_FOLDING_OUTLINE_SHOWN = p.getBoolean(after + "IS_FOLDING_OUTLINE_SHOWN", value);
p.setValue(before + "IS_WHITESPACES_SHOWN", valueOf(eo.IS_WHITESPACES_SHOWN)); eo.IS_WHITESPACES_SHOWN = p.getBoolean(after + "IS_WHITESPACES_SHOWN", value);
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.ide.ui.ToolbarSettings;
+import com.intellij.ide.ui.experimental.toolbar.ExperimentalToolbarSettings;
+import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+
+public class ViewNewToolbarAction extends ToggleAction implements DumbAware {
+
+ @Override
+ public boolean isSelected(@NotNull AnActionEvent event) {
+ var toolbarService = ToolbarSettings.Companion.getInstance();
+ if (toolbarService instanceof ExperimentalToolbarSettings) {
+ return ((ExperimentalToolbarSettings)toolbarService).getShowNewToolbar();
+ }
+ return false;
+ }
+
+ @Override
+ public void setSelected(@NotNull AnActionEvent event, boolean state) {
+ UISettings uiSettings = UISettings.getInstance();
+ var toolbarService = ToolbarSettings.Companion.getInstance();
+ ((ExperimentalToolbarSettings)toolbarService).setShowNewToolbar(state);
+ uiSettings.fireUISettingsChanged();
+ }
+}
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+
+public class ViewObsoleteNavBarAction extends ToggleAction implements DumbAware {
+
+ @Override
+ public boolean isSelected(@NotNull AnActionEvent event) {
+ return UISettings.getInstance().getShowNavigationBar();
+ }
+
+ @Override
+ public void setSelected(@NotNull AnActionEvent event, boolean state) {
+ UISettings uiSettings = UISettings.getInstance();
+ uiSettings.setShowNavigationBar(state);
+ uiSettings.fireUISettingsChanged();
+ }
+}
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+
+public class ViewObsoleteToolbarAction extends ToggleAction implements DumbAware {
+ @Override
+ public boolean isSelected(@NotNull AnActionEvent event) {
+ return UISettings.getInstance().getShowMainToolbar();
+ }
+
+ @Override
+ public void setSelected(@NotNull AnActionEvent event, boolean state) {
+ UISettings uiSettings = UISettings.getInstance();
+ uiSettings.setShowMainToolbar(state);
+ uiSettings.fireUISettingsChanged();
+ }
+}
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+
+
+public class ViewToolbarActionsGroup extends DefaultActionGroup {
+ @Override
+ public void update(@NotNull AnActionEvent e) {
+ super.update(e);
+ var isEnabled = !Registry.is("ide.new.navbar", false);
+ e.getPresentation().setEnabledAndVisible(isEnabled);
+ Arrays.stream(getChildren(e)).forEach(action -> action.getTemplatePresentation().setEnabledAndVisible(isEnabled));
+ }
+}
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.openapi.actionSystem.AnAction;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.DefaultActionGroup;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class ViewToolbarNewActionGroup extends DefaultActionGroup implements DumbAware {
+
+ @Override
+ public void update(@NotNull AnActionEvent e) {
+ super.update(e);
+ e.getPresentation().setEnabledAndVisible(Registry.is("ide.new.navbar", false));
+ }
+
+ @Override
+ public AnAction @NotNull [] getChildren(@Nullable AnActionEvent e) {
+ return super.getChildren(e);
+ }
+}
--- /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.ide.actions.toolbar.experimental;
+
+import com.intellij.ide.ui.UISettings;
+import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.actionSystem.ToggleAction;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.registry.Registry;
+import org.jetbrains.annotations.NotNull;
+
+public class ViewToolbarObsoleteWithNavBarAction extends ToggleAction implements DumbAware {
+ @Override
+ public boolean isSelected(@NotNull AnActionEvent event) {
+ return UISettings.getInstance().getShowNavigationBar();
+ }
+
+ @Override
+ public void setSelected(@NotNull AnActionEvent event, boolean state) {
+ UISettings uiSettings = UISettings.getInstance();
+ uiSettings.setShowNavigationBar(state);
+ uiSettings.fireUISettingsChanged();
+ }
+}
action.ReplaceInPath.description=Replace a string in multiple files with another string
group.ViewMenu.text=_View
action.ViewToolBar.text=_Toolbar
+action.ViewObsoleteToolbarAction.text=_Toolbar (Obsolete)
+action.ViewObsoleteNavBarAction.text=Navigation bar
+action.CustomizeToolbarAction.text=Customize toolbar
+action.ViewNewToolbarAction.text=New Toolbar
action.ViewToolBar.description=Show/hide the main toolbar
action.ViewStatusBar.text=_Status Bar
action.ViewStatusBar.description=Show/hide the status bar
group.ViewStatusBarWidgetsGroup.text=Status Bar _Widgets
+group.ViewToolbarNewGroup.text=Main Toolbar
group.ViewStatusBarWidgetsGroup.description=Show/hide status bar widgets
action.ViewMainMenu.text=Main Menu
action.ViewMainMenu.description=Show/hide the main menu
<applicationService serviceImplementation="com.intellij.ide.macro.MacroManager"/>
<ideRootPaneNorth implementation="com.intellij.ide.navigationToolbar.NavBarRootPaneExtension"/>
+ <ideRootPaneNorth implementation="com.intellij.ide.navigationToolbar.experimental.NewToolbarRootPaneExtension" order="first"/>
<navbar implementation="com.intellij.ide.navigationToolbar.DefaultNavBarExtension" id="defaultNavbar" order="last"/>
<applicationService serviceInterface="com.intellij.ide.navigationToolbar.NavBarModelBuilder"
serviceImplementation="com.intellij.ide.navigationToolbar.NavBarModelBuilderImpl"/>
</action>
<action id="ViewNavigationBar" class="com.intellij.ide.actions.ViewNavigationBarAction">
- <add-to-group group-id="UIToggleActions" relative-to-action="ViewStatusBarWidgetsGroup" anchor="after"/>
+ <add-to-group group-id="ViewToolbarActionsGroup"/>
<override-text place="NavBar"/>
</action>
<reference ref="SearchEverywhere"/>
</group>
- <action id="RunDebugConfigAction" class="com.intellij.execution.segmentedRunDebugWidget.SegmentedRDCAction">
- <add-to-group group-id="ToolbarRunGroup" anchor="first"/>
- </action>
+
+ <group id="NewToolbarActions">
+ <group id="LeftToolbarSideGroup" class="com.intellij.ide.navigationToolbar.experimental.LeftToolbarGroup">
+ <reference id="Back"/>
+ <reference id="Forward"/>
+ <action id="SegmentedVcsControlAction" class="com.intellij.execution.segmentedVcsWidget.SegmentedVcsControlAction"/>
+ <action id="SearchEverywhereNewToolbarAction" class="com.intellij.ide.navigationToolbar.experimental.SearchEverywhereNewToolbarAction"/>
+ </group>
+ <group id="CenterToolbarSideGroup" class="com.intellij.ide.navigationToolbar.experimental.CenterToolbarGroup">
+ </group>
+ <group id="RightToolbarSideGroup" class="com.intellij.ide.navigationToolbar.experimental.RightToolbarGroup">
+ <action id="RunDebugConfigAction" class="com.intellij.execution.segmentedRunDebugWidget.SegmentedRDCAction"/>
+ </group>
+ </group>
<group id="SegmentedRunDebugConfigActionGroup">
<!--<group class="com.intellij.execution.segmentedRunDebugWidget.RDCPillLabelGroup"/>-->
<action class="com.intellij.execution.actions.ActivateRunToolWindowAction" id="ActivateRunToolWindow">
<add-to-group group-id="ActivateToolWindowActions"/>
</action>
-
+
</actions>
</idea-plugin>
<synonym key="action.ToggleZenMode.enter"/>
</action>
</group>
+
<group id="UIToggleActions">
<separator/>
- <action id="ViewToolBar" class="com.intellij.ide.actions.ViewToolbarAction"/>
+ <action id="ViewMainMenu" class="com.intellij.ide.actions.ViewMainMenuAction"/>
+ <group id="ViewToolbarActionsGroup" class="com.intellij.ide.actions.toolbar.experimental.ViewToolbarActionsGroup"/>
<action id="ViewToolButtons" class="com.intellij.ide.actions.ViewToolWindowButtonsAction"/>
<action id="ViewStatusBar" class="com.intellij.ide.actions.ViewStatusBarAction"/>
<group id="ViewStatusBarWidgetsGroup" class="com.intellij.openapi.wm.impl.status.widget.StatusBarWidgetsActionGroup" popup="true"/>
- <action id="ViewMainMenu" class="com.intellij.ide.actions.ViewMainMenuAction"/>
<action id="ViewInplaceComments" class="com.intellij.ide.actions.ViewInplaceCommentsAction"/>
</group>
</group>
+ <action id="ViewToolBar" class="com.intellij.ide.actions.ViewToolbarAction">
+ <add-to-group group-id="ViewToolbarActionsGroup"/>
+ </action>
+
+ <group id="ViewToolbarNewGroup" class="com.intellij.ide.actions.toolbar.experimental.ViewToolbarNewActionGroup" popup="true">
+ <add-to-group group-id="UIToggleActions" relative-to-action="ViewToolButtons" anchor="before"/>
+ <action id="ViewNewToolbarAction" class="com.intellij.ide.actions.toolbar.experimental.ViewNewToolbarAction"/>
+ <action id="ViewObsoleteToolbarAction" class="com.intellij.ide.actions.toolbar.experimental.ViewObsoleteToolbarAction"/>
+ <action id="ViewObsoleteNavBarAction" class="com.intellij.ide.actions.toolbar.experimental.ViewObsoleteNavBarAction"/>
+ <separator/>
+ <action id="CustomizeToolbarAction" class="com.intellij.ide.actions.CustomizeToolbarAction"/>
+ </group>
+
<action id="EditSource" class="com.intellij.ide.actions.EditSourceAction" icon="AllIcons.Actions.EditSource"/>
<action id="OpenInRightSplit" class="com.intellij.ide.actions.OpenInRightSplitAction" icon="AllIcons.Actions.SplitVertically" />
<action id="ViewSource" class="com.intellij.ide.actions.ViewSourceAction"/>
</group>
<group id="NavBarVcsGroup"/>
- <group id="NavBarVcsGroupLight"/>
+ <group id="SegmentedVcsActionsBarGroup"/>
<group id="EditorPopupMenu">
<reference ref="$Cut"/>
<action id="CheckinProject" class="com.intellij.openapi.vcs.actions.CommonCheckinProjectAction" icon="AllIcons.Actions.Commit">
<keyboard-shortcut first-keystroke="control K" keymap="$default"/>
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
+ </action>
+ <action id="ChangesView.ToggleCommitUi" class="com.intellij.vcs.commit.ToggleChangesViewCommitUiAction" use-shortcut-of="CheckinProject">
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
</action>
- <action id="ChangesView.ToggleCommitUi" class="com.intellij.vcs.commit.ToggleChangesViewCommitUiAction" use-shortcut-of="CheckinProject" />
<action id="CheckinFiles" class="com.intellij.openapi.vcs.actions.CommonCheckinFilesAction"/>
<action id="UpdateFiles" class="com.intellij.openapi.vcs.update.CommonUpdateFileOrDirectoryAction"/>
<action id="CheckStatusForFiles" class="com.intellij.openapi.vcs.update.CommonStatusFileOrDirectoryAction"/>
<group class="com.intellij.openapi.vcs.actions.VcsActionGroup" id="VcsGroup"/>
<action id="Vcs.UpdateProject" class="com.intellij.openapi.vcs.update.CommonUpdateProjectAction" icon="AllIcons.Actions.CheckOut">
<keyboard-shortcut first-keystroke="control T" keymap="$default"/>
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
</action>
<group class="com.intellij.openapi.vcs.actions.VcsGroupsWrapper" id="VcsFileGroupPopup" popup="true">
<add-to-group group-id="VersionControlsGroup" />
<add-to-group group-id="NavBarVcsGroup" anchor="first"/>
</group>
- <action id="Vcs.Toolbar.QuickListPopupAction"
- class="com.intellij.openapi.vcs.actions.VcsQuickActionsToolbarPopup" icon="AllIcons.Actions.More"/>
-
- <!-- New light VCS toolbar for the root toolbar instead of navbar -->
- <group id="VcsNavBarToolbarActionsLight">
- <reference ref="Vcs.UpdateProject"/>
- <reference ref="CheckinProject"/>
- <reference ref="ChangesView.ToggleCommitUi"/>
- <reference ref="Vcs.Toolbar.QuickListPopupAction"/>
- <add-to-group group-id="NavBarVcsGroupLight" anchor="first"/>
- </group>
-
<!-- Window -->
<action id="CloseAllUnmodifiedEditors" class="com.intellij.ide.actions.CloseAllUnmodifiedEditorsAction">
<add-to-group group-id="CloseEditorsGroup" anchor="before" relative-to-action="CloseAllUnpinnedEditors"/>
// 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.actions.QuickSwitchSchemeAction;
import com.intellij.ide.ui.customization.CustomActionsSchema;
-import com.intellij.openapi.actionSystem.ActionPlaces;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.DefaultActionGroup;
+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.project.Project;
+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 org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Objects;
-final class VcsQuickActionsToolbarPopup extends QuickSwitchSchemeAction implements DumbAware {
- VcsQuickActionsToolbarPopup() {
- myActionPlace = ActionPlaces.MAIN_TOOLBAR;
- getTemplatePresentation().setText(VcsBundle.messagePointer("vcs.quicklist.popup.title"));
- }
-
- @Override
- protected String getPopupTitle(@NotNull AnActionEvent e) {
- return VcsBundle.message("action.Vcs.Toolbar.QuickListPopupAction.text");
- }
+/**
+ * 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 {
- @Override
- protected void fillActions(@Nullable Project project,
- @NotNull DefaultActionGroup group,
- @NotNull DataContext dataContext) {
- if (project == null) return;
- CustomActionsSchema schema = CustomActionsSchema.getInstance();
- group.add(Objects.requireNonNull(schema.getCorrectedAction(VcsActions.VCS_OPERATIONS_POPUP)));
+ public VcsQuickActionsToolbarPopup() {
+ getTemplatePresentation().setText(VcsBundle.messagePointer("vcs.quicklist.popup.title"));
}
- @Override
- protected void showPopup(AnActionEvent e, ListPopup popup) {
+ private static void showPopup(@NotNull AnActionEvent e, @NotNull ListPopup popup) {
InputEvent mouseEvent = e.getInputEvent();
if (mouseEvent instanceof MouseEvent) {
Object source = mouseEvent.getSource();
Point topLeftCorner = ((JComponent)source).getLocationOnScreen();
Point bottomLeftCorner = new Point(topLeftCorner.x, topLeftCorner.y + ((JComponent)source).getHeight());
popup.setLocation(bottomLeftCorner);
+ popup.show((JComponent)source);
}
}
- super.showPopup(e, popup);
+ }
+
+ @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;
+
+ ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
+ VcsBundle.message("action.Vcs.Toolbar.QuickListPopupAction.text"),
+ group, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, true, null, -1,
+ action -> true, ActionPlaces.MAIN_TOOLBAR);
+
+ showPopup(e, popup);
}
}
actions = replacingActions != null ? JBIterable.from(replacingActions) :
providers.flatMap(p -> p.getVcsActions(project, vcs, dataContext));
}
- else actions = JBIterable.empty();
+ else {
+ actions = JBIterable.empty();
+ }
return actions.toList().toArray(EMPTY_ARRAY);
}
}
return EMPTY_ARRAY;
}
else {
- return new AnAction[] { Separator.create(pair.second.getDisplayName()) };
+ return new AnAction[]{Separator.create(pair.second.getDisplayName())};
}
}
}
</group>
<action id="Vcs.ShowBranches" class="git4idea.actions.GitBranchesComboBoxAction" icon="AllIcons.Vcs.Branch">
- <add-to-group group-id="VcsNavBarToolbarActionsLight" anchor="first"/>
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
+ </action>
+
+ <action id="Vcs.ShowMoreActions" class="git4idea.actions.GitQuickActionsToolbarPopup" icon="AllIcons.Actions.More">
+ <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="last"/>
</action>
<!--This group is empty and unused, left for plugins compatibility.-->
--- /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 git4idea.actions;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.actionSystem.impl.ActionButtonWithText;
+import com.intellij.openapi.vcs.VcsBundle;
+import com.intellij.openapi.vcs.actions.VcsQuickActionsToolbarPopup;
+import com.intellij.util.IconUtil;
+import com.intellij.util.ui.JBInsets;
+import git4idea.branch.GitBranchUtil;
+import git4idea.repo.GitRepository;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+import java.awt.*;
+
+
+/**
+ * Git implementation of the quick popup action
+ */
+final class GitQuickActionsToolbarPopup extends VcsQuickActionsToolbarPopup {
+
+ GitQuickActionsToolbarPopup() {
+ super();
+ 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 update(@NotNull AnActionEvent e) {
+ var project = e.getProject();
+ Presentation presentation = e.getPresentation();
+ if (project == null || project.isDisposed() || !project.isOpen()) {
+ presentation.setEnabledAndVisible(false);
+ return;
+ }
+ GitRepository repo = GitBranchUtil.getCurrentRepository(project);
+
+ if (repo == null) {
+ presentation.setText(VcsBundle.message("version.control.main.configurable.name"));
+ presentation.setIcon(AllIcons.Vcs.BranchNode);
+ }
+ else {
+ Icon icon = AllIcons.Actions.More;
+ if (icon.getIconWidth() < ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.width) {
+ icon = IconUtil.toSize(icon, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.width,
+ ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE.height);
+ }
+ presentation.setIcon(icon);
+ presentation.setText(String::new);
+ }
+
+ super.update(e);
+ }
+}
@Override
public boolean isEnabledByDefault() {
- return !UISettings.getInstance().getShowNewNavbarVcsGroup();
+ return !Registry.is("ide.new.navbar.vcs.group", false);
}
@Override