From b83bd2cfad4d028bcc9c7918f63c8004de19ae9f Mon Sep 17 00:00:00 2001 From: Annika Holmqvist Date: Wed, 29 Oct 2025 11:50:29 +0100 Subject: [PATCH 01/18] Add chat functionality, UI enhancements, and first update controller logic --- mvnw | 0 .../java/com/example/HelloController.java | 35 +++- src/main/java/com/example/HelloModel.java | 192 ++++++++++++++++++ .../resources/com/example/hello-view.fxml | 45 +++- 4 files changed, 259 insertions(+), 13 deletions(-) mode change 100644 => 100755 mvnw diff --git a/mvnw b/mvnw old mode 100644 new mode 100755 diff --git a/src/main/java/com/example/HelloController.java b/src/main/java/com/example/HelloController.java index fdd160a0..6ee23949 100644 --- a/src/main/java/com/example/HelloController.java +++ b/src/main/java/com/example/HelloController.java @@ -1,7 +1,11 @@ package com.example; + +import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.Label; +import javafx.scene.control.Button; +import javafx.scene.control.ListView; +import javafx.scene.control.TextField; /** * Controller layer: mediates between the view (FXML) and the model. @@ -11,12 +15,33 @@ public class HelloController { private final HelloModel model = new HelloModel(); @FXML - private Label messageLabel; + public TextField messageInput; + @FXML + public Button sendButton; + @FXML + public Button attachButton; + @FXML + public TextField nameInput; + + + + @FXML + public ListView chatListView; @FXML private void initialize() { - if (messageLabel != null) { - messageLabel.setText(model.getGreeting()); - } + + ObservableList history = model.getChatHistory(); + + chatListView.setItems(history); + + } + + @FXML + public void handleSendButton() { + String messageText= messageInput.getText(); + String senderName=nameInput.getText(); + + } } diff --git a/src/main/java/com/example/HelloModel.java b/src/main/java/com/example/HelloModel.java index 385cfd10..f786c541 100644 --- a/src/main/java/com/example/HelloModel.java +++ b/src/main/java/com/example/HelloModel.java @@ -1,5 +1,16 @@ package com.example; +import javafx.beans.InvalidationListener; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + /** * Model layer: encapsulates application data and business logic. */ @@ -12,4 +23,185 @@ public String getGreeting() { String javafxVersion = System.getProperty("javafx.version"); return "Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."; } + + + + public record ChatEntry( + String sender, + String message, + LocalDate timeStamp){} + + + private static final DateTimeFormatter TIME_FORMATTER=DateTimeFormatter.ofPattern("HH:mm"); + + public ObservableList getChatHistory() { + } + + ObservableList chatHistory=new ObservableList() { + @Override + public void addListener(ListChangeListener listChangeListener) { + + } + + @Override + public void removeListener(ListChangeListener listChangeListener) { + + } + + @Override + public boolean addAll(String... strings) { + return false; + } + + @Override + public boolean setAll(String... strings) { + return false; + } + + @Override + public boolean setAll(Collection collection) { + return false; + } + + @Override + public boolean removeAll(String... strings) { + return false; + } + + @Override + public boolean retainAll(String... strings) { + return false; + } + + @Override + public void remove(int i, int i1) { + + } + + @Override + public int size() { + return 0; + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public boolean contains(Object o) { + return false; + } + + @Override + public Iterator iterator() { + return null; + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(T[] a) { + return null; + } + + @Override + public boolean add(String s) { + return false; + } + + @Override + public boolean remove(Object o) { + return false; + } + + @Override + public boolean containsAll(Collection c) { + return false; + } + + @Override + public boolean addAll(Collection c) { + return false; + } + + @Override + public boolean addAll(int index, Collection c) { + return false; + } + + @Override + public boolean removeAll(Collection c) { + return false; + } + + @Override + public boolean retainAll(Collection c) { + return false; + } + + @Override + public void clear() { + + } + + @Override + public String get(int index) { + return ""; + } + + @Override + public String set(int index, String element) { + return ""; + } + + @Override + public void add(int index, String element) { + + } + + @Override + public String remove(int index) { + return ""; + } + + @Override + public int indexOf(Object o) { + return 0; + } + + @Override + public int lastIndexOf(Object o) { + return 0; + } + + @Override + public ListIterator listIterator() { + return null; + } + + @Override + public ListIterator listIterator(int index) { + return null; + } + + @Override + public List subList(int fromIndex, int toIndex) { + return List.of(); + } + + @Override + public void addListener(InvalidationListener invalidationListener) { + + } + + @Override + public void removeListener(InvalidationListener invalidationListener) { + + } + } + } diff --git a/src/main/resources/com/example/hello-view.fxml b/src/main/resources/com/example/hello-view.fxml index 20a7dc82..95455f15 100644 --- a/src/main/resources/com/example/hello-view.fxml +++ b/src/main/resources/com/example/hello-view.fxml @@ -1,9 +1,38 @@ - - - - - - - + + + + + +
+ + +
+ + + + + + + + +