diff options
Diffstat (limited to 'src/com.example.portfolio2/com/example/portfolio2/Controller.java')
-rw-r--r-- | src/com.example.portfolio2/com/example/portfolio2/Controller.java | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/com.example.portfolio2/com/example/portfolio2/Controller.java b/src/com.example.portfolio2/com/example/portfolio2/Controller.java index 7dafe72..cf98c3c 100644 --- a/src/com.example.portfolio2/com/example/portfolio2/Controller.java +++ b/src/com.example.portfolio2/com/example/portfolio2/Controller.java @@ -13,24 +13,41 @@ import java.util.List; class Controller{ private Model model; - private HelloApplication view; // We do this without using the view directly like this, instead passing options. - void initialize() { // calls on the database + + // We do this without using the view directly like this, instead passing options. + private HelloApplication view; + + // calls on the database + void initialize() { model.initialize(); } + Controller(Model model, HelloApplication view){ this.model=model; this.view=view; } + void onComboSelected(ComboBox<String> combo, ComboBox<String> select, TextArea area) { - select.getItems().clear(); // Clear the activity selection box + + // Clear the activity selection box + select.getItems().clear(); area.clear(); // Clear text area - select.getItems().addAll(model.selectProgram((String) combo.getValue())); // Fill activity box using model method + + // Fill activity box using model method + select.getItems().addAll(model.selectProgram((String) combo.getValue())); } + void onActivitySelected(ComboBox<String> combo, ComboBox<String> select, TextArea area) { - addActivity((String) select.getValue(), area); // Passes the value chosen in the box - updateArea(combo, area); // Updates the text area based on the category choice + + // Passes the value chosen in the box + addActivity((String) select.getValue(), area); + + // Updates the text area based on the category choice // users can choose from the ComboBox, string (activity) and the area would update. + updateArea(combo, area); } + 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 for (String sub : subjectModules) { if (sub.equals(subject1.getValue())) { @@ -40,18 +57,25 @@ class Controller{ } } } - void addActivity(String s, TextArea textArea) { // Calls on model method to add participation in the database + + // Calls on model method to add participation in the database + void addActivity(String s, TextArea textArea) { model.addParticipation(model.getActivityIndeks(s)); } - void updateArea(ComboBox combo, TextArea textArea) { // Clears the text area and adds all activity names from activities in participation + + // Clears the text area and adds all activity names from activities in participation + void updateArea(ComboBox combo, TextArea textArea) { textArea.clear(); for(String s : model.getParticipation((String) combo.getValue())) { textArea.appendText(s + "\n"); } } - void updateEcts(Label ectslabel, ComboBox<String> comboBox) { // Updates the labels with the current ECTS of the program type + + // Updates the labels with the current ECTS of the program type + void updateEcts(Label ectslabel, ComboBox<String> comboBox) { ectslabel.setText("ECTS: "+model.getSumEcts(comboBox.getValue())); } + void fillElective(ComboBox<String> electiveBox) { electiveBox.getItems().addAll(model.getAllActivities()); } |