From 34e38a3e79a21f78ec18d228a881505131af49f0 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Mon, 28 Apr 2025 19:16:17 +0200 Subject: add and improve javadoc --- .../com/example/portfolio2/Controller.java | 55 ++++++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) (limited to 'src/com.example.portfolio2/com/example/portfolio2/Controller.java') diff --git a/src/com.example.portfolio2/com/example/portfolio2/Controller.java b/src/com.example.portfolio2/com/example/portfolio2/Controller.java index 031b6cc..f38a3ca 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Controller.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Controller.java @@ -11,41 +11,66 @@ import javafx.scene.control.TextArea; import java.util.List; +/// Bachelorizer - Controller class Controller{ + + /// Application model private Model model; - // We do this without using the view directly like this, instead passing options. + /// Application view private HelloApplication view; - // calls on the database + /// clear the participation database at program launch void initialize() { model.initialize(); } + /// default constructor + /// + /// @param model Application model + /// @param view Application view Controller(Model model, HelloApplication view){ this.model=model; this.view=view; } + /// callback when category box is selected + /// + /// @param combo involved activity box + /// @param select selected item + /// @param area whole text area void onComboSelected(ComboBox combo, ComboBox select, TextArea area) { - // Clear the activity selection box + // clear the activity selection box select.getItems().clear(); - area.clear(); // Clear text area - // Fill activity box using model method + // clear text area + area.clear(); + + // fill activity box using model method select.getItems().addAll(model.selectProgram(combo.getValue())); } + /// callback when activity box is selected + /// + /// @param combo involved activity box + /// @param select selected item + /// @param area whole text area void onActivitySelected(ComboBox combo, ComboBox select, TextArea area) { - // Passes the value chosen in the box + // pass the value chosen in the box addActivity(select.getValue(), area); - // Updates the text area based on the category choice + // update text area based on category choice + // // users can choose from the ComboBox, string (activity) and the area would update. updateArea(combo, area); } + /// callback when subject module box is selected + /// + /// @param subject1 involved 1st column subject module box + /// @param subject2 involved 2nd column subject module box + /// @param subjectModules list of selected subject modules void onSubjectModuleSelected(ComboBox subject1, ComboBox subject2, List subjectModules) { // Beautiful loop we've created to remove option chosen in one subject module box from the other @@ -58,12 +83,20 @@ class Controller{ } } - // Calls on model method to add participation in the database + /// add participation to database + /// @param s activity identifier + /// @param textArea whole text area void addActivity(String s, TextArea textArea) { model.addParticipation(model.getActivityIndeks(s)); } - // Clears the text area and adds all activity names from activities in participation + /// update text area for an activity box + /// + /// Clears the text area + /// and adds all activity names from activities in participation. + /// + /// @param combo involved activity box + /// @param textArea whole text area void updateArea(ComboBox combo, TextArea textArea) { textArea.clear(); for(String s : model.getParticipation(combo.getValue())) { @@ -71,7 +104,9 @@ class Controller{ } } - // Updates the labels with the current ECTS of the program type + /// update label with current ECTS of program type + /// @param ectslabel text display area for ECTS points + /// @param comboBox involved activity box void updateEcts(Label ectslabel, ComboBox comboBox) { ectslabel.setText("ECTS: "+model.getSumEcts(comboBox.getValue())); } -- cgit v1.2.3