vcs: cleanup - move class
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 3 Dec 2020 19:50:06 +0000 (22:50 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 11 Jan 2021 17:55:22 +0000 (17:55 +0000)
GitOrigin-RevId: fe74bbc0736452b37db25caa2f0c3dbb9b24c1c0

platform/vcs-impl/resources/META-INF/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/CommonCheckinProjectAction.kt
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ChangesViewManager.java
platform/vcs-impl/src/com/intellij/vcs/commit/ChangesViewCommitWorkflowHandler.kt
platform/vcs-impl/src/com/intellij/vcs/commit/ToggleChangesViewCommitUiAction.kt [deleted file]

index daa9141dfae7df204583889eff9d4aec81151acf..275a154ddd32da33bdedd2d967e5f3874c45cece 100644 (file)
@@ -9,7 +9,7 @@
       <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">
+    <action id="ChangesView.ToggleCommitUi" class="com.intellij.openapi.vcs.actions.ToggleChangesViewCommitUiAction" use-shortcut-of="CheckinProject">
       <add-to-group group-id="SegmentedVcsActionsBarGroup" anchor="first"/>
     </action>
     <action id="CheckinFiles" class="com.intellij.openapi.vcs.actions.CommonCheckinFilesAction"/>
index 23f87cfa442c7bc3c2e22e65d130641746b7db40..1fdfdee41435626ed0d372a9ff55beee476d2d21 100644 (file)
@@ -4,13 +4,18 @@ package com.intellij.openapi.vcs.actions
 import com.intellij.openapi.actionSystem.ActionPlaces.CHANGES_VIEW_POPUP
 import com.intellij.openapi.actionSystem.ActionPlaces.CHANGES_VIEW_TOOLBAR
 import com.intellij.openapi.actionSystem.AnActionEvent
+import com.intellij.openapi.actionSystem.IdeActions
 import com.intellij.openapi.actionSystem.PlatformDataKeys.CONTENT_MANAGER
+import com.intellij.openapi.actionSystem.ex.ActionUtil
+import com.intellij.openapi.project.DumbAwareToggleAction
+import com.intellij.openapi.util.registry.Registry
 import com.intellij.openapi.vcs.FilePath
 import com.intellij.openapi.vcs.ProjectLevelVcsManager
 import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.Companion.LOCAL_CHANGES
-import com.intellij.vcs.commit.isToggleCommitUi
 import com.intellij.vcsUtil.VcsUtil.getFilePath
 
+internal val isToggleCommitUi = Registry.get("vcs.non.modal.commit.toggle.ui")
+
 private val LOCAL_CHANGES_ACTION_PLACES = setOf(CHANGES_VIEW_TOOLBAR, CHANGES_VIEW_POPUP)
 private fun AnActionEvent.isFromLocalChangesPlace() = place in LOCAL_CHANGES_ACTION_PLACES
 
@@ -37,3 +42,34 @@ open class CommonCheckinProjectAction : AbstractCommonCheckinAction() {
 
   override fun approximatelyHasRoots(dataContext: VcsContext): Boolean = true
 }
+
+private class ToggleChangesViewCommitUiAction : DumbAwareToggleAction() {
+  // need to use `CommonCheckinProjectAction` inheritor - otherwise action is invisible in Local Changes
+  private val commitProjectAction = object : CommonCheckinProjectAction() {}
+
+  init {
+    ActionUtil.copyFrom(this, IdeActions.ACTION_CHECKIN_PROJECT)
+  }
+
+  override fun update(e: AnActionEvent) {
+    super.update(e)
+
+    when {
+      !e.isProjectUsesNonModalCommit() || !isToggleCommitUi.asBoolean() || !e.isFromLocalChanges() ->
+        e.presentation.isEnabledAndVisible = false
+
+      isSelected(e) -> e.presentation.isEnabledAndVisible = true
+      else -> commitProjectAction.update(e)
+    }
+  }
+
+  override fun isSelected(e: AnActionEvent): Boolean = e.getProjectCommitWorkflowHandler()?.isActive == true
+
+  override fun setSelected(e: AnActionEvent, state: Boolean) =
+    if (state) {
+      commitProjectAction.actionPerformed(e)
+    }
+    else {
+      e.getProjectCommitWorkflowHandler()!!.deactivate(false)
+    }
+}
index 36987757f8433c14cc29ebbe0ead26b5adaffeee..6a92f9d6775432fefa2e72bf0f2813abdf875148 100644 (file)
@@ -80,7 +80,7 @@ import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager.getT
 import static com.intellij.openapi.vcs.changes.ui.ChangesViewContentManagerKt.isCommitToolWindowShown;
 import static com.intellij.util.containers.ContainerUtil.set;
 import static com.intellij.util.ui.JBUI.Panels.simplePanel;
-import static com.intellij.vcs.commit.ToggleChangesViewCommitUiActionKt.isToggleCommitUi;
+import static com.intellij.openapi.vcs.actions.CommonCheckinProjectActionKt.isToggleCommitUi;
 import static java.util.Arrays.asList;
 import static java.util.Objects.requireNonNull;
 
index dee3876abcdee7b2ca279e4ed078edb93f3aa296..a56e7aabbdc0116191e570dc4d13a05b56e4258f 100644 (file)
@@ -11,6 +11,7 @@ import com.intellij.openapi.util.Disposer
 import com.intellij.openapi.vcs.CheckinProjectPanel
 import com.intellij.openapi.vcs.FilePath
 import com.intellij.openapi.vcs.VcsDataKeys.COMMIT_WORKFLOW_HANDLER
+import com.intellij.openapi.vcs.actions.isToggleCommitUi
 import com.intellij.openapi.vcs.changes.*
 import com.intellij.openapi.vcs.checkin.CheckinHandler
 import com.intellij.util.EventDispatcher
diff --git a/platform/vcs-impl/src/com/intellij/vcs/commit/ToggleChangesViewCommitUiAction.kt b/platform/vcs-impl/src/com/intellij/vcs/commit/ToggleChangesViewCommitUiAction.kt
deleted file mode 100644 (file)
index 880abbb..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
-package com.intellij.vcs.commit
-
-import com.intellij.openapi.actionSystem.AnActionEvent
-import com.intellij.openapi.actionSystem.IdeActions.ACTION_CHECKIN_PROJECT
-import com.intellij.openapi.actionSystem.ex.ActionUtil.copyFrom
-import com.intellij.openapi.project.DumbAwareToggleAction
-import com.intellij.openapi.util.registry.Registry
-import com.intellij.openapi.vcs.actions.CommonCheckinProjectAction
-import com.intellij.openapi.vcs.actions.getProjectCommitWorkflowHandler
-import com.intellij.openapi.vcs.actions.isFromLocalChanges
-import com.intellij.openapi.vcs.actions.isProjectUsesNonModalCommit
-
-internal val isToggleCommitUi = Registry.get("vcs.non.modal.commit.toggle.ui")
-
-private class ToggleChangesViewCommitUiAction : DumbAwareToggleAction() {
-  // need to use `CommonCheckinProjectAction` inheritor - otherwise action is invisible in Local Changes
-  private val commitProjectAction = object : CommonCheckinProjectAction() {}
-
-  init {
-    copyFrom(this, ACTION_CHECKIN_PROJECT)
-  }
-
-  override fun update(e: AnActionEvent) {
-    super.update(e)
-
-    when {
-      !e.isProjectUsesNonModalCommit() || !isToggleCommitUi.asBoolean() || !e.isFromLocalChanges() ->
-        e.presentation.isEnabledAndVisible = false
-
-      isSelected(e) -> e.presentation.isEnabledAndVisible = true
-      else -> commitProjectAction.update(e)
-    }
-  }
-
-  override fun isSelected(e: AnActionEvent): Boolean = e.getProjectCommitWorkflowHandler()?.isActive == true
-
-  override fun setSelected(e: AnActionEvent, state: Boolean) =
-    if (state) {
-      commitProjectAction.actionPerformed(e)
-    }
-    else {
-      e.getProjectCommitWorkflowHandler()!!.deactivate(false)
-    }
-}
\ No newline at end of file