From fb70a4176d14437a85c43c6e58bd31743cc16370 Mon Sep 17 00:00:00 2001 From: dankl Date: Wed, 8 Jan 2020 20:33:44 +0100 Subject: [PATCH] Started MainWindow --- .../ui/javafx/BankingJavaFXApplication.kt | 23 ++++++++++++ .../javafx/dialogs/mainwindow/MainWindow.kt | 27 ++++++++++++++ .../mainwindow/controls/MainMenuBar.kt | 24 +++++++++++++ .../src/main/resources/Messages.properties | 4 +++ .../src/main/resources/Messages_de.properties | 4 +++ .../src/main/resources/logback.xml | 36 +++++++++++++++++++ .../dankito/banking/ui/javafx/RouterJavaFx.kt | 26 ++++++++++++++ .../ui/javafx/util/Base64ServiceJava8.kt | 21 +++++++++++ 8 files changed, 165 insertions(+) create mode 100755 BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/BankingJavaFXApplication.kt create mode 100755 BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt create mode 100644 BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt create mode 100755 BankingJavaFxApp/src/main/resources/Messages.properties create mode 100755 BankingJavaFxApp/src/main/resources/Messages_de.properties create mode 100755 BankingJavaFxApp/src/main/resources/logback.xml create mode 100644 BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/RouterJavaFx.kt create mode 100644 BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/util/Base64ServiceJava8.kt diff --git a/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/BankingJavaFXApplication.kt b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/BankingJavaFXApplication.kt new file mode 100755 index 00000000..fb5fe538 --- /dev/null +++ b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/BankingJavaFXApplication.kt @@ -0,0 +1,23 @@ +package net.dankito.banking.ui.javafx + +import javafx.application.Application +import net.dankito.banking.javafx.dialogs.mainwindow.MainWindow +import net.dankito.utils.javafx.ui.Utf8App + + +open class BankingJavaFXApplication : Utf8App("Messages", MainWindow::class) { + + + @Throws(Exception::class) + override fun stop() { + super.stop() + System.exit(0) // otherwise Window would be closed but application still running in background + } + +} + + + +fun main(args: Array) { + Application.launch(BankingJavaFXApplication::class.java, *args) +} \ No newline at end of file diff --git a/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt new file mode 100755 index 00000000..bf3cd7f6 --- /dev/null +++ b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/MainWindow.kt @@ -0,0 +1,27 @@ +package net.dankito.banking.javafx.dialogs.mainwindow + +import net.dankito.banking.fints4javaBankingClientCreator +import net.dankito.banking.ui.javafx.RouterJavaFx +import net.dankito.banking.ui.javafx.dialogs.mainwindow.controls.MainMenuBar +import net.dankito.banking.ui.javafx.util.Base64ServiceJava8 +import net.dankito.banking.ui.presenter.MainWindowPresenter +import tornadofx.FX.Companion.messages +import tornadofx.View +import tornadofx.borderpane +import tornadofx.get + + +class MainWindow : View(messages["main.window.title"]) { + + private val presenter = MainWindowPresenter(fints4javaBankingClientCreator(), Base64ServiceJava8(), RouterJavaFx()) + + + + override val root = borderpane { + prefHeight = 620.0 + prefWidth = 1150.0 + + top = MainMenuBar().root + } + +} \ No newline at end of file diff --git a/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt new file mode 100644 index 00000000..53200fb8 --- /dev/null +++ b/BankingJavaFxApp/src/main/kotlin/net/dankito/banking/ui/javafx/dialogs/mainwindow/controls/MainMenuBar.kt @@ -0,0 +1,24 @@ +package net.dankito.banking.ui.javafx.dialogs.mainwindow.controls + +import javafx.scene.input.KeyCode +import javafx.scene.input.KeyCodeCombination +import javafx.scene.input.KeyCombination +import tornadofx.* + + +open class MainMenuBar : View() { + + override val root = + menubar { + minHeight = 30.0 + maxHeight = 30.0 + + menu(messages["main.window.menu.file"]) { + + item(messages["main.window.menu.file.quit"], KeyCodeCombination(KeyCode.Q, KeyCombination.SHORTCUT_DOWN)) { + action { primaryStage.close() } + } + } + } + +} \ No newline at end of file diff --git a/BankingJavaFxApp/src/main/resources/Messages.properties b/BankingJavaFxApp/src/main/resources/Messages.properties new file mode 100755 index 00000000..0b9f02dc --- /dev/null +++ b/BankingJavaFxApp/src/main/resources/Messages.properties @@ -0,0 +1,4 @@ +main.window.title=Banking + +main.window.menu.file=File +main.window.menu.file.quit=Quit \ No newline at end of file diff --git a/BankingJavaFxApp/src/main/resources/Messages_de.properties b/BankingJavaFxApp/src/main/resources/Messages_de.properties new file mode 100755 index 00000000..ed4c040c --- /dev/null +++ b/BankingJavaFxApp/src/main/resources/Messages_de.properties @@ -0,0 +1,4 @@ +main.window.title=Banking + +main.window.menu.file=Datei +main.window.menu.file.quit=Beenden \ No newline at end of file diff --git a/BankingJavaFxApp/src/main/resources/logback.xml b/BankingJavaFxApp/src/main/resources/logback.xml new file mode 100755 index 00000000..4d692917 --- /dev/null +++ b/BankingJavaFxApp/src/main/resources/logback.xml @@ -0,0 +1,36 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + DEBUG + + + + + + + + + data/logs/Banking-${bySecond}.log + + + %-4relative [%thread] %-5level %logger{35} - %msg%n + + + + DEBUG + + + + + + + + \ No newline at end of file diff --git a/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/RouterJavaFx.kt b/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/RouterJavaFx.kt new file mode 100644 index 00000000..97afce95 --- /dev/null +++ b/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/RouterJavaFx.kt @@ -0,0 +1,26 @@ +package net.dankito.banking.ui.javafx + +import net.dankito.banking.ui.IRouter +import net.dankito.banking.ui.model.Account +import net.dankito.banking.ui.model.tan.EnterTanGeneratorAtcResult +import net.dankito.banking.ui.model.tan.EnterTanResult +import net.dankito.banking.ui.model.tan.TanChallenge +import net.dankito.banking.ui.model.tan.TanGeneratorTanMedium +import net.dankito.banking.ui.presenter.MainWindowPresenter + + +open class RouterJavaFx : IRouter { + + override fun showAddAccountDialog(presenter: MainWindowPresenter) { + + } + + override fun getTanFromUserFromNonUiThread(account: Account, tanChallenge: TanChallenge, presenter: MainWindowPresenter): EnterTanResult { + return EnterTanResult.userDidNotEnterTan() + } + + override fun getAtcFromUserFromNonUiThread(tanMedium: TanGeneratorTanMedium): EnterTanGeneratorAtcResult { + return EnterTanGeneratorAtcResult.userDidNotEnterTan() + } + +} \ No newline at end of file diff --git a/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/util/Base64ServiceJava8.kt b/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/util/Base64ServiceJava8.kt new file mode 100644 index 00000000..78b39896 --- /dev/null +++ b/BankingJavaFxControls/src/main/kotlin/net/dankito/banking/ui/javafx/util/Base64ServiceJava8.kt @@ -0,0 +1,21 @@ +package net.dankito.banking.ui.javafx.util + +import net.dankito.banking.util.IBase64Service +import java.nio.charset.Charset +import java.util.* + + +// TODO: use version from JavaFxUtils +open class Base64ServiceJava8 : IBase64Service { + + override fun encode(text: String, charset: Charset): String { + return Base64.getEncoder().encodeToString(text.toByteArray(charset)) + } + + override fun decode(base64: String, charset: Charset): String { + val decodedBytes = Base64.getDecoder().decode(base64) + + return String(decodedBytes, charset) + } + +} \ No newline at end of file