Skip to content

Commit

Permalink
ACT & UI: Add "Show Setting" action for Cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Chernyavsky authored and mchernyavsky committed Sep 9, 2019
1 parent 2a811cc commit 7f899cc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Expand Up @@ -91,4 +91,8 @@ class CargoConfigurable(project: Project) : RsConfigurableBase(project) {
compileAllTargets = settings.compileAllTargets
useOffline = settings.useOffline
}

companion object {
const val DISPLAY_NAME: String = "Cargo"
}
}
24 changes: 24 additions & 0 deletions 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)
}
}
8 changes: 8 additions & 0 deletions src/main/resources/META-INF/core.xml
Expand Up @@ -980,6 +980,12 @@
icon="AllIcons.Actions.Collapseall"
use-shortcut-of="CollapseAll"/>

<action id="Cargo.ShowSettings"
class="org.rust.ide.actions.CargoEditSettingsAction" text="Cargo Settings"
description="Edit Cargo settings for the current project"
icon="AllIcons.General.Settings">
</action>

<group id="Rust.Cargo">
<reference id="Cargo.RefreshCargoProject"/>
<reference id="Cargo.AttachCargoProject"/>
Expand All @@ -991,6 +997,8 @@
<separator/>
<reference id="Cargo.ExpandAll"/>
<reference id="Cargo.CollapseAll"/>
<separator/>
<reference id="Cargo.ShowSettings"/>
</group>

</actions>
Expand Down

0 comments on commit 7f899cc

Please sign in to comment.