From 19584cfa12e80bd32e686c8da416aaec9aa063b9 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Wed, 30 Apr 2025 13:40:58 +0200 Subject: improve separation of concerns between view and controller --- .../com/example/portfolio2/Window.java | 41 +++++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'src/com.example.portfolio2/com/example/portfolio2/Window.java') diff --git a/src/com.example.portfolio2/com/example/portfolio2/Window.java b/src/com.example.portfolio2/com/example/portfolio2/Window.java index d3e2b06..774b012 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Window.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Window.java @@ -100,9 +100,8 @@ public final class Window extends Application { "HumTek", "NatBach"); col.categoryCombo.setOnAction(event -> { con.onCategorySelected( - col.categoryCombo.getValue(), - col.activitySelect, - col.area); + col.section, + col.categoryCombo.getValue()); }); } // TODO: use the list for filling the box @@ -118,9 +117,8 @@ public final class Window extends Application { GUI.Section.SUBJECT2.column) .categoryCombo); con.onCategorySelected( - col.categoryCombo.getValue(), - col.activitySelect, - col.area); + col.section, + col.categoryCombo.getValue()); }); } case GUI.Section.SUBJECT2 -> { @@ -136,9 +134,8 @@ public final class Window extends Application { GUI.Section.SUBJECT1.column) .categoryCombo); con.onCategorySelected( - col.categoryCombo.getValue(), - col.activitySelect, - col.area); + col.section, + col.categoryCombo.getValue()); }); } case GUI.Section.ELECTIVE -> { @@ -219,4 +216,30 @@ public final class Window extends Application { ectsLabel); } } + + /// populate activities for a category + /// + /// @param section structural section to operate on + /// @param activities activities to apply as string + public void setOptions( + final GUI.Section section, final List activities + ) { + + // clear the activity selection box + columns.get(section.column).activitySelect + .getItems().clear(); + + // fill activity box from data in store + columns.get(section.column).activitySelect + .getItems().addAll(activities); + } + + /// remove selections from a category + /// + /// @param section structural section to operate on + public void clearSelections(final GUI.Section section) { + + // clear text area + columns.get(section.column).area.clear(); + } } -- cgit v1.2.3