diff options
author | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 19:16:17 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2025-04-28 19:16:17 +0200 |
commit | 34e38a3e79a21f78ec18d228a881505131af49f0 (patch) | |
tree | 951f4735b00ff39827a0eeb2da03eb2ad8a564b4 /src/com.example.portfolio2/com/example/portfolio2/Controller.java | |
parent | b3627749041ce2ace1fc34d7b1c225feb46ae9bf (diff) |
add and improve javadoc
Diffstat (limited to 'src/com.example.portfolio2/com/example/portfolio2/Controller.java')
-rw-r--r-- | src/com.example.portfolio2/com/example/portfolio2/Controller.java | 55 |
1 files changed, 45 insertions, 10 deletions
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<String> combo, ComboBox<String> 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<String> combo, ComboBox<String> 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<String> subject1, ComboBox<String> subject2, List<String> 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<String> 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<String> comboBox) { ectslabel.setText("ECTS: "+model.getSumEcts(comboBox.getValue())); } |