mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
Flow triage view now is ordered by stateMachines observation arrival.
Fix bug onUndock when there is no transactions in transactions view.
This commit is contained in:
parent
556eb756a8
commit
5e1e50071d
@ -4,9 +4,8 @@ import javafx.beans.property.SimpleIntegerProperty
|
|||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.beans.value.ObservableValue
|
import javafx.beans.value.ObservableValue
|
||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
import net.corda.client.jfx.utils.LeftOuterJoinedMap
|
|
||||||
import net.corda.client.jfx.utils.fold
|
import net.corda.client.jfx.utils.fold
|
||||||
import net.corda.client.jfx.utils.getObservableValues
|
import net.corda.client.jfx.utils.map
|
||||||
import net.corda.client.jfx.utils.recordAsAssociation
|
import net.corda.client.jfx.utils.recordAsAssociation
|
||||||
import net.corda.core.ErrorOr
|
import net.corda.core.ErrorOr
|
||||||
import net.corda.core.flows.FlowInitiator
|
import net.corda.core.flows.FlowInitiator
|
||||||
@ -29,8 +28,8 @@ data class ProgressTrackingEvent(val stateMachineId: StateMachineRunId, val mess
|
|||||||
data class ProgressStatus(val status: String?)
|
data class ProgressStatus(val status: String?)
|
||||||
|
|
||||||
sealed class StateMachineStatus {
|
sealed class StateMachineStatus {
|
||||||
data class Added(val stateMachineName: String, val flowInitiator: FlowInitiator) : StateMachineStatus()
|
data class Added(val id: StateMachineRunId, val stateMachineName: String, val flowInitiator: FlowInitiator) : StateMachineStatus()
|
||||||
data class Removed(val result: ErrorOr<*>) : StateMachineStatus()
|
data class Removed(val id: StateMachineRunId, val result: ErrorOr<*>) : StateMachineStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
data class StateMachineData(
|
data class StateMachineData(
|
||||||
@ -62,29 +61,34 @@ class StateMachineDataModel {
|
|||||||
|
|
||||||
val counter = Counter()
|
val counter = Counter()
|
||||||
|
|
||||||
private val stateMachineStatus = stateMachineUpdates.fold(FXCollections.observableHashMap<StateMachineRunId, SimpleObjectProperty<StateMachineStatus>>()) { map, update ->
|
private val stateMachineIndexMap = HashMap<StateMachineRunId, Int>()
|
||||||
|
private val stateMachineStatus = stateMachineUpdates.fold(FXCollections.observableArrayList<SimpleObjectProperty<StateMachineStatus>>()) { list, update ->
|
||||||
when (update) {
|
when (update) {
|
||||||
is StateMachineUpdate.Added -> {
|
is StateMachineUpdate.Added -> {
|
||||||
counter.addSmm()
|
counter.addSmm()
|
||||||
val flowInitiator= update.stateMachineInfo.initiator
|
val flowInitiator= update.stateMachineInfo.initiator
|
||||||
val added: SimpleObjectProperty<StateMachineStatus> =
|
val added: SimpleObjectProperty<StateMachineStatus> =
|
||||||
SimpleObjectProperty(StateMachineStatus.Added(update.stateMachineInfo.flowLogicClassName, flowInitiator))
|
SimpleObjectProperty(StateMachineStatus.Added(update.id, update.stateMachineInfo.flowLogicClassName, flowInitiator))
|
||||||
map[update.id] = added
|
list.add(added)
|
||||||
|
stateMachineIndexMap[update.id] = list.size - 1
|
||||||
}
|
}
|
||||||
is StateMachineUpdate.Removed -> {
|
is StateMachineUpdate.Removed -> {
|
||||||
val added = map[update.id]
|
val addedIdx = stateMachineIndexMap[update.id]
|
||||||
|
val added = addedIdx?.let { list.getOrNull(addedIdx) }
|
||||||
added ?: throw Exception("State machine removed with unknown id ${update.id}")
|
added ?: throw Exception("State machine removed with unknown id ${update.id}")
|
||||||
counter.removeSmm(update.result)
|
counter.removeSmm(update.result)
|
||||||
added.set(StateMachineStatus.Removed(update.result))
|
list[addedIdx].set(StateMachineStatus.Removed(update.id, update.result))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val stateMachineDataList = LeftOuterJoinedMap(stateMachineStatus, progressEvents) { id, status, progress ->
|
private val stateMachineDataList = stateMachineStatus.map {
|
||||||
val smStatus = status.value as StateMachineStatus.Added
|
val smStatus = it.value as StateMachineStatus.Added
|
||||||
|
val id = smStatus.id
|
||||||
|
val progress = SimpleObjectProperty(progressEvents.get(id))
|
||||||
StateMachineData(id, smStatus.stateMachineName, smStatus.flowInitiator,
|
StateMachineData(id, smStatus.stateMachineName, smStatus.flowInitiator,
|
||||||
Pair(status, EasyBind.map(progress) { ProgressStatus(it?.message) }))
|
Pair(it, EasyBind.map(progress) { ProgressStatus(it?.message) }))
|
||||||
}.getObservableValues()
|
}
|
||||||
|
|
||||||
val stateMachinesAll = stateMachineDataList
|
val stateMachinesAll = stateMachineDataList
|
||||||
val error = counter.errored
|
val error = counter.errored
|
||||||
|
@ -4,7 +4,6 @@ import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon
|
|||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
import javafx.scene.Node
|
import javafx.scene.Node
|
||||||
import javafx.scene.control.Label
|
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
class CordaViewModel {
|
class CordaViewModel {
|
||||||
|
@ -88,9 +88,11 @@ class TransactionViewer : CordaView("Transactions") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onUndock() {
|
override fun onUndock() {
|
||||||
val isExpanded = expander.getExpandedProperty(transactionViewTable.items[scrollPosition]) // It is evil.
|
if (scrollPosition != 0) {
|
||||||
if (isExpanded.value) expander.toggleExpanded(scrollPosition)
|
val isExpanded = expander.getExpandedProperty(transactionViewTable.items[scrollPosition])
|
||||||
scrollPosition = 0
|
if (isExpanded.value) expander.toggleExpanded(scrollPosition)
|
||||||
|
scrollPosition = 0
|
||||||
|
}
|
||||||
txIdToScroll = null
|
txIdToScroll = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user