mirror of
https://github.com/corda/corda.git
synced 2024-12-25 15:41:10 +00:00
ENT-1240: Only add IOUView when applicable. (#189)
This commit is contained in:
parent
a5ca027d54
commit
4aa2a8ea18
@ -65,10 +65,21 @@ class Main : App(MainView::class) {
|
||||
if (!isLoggedIn) {
|
||||
stage.hide()
|
||||
loginView.login()
|
||||
addOptionalViews()
|
||||
(find(primaryView) as MainView).initializeControls()
|
||||
stage.show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun addOptionalViews() {
|
||||
val iouView = find<IOUViewer>()
|
||||
Models.get<CordaViewModel>(Main::class).apply {
|
||||
if (iouView.isEnabledForNode()) {
|
||||
registerView(iouView)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun asInteger(s: String?): Int? {
|
||||
try {
|
||||
return s?.toInt()
|
||||
@ -105,7 +116,6 @@ class Main : App(MainView::class) {
|
||||
registerView<StateMachineViewer>()
|
||||
// CordApps Views.
|
||||
registerView<CashViewer>()
|
||||
registerView<IOUViewer>()
|
||||
// Tools.
|
||||
registerView<Network>()
|
||||
registerView<Settings>()
|
||||
|
@ -11,9 +11,13 @@ class CordaViewModel {
|
||||
val registeredViews = mutableListOf<CordaView>().observable()
|
||||
|
||||
inline fun <reified T> registerView() where T : CordaView {
|
||||
registerView(find<T>())
|
||||
}
|
||||
|
||||
fun registerView(view: CordaView) {
|
||||
// Note: this is weirdly very important, as it forces the initialisation of Views. Therefore this is the entry
|
||||
// point to the top level observable/stream wiring! Any events sent before this init may be lost!
|
||||
registeredViews.add(find<T>().apply { root })
|
||||
registeredViews.add(view.apply { root })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class MainView : View(WINDOW_TITLE) {
|
||||
private val menuItemArrowCSS = "sidebar-menu-item-arrow"
|
||||
private val menuItemSelectedCSS = "$menuItemCSS-selected"
|
||||
|
||||
init {
|
||||
fun initializeControls() {
|
||||
// Header
|
||||
userButton.textProperty().bind(myIdentity.map { it?.let { PartyNameFormatter.short.format(it.name) } })
|
||||
exit.setOnAction {
|
||||
|
@ -4,7 +4,9 @@ import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon
|
||||
import de.jensd.fx.glyphs.fontawesome.FontAwesomeIconView
|
||||
import javafx.scene.input.MouseButton
|
||||
import javafx.scene.layout.BorderPane
|
||||
import net.corda.core.utilities.Try
|
||||
import net.corda.explorer.model.CordaView
|
||||
import net.corda.explorer.model.MembershipListModel
|
||||
import tornadofx.*
|
||||
|
||||
class IOUViewer : CordaView("IOU") {
|
||||
@ -24,4 +26,10 @@ class IOUViewer : CordaView("IOU") {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun isEnabledForNode(): Boolean = Try.on {
|
||||
// Assuming if the model can be initialized - the CorDapp is installed
|
||||
val allParties = MembershipListModel().allParties
|
||||
allParties[0]
|
||||
}.isSuccess
|
||||
}
|
Loading…
Reference in New Issue
Block a user