Skip to content

Commit

Permalink
The Hydra settings panel opens when you click the Action
Browse files Browse the repository at this point in the history
  • Loading branch information
maris123 committed Nov 9, 2017
1 parent 16b3f60 commit 3d2a076
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@
<keyboard-shortcut first-keystroke="alt control shift E" keymap="$default"/>
</action>
<action id="Hydra.EnableSettings" class="org.jetbrains.plugins.hydra.actions.EnableHydraSettingsAction"
text="Enable/Disable Hydra Settings" description="Enables or Disables Hydra Settings Panel">
text="Open Hydra Settings" description="Enables or Disables Hydra Settings Panel">
</action>
<action id="ScalaConsole.Execute" class="org.jetbrains.plugins.scala.console.ScalaConsoleExecuteAction" text="Execute Console Statement">
<keyboard-shortcut first-keystroke="control ENTER" keymap="$default"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
package org.jetbrains.plugins.hydra.actions

import com.intellij.openapi.actionSystem.{AnActionEvent, CommonDataKeys, ToggleAction}
import com.intellij.openapi.actionSystem.{AnAction, AnActionEvent, CommonDataKeys}
import com.intellij.openapi.project.Project
import org.jetbrains.plugins.hydra.compiler.HydraCompilerSettings
import org.jetbrains.plugins.hydra.compiler.{HydraCompilerSettings, HydraCompilerSettingsManager}

/**
* @author Maris Alexandru
*/
class EnableHydraSettingsAction extends ToggleAction{

override def setSelected(e: AnActionEvent, toSet: Boolean): Unit = {
class EnableHydraSettingsAction extends AnAction{
def actionPerformed(e: AnActionEvent): Unit = {
CommonDataKeys.PROJECT.getData(e.getDataContext) match {
case project: Project => {
val settings = HydraCompilerSettings.getInstance(project)
settings.isHydraSettingsEnabled = toSet
HydraCompilerSettingsManager.showHydraCompileSettingsDialog(project)
settings.isHydraSettingsEnabled = true
}
case _ =>
}
}

override def isSelected(e: AnActionEvent): Boolean = {
CommonDataKeys.PROJECT.getData(e.getDataContext) match {
case project: Project => {
val settings = HydraCompilerSettings.getInstance(project)
settings.isHydraSettingsEnabled
}
case _ => false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.jetbrains.plugins.hydra.compiler

import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project

/**
* @author Maris Alexandru
*/
object HydraCompilerSettingsManager {
def showHydraCompileSettingsDialog(project: Project): Unit = ShowSettingsUtil.getInstance().showSettingsDialog(project, "Hydra Compiler")
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.jetbrains.plugins.hydra.notification

import com.intellij.openapi.module.Module
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.ui.{EditorNotificationPanel, EditorNotifications}
import org.jetbrains.plugins.hydra.HydraVersions
import org.jetbrains.plugins.hydra.compiler.HydraCompilerSettings
import org.jetbrains.plugins.hydra.compiler.{HydraCompilerSettings, HydraCompilerSettingsManager}
import org.jetbrains.plugins.hydra.settings.HydraApplicationSettings
import org.jetbrains.plugins.scala.project.notification.AbstractNotificationProvider
import org.jetbrains.plugins.hydra.notification.HydraArtifactsNotificationProvider._
Expand All @@ -31,18 +30,17 @@ class HydraArtifactsNotificationProvider(project: Project, notifications: Editor
}
}

override protected def createTask(module: Module): Runnable = () => showHydraCompileSettingsDialog()
override protected def createTask(module: Module): Runnable = () => HydraCompilerSettingsManager.showHydraCompileSettingsDialog(project)

override protected def panelText: String = s"No $developerKitTitle artifacts in module. Please download the artifacts."

override protected def developerKitTitle: String = HydraTitle

private def showHydraCompileSettingsDialog(): Unit = ShowSettingsUtil.getInstance().showSettingsDialog(project, "Hydra Compiler")

}

object HydraArtifactsNotificationProvider {
private val HydraTitle = "Hydra"

private val ProviderKey = Key.create[EditorNotificationPanel](HydraTitle)

}

0 comments on commit 3d2a076

Please sign in to comment.