aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Controller.java20
-rw-r--r--src/com.example.portfolio2/com/example/portfolio2/Window.java41
2 files changed, 38 insertions, 23 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/Controller.java b/src/com.example.portfolio2/com/example/portfolio2/Controller.java
index 66519ae..3354dcd 100644
--- a/src/com.example.portfolio2/com/example/portfolio2/Controller.java
+++ b/src/com.example.portfolio2/com/example/portfolio2/Controller.java
@@ -42,23 +42,15 @@ class Controller {
/// callback when category has been selected
///
+ /// @param section section the category is tied to
/// @param category selected category
- /// @param select activity selection object
- /// @param area activity listing object
+ // TODO: require a UI instead
void onCategorySelected(
- final String category,
- final ComboBox<String> select,
- final TextArea area
+ final GUI.Section section,
+ final String category
) {
-
- // clear the activity selection box
- select.getItems().clear();
-
- // clear text area
- area.clear();
-
- // fill activity box from data in store
- select.getItems().addAll(store.selectProgram(category));
+ view.clearSelections(section);
+ view.setOptions(section,store.selectProgram(category));
}
/// callback when activity has been selected
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<String> 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();
+ }
}