Scratch: add Make before Run checkbox
This commit is contained in:
@@ -38,7 +38,7 @@ class RunScratchAction : AnAction(
|
|||||||
val scratchTopPanel = getScratchPanelFromSelectedEditor(project) ?: return
|
val scratchTopPanel = getScratchPanelFromSelectedEditor(project) ?: return
|
||||||
val scratchFile = scratchTopPanel.scratchFile
|
val scratchFile = scratchTopPanel.scratchFile
|
||||||
|
|
||||||
val isMakeBeforeRun = false // todo use property from panel
|
val isMakeBeforeRun = scratchTopPanel.isMakeBeforeRun()
|
||||||
val isRepl = scratchTopPanel.isRepl()
|
val isRepl = scratchTopPanel.isRepl()
|
||||||
|
|
||||||
val provider = ScratchFileLanguageProvider.get(scratchFile.psiFile.language) ?: return
|
val provider = ScratchFileLanguageProvider.get(scratchFile.psiFile.language) ?: return
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.intellij.openapi.project.Project
|
|||||||
import com.intellij.openapi.vfs.VirtualFile
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.psi.PsiManager
|
import com.intellij.psi.PsiManager
|
||||||
import com.intellij.ui.components.panels.HorizontalLayout
|
import com.intellij.ui.components.panels.HorizontalLayout
|
||||||
import com.intellij.uiDesigner.core.Spacer
|
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
import org.jetbrains.kotlin.idea.scratch.ScratchFile
|
import org.jetbrains.kotlin.idea.scratch.ScratchFile
|
||||||
import org.jetbrains.kotlin.idea.scratch.ScratchFileLanguageProvider
|
import org.jetbrains.kotlin.idea.scratch.ScratchFileLanguageProvider
|
||||||
@@ -49,17 +48,24 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
|
|
||||||
private val moduleChooser: ModulesComboBox
|
private val moduleChooser: ModulesComboBox
|
||||||
private val isReplCheckbox: JCheckBox
|
private val isReplCheckbox: JCheckBox
|
||||||
|
private val isMakeBeforeRunCheckbox: JCheckBox
|
||||||
|
|
||||||
init {
|
init {
|
||||||
add(createActionsToolbar())
|
add(createActionsToolbar())
|
||||||
add(JSeparator())
|
|
||||||
isReplCheckbox = JCheckBox("Use Repl", false)
|
isReplCheckbox = JCheckBox("Use REPL", false).customize()
|
||||||
add(isReplCheckbox)
|
add(isReplCheckbox)
|
||||||
add(JSeparator())
|
|
||||||
add(JLabel("Use classpath of module: "))
|
add(JSeparator(SwingConstants.VERTICAL))
|
||||||
|
|
||||||
|
isMakeBeforeRunCheckbox = JCheckBox("Make before Run", false).customize()
|
||||||
|
add(isMakeBeforeRunCheckbox)
|
||||||
|
|
||||||
|
add(JSeparator(SwingConstants.VERTICAL))
|
||||||
|
|
||||||
moduleChooser = createModuleChooser(scratchFile.psiFile.project)
|
moduleChooser = createModuleChooser(scratchFile.psiFile.project)
|
||||||
|
add(JLabel("Use classpath of module"))
|
||||||
add(moduleChooser)
|
add(moduleChooser)
|
||||||
add(Spacer())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getModule(): Module? = moduleChooser.selectedModule
|
fun getModule(): Module? = moduleChooser.selectedModule
|
||||||
@@ -71,12 +77,18 @@ class ScratchTopPanel private constructor(val scratchFile: ScratchFile) : JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun isRepl() = isReplCheckbox.isSelected
|
fun isRepl() = isReplCheckbox.isSelected
|
||||||
|
fun isMakeBeforeRun() = isMakeBeforeRunCheckbox.isSelected
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
fun setReplMode(isSelected: Boolean) {
|
fun setReplMode(isSelected: Boolean) {
|
||||||
isReplCheckbox.isSelected = isSelected
|
isReplCheckbox.isSelected = isSelected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun JCheckBox.customize(): JCheckBox {
|
||||||
|
verticalTextPosition = SwingConstants.BOTTOM
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
private fun createActionsToolbar(): JComponent {
|
private fun createActionsToolbar(): JComponent {
|
||||||
val toolbarGroup = DefaultActionGroup().apply {
|
val toolbarGroup = DefaultActionGroup().apply {
|
||||||
add(RunScratchAction())
|
add(RunScratchAction())
|
||||||
|
|||||||
Reference in New Issue
Block a user