Schedule-Creator

Java GUI to create schedules for UNCG students
git clone git://git.wrycode.com/wrycode/archive/Schedule-Creator.git
Log | Files | Refs | README

commit 5c950330db4c02b9d5c8c6031f674f3b8d72c1b1
parent 4ac497758bb2706ac2fdbcc1dc7df30eebd2816a
Author: Ilyass Sfar <42755577+cloud0x9@users.noreply.github.com>
Date:   Mon,  6 Apr 2020 21:22:03 -0400

Add email API button in UI (#54)

* Add API package and interface

* Add API call method and Adapter

* Change which file TIME and DAY use

* Jamison/gui change (#46)

* refactor

* style guide

* refactor

* Add API package and interface

* Add API call method and Adapter

* Change which file TIME and DAY use

* change field in Semester class

* update UI design; remove generateSchedules bug; refactor

* merge sfar branch; add lib package with necessary jar file

* implement CRN pop up box

* implement show CRN pop up

* lib package and jar file

* Improve CRN pop up design (#47)

* refactor

* style guide

* refactor

* Add API package and interface

* Add API call method and Adapter

* Change which file TIME and DAY use

* change field in Semester class

* update UI design; remove generateSchedules bug; refactor

* merge sfar branch; add lib package with necessary jar file

* implement CRN pop up box

* implement show CRN pop up

* lib package and jar file

* improve CRN pop up design

* Completely delete old API, set up email API interface, and add all necessary libraries for the email API.

* Added Email API interface, adapter, and direct call method.
Also added example in test class.

* Added dedicated email for the project

* remove old API

* remove old API

* remove old API

* catch up with master

* Connect Email API to UI

* comments/format

* fix show CRN bug

Co-authored-by: jamisonv93 <47033011+jamisonv93@users.noreply.github.com>
Co-authored-by: Sfar <isfar314@gmail.com>
Co-authored-by: Jamison Valentine <jamisont.valentine@gmail.com>
Diffstat:
MScheduleCreator/Tests.java | 8+++-----
MScheduleCreator/controllers/CoursesController.java | 48++++++++++++++++++++++++++++++++++++------------
AScheduleCreator/controllers/PopupController.java | 36++++++++++++++++++++++++++++++++++++
AScheduleCreator/resources/views/email_popup.fxml | 36++++++++++++++++++++++++++++++++++++
MScheduleCreator/resources/views/select_courses.fxml | 9++++-----
5 files changed, 115 insertions(+), 22 deletions(-)

diff --git a/ScheduleCreator/Tests.java b/ScheduleCreator/Tests.java @@ -5,15 +5,13 @@ package ScheduleCreator; * * @author Nick Econopouly, Ilyass Sfar * - * Last Updated: 3/27/2020 + * Last Updated: 4/6/2020 */ - import ScheduleCreator.API.EmailAdapter; import com.mailjet.client.errors.MailjetException; import com.mailjet.client.errors.MailjetSocketTimeoutException; import java.io.IOException; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; public class Tests { @@ -24,8 +22,8 @@ public class Tests { Admin.regenDB(); // //Test api call, - EmailAdapter testAPI = new EmailAdapter(); - testAPI.SendEmail("isfar314@gmail.com", "Testing Email API Call"); + //EmailAdapter testAPI = new EmailAdapter(); + //testAPI.SendEmail("isfar314@gmail.com", "Testing Email API Call"); } public static void testSemester() throws IOException { diff --git a/ScheduleCreator/controllers/CoursesController.java b/ScheduleCreator/controllers/CoursesController.java @@ -1,5 +1,12 @@ package ScheduleCreator.controllers; +/** + * This class controls interactions in the Courses View. + * + * @author Jamison Valentine, Ilyass Sfar, Nick Econopouly, Nathan Tolodzieki + * + * Last Updated: 4/6/2020 + */ import java.io.IOException; import java.net.URL; import java.util.ArrayList; @@ -20,11 +27,13 @@ import javafx.collections.ObservableList; import javafx.collections.transformation.FilteredList; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.geometry.HPos; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.geometry.VPos; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; @@ -42,14 +51,8 @@ import javafx.scene.layout.Priority; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.scene.shape.Rectangle; +import javafx.stage.Stage; -/** - * This class controls interactions in the Courses View. - * - * @author Jamison Valentine, Ilyass Sfar, Nick Econopouly, Nathan Tolodzieki - * - * Last Updated: 3/31/2020 - */ public class CoursesController implements Initializable { @FXML @@ -243,7 +246,8 @@ public class CoursesController implements Initializable { } /** - * Gets sections for a selected course and adds them to the sections listview. + * Gets sections for a selected course and adds them to the sections + * listview. * * @param _event */ @@ -401,14 +405,15 @@ public class CoursesController implements Initializable { } /** - * If there are no selections, force select all; if there are any selections, - * unselect all of them. + * If there are no selections, force select all; if there are any + * selections, unselect all of them. * * @param _event */ public void selectAll(ActionEvent _event) { - if (this.sectionTabPane.getSelectionModel().getSelectedItem() == null) + if (this.sectionTabPane.getSelectionModel().getSelectedItem() == null) { return; + } int index = this.sectionTabPane.getSelectionModel().getSelectedIndex(); Tab currentTab = this.sectionTabPane.getTabs().get(index); @@ -456,6 +461,7 @@ public class CoursesController implements Initializable { } public void showCRNs(ActionEvent _event) { + if (this.currentSemester == null) return; if (this.currentSemester.getSelectedCourses().size() == 0) return; this.CRNContainer.getChildren().clear(); StringBuilder content = new StringBuilder(); @@ -583,8 +589,9 @@ public class CoursesController implements Initializable { if (!section.isOnline()) { this.addEntry(section, ++numberOfCampusCourses); } else { - if (onlineCourses >= 1) + if (onlineCourses >= 1) { label.append(" | "); + } label.append(section.getID()); onlineCourses++; } @@ -608,4 +615,21 @@ public class CoursesController implements Initializable { this.loadSchedule(this.currentSemester.getSchedules().get(this.currentScheduleIndex)); } } + + //Calls popup fxml for the email api + public void popupAction(ActionEvent event) { + try { + FXMLLoader fxmlLoader = new FXMLLoader(); + fxmlLoader.setLocation(getClass().getResource("/ScheduleCreator/resources/views/email_popup.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 450, 150); + Stage stage = new Stage(); + stage.setTitle("Email Course Information"); + stage.setScene(scene); + stage.show(); + } catch (IOException e) { + Logger logger = Logger.getLogger(getClass().getName()); + logger.log(Level.SEVERE, "Failed to create new Window.", e); + } + } + } diff --git a/ScheduleCreator/controllers/PopupController.java b/ScheduleCreator/controllers/PopupController.java @@ -0,0 +1,36 @@ +package ScheduleCreator.controllers; + +/** + * Controller for email api popup + * + * @author Ilyass Sfar + * + * Last Updated: 4/6/2020 + */ +import ScheduleCreator.API.EmailAdapter; +import com.mailjet.client.errors.MailjetException; +import com.mailjet.client.errors.MailjetSocketTimeoutException; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TextField; +import javafx.stage.Stage; + +public class PopupController { + + @FXML + private TextField emailTF; + + @FXML + private Button sendBtn; + + //Calls email api + @FXML + public void sendEmail(ActionEvent event) throws MailjetException, MailjetSocketTimeoutException { + EmailAdapter testAPI = new EmailAdapter(); + testAPI.SendEmail(emailTF.getText(), "This is a temp UI API test call"); + Stage stage = (Stage) sendBtn.getScene().getWindow(); + stage.close(); + } + +} diff --git a/ScheduleCreator/resources/views/email_popup.fxml b/ScheduleCreator/resources/views/email_popup.fxml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.text.Font?> + +<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ScheduleCreator.controllers.PopupController"> + <children> + <HBox alignment="CENTER" prefHeight="18.0" prefWidth="95.0" style="-fx-background-color: #66ccff;"> + <children> + <Label text="Enter Your Email"> + <font> + <Font size="14.0" /> + </font> + </Label> + </children> + </HBox> + <HBox alignment="CENTER" /> + <HBox alignment="CENTER"> + <children> + <Label prefWidth="70.0" text=" Email :" /> + <Label prefWidth="70.0" /> + <TextField fx:id="emailTF" prefHeight="27.0" prefWidth="237.0" promptText="Enter Your Email Here" /> + </children> + </HBox> + <HBox alignment="CENTER" /> + <Button fx:id="sendBtn" mnemonicParsing="false" onAction="#sendEmail" prefHeight="27.0" prefWidth="378.0" text="Send" /> + </children> + <padding> + <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> + </padding> +</VBox> diff --git a/ScheduleCreator/resources/views/select_courses.fxml b/ScheduleCreator/resources/views/select_courses.fxml @@ -1,9 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<?import java.lang.*?> -<?import javafx.geometry.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> <?import javafx.geometry.Insets?> <?import javafx.scene.control.Button?> <?import javafx.scene.control.ComboBox?> @@ -19,7 +15,7 @@ <?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.VBox?> -<GridPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ScheduleCreator.controllers.CoursesController"> +<GridPane xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ScheduleCreator.controllers.CoursesController"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="2.0" prefWidth="20.0" /> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" /> @@ -146,6 +142,9 @@ </BorderPane.margin> </Button> </center> + <right> + <Button mnemonicParsing="false" onAction="#popupAction" text="Email CRNs" BorderPane.alignment="CENTER" /> + </right> </BorderPane> <BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="1"> <center>