From f111170c62524b64e5cc970e59d2ff6221336481 Mon Sep 17 00:00:00 2001 From: Konstantin Aleev Date: Tue, 8 Oct 2024 19:10:57 +0200 Subject: [PATCH] [services] IJPL-17077 add an option to run configuration on double click GitOrigin-RevId: fcb41fe94a01e453ec789be621a972f0c3cdbd55 --- .../intellij.platform.execution.dashboard.xml | 6 ++- .../RunDashboardServiceViewContributor.java | 5 ++ .../RunDashboardDoubleClickRunAction.kt | 47 +++++++++++++++++++ ...ntellij.platform.execution.serviceView.xml | 12 +++-- .../src/ServiceViewActionProvider.java | 12 +---- .../src/messages/ActionsBundle.properties | 1 + 6 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 platform/execution.dashboard/src/actions/RunDashboardDoubleClickRunAction.kt diff --git a/platform/execution.dashboard/resources/intellij.platform.execution.dashboard.xml b/platform/execution.dashboard/resources/intellij.platform.execution.dashboard.xml index 5785470b1d55..8a5918401bfb 100644 --- a/platform/execution.dashboard/resources/intellij.platform.execution.dashboard.xml +++ b/platform/execution.dashboard/resources/intellij.platform.execution.dashboard.xml @@ -93,7 +93,11 @@ - + + + + diff --git a/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java b/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java index fa6a0a31fdcb..bfa3d1737af8 100644 --- a/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java +++ b/platform/execution.dashboard/src/RunDashboardServiceViewContributor.java @@ -34,6 +34,7 @@ import com.intellij.openapi.util.NullableLazyValue; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.platform.execution.dashboard.actions.RunDashboardDoubleClickRunAction; import com.intellij.platform.execution.dashboard.tree.FolderDashboardGroupingRule.FolderDashboardGroup; import com.intellij.platform.execution.dashboard.tree.GroupingNode; import com.intellij.platform.execution.dashboard.tree.RunConfigurationNode; @@ -416,6 +417,10 @@ public final class RunDashboardServiceViewContributor @Override public boolean handleDoubleClick(@NotNull MouseEvent event) { + if (!RunDashboardDoubleClickRunAction.Companion.isDoubleClickRunEnabled$intellij_platform_execution_dashboard()) { + return ServiceViewDescriptor.super.handleDoubleClick(event); + } + Executor executor = getExecutor(); if (executor == null) return true; diff --git a/platform/execution.dashboard/src/actions/RunDashboardDoubleClickRunAction.kt b/platform/execution.dashboard/src/actions/RunDashboardDoubleClickRunAction.kt new file mode 100644 index 000000000000..dc35d6db9828 --- /dev/null +++ b/platform/execution.dashboard/src/actions/RunDashboardDoubleClickRunAction.kt @@ -0,0 +1,47 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.platform.execution.dashboard.actions + +import com.intellij.execution.dashboard.RunDashboardManager +import com.intellij.ide.util.PropertiesComponent +import com.intellij.openapi.actionSystem.ActionUpdateThread +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.actionSystem.PlatformDataKeys +import com.intellij.openapi.actionSystem.ToggleAction +import com.intellij.openapi.project.DumbAware + +private const val DOUBLE_CLICK_SETTING = "run.dashboard.double.click.run" + +class RunDashboardDoubleClickRunAction : ToggleAction(), DumbAware { + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT + + override fun update(e: AnActionEvent) { + super.update(e) + val project = e.project + if (project == null) { + e.presentation.isEnabledAndVisible = false + return + } + val toolWindow = e.getData(PlatformDataKeys.TOOL_WINDOW) + if (toolWindow == null) { + e.presentation.isEnabledAndVisible = false + return + } + e.presentation.isEnabledAndVisible = + RunDashboardManager.getInstance(project).toolWindowId == toolWindow.id + } + + override fun isSelected(e: AnActionEvent): Boolean { + return isDoubleClickRunEnabled() + } + + override fun setSelected(e: AnActionEvent, state: Boolean) { + PropertiesComponent.getInstance().setValue(DOUBLE_CLICK_SETTING, state, true) + } + + companion object { + @JvmStatic + internal fun isDoubleClickRunEnabled(): Boolean { + return PropertiesComponent.getInstance().getBoolean(DOUBLE_CLICK_SETTING, true) + } + } +} \ No newline at end of file diff --git a/platform/execution.serviceView/resources/intellij.platform.execution.serviceView.xml b/platform/execution.serviceView/resources/intellij.platform.execution.serviceView.xml index 38c2382f8ab7..59aeb662a2d9 100644 --- a/platform/execution.serviceView/resources/intellij.platform.execution.serviceView.xml +++ b/platform/execution.serviceView/resources/intellij.platform.execution.serviceView.xml @@ -49,10 +49,12 @@ - - - + + + + + diff --git a/platform/execution.serviceView/src/ServiceViewActionProvider.java b/platform/execution.serviceView/src/ServiceViewActionProvider.java index 257d35691160..7c7cab2d5da6 100644 --- a/platform/execution.serviceView/src/ServiceViewActionProvider.java +++ b/platform/execution.serviceView/src/ServiceViewActionProvider.java @@ -31,7 +31,6 @@ import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -109,15 +108,8 @@ final class ServiceViewActionProvider { } List getAdditionalGearActions() { - List result = new ArrayList<>(); - AnAction selectActiveServiceActions = ActionManager.getInstance().getAction("ServiceView.SelectActiveService"); - ContainerUtil.addIfNotNull(result, selectActiveServiceActions); - result.add(Separator.getInstance()); - AnAction configureServicesActions = ActionManager.getInstance().getAction("ServiceView.ConfigureServices"); - ContainerUtil.addIfNotNull(result, configureServicesActions); - AnAction showServicesActions = ActionManager.getInstance().getAction("ServiceView.ShowServices"); - ContainerUtil.addIfNotNull(result, showServicesActions); - return result; + AnAction additionalActions = ActionManager.getInstance().getAction("ServiceView.Gear"); + return ContainerUtil.createMaybeSingletonList(additionalActions); } @Nullable diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index e7ff466fe8ce..46277bf2d897 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -2424,6 +2424,7 @@ action.ServiceView.ConfigureServices.text=Configure Services Tool Window action.RunDashboard.GroupByType.text=Type action.RunDashboard.GroupByStatus.text=Status action.RunDashboard.AddConfiguration.text=Run Configuration\u2026 +action.RunDashboard.DoubleClickRun.text=Double Click to Run Configuration action.UpdateRunningApplication.text=Update Running Application action.TypingLatencyReport.text=Typing Latency Report action.RetypeFile.text=Retype Current File