Scratch: hide 'make module' checkbox when no module is selected
^KT-23985
This commit is contained in:
@@ -63,6 +63,7 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
private val isMakeBeforeRunCheckbox: JCheckBox
|
private val isMakeBeforeRunCheckbox: JCheckBox
|
||||||
private val isInteractiveCheckbox: JCheckBox
|
private val isInteractiveCheckbox: JCheckBox
|
||||||
|
|
||||||
|
private val moduleSeparator: JSeparator
|
||||||
private val actionsToolbar: ActionToolbar
|
private val actionsToolbar: ActionToolbar
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -81,7 +82,10 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
add(JSeparator(SwingConstants.VERTICAL))
|
moduleSeparator = JSeparator(SwingConstants.VERTICAL)
|
||||||
|
add(moduleSeparator)
|
||||||
|
|
||||||
|
changeMakeModuleCheckboxVisibility(false)
|
||||||
|
|
||||||
isInteractiveCheckbox = JCheckBox("Interactive mode")
|
isInteractiveCheckbox = JCheckBox("Interactive mode")
|
||||||
add(isInteractiveCheckbox)
|
add(isInteractiveCheckbox)
|
||||||
@@ -119,6 +123,9 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
fun addModuleListener(f: (PsiFile, Module?) -> Unit) {
|
fun addModuleListener(f: (PsiFile, Module?) -> Unit) {
|
||||||
moduleChooser.addActionListener {
|
moduleChooser.addActionListener {
|
||||||
val selectedModule = moduleChooser.selectedModule
|
val selectedModule = moduleChooser.selectedModule
|
||||||
|
|
||||||
|
changeMakeModuleCheckboxVisibility(selectedModule != null)
|
||||||
|
|
||||||
val psiFile = scratchFile.getPsiFile()
|
val psiFile = scratchFile.getPsiFile()
|
||||||
if (psiFile != null) {
|
if (psiFile != null) {
|
||||||
f(psiFile, selectedModule)
|
f(psiFile, selectedModule)
|
||||||
@@ -141,6 +148,11 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
isInteractiveCheckbox.isSelected = isSelected
|
isInteractiveCheckbox.isSelected = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun changeMakeModuleCheckboxVisibility(isVisible: Boolean) {
|
||||||
|
isMakeBeforeRunCheckbox.isVisible = isVisible
|
||||||
|
moduleSeparator.isVisible = isVisible
|
||||||
|
}
|
||||||
|
|
||||||
fun updateToolbar() {
|
fun updateToolbar() {
|
||||||
ApplicationManager.getApplication().invokeLater {
|
ApplicationManager.getApplication().invokeLater {
|
||||||
actionsToolbar.updateActionsImmediately()
|
actionsToolbar.updateActionsImmediately()
|
||||||
|
|||||||
Reference in New Issue
Block a user