mirror of
https://github.com/corda/corda.git
synced 2025-06-01 23:20:54 +00:00
Make flow initiator view code more generic.
This commit is contained in:
parent
c734f625ad
commit
ab0bc8b8d0
@ -135,200 +135,160 @@ class StateMachineViewer : CordaView("Flow Triage") {
|
|||||||
|
|
||||||
private inner class StateMachineDetailsView(val smmData: StateMachineData) : Fragment() {
|
private inner class StateMachineDetailsView(val smmData: StateMachineData) : Fragment() {
|
||||||
override val root by fxml<Parent>()
|
override val root by fxml<Parent>()
|
||||||
private val flowNamePane by fxid<TitledPane>()
|
private val flowNameLabel by fxid<Label>()
|
||||||
private val flowProgressPane by fxid<TitledPane>()
|
private val flowProgressPane by fxid<TitledPane>()
|
||||||
private val flowInitiatorPane by fxid<TitledPane>()
|
private val flowInitiatorGrid by fxid<GridPane>()
|
||||||
private val flowResultPane by fxid<TitledPane>()
|
private val flowResultVBox by fxid<VBox>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
flowNamePane.apply {
|
flowNameLabel.apply {
|
||||||
content = label {
|
text = FlowNameFormatter.boring.format(smmData.stateMachineName)
|
||||||
text = FlowNameFormatter.boring.format(smmData.stateMachineName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
flowProgressPane.apply {
|
flowProgressPane.apply {
|
||||||
content = label {
|
content = label {
|
||||||
text = smmData.stateMachineStatus.value?.status // TODO later we can do some magic with showing progress steps with subflows
|
text = smmData.stateMachineStatus.value?.status // TODO later we can do some magic with showing progress steps with subflows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flowInitiatorPane.apply {
|
when (smmData.flowInitiator) {
|
||||||
//TODO use fxml to access initiatorGridPane
|
is FlowInitiator.Shell -> makeShellGrid(flowInitiatorGrid) // TODO Extend this when we will have more information on shell user.
|
||||||
// initiatorGridPane.apply {when...
|
is FlowInitiator.Peer -> makePeerGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.Peer)
|
||||||
content = when (smmData.flowInitiator) {
|
is FlowInitiator.RPC -> makeRPCGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.RPC)
|
||||||
is FlowInitiator.Shell -> ShellNode() // TODO Extend this when we will have more information on shell user.
|
is FlowInitiator.Scheduled -> makeScheduledGrid(flowInitiatorGrid, smmData.flowInitiator as FlowInitiator.Scheduled)
|
||||||
is FlowInitiator.Peer -> PeerNode(smmData.flowInitiator as FlowInitiator.Peer)
|
|
||||||
is FlowInitiator.RPC -> RPCNode(smmData.flowInitiator as FlowInitiator.RPC)
|
|
||||||
is FlowInitiator.Scheduled -> ScheduledNode(smmData.flowInitiator as FlowInitiator.Scheduled)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
flowResultPane.apply {
|
val status = smmData.addRmStatus.value
|
||||||
val status = smmData.addRmStatus.value
|
if (status is StateMachineStatus.Removed) {
|
||||||
if (status is StateMachineStatus.Removed) {
|
status.result.match(onValue = { makeResultVBox(flowResultVBox, it) }, onError = { makeErrorVBox(flowResultVBox, it) })
|
||||||
content = status.result.match(onValue = { ResultNode(it) }, onError = { ErrorNode(it) })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make that Vbox part of FXML
|
private fun <T>makeResultVBox(vbox: VBox, result: T) {
|
||||||
private inner class ResultNode<T>(result: T) : VBox() {
|
if (result == null) {
|
||||||
init {
|
vbox.apply { label("No return value from flow.") }
|
||||||
spacing = 10.0
|
} else if (result is SignedTransaction) {
|
||||||
padding = Insets(5.0, 5.0, 5.0, 5.0)
|
|
||||||
if (result == null) {
|
|
||||||
label("No return value from flow.")
|
|
||||||
} else if (result is SignedTransaction) {
|
|
||||||
// scrollpane {
|
// scrollpane {
|
||||||
// hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
// hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
||||||
// vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
// vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
||||||
// TODO Make link to transaction view
|
// TODO Make link to transaction view
|
||||||
label("Signed transaction")
|
vbox.apply {
|
||||||
label {
|
label("Signed transaction")
|
||||||
text = result.id.toString()
|
label {
|
||||||
graphic = identicon(result.id, 30.0)
|
text = result.id.toString()
|
||||||
tooltip = identiconToolTip(result.id)
|
graphic = identicon(result.id, 30.0)
|
||||||
}
|
tooltip = identiconToolTip(result.id)
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
} else if (result is Unit) {
|
|
||||||
label("Flow completed with success.")
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// TODO Here we could have sth different than SignedTransaction
|
|
||||||
label(result.toString())
|
|
||||||
}
|
}
|
||||||
|
} else if (result is Unit) {
|
||||||
|
vbox.apply { label("Flow completed with success.") }
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// TODO Here we could have sth different than SignedTransaction
|
||||||
|
vbox.apply { label(result.toString()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make that Vbox part of FXML
|
private fun makeErrorVBox(vbox: VBox, error: Throwable) {
|
||||||
private inner class ErrorNode(val error: Throwable) : VBox() {
|
vbox.apply {
|
||||||
init {
|
label("Error") {
|
||||||
|
graphic = FontAwesomeIconView(FontAwesomeIcon.BOLT).apply {
|
||||||
|
glyphSize = 30
|
||||||
|
textAlignment = TextAlignment.CENTER
|
||||||
|
style = "-fx-fill: -color-4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO border styling?
|
||||||
|
vbox.apply {
|
||||||
vbox {
|
vbox {
|
||||||
spacing = 10.0
|
spacing = 10.0
|
||||||
padding = Insets(5.0, 5.0, 5.0, 5.0)
|
label { text = error::class.simpleName }
|
||||||
label("Error") {
|
scrollpane { //TODO do that error scroll pane nicely
|
||||||
graphic = FontAwesomeIconView(FontAwesomeIcon.BOLT).apply {
|
hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
||||||
glyphSize = 30
|
vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
||||||
textAlignment = TextAlignment.CENTER
|
label { text = error.message }
|
||||||
style = "-fx-fill: -color-4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// TODO think of border styling
|
|
||||||
vbox {
|
|
||||||
spacing = 10.0
|
|
||||||
label { text = error::class.simpleName }
|
|
||||||
scrollpane {
|
|
||||||
hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
|
||||||
vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
|
||||||
label { text = error.message }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class ShellNode : Label() {
|
|
||||||
init {
|
|
||||||
label("Flow started by shell user")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO make it more generic, reuse gridpane definition - to fxml
|
|
||||||
private inner class PeerNode(val initiator: FlowInitiator.Peer): GridPane() {
|
|
||||||
init {
|
|
||||||
gridpane {
|
|
||||||
padding = Insets(0.0, 5.0, 10.0, 10.0)
|
|
||||||
vgap = 10.0
|
|
||||||
hgap = 10.0
|
|
||||||
row {
|
|
||||||
label("Flow started by a peer node") {
|
|
||||||
gridpaneConstraints {
|
|
||||||
columnSpan = 2
|
|
||||||
hAlignment = HPos.CENTER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// scrollpane { // TODO scrollbar vbox + hbox
|
|
||||||
// hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
|
||||||
// vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
|
||||||
row {
|
|
||||||
label("Legal name: ") {
|
|
||||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
|
||||||
style { fontWeight = FontWeight.BOLD }
|
|
||||||
minWidth = 150.0
|
|
||||||
prefWidth = 150.0
|
|
||||||
}
|
|
||||||
label(initiator.party.name) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
label("Owning key: ") {
|
|
||||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
|
||||||
style { fontWeight = FontWeight.BOLD }
|
|
||||||
minWidth = 150.0
|
|
||||||
prefWidth = 150.0
|
|
||||||
}
|
|
||||||
label(initiator.party.owningKey.toBase58String()) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class RPCNode(val initiator: FlowInitiator.RPC) : GridPane() {
|
|
||||||
init {
|
|
||||||
gridpane {
|
|
||||||
padding = Insets(0.0, 5.0, 10.0, 10.0)
|
|
||||||
vgap = 10.0
|
|
||||||
hgap = 10.0
|
|
||||||
row {
|
|
||||||
label("Flow started by a RPC user") {
|
|
||||||
gridpaneConstraints {
|
|
||||||
columnSpan = 2
|
|
||||||
hAlignment = HPos.CENTER
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
row {
|
|
||||||
label("User name: ") {
|
|
||||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
|
||||||
style { fontWeight = FontWeight.BOLD }
|
|
||||||
prefWidth = 150.0
|
|
||||||
}
|
|
||||||
label(initiator.username) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO test
|
// TODO test
|
||||||
private inner class ScheduledNode(val initiator: FlowInitiator.Scheduled) : GridPane() {
|
private fun makeShellGrid(gridPane: GridPane) {
|
||||||
init {
|
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||||
gridpane {
|
title.apply {
|
||||||
padding = Insets(0.0, 5.0, 10.0, 10.0)
|
text = "Flow started by shell user"
|
||||||
vgap = 10.0
|
}
|
||||||
hgap = 10.0
|
}
|
||||||
row {
|
|
||||||
label("Flow started as scheduled activity")
|
private fun makePeerGrid(gridPane: GridPane, initiator: FlowInitiator.Peer) {
|
||||||
gridpaneConstraints {
|
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||||
columnSpan = 2
|
title.apply {
|
||||||
hAlignment = HPos.CENTER
|
text = "Flow started by a peer node"
|
||||||
}
|
}
|
||||||
|
gridPane.apply{
|
||||||
|
// scrollpane { // TODO scrollbar vbox + hbox
|
||||||
|
// hbarPolicy = ScrollPane.ScrollBarPolicy.AS_NEEDED
|
||||||
|
// vbarPolicy = ScrollPane.ScrollBarPolicy.NEVER
|
||||||
|
row {
|
||||||
|
label("Legal name: ") {
|
||||||
|
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||||
|
style { fontWeight = FontWeight.BOLD }
|
||||||
|
minWidth = 150.0
|
||||||
|
prefWidth = 150.0
|
||||||
}
|
}
|
||||||
row {
|
label(initiator.party.name) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
||||||
label("Scheduled state: ") {
|
}
|
||||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
row {
|
||||||
style { fontWeight = FontWeight.BOLD }
|
label("Owning key: ") {
|
||||||
prefWidth = 150.0
|
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||||
}
|
style { fontWeight = FontWeight.BOLD }
|
||||||
label(initiator.scheduledState.ref.toString()) { gridpaneConstraints { hAlignment = HPos.LEFT } } //TODO format
|
minWidth = 150.0
|
||||||
|
prefWidth = 150.0
|
||||||
}
|
}
|
||||||
row {
|
label(initiator.party.owningKey.toBase58String()) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
||||||
label("Scheduled at: ") {
|
}
|
||||||
gridpaneConstraints { hAlignment = HPos.LEFT }
|
}
|
||||||
style { fontWeight = FontWeight.BOLD }
|
}
|
||||||
prefWidth = 150.0
|
|
||||||
}
|
private fun makeRPCGrid(gridPane: GridPane, initiator: FlowInitiator.RPC) {
|
||||||
label(initiator.scheduledState.scheduledAt.toString()) { gridpaneConstraints { hAlignment = HPos.LEFT } } //TODO format
|
val title = gridPane.lookup("#flowInitiatorTitle") as Label
|
||||||
|
title.apply {
|
||||||
|
text = "Flow started by a RPC user"
|
||||||
|
}
|
||||||
|
gridPane.apply {
|
||||||
|
row {
|
||||||
|
label("User name: ") {
|
||||||
|
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||||
|
style { fontWeight = FontWeight.BOLD }
|
||||||
|
prefWidth = 150.0
|
||||||
}
|
}
|
||||||
|
label(initiator.username) { gridpaneConstraints { hAlignment = HPos.LEFT } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO test
|
||||||
|
private fun makeScheduledGrid(gridPane: GridPane, initiator: FlowInitiator.Scheduled) {
|
||||||
|
val title = gridPane.lookup("flowInitiatorTitle") as Label
|
||||||
|
title.apply {
|
||||||
|
text = "Flow started as scheduled activity"
|
||||||
|
}
|
||||||
|
gridPane.apply {
|
||||||
|
row {
|
||||||
|
label("Scheduled state: ") {
|
||||||
|
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||||
|
style { fontWeight = FontWeight.BOLD }
|
||||||
|
prefWidth = 150.0
|
||||||
|
}
|
||||||
|
label(initiator.scheduledState.ref.toString()) { gridpaneConstraints { hAlignment = HPos.LEFT } } //TODO format
|
||||||
|
}
|
||||||
|
row {
|
||||||
|
label("Scheduled at: ") {
|
||||||
|
gridpaneConstraints { hAlignment = HPos.LEFT }
|
||||||
|
style { fontWeight = FontWeight.BOLD }
|
||||||
|
prefWidth = 150.0
|
||||||
|
}
|
||||||
|
label(initiator.scheduledState.scheduledAt.toString()) { gridpaneConstraints { hAlignment = HPos.LEFT } } //TODO format
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,37 @@
|
|||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
<?import javafx.scene.control.TitledPane?>
|
<?import javafx.scene.control.TitledPane?>
|
||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
|
||||||
<?import javafx.scene.layout.ColumnConstraints?>
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<GridPane stylesheets="@../css/corda.css" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1">
|
<GridPane stylesheets="@../css/corda.css" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="5" left="5" right="5" top="5" />
|
<Insets bottom="5" left="5" right="5" top="5" />
|
||||||
</padding>
|
</padding>
|
||||||
<TitledPane fx:id="flowNamePane" collapsible="false" text="Flow name" GridPane.columnSpan="2" GridPane.fillWidth="true" GridPane.rowIndex="0">
|
<TitledPane fx:id="flowNamePane" collapsible="false" text="Flow name" GridPane.columnSpan="2" GridPane.fillWidth="true" GridPane.rowIndex="0">
|
||||||
|
<!--TODO text styling-->
|
||||||
<Label fx:id="flowNameLabel"/>
|
<Label fx:id="flowNameLabel"/>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
<TitledPane fx:id="flowInitiatorPane" collapsible="false" maxHeight="Infinity" text="Flow initiator"
|
<TitledPane fx:id="flowInitiatorPane" collapsible="false" maxHeight="Infinity" text="Flow initiator"
|
||||||
GridPane.columnIndex="0" GridPane.fillWidth="true" GridPane.rowIndex="1">
|
GridPane.columnIndex="0" GridPane.fillWidth="true" GridPane.rowIndex="1">
|
||||||
<!-- todo add gridpane - from code! -->
|
<GridPane fx:id="flowInitiatorGrid" vgap="10.0" hgap="10.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="10.0" top="10.0" />
|
||||||
|
</padding>
|
||||||
|
<!--TODO text styling-->
|
||||||
|
<Label fx:id="flowInitiatorTitle" GridPane.columnSpan="2" GridPane.rowIndex="0" GridPane.columnIndex="1" GridPane.halignment="LEFT"/>
|
||||||
|
</GridPane>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
<TitledPane fx:id="flowResultPane" collapsible="false" maxHeight="Infinity" text="Result" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
<TitledPane fx:id="flowResultPane" collapsible="false" maxHeight="Infinity" text="Result" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
<!-- todo add vbox - from code! -->
|
<VBox fx:id="flowResultVBox" spacing="10.0">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5" left="5" right="5" top="5"/>
|
||||||
|
</padding>
|
||||||
|
</VBox>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
<TitledPane fx:id="flowProgressPane" collapsible="false" maxWidth="Infinity" text="Progress steps" GridPane.columnSpan="2" GridPane.rowIndex="2">
|
<TitledPane fx:id="flowProgressPane" collapsible="false" maxWidth="Infinity" text="Progress steps" GridPane.columnSpan="2" GridPane.rowIndex="2">
|
||||||
|
<!--TODO add progress graph-->
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints minWidth="450.0"/>
|
<ColumnConstraints minWidth="450.0"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user