ui: introduce place IDs for ConsoleView
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Wed, 12 Aug 2020 00:39:24 +0000 (03:39 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 12 Aug 2020 19:08:33 +0000 (19:08 +0000)
GitOrigin-RevId: a1ca461adaca03e9652aa7db8ff997b8950afe1f

platform/execution-impl/src/com/intellij/execution/ConsoleFolding.java
platform/lang-api/src/com/intellij/execution/ui/ConsoleView.java
platform/lang-api/src/com/intellij/execution/ui/ConsoleViewPlace.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/vcs/console/VcsConsoleView.kt
plugins/git4idea/src/git4idea/console/GitConsoleFolding.kt

index 9d909bc120133c8082826f00e681caf255d39adc..6f72f1dc85f98f397182ce620cc1586f2898c45f 100644 (file)
@@ -42,6 +42,11 @@ public abstract class ConsoleFolding {
     return getPlaceholderText(lines);
   }
 
     return getPlaceholderText(lines);
   }
 
+  /**
+   * Return true if provider should be used for a given console.
+   *
+   * @see ConsoleView#getPlace()
+   */
   public boolean isEnabledForConsole(@NotNull ConsoleView consoleView) {
     return true;
   }
   public boolean isEnabledForConsole(@NotNull ConsoleView consoleView) {
     return true;
   }
index c48125938a565c591ee5e15e66c11cba8b8f456e..43c7c45deb7f15f65fed7c8675948b31f3ac0396 100644 (file)
@@ -54,4 +54,9 @@ public interface ConsoleView extends ExecutionConsole {
   AnAction @NotNull [] createConsoleActions();
 
   void allowHeavyFilters();
   AnAction @NotNull [] createConsoleActions();
 
   void allowHeavyFilters();
+
+  @NotNull
+  default ConsoleViewPlace getPlace() {
+    return ConsoleViewPlace.UNKNOWN;
+  }
 }
\ No newline at end of file
 }
\ No newline at end of file
diff --git a/platform/lang-api/src/com/intellij/execution/ui/ConsoleViewPlace.java b/platform/lang-api/src/com/intellij/execution/ui/ConsoleViewPlace.java
new file mode 100644 (file)
index 0000000..e2ea5be
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.execution.ui;
+
+import org.jetbrains.annotations.NonNls;
+
+public class ConsoleViewPlace {
+  public static final ConsoleViewPlace UNKNOWN = new ConsoleViewPlace("Unknown");
+
+  private final String myDescription;
+
+  public ConsoleViewPlace(@NonNls String description) {
+    myDescription = description;
+  }
+
+  @Override
+  public String toString() {
+    return String.format("ConsoleViewPlace(%s)", myDescription);
+  }
+}
\ No newline at end of file
index b3da77b1d203f14cf3737d42173fc67d93feb830..61a70c9f8ec0864c3d1dea1fe374d9be841ed0c1 100644 (file)
@@ -3,6 +3,7 @@ package com.intellij.vcs.console
 
 import com.intellij.execution.impl.ConsoleViewImpl
 import com.intellij.execution.impl.EditorHyperlinkSupport
 
 import com.intellij.execution.impl.ConsoleViewImpl
 import com.intellij.execution.impl.EditorHyperlinkSupport
+import com.intellij.execution.ui.ConsoleViewPlace
 import com.intellij.openapi.diagnostic.logger
 import com.intellij.openapi.extensions.ExtensionPointName
 import com.intellij.openapi.project.Project
 import com.intellij.openapi.diagnostic.logger
 import com.intellij.openapi.extensions.ExtensionPointName
 import com.intellij.openapi.project.Project
@@ -11,8 +12,13 @@ import com.intellij.openapi.util.TextRange
 class VcsConsoleView(project: Project) : ConsoleViewImpl(project, true) {
   companion object {
     private val LOG = logger<VcsConsoleView>()
 class VcsConsoleView(project: Project) : ConsoleViewImpl(project, true) {
   companion object {
     private val LOG = logger<VcsConsoleView>()
+
+    @JvmField
+    val CONSOLE_PLACE: ConsoleViewPlace = ConsoleViewPlace("VCS Console")
   }
 
   }
 
+  override fun getPlace(): ConsoleViewPlace = CONSOLE_PLACE
+
   override fun updateFoldings(startLine: Int, endLine: Int) {
     super.updateFoldings(startLine, endLine)
 
   override fun updateFoldings(startLine: Int, endLine: Int) {
     super.updateFoldings(startLine, endLine)
 
index f9093aa0470ee8d9dec5fca29ce43f0c3c09c044..ca088fb7a0e6d3abf8af3ad86a4cf8582af14535 100644 (file)
@@ -54,6 +54,6 @@ class GitProgressOutputConsoleFolding : ConsoleFolding() {
   }
 
   override fun isEnabledForConsole(consoleView: ConsoleView): Boolean {
   }
 
   override fun isEnabledForConsole(consoleView: ConsoleView): Boolean {
-    return consoleView is VcsConsoleView
+    return consoleView.place == VcsConsoleView.CONSOLE_PLACE
   }
 }
\ No newline at end of file
   }
 }
\ No newline at end of file