代码(JavaFX应用程序,kotlin):
class TempController {
@FXML
private lateinit var treeTable: TreeTableView<SkillTableDAO>
@FXML
private lateinit var colValue: TreeTableColumn<SkillTableDAO, String>
private val skillTree: MutableMap<Long, TreeItem<SkillTableDAO>> = ConcurrentHashMap()
@Suppress("unused")
fun initialize() {
colValue.setCellValueFactory {
ReadOnlyStringWrapper(it.value.value.getValue())
}
val treeRoot = TreeItem<SkillTableDAO>(null).apply { isExpanded = true }
treeTable.isShowRoot = false
treeTable.root = treeRoot
Pck_CmdSetSkill.listen { packet ->
Platform.runLater {
var node = skillTree[packet.id]
if (node != null) {
node.value.onPacket(packet)
// Packets goning unordered, so try to find parent
if ((node.parent == treeRoot || node.parent.value.id != node.value.parentId) && skillTree.containsKey(packet.parentId)) {
node.parent.children.remove(node)
skillTree[packet.parentId]!!.children.add(node)
}
} else {
node = TreeItem(SkillTableDAO(packet))
skillTree[packet.id] = node
(skillTree[packet.parentId] ?: treeRoot).children.add(node)
}
}
}
}
@Suppress("unused")
class SkillTableDAO(packet: Pck_CmdSetSkill.Packet) {
val id: Long = packet.id
val parentId: Long = packet.parentId
var value: Float = packet.value
fun onPacket(packet: Pck_CmdSetSkill.Packet): SkillTableDAO {
this.value = packet.value
return this
}
fun getValue() = value.toString()
}
}
当我更改对象的值时(发生Pck_CmdSetSkill.listen
时,单元格的值保持其原始状态。我究竟做错了什么?
我尝试了几种可观察到的变体,但是失败了……我也尝试过it.value.value.value.toString()
,但是没有发生任何新的事情。
答案 0 :(得分:0)
Pck_CmdSetSkill仅在其他地方被称为初始错误代码=(