From e4d4db9fb9605b548007218d2195c061b9a09ecc Mon Sep 17 00:00:00 2001
From: Abhay Menon <abhay.menon@uwaterloo.ca>
Date: Thu, 16 Feb 2023 14:29:21 -0500
Subject: [PATCH] Updated branch to display basic GUI

---
 console/build.gradle                          |  8 +++++
 .../kotlin/notes/multi/console/Console.kt     | 18 +++++++++---
 .../notes/multi/utilities/NoteTextWindow.kt   | 29 ++++++++++++++-----
 3 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/console/build.gradle b/console/build.gradle
index 127f593..c32e5df 100644
--- a/console/build.gradle
+++ b/console/build.gradle
@@ -4,6 +4,14 @@
 
 plugins {
     id 'notes.multi.kotlin-application-conventions'
+    id 'application'
+    id 'org.jetbrains.kotlin.jvm'
+    id 'org.openjfx.javafxplugin' version '0.0.13'
+}
+
+javafx {
+    version = '18.0.2'
+    modules = ['javafx.controls', 'javafx.graphics']
 }
 
 dependencies {
diff --git a/console/src/main/kotlin/notes/multi/console/Console.kt b/console/src/main/kotlin/notes/multi/console/Console.kt
index 7db3c27..9ae4ea5 100644
--- a/console/src/main/kotlin/notes/multi/console/Console.kt
+++ b/console/src/main/kotlin/notes/multi/console/Console.kt
@@ -5,10 +5,20 @@ package notes.multi.console
 
 import notes.multi.utilities.Filemanager
 
+import notes.multi.utilities.Note
+import notes.multi.utilities.TextWindow
+import javafx.application.Application
+
 fun main() {
     // thesea re test functions feel free to use
-    val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt")
-    f.writefile("hello world")
-    f.deletefile()
-    println(f.openfile())
+    val n = Note()
+    val noteTitle = n.title
+    val noteContent = n.text.toString()
+    println(noteContent)
+    Application.launch(TextWindow()::class.java, "--title=${noteTitle}", "--text=${noteContent}")
+
+    // val f = Filemanager("${System.getProperty("user.dir")}/test/", "hello.txt")
+    // f.writefile("hello world")
+    // f.deletefile()
+    // println(f.openfile())
 }
diff --git a/utilities/src/main/kotlin/notes/multi/utilities/NoteTextWindow.kt b/utilities/src/main/kotlin/notes/multi/utilities/NoteTextWindow.kt
index be95fc6..d84e2b0 100644
--- a/utilities/src/main/kotlin/notes/multi/utilities/NoteTextWindow.kt
+++ b/utilities/src/main/kotlin/notes/multi/utilities/NoteTextWindow.kt
@@ -6,20 +6,35 @@ import javafx.scene.Scene
 import javafx.scene.control.ScrollPane
 import javafx.scene.control.TextArea
 import javafx.scene.layout.VBox
+import javafx.application.Application.Parameters
 
-
-class TextWindow(val note: Note): Application() {
+class TextWindow(): Application() {
+    var paramsMap = mutableMapOf<String, String>()
     override fun init() {
         super.init()
+        val params = getParameters()
+        paramsMap = params.getNamed()
     }
-    override fun start(stage: Stage?) {
-        stage?.setTitle(note.title)
+
+    override fun start(stage: Stage) {
+        stage.setTitle(paramsMap["title"])
         val textarea = TextArea()
-        textarea.setText(note.text.toString())
+        textarea.setText(paramsMap["text"])
         textarea.setWrapText(true)
         val scroll = ScrollPane()
+
+        scroll.setFitToHeight(true)
+        scroll.setHmin(300.0)
+        scroll.setFitToWidth(true)
+
+        // REMOVE THESE COMMENTS
+        // println("===========")
+        // println(scroll.isFitToHeight)
+        // println(scroll.isFitToWidth)
+
         scroll.content = textarea
-        stage?.scene = Scene(VBox(scroll), 300.0, 300.0)
-        stage?.show()
+
+        stage.scene = Scene(VBox(scroll), 300.0, 300.0)
+        stage.show()
     }
 }
\ No newline at end of file
-- 
GitLab