Implement panel and main menu entries for the new toolbar. VCS widget. REF #RIDER...
authorElena.Korotkova <elena.korotkova@jetbrains.com>
Wed, 9 Sep 2020 11:46:56 +0000 (14:46 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Sun, 11 Oct 2020 18:18:54 +0000 (18:18 +0000)
Add Toolbar UI State Service: ToolbarSettings

GitOrigin-RevId: 6de7cc1e01bee0155e0adcbb461e1ca59e23a230

35 files changed:
platform/dvcs-impl/src/META-INF/dvcs.xml
platform/editor-ui-api/resources/META-INF/Editor.xml
platform/editor-ui-api/src/com/intellij/ide/ui/CoreToolbarSettings.kt [new file with mode: 0644]
platform/editor-ui-api/src/com/intellij/ide/ui/ToolbarSettings.kt [new file with mode: 0644]
platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt
platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarSettings.kt [new file with mode: 0644]
platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateEnum.kt [new file with mode: 0644]
platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateWrapper.kt [new file with mode: 0644]
platform/execution-impl/src/com/intellij/execution/segmentedVcsWidget/SegmentedVcsControlAction.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java
platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarModifier.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java
platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/CenterToolbarGroup.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/LeftToolbarGroup.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/NewToolbarRootPaneExtension.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/RightToolbarGroup.kt [new file with mode: 0644]
platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/SearchEverywhereNewToolbarAction.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/CustomizeToolbarAction.kt [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/ToggleDistractionFreeModeAction.java
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewNewToolbarAction.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteNavBarAction.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteToolbarAction.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarActionsGroup.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarNewActionGroup.java [new file with mode: 0644]
platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarObsoleteWithNavBarAction.java [new file with mode: 0644]
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources/src/META-INF/LangExtensions.xml
platform/platform-resources/src/idea/LangActions.xml
platform/platform-resources/src/idea/PlatformActions.xml
platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickActionsToolbarPopup.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/VcsQuickListPopupAction.java
plugins/git4idea/resources/META-INF/plugin.xml
plugins/git4idea/src/git4idea/actions/GitQuickActionsToolbarPopup.java [new file with mode: 0644]
plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java

index 0a41179606f03d9b4df1726d6c75f5578cfca0e0..227e4ca9500d8b5f53aaa5b06d54ea79c47bafce 100644 (file)
@@ -24,7 +24,7 @@
       <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"/>
 
index 9a3431c4022f09e74a6878f968fe54d480308883..0c7ce730c218f79e4ab45e0128cb478da9d54e19 100644 (file)
@@ -10,6 +10,9 @@
   <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" />
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/CoreToolbarSettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/CoreToolbarSettings.kt
new file mode 100644 (file)
index 0000000..aeac5bf
--- /dev/null
@@ -0,0 +1,37 @@
+// 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!!
+  }
+
+}
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/ToolbarSettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/ToolbarSettings.kt
new file mode 100644 (file)
index 0000000..d9b4e04
--- /dev/null
@@ -0,0 +1,23 @@
+// 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
index 1d1eb4bd7a3cccbed13b0538122feed29f8bef91..fbe1f058aa31d9f415916e869c79f6e9011bc39c 100644 (file)
@@ -165,10 +165,14 @@ class UISettings @NonInjectable constructor(private val notRoamableOptions: NotR
 
   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) {
@@ -211,9 +215,10 @@ class UISettings @NonInjectable constructor(private val notRoamableOptions: NotR
     }
 
   var showMainToolbar: Boolean
-    get() = state.showMainToolbar
+    get() =  state.showMainToolbar
     set(value) {
-      state.showMainToolbar = value
+      ToolbarSettings.getInstance().setToolbarVisible(value)
+      fireUISettingsChanged()
     }
 
   var showIconsInMenus: Boolean
@@ -428,11 +433,6 @@ class UISettings @NonInjectable constructor(private val notRoamableOptions: NotR
       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
@@ -579,6 +579,7 @@ class UISettings @NonInjectable constructor(private val notRoamableOptions: NotR
     }
 
     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
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarSettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarSettings.kt
new file mode 100644 (file)
index 0000000..2ed17b2
--- /dev/null
@@ -0,0 +1,119 @@
+// 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()
+    }
+}
+
+
+
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateEnum.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateEnum.kt
new file mode 100644 (file)
index 0000000..fbde6df
--- /dev/null
@@ -0,0 +1,15 @@
+// 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
diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateWrapper.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/experimental/toolbar/ExperimentalToolbarStateWrapper.kt
new file mode 100644 (file)
index 0000000..17e2a4f
--- /dev/null
@@ -0,0 +1,11 @@
+// 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
diff --git a/platform/execution-impl/src/com/intellij/execution/segmentedVcsWidget/SegmentedVcsControlAction.kt b/platform/execution-impl/src/com/intellij/execution/segmentedVcsWidget/SegmentedVcsControlAction.kt
new file mode 100644 (file)
index 0000000..6a57f67
--- /dev/null
@@ -0,0 +1,26 @@
+// 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
index aef15383107f64e26e7a883a96986e55a3925bb1..eb032d987eeebc14327851e77442087f4a74a49a 100644 (file)
@@ -72,7 +72,7 @@ public class SearchEverywhereAction extends SearchEverywhereBaseAction implement
     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
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarModifier.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarModifier.kt
new file mode 100644 (file)
index 0000000..e69de29
index dd3f8e96ce426f6e62afefbd7908937a982b7ad0..d327f7beb1f6ef34044839f8a1c4f7ebe57fa2a6 100644 (file)
@@ -14,7 +14,6 @@ import com.intellij.openapi.wm.impl.IdeFrameImpl;
 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;
@@ -29,7 +28,7 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
   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;
@@ -39,16 +38,20 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
     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);
     }
@@ -60,7 +63,8 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
   }
 
   public boolean isMainToolbarVisible() {
-    return !UISettings.getInstance().getPresentationMode() && (UISettings.getInstance().getShowMainToolbar() || !myNavToolbarGroupExist);
+    return !UISettings.getInstance().getPresentationMode() &&
+           (UISettings.getInstance().getShowMainToolbar() || !myNavToolbarGroupExist);
   }
 
   public static boolean runToolbarExists() {
@@ -88,7 +92,7 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
 
       addNavigationBarPanel(myWrapperPanel);
 
-      toggleRunPanel(!UISettings.getInstance().getShowMainToolbar() && !UISettings.getInstance().getPresentationMode());
+      toggleRunPanel(isShowToolPanel(UISettings.getInstance()));
     }
     return myWrapperPanel;
   }
@@ -115,7 +119,8 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
       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);
     }
   }
 
@@ -125,7 +130,8 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
       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
@@ -200,7 +206,7 @@ public final class NavBarRootPaneExtension extends IdeRootPaneNorthExtension {
         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();
       }
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/CenterToolbarGroup.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/CenterToolbarGroup.kt
new file mode 100644 (file)
index 0000000..8a0e57d
--- /dev/null
@@ -0,0 +1,7 @@
+// 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
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/LeftToolbarGroup.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/LeftToolbarGroup.kt
new file mode 100644 (file)
index 0000000..32ec23c
--- /dev/null
@@ -0,0 +1,7 @@
+// 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
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/NewToolbarRootPaneExtension.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/NewToolbarRootPaneExtension.kt
new file mode 100644 (file)
index 0000000..a161556
--- /dev/null
@@ -0,0 +1,120 @@
+// 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
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/RightToolbarGroup.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/RightToolbarGroup.kt
new file mode 100644 (file)
index 0000000..8466b32
--- /dev/null
@@ -0,0 +1,7 @@
+// 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
diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/SearchEverywhereNewToolbarAction.kt b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/experimental/SearchEverywhereNewToolbarAction.kt
new file mode 100644 (file)
index 0000000..8cbda81
--- /dev/null
@@ -0,0 +1,58 @@
+// 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
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/CustomizeToolbarAction.kt b/platform/platform-impl/src/com/intellij/ide/actions/CustomizeToolbarAction.kt
new file mode 100644 (file)
index 0000000..e270719
--- /dev/null
@@ -0,0 +1,16 @@
+// 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
index 470505d5a22c2ebe2057ec4a5367781465a35691..774ac422c738c9331ca3f59409257c30d2ef8190 100644 (file)
@@ -54,10 +54,10 @@ public class ToggleDistractionFreeModeAction extends DumbAwareAction implements
     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();
@@ -75,14 +75,16 @@ public class ToggleDistractionFreeModeAction extends DumbAwareAction implements
   }
 
   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);
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewNewToolbarAction.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewNewToolbarAction.java
new file mode 100644 (file)
index 0000000..698795f
--- /dev/null
@@ -0,0 +1,32 @@
+// 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();
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteNavBarAction.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteNavBarAction.java
new file mode 100644 (file)
index 0000000..0cba955
--- /dev/null
@@ -0,0 +1,24 @@
+// 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();
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteToolbarAction.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewObsoleteToolbarAction.java
new file mode 100644 (file)
index 0000000..1435dd3
--- /dev/null
@@ -0,0 +1,23 @@
+// 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();
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarActionsGroup.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarActionsGroup.java
new file mode 100644 (file)
index 0000000..82fbd7c
--- /dev/null
@@ -0,0 +1,20 @@
+// 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));
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarNewActionGroup.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarNewActionGroup.java
new file mode 100644 (file)
index 0000000..e2f8217
--- /dev/null
@@ -0,0 +1,24 @@
+// 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);
+  }
+}
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarObsoleteWithNavBarAction.java b/platform/platform-impl/src/com/intellij/ide/actions/toolbar/experimental/ViewToolbarObsoleteWithNavBarAction.java
new file mode 100644 (file)
index 0000000..15ea169
--- /dev/null
@@ -0,0 +1,23 @@
+// 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();
+  }
+}
index 1d95618f005658d4dc3c8364488ca15ade747736..ca62f46a5615a9d62e8762a5235c0adde5e13479 100644 (file)
@@ -433,10 +433,15 @@ action.ReplaceInPath.synonym1=Repl_ace in Path
 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
index bab2a174cd5a036d180d5824f3d075e22d93b810..331ddfaac968dee3dc630d5bfbd2ddf4cc0e0308 100644 (file)
     <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"/>
index fea08ee26f0a3374da5ce60cb3e10a9892c6e6c2..e63479c94e4a9d952a6cd2be583d4987629a837c 100644 (file)
     </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>
index 6e45eb86ac47bd117037fe11ffbfa405c90bf78a..f82858b9d28dcb79d7a8619fac90e16e2b0600dd 100644 (file)
               <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"/>
index 1191973338a655998d0cda25626af7a4cb1536d0..1deb56f4f778c23d0f1e60d12272ef9230c97620 100644 (file)
@@ -7,8 +7,11 @@
 
     <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"/>
@@ -33,6 +36,7 @@
     <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"/>
index dabaf56f450e9d0baa7b8d0305276e04cb25b8e5..83aeef575ae53cf08f63f9100dceba30c5f071db 100644 (file)
@@ -1,19 +1,18 @@
 // 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.*;
@@ -21,28 +20,17 @@ import java.awt.event.InputEvent;
 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();
@@ -50,8 +38,40 @@ final class VcsQuickActionsToolbarPopup extends QuickSwitchSchemeAction implemen
         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);
   }
 }
index 5a184a43f9b21161e28f9ab41ecdf22df141045e..33b3a22578b05e1ac2954fbb3661568e06595294 100644 (file)
@@ -82,7 +82,9 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements
         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);
     }
   }
@@ -97,7 +99,7 @@ public class VcsQuickListPopupAction extends QuickSwitchSchemeAction implements
         return EMPTY_ARRAY;
       }
       else {
-        return new AnAction[] { Separator.create(pair.second.getDisplayName()) };
+        return new AnAction[]{Separator.create(pair.second.getDisplayName())};
       }
     }
   }
index 886bd434fd76af586b4a1438c5c86ef56646bbd7..6080ef1f22c0c3a6592ff5c31b413bf30c3f70a1 100644 (file)
     </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.-->
diff --git a/plugins/git4idea/src/git4idea/actions/GitQuickActionsToolbarPopup.java b/plugins/git4idea/src/git4idea/actions/GitQuickActionsToolbarPopup.java
new file mode 100644 (file)
index 0000000..1ff0fb4
--- /dev/null
@@ -0,0 +1,71 @@
+// 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);
+  }
+}
index 200f7632b6b79b486213376634349a2c965662be..a541ec791677bbebd53d394a1ca0a931332a5d39 100644 (file)
@@ -147,7 +147,7 @@ public class GitBranchWidget extends DvcsStatusWidget<GitRepository> {
 
     @Override
     public boolean isEnabledByDefault() {
-      return !UISettings.getInstance().getShowNewNavbarVcsGroup();
+      return !Registry.is("ide.new.navbar.vcs.group", false);
     }
 
     @Override