generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/cc/unitmesh/devti/settings/configurable/CoUnitToolConfigurable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package cc.unitmesh.devti.settings.configurable | ||
|
||
import cc.unitmesh.devti.AutoDevBundle | ||
import com.intellij.openapi.Disposable | ||
import com.intellij.openapi.options.BoundConfigurable | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.ui.DialogPanel | ||
import com.intellij.openapi.util.Disposer | ||
import com.intellij.ui.dsl.builder.Cell | ||
import com.intellij.ui.dsl.builder.Row | ||
import com.intellij.ui.dsl.builder.panel | ||
import com.intellij.ui.dsl.gridLayout.HorizontalAlign | ||
import javax.swing.JComponent | ||
import javax.swing.JTextField | ||
|
||
class CoUnitToolConfigurable(project: Project) : | ||
BoundConfigurable(AutoDevBundle.message("settings.external.counit.name")), Disposable { | ||
private val pathToToolchainComboBox = CoUnitToolchainPathChoosingComboBox() | ||
private val serverAddress = JTextField() | ||
override fun createPanel(): DialogPanel = panel { | ||
row { | ||
checkBox(AutoDevBundle.message("settings.external.counit.enable.label")) | ||
.comment(AutoDevBundle.message("settings.external.counit.enable.label.comment")) | ||
// .bindSelected(project::enableCoUnit) | ||
} | ||
|
||
row(AutoDevBundle.message("settings.external.counit.server.address.label")) { | ||
fullWidthCell(serverAddress) | ||
// .bind( | ||
// componentGet = { it.text }, | ||
// componentSet = { component, value -> component.text = value }, | ||
// prop = state::additionalArguments.toMutableProperty() | ||
// ) | ||
} | ||
|
||
row(AutoDevBundle.message("settings.external.counit.location.label")) { | ||
fullWidthCell(pathToToolchainComboBox) | ||
} | ||
} | ||
|
||
override fun dispose() { | ||
Disposer.dispose(pathToToolchainComboBox) | ||
} | ||
} | ||
|
||
fun <T : JComponent> Row.fullWidthCell(component: T): Cell<T> { | ||
return cell(component) | ||
.horizontalAlign(HorizontalAlign.FILL) | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/cc/unitmesh/devti/settings/configurable/CoUnitToolConfigurableProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cc.unitmesh.devti.settings.configurable | ||
|
||
import com.intellij.openapi.options.Configurable | ||
import com.intellij.openapi.options.ConfigurableProvider | ||
import com.intellij.openapi.project.Project | ||
|
||
class CoUnitToolConfigurableProvider (private val project: Project) : ConfigurableProvider() { | ||
override fun createConfigurable(): Configurable { | ||
return CoUnitToolConfigurable(project) | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ain/kotlin/cc/unitmesh/devti/settings/configurable/CoUnitToolchainPathChoosingComboBox.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Use of this source code is governed by the MIT license that can be | ||
* found in the LICENSE file. | ||
*/ | ||
package cc.unitmesh.devti.settings.configurable | ||
|
||
import com.intellij.openapi.fileChooser.FileChooser | ||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory | ||
import com.intellij.openapi.ui.ComboBoxWithWidePopup | ||
import com.intellij.openapi.ui.ComponentWithBrowseButton | ||
import com.intellij.ui.ComboboxSpeedSearch | ||
import com.intellij.ui.DocumentAdapter | ||
import com.intellij.ui.components.fields.ExtendableTextField | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import javax.swing.event.DocumentEvent | ||
import javax.swing.plaf.basic.BasicComboBoxEditor | ||
|
||
class CoUnitToolchainPathChoosingComboBox(onTextChanged: () -> Unit = {}) : | ||
ComponentWithBrowseButton<ComboBoxWithWidePopup<Path>>(ComboBoxWithWidePopup(), null) { | ||
private val editor: BasicComboBoxEditor = object : BasicComboBoxEditor() { | ||
override fun createEditorComponent(): ExtendableTextField = ExtendableTextField() | ||
} | ||
|
||
private val pathTextField: ExtendableTextField | ||
get() = childComponent.editor.editorComponent as ExtendableTextField | ||
|
||
init { | ||
ComboboxSpeedSearch(childComponent) | ||
childComponent.editor = editor | ||
childComponent.isEditable = true | ||
|
||
addActionListener { | ||
val descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor() | ||
FileChooser.chooseFile(descriptor, null, null) { file -> | ||
childComponent.selectedItem = Paths.get(file.path) | ||
} | ||
} | ||
|
||
pathTextField.document.addDocumentListener( | ||
object : DocumentAdapter() { | ||
override fun textChanged(e: DocumentEvent) { | ||
onTextChanged() | ||
} | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters