Added AccountsTreeView
This commit is contained in:
parent
5d6a067601
commit
10916d4fba
|
@ -1,7 +1,9 @@
|
||||||
package net.dankito.banking.javafx.dialogs.mainwindow
|
package net.dankito.banking.javafx.dialogs.mainwindow
|
||||||
|
|
||||||
|
import javafx.scene.control.SplitPane
|
||||||
import net.dankito.banking.fints4javaBankingClientCreator
|
import net.dankito.banking.fints4javaBankingClientCreator
|
||||||
import net.dankito.banking.ui.javafx.RouterJavaFx
|
import net.dankito.banking.ui.javafx.RouterJavaFx
|
||||||
|
import net.dankito.banking.ui.javafx.controls.AccountTransactionsView
|
||||||
import net.dankito.banking.ui.javafx.controls.AccountsView
|
import net.dankito.banking.ui.javafx.controls.AccountsView
|
||||||
import net.dankito.banking.ui.javafx.dialogs.mainwindow.controls.MainMenuBar
|
import net.dankito.banking.ui.javafx.dialogs.mainwindow.controls.MainMenuBar
|
||||||
import net.dankito.banking.ui.javafx.util.Base64ServiceJava8
|
import net.dankito.banking.ui.javafx.util.Base64ServiceJava8
|
||||||
|
@ -15,9 +17,6 @@ class MainWindow : View(messages["application.title"]) {
|
||||||
private val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), Base64ServiceJava8(), RouterJavaFx())
|
private val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), Base64ServiceJava8(), RouterJavaFx())
|
||||||
|
|
||||||
|
|
||||||
private var accountsView = AccountsView(presenter)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override val root = borderpane {
|
override val root = borderpane {
|
||||||
prefHeight = 620.0
|
prefHeight = 620.0
|
||||||
|
@ -27,9 +26,13 @@ class MainWindow : View(messages["application.title"]) {
|
||||||
|
|
||||||
center {
|
center {
|
||||||
splitpane {
|
splitpane {
|
||||||
|
add(AccountsView(presenter).apply {
|
||||||
|
SplitPane.setResizableWithParent(this.root, false)
|
||||||
|
})
|
||||||
|
|
||||||
|
add(AccountTransactionsView(presenter))
|
||||||
|
|
||||||
setDividerPosition(0, 0.2)
|
setDividerPosition(0, 0.2)
|
||||||
|
|
||||||
add(accountsView)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ main.window.menu.file.new.account=Account
|
||||||
main.window.menu.file.quit=Quit
|
main.window.menu.file.quit=Quit
|
||||||
|
|
||||||
|
|
||||||
|
accounts.view.all.accounts=All accounts
|
||||||
accounts.view.context.menu.info=Info
|
accounts.view.context.menu.info=Info
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ main.window.menu.file.new.account=Konto
|
||||||
main.window.menu.file.quit=Beenden
|
main.window.menu.file.quit=Beenden
|
||||||
|
|
||||||
|
|
||||||
|
accounts.view.all.accounts=Alle Konten
|
||||||
accounts.view.context.menu.info=Info
|
accounts.view.context.menu.info=Info
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package net.dankito.banking.ui.javafx.controls
|
||||||
|
|
||||||
|
import javafx.collections.ObservableList
|
||||||
|
import javafx.scene.control.TreeView
|
||||||
|
import net.dankito.banking.ui.javafx.model.AccountsRootTreeItem
|
||||||
|
import net.dankito.banking.ui.model.Account
|
||||||
|
|
||||||
|
|
||||||
|
open class AccountsTreeView(accounts: ObservableList<Account>) : TreeView<String>(AccountsRootTreeItem(accounts))
|
|
@ -1,6 +1,9 @@
|
||||||
package net.dankito.banking.ui.javafx.controls
|
package net.dankito.banking.ui.javafx.controls
|
||||||
|
|
||||||
|
import javafx.collections.FXCollections
|
||||||
import javafx.geometry.Pos
|
import javafx.geometry.Pos
|
||||||
|
import javafx.scene.control.TreeItem
|
||||||
|
import javafx.scene.layout.Priority
|
||||||
import net.dankito.banking.ui.presenter.MainWindowPresenter
|
import net.dankito.banking.ui.presenter.MainWindowPresenter
|
||||||
import net.dankito.utils.javafx.ui.controls.addButton
|
import net.dankito.utils.javafx.ui.controls.addButton
|
||||||
import net.dankito.utils.javafx.ui.extensions.fixedHeight
|
import net.dankito.utils.javafx.ui.extensions.fixedHeight
|
||||||
|
@ -10,6 +13,15 @@ import tornadofx.*
|
||||||
|
|
||||||
open class AccountsView(protected val presenter: MainWindowPresenter) : View() {
|
open class AccountsView(protected val presenter: MainWindowPresenter) : View() {
|
||||||
|
|
||||||
|
protected val accounts = FXCollections.observableArrayList(presenter.accounts)
|
||||||
|
|
||||||
|
|
||||||
|
init {
|
||||||
|
presenter.addAccountAddedListener {
|
||||||
|
accounts.setAll(presenter.accounts)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override val root = vbox {
|
override val root = vbox {
|
||||||
borderpane {
|
borderpane {
|
||||||
|
@ -35,9 +47,18 @@ open class AccountsView(protected val presenter: MainWindowPresenter) : View() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add(AccountsTreeView(accounts).apply {
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, newValue -> selectedAccountChanged(newValue) }
|
||||||
|
|
||||||
|
vboxConstraints {
|
||||||
|
vGrow = Priority.ALWAYS
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showAddAccountDialog() {
|
|
||||||
|
protected open fun showAddAccountDialog() {
|
||||||
presenter.showAddAccountDialog()
|
presenter.showAddAccountDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package net.dankito.banking.ui.javafx.model
|
||||||
|
|
||||||
|
import net.dankito.banking.ui.model.Account
|
||||||
|
|
||||||
|
|
||||||
|
open class AccountsAccountTreeItem(account: Account) : AccountsTreeItemBase(account.displayName) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
isExpanded = true
|
||||||
|
|
||||||
|
account.bankAccounts.forEach { bankAccount ->
|
||||||
|
children.add(AccountsBankAccountTreeItem(bankAccount))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package net.dankito.banking.ui.javafx.model
|
||||||
|
|
||||||
|
import net.dankito.banking.ui.model.BankAccount
|
||||||
|
|
||||||
|
|
||||||
|
open class AccountsBankAccountTreeItem(bankAccount: BankAccount) : AccountsTreeItemBase(bankAccount.displayName)
|
|
@ -0,0 +1,27 @@
|
||||||
|
package net.dankito.banking.ui.javafx.model
|
||||||
|
|
||||||
|
import javafx.collections.ListChangeListener
|
||||||
|
import javafx.collections.ObservableList
|
||||||
|
import net.dankito.banking.ui.model.Account
|
||||||
|
import tornadofx.FX.Companion.messages
|
||||||
|
import tornadofx.get
|
||||||
|
import tornadofx.runLater
|
||||||
|
|
||||||
|
|
||||||
|
open class AccountsRootTreeItem(accounts: ObservableList<Account>) : AccountsTreeItemBase(messages["accounts.view.all.accounts"]) {
|
||||||
|
|
||||||
|
init {
|
||||||
|
setAccounts(accounts)
|
||||||
|
|
||||||
|
accounts.addListener(ListChangeListener<Account> { c ->
|
||||||
|
runLater { setAccounts(accounts) }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun setAccounts(accounts: List<Account>) {
|
||||||
|
isExpanded = accounts.isNotEmpty()
|
||||||
|
|
||||||
|
children.setAll(accounts.map { AccountsAccountTreeItem(it) })
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package net.dankito.banking.ui.javafx.model
|
||||||
|
|
||||||
|
import javafx.scene.control.TreeItem
|
||||||
|
|
||||||
|
|
||||||
|
abstract class AccountsTreeItemBase(description: String) : TreeItem<String>(description)
|
Loading…
Reference in New Issue