IDEA-264143 The root node is configurable in the Run/Debug Configurations dialog
authorDmitry Avdeev <dmitry.avdeev@jetbrains.com>
Fri, 12 Mar 2021 17:11:25 +0000 (20:11 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Fri, 12 Mar 2021 18:52:15 +0000 (18:52 +0000)
GitOrigin-RevId: 5482574f13702a930e12ae04a7bac64eb8255c3b

platform/execution-impl/src/com/intellij/execution/impl/ProjectRunConfigurationConfigurable.kt
platform/execution-impl/src/com/intellij/execution/impl/RunConfigurable.kt
platform/lang-api/resources/messages/ExecutionBundle.properties
platform/platform-api/src/com/intellij/util/ui/StatusText.java

index c203901c86bdc29fc0a1448e8a413513b1e3db89..f88477347f05a478710ef074807e22c7bd02f0d4 100644 (file)
@@ -2,16 +2,16 @@
 package com.intellij.execution.impl
 
 import com.intellij.execution.ExecutionBundle
+import com.intellij.execution.configurations.ConfigurationType
 import com.intellij.openapi.actionSystem.ActionToolbarPosition
 import com.intellij.openapi.project.Project
-import com.intellij.ui.AnActionButton
-import com.intellij.ui.JBColor
-import com.intellij.ui.ScrollPaneFactory
-import com.intellij.ui.ToolbarDecorator
+import com.intellij.ui.*
 import com.intellij.ui.components.ActionLink
+import com.intellij.ui.components.JBPanelWithEmptyText
 import com.intellij.util.ui.JBDimension
 import com.intellij.util.ui.JBUI
 import java.awt.BorderLayout
+import java.awt.event.MouseEvent
 import javax.swing.JComponent
 import javax.swing.JPanel
 import javax.swing.tree.DefaultMutableTreeNode
@@ -77,4 +77,15 @@ open class ProjectRunConfigurationConfigurable(project: Project, runDialog: RunD
       }
     }
   }
+
+  override fun createTipPanelAboutAddingNewRunConfiguration(configurationType: ConfigurationType?): JComponent {
+    val messagePanel = JBPanelWithEmptyText()
+    messagePanel.emptyText.appendLine(ExecutionBundle.message("status.text.add.new.run.configuration"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) {
+      if (configurationType == null) {
+        toolbarAddAction.showAddPopup(true, it.source as MouseEvent)
+      }
+      else createNewConfiguration(configurationType.configurationFactories[0])
+    }.appendLine(ExecutionBundle.message("status.text.or.select.run.configuration.to.edit"), SimpleTextAttributes.GRAYED_ATTRIBUTES, null)
+    return messagePanel
+  }
 }
\ No newline at end of file
index a59d58c1af4b2aaae659749610edb3602554a07f..9990a9a3912b1bc8a54880af858c531a57b42327 100644 (file)
@@ -35,6 +35,7 @@ import com.intellij.openapi.wm.IdeFocusManager.getGlobalInstance
 import com.intellij.ui.*
 import com.intellij.ui.RowsDnDSupport.RefinedDropSupport.Position.*
 import com.intellij.ui.SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES
+import com.intellij.ui.awt.RelativePoint
 import com.intellij.ui.components.JBPanelWithEmptyText
 import com.intellij.ui.mac.TouchbarDataKeys
 import com.intellij.ui.popup.PopupState
@@ -57,6 +58,7 @@ import java.awt.GridBagConstraints
 import java.awt.GridBagLayout
 import java.awt.datatransfer.Transferable
 import java.awt.event.KeyEvent
+import java.awt.event.MouseEvent
 import java.util.concurrent.Callable
 import java.util.function.ToIntFunction
 import javax.swing.*
@@ -221,13 +223,7 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
           showTemplateConfigurable(userObject)
         }
         else if (userObject is ConfigurationType) {
-          val factories = userObject.configurationFactories
-          if (factories.size == 1) {
-            showTemplateConfigurable(factories[0])
-          }
-          else {
-            drawPressAddButtonMessage(userObject)
-          }
+           drawPressAddButtonMessage(userObject)
         }
       }
       updateDialog()
@@ -236,7 +232,7 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
     sortTopLevelBranches()
     tree.emptyText.appendText(ExecutionBundle.message("status.text.no.run.configurations.added")).appendLine(
       ExecutionBundle.message("status.text.add.new"), LINK_PLAIN_ATTRIBUTES) {
-      toolbarAddAction.showAddPopup(true, tree)}
+      toolbarAddAction.showAddPopup(true, it.source as MouseEvent)}
     val shortcut = KeymapUtil.getShortcutsText(toolbarAddAction.shortcutSet.shortcuts)
     if (shortcut.isNotEmpty()) tree.emptyText.appendText(" $shortcut")
     (tree.model as DefaultTreeModel).reload()
@@ -413,6 +409,11 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
 
   private fun drawPressAddButtonMessage(configurationType: ConfigurationType?) {
     val panel = JPanel(BorderLayout())
+    if (!(configurationType is UnknownConfigurationType)) {
+      createTipPanelAboutAddingNewRunConfiguration(configurationType)?.let {
+        panel.add(it, BorderLayout.CENTER)
+      }
+    }
     if (configurationType == null) {
       val wrapper = JPanel(BorderLayout())
       if (project.isDefault || !DumbService.isDumb(project)) {
@@ -443,6 +444,8 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
     rightPanel.repaint()
   }
 
+  protected open fun createTipPanelAboutAddingNewRunConfiguration(configurationType: ConfigurationType?): JComponent? = null
+
   protected open fun createLeftPanel(): JComponent {
     initTree()
     return ScrollPaneFactory.createScrollPane(tree)
@@ -954,7 +957,7 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
       showAddPopup(true, null)
     }
 
-    fun showAddPopup(showApplicableTypesOnly: Boolean, component: JComponent?) {
+    fun showAddPopup(showApplicableTypesOnly: Boolean, clickEvent: MouseEvent?) {
       if (showApplicableTypesOnly && myPopupState.isRecentlyHidden) return // do not show new popup
       val allTypes = ConfigurationType.CONFIGURATION_TYPE_EP.extensionList
       val configurationTypes: MutableList<ConfigurationType?> = configurationTypeSorted(project, showApplicableTypesOnly, allTypes, true).toMutableList()
@@ -970,8 +973,8 @@ open class RunConfigurable @JvmOverloads constructor(protected val project: Proj
                                                           { showAddPopup(false, null) }, true)
       //new TreeSpeedSearch(myTree);
       myPopupState.prepareToShow(popup)
-      if (component == null) popup.showUnderneathOf(toolbarDecorator!!.actionsPanel)
-      else popup.showInBestPositionFor(DataManager.getInstance().getDataContext(component))
+      if (clickEvent == null) popup.showUnderneathOf(toolbarDecorator!!.actionsPanel)
+      else popup.show(RelativePoint(clickEvent))
     }
   }
 
index b2196ee57448efaf98e49e56f011803a577012ae..bd9132ffd90824ec25a72209959f747f4237dac9 100644 (file)
@@ -215,9 +215,6 @@ module.doesn.t.exist.in.project.error.text=Module ''{0}'' doesn''t exist in proj
 run.configuration.unnamed.name.prefix=Unnamed
 no.main.class.specified.error.text=No main class specified
 action.name.save.configuration=Save Configuration
-#2 - configuration type description
-empty.run.configuration.panel.text.label1=Click the
-empty.run.configuration.panel.text.label3=button to create a new {0} based on templates
 
 edit.run.configuration.run.configuration.name.label=&Name:
 edit.run.configuration.run.configuration.manage.targets.label=Manage targets...
@@ -602,4 +599,6 @@ startup.tasks.confirmation.notification.action.allow=Allow
 startup.tasks.confirmation.notification.action.disallow=Disallow
 startup.tasks.confirmation.notification.action.review=Review
 edit.configuration.templates=Edit configuration templates...
-progress.title.patch.java.command.line.parameters=Patch java command line parameters
\ No newline at end of file
+progress.title.patch.java.command.line.parameters=Patch java command line parameters
+status.text.add.new.run.configuration=Add new run configuration...
+status.text.or.select.run.configuration.to.edit=or select run configuration to edit
\ No newline at end of file
index f5cd410e116d7dbc4754b3f46620dbd1702f2ab4..b64add54410c36112336e7016f2cfc750e31811f 100644 (file)
@@ -83,7 +83,7 @@ public abstract class StatusText {
         if (e.getButton() == MouseEvent.BUTTON1 && clickCount == 1) {
           ActionListener actionListener = findActionListenerAt(e.getPoint());
           if (actionListener != null) {
-            actionListener.actionPerformed(new ActionEvent(this, 0, ""));
+            actionListener.actionPerformed(new ActionEvent(e, 0, ""));
             return true;
           }
         }