PluginsView.kt

This commit is contained in:
ryoii 2020-03-17 22:54:51 +08:00
parent 6602687371
commit fe250735f3
2 changed files with 34 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package net.mamoe.mirai.console.graphical.model
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject
import javafx.beans.property.SimpleBooleanProperty
import javafx.beans.property.SimpleStringProperty
import net.mamoe.mirai.console.plugins.PluginDescription
import tornadofx.getValue
import tornadofx.setValue
@ -14,6 +15,11 @@ class PluginModel(
) : RecursiveTreeObject<PluginModel>() {
constructor(plugin: PluginDescription) : this(plugin.name, plugin.version, plugin.author, plugin.info)
val nameProperty = SimpleStringProperty(this, "nameProperty", name)
val versionProperty = SimpleStringProperty(this, "versionProperty", version)
val authorProperty = SimpleStringProperty(this, "authorProperty", author)
val descriptionProperty = SimpleStringProperty(this, "descriptionProperty", description)
val enabledProperty = SimpleBooleanProperty(this, "enabledProperty")
var enabled by enabledProperty
}

View File

@ -12,21 +12,48 @@ class PluginsView : View() {
val plugins = controller.pluginList
override val root = jfxTreeTableView(plugins) {
isShowRoot = false
columns.addAll(
JFXTreeTableColumn<PluginModel, String>("插件名").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
setCellValueFactory {
return@setCellValueFactory it.value.value.nameProperty
}
},
JFXTreeTableColumn<PluginModel, String>("版本").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
setCellValueFactory {
return@setCellValueFactory it.value.value.versionProperty
}
},
JFXTreeTableColumn<PluginModel, String>("作者").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.1))
setCellValueFactory {
return@setCellValueFactory it.value.value.authorProperty
}
},
JFXTreeTableColumn<PluginModel, String>("介绍").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.6))
setCellValueFactory {
return@setCellValueFactory it.value.value.descriptionProperty
}
},
JFXTreeTableColumn<PluginModel, String>("操作").apply {
JFXTreeTableColumn<PluginModel, PluginModel>("操作").apply {
prefWidthProperty().bind(this@jfxTreeTableView.widthProperty().multiply(0.08))
// setCellValueFactory { return@setCellValueFactory it.value.valueProperty() }
//
// setCellFactory {
// return@setCellFactory object : TreeTableCell<PluginModel, PluginModel>() {
// override fun updateItem(item: PluginModel?, empty: Boolean) {
//
// }
// }
// }
}
)
}