From 7f899cc5af26ed60f1d5fccf1238b0070a431966 Mon Sep 17 00:00:00 2001 From: Mikhail Chernyavsky Date: Thu, 22 Aug 2019 03:49:37 +0300 Subject: [PATCH] ACT & UI: Add "Show Setting" action for Cargo --- .../project/configurable/CargoConfigurable.kt | 4 ++++ .../ide/actions/CargoEditSettingsAction.kt | 24 +++++++++++++++++++ src/main/resources/META-INF/core.xml | 8 +++++++ 3 files changed, 36 insertions(+) create mode 100644 src/main/kotlin/org/rust/ide/actions/CargoEditSettingsAction.kt diff --git a/src/main/kotlin/org/rust/cargo/project/configurable/CargoConfigurable.kt b/src/main/kotlin/org/rust/cargo/project/configurable/CargoConfigurable.kt index e4c347fea7a..c5e880ae420 100644 --- a/src/main/kotlin/org/rust/cargo/project/configurable/CargoConfigurable.kt +++ b/src/main/kotlin/org/rust/cargo/project/configurable/CargoConfigurable.kt @@ -91,4 +91,8 @@ class CargoConfigurable(project: Project) : RsConfigurableBase(project) { compileAllTargets = settings.compileAllTargets useOffline = settings.useOffline } + + companion object { + const val DISPLAY_NAME: String = "Cargo" + } } diff --git a/src/main/kotlin/org/rust/ide/actions/CargoEditSettingsAction.kt b/src/main/kotlin/org/rust/ide/actions/CargoEditSettingsAction.kt new file mode 100644 index 00000000000..147006518e8 --- /dev/null +++ b/src/main/kotlin/org/rust/ide/actions/CargoEditSettingsAction.kt @@ -0,0 +1,24 @@ +/* + * Use of this source code is governed by the MIT license that can be + * found in the LICENSE file. + */ + +package org.rust.ide.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.options.ShowSettingsUtil +import com.intellij.openapi.project.DumbAware +import org.rust.cargo.project.configurable.CargoConfigurable + +class CargoEditSettingsAction : AnAction(), DumbAware { + + override fun update(e: AnActionEvent) { + super.update(e) + e.presentation.isEnabledAndVisible = e.project != null + } + + override fun actionPerformed(e: AnActionEvent) { + ShowSettingsUtil.getInstance().showSettingsDialog(e.project, CargoConfigurable.DISPLAY_NAME) + } +} diff --git a/src/main/resources/META-INF/core.xml b/src/main/resources/META-INF/core.xml index 323efca9c94..d54d31ca154 100644 --- a/src/main/resources/META-INF/core.xml +++ b/src/main/resources/META-INF/core.xml @@ -980,6 +980,12 @@ icon="AllIcons.Actions.Collapseall" use-shortcut-of="CollapseAll"/> + + + @@ -991,6 +997,8 @@ + +