Commit f7ce9d42 authored by Josselin ENET's avatar Josselin ENET

Added javadoc

Added javadoc to the classes being part of the UI.
parent 2aa78287
......@@ -14,6 +14,12 @@ public class AdminHomeController extends SceneController {
public AdminHomeController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he connects.
* It displays buttons to access different functionalities, such as user management, travel management
* and travel reservation for an agent.
* @return returns the scene to set the stage with.
*/
public Scene createScene() {
gui.setTitle("Admin Home");
......
......@@ -15,6 +15,12 @@ public class AdminTravelModificationController extends SceneController {
public AdminTravelModificationController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to modify an existing travel.
* It displays a list of travels and a modify button. However we didn't know how to handle the modifications,
* so it's not actually doing anything.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("Travel Modification");
......@@ -88,12 +94,21 @@ public class AdminTravelModificationController extends SceneController {
return result;
}
private void updateComboBox(ComboBox usersComboBox) {
/**
* Updates the content of the list of travels.
* @param travelsComboBox - list of travels to update.
*/
private void updateComboBox(ComboBox travelsComboBox) {
List<Travel> travelsList = gui.getTravelsDB().getAllTravel();
ObservableListImplementation<Travel> travelsObservableList = new ObservableListImplementation<>(travelsList);
usersComboBox.setItems(travelsObservableList);
travelsComboBox.setItems(travelsObservableList);
}
/**
* Modifies a travel with the given values. We didn't know how to implement this, so
* it just shows a window.
* @param travel - travel to modify.
*/
public void handleModify(Travel travel) {
AlertHandler.showAlert(INFORMATION, "To do.");
}
......
......@@ -15,6 +15,11 @@ public class AdminTravelRemovalController extends SceneController {
public AdminTravelRemovalController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to remove a travel.
* It displays a list of travels as well as a remove button.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("Travel Removal");
......@@ -88,12 +93,20 @@ public class AdminTravelRemovalController extends SceneController {
return result;
}
private void updateComboBox(ComboBox usersComboBox) {
/**
* Updates the content of the list of travels.
* @param travelsComboBox - list of travels to update.
*/
private void updateComboBox(ComboBox travelsComboBox) {
List<Travel> travelsList = gui.getTravelsDB().getAllTravel();
ObservableListImplementation<Travel> travelsObservableList = new ObservableListImplementation<>(travelsList);
usersComboBox.setItems(travelsObservableList);
travelsComboBox.setItems(travelsObservableList);
}
/**
* Removes a travel from the list of existing travels.
* @param travel - travel to remove.
*/
public void handleRemove(Travel travel) {
if (gui.getTravelsDB().removeTravel(travel)) {
AlertHandler.showAlert(INFORMATION, "Travel deleted.");
......
......@@ -18,6 +18,11 @@ public class AdminTravelReservationController extends SceneController {
public AdminTravelReservationController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to book a travel for an agent.
* It displays a list of agents and a list of travels, as well as a reserve button.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("Travel Reservation for Agent");
......@@ -127,18 +132,31 @@ public class AdminTravelReservationController extends SceneController {
return result;
}
/**
* Updates the content of the list of users.
* @param usersComboBox - list of users to update.
*/
private void updateUsersComboBox(ComboBox usersComboBox) {
List<Person> usersList = gui.getUsersDB().getAllAgent();
ObservableListImplementation<Person> travelsObservableList = new ObservableListImplementation<>(usersList);
usersComboBox.setItems(travelsObservableList);
}
/**
* Updates the content of the list of travels.
* @param travelsComboBox - list of travels to update.
*/
private void updateTravelsComboBox(ComboBox travelsComboBox) {
List<Travel> travelsList = gui.getTravelsDB().getAllTravel();
ObservableListImplementation<Travel> travelsObservableList = new ObservableListImplementation<>(travelsList);
travelsComboBox.setItems(travelsObservableList);
}
/**
* Adds a travel to the calendar of an agent.
* @param user - agent to add the travel to.
* @param travel - travel to book.
*/
public void handleReserve(Agent user, Travel travel) {
Calendar userCalendar = user.getCalendarAssociation().get();
if (userCalendar.getTravelAssociation().contains(travel)) {
......
......@@ -14,6 +14,11 @@ public class AdminUserAdditionController extends SceneController {
public AdminUserAdditionController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to add a user.
* It displays different fields needed to create a new user as well as a add button.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("User Addition");
......@@ -84,6 +89,13 @@ public class AdminUserAdditionController extends SceneController {
return result;
}
/**
* Adds a new user to the list of all users.
* @param name - name of the new user.
* @param username - pseudo of the new user.
* @param role - role of the new user.
* @param password - password of the new user.
*/
public void handleAdd(String name, String username, String role, String password) {
System.out.println(role);
if (name.equals("")) {
......
......@@ -18,6 +18,11 @@ public class AdminUserModificationController extends SceneController {
public AdminUserModificationController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to modify an existing user.
* It displays a list of users and a checkbox to change the role as well as a password field to set a new password.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("User Modification");
......@@ -107,6 +112,12 @@ public class AdminUserModificationController extends SceneController {
}
/**
* Modifies an existing user with the given informations.
* @param modifiedUser - user to modify.
* @param newRole - true if we need to change the role of the selected user.
* @param newPassword - new password of the user.
*/
public void handleModify(Person modifiedUser, boolean newRole, String newPassword) {
if (modifiedUser.equals(gui.getCurrentUser())) {
AlertHandler.showAlert(ERROR, "Impossible to modify the current user.");
......@@ -132,6 +143,10 @@ public class AdminUserModificationController extends SceneController {
}
}
/**
* Updates the content of the list of users.
* @param usersComboBox - list of users to update.
*/
private void updateComboBox(ComboBox usersComboBox) {
List<Person> usersList = gui.getUsersDB().getAllUser();
ObservableListImplementation<Person> usersObservableList = new ObservableListImplementation<>(usersList);
......
......@@ -14,6 +14,11 @@ public class AdminUserRemovalController extends SceneController {
public AdminUserRemovalController(GUI gui) { super(gui); }
/**
* Creates a scene to show an admin when he wants to remove an existing user.
* It displays a list of users and a remove button.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("User Removal");
......@@ -85,12 +90,20 @@ public class AdminUserRemovalController extends SceneController {
return result;
}
/**
* Updates the content of the list of users.
* @param usersComboBox - list of users to update.
*/
private void updateComboBox(ComboBox usersComboBox) {
List<Person> usersList = gui.getUsersDB().getAllUser();
ObservableListImplementation<Person> usersObservableList = new ObservableListImplementation<>(usersList);
usersComboBox.setItems(usersObservableList);
}
/**
* Removes a user from the list of existing user.
* @param user - user to remove.
*/
public void handleRemove(Person user) {
if (user.equals(gui.getCurrentUser())) {
......
......@@ -18,6 +18,11 @@ public class AgentBookedTravelsController extends SceneController {
public AgentBookedTravelsController(GUI gui) { super(gui); }
/**
* Creates a scene to show the current agent wants to see all his booked travels.
* It displays a list of travels contained in the current user's calendar.
* @return returns the scene to set the stage with.
*/
@Override
public Scene createScene() {
gui.setTitle("Booked Travels");
......@@ -65,6 +70,10 @@ public class AgentBookedTravelsController extends SceneController {
return result;
}
/**
* Updates the content of the lis of booked travels.
* @param travelsListView - list of travels to update.
*/
private void updateListView(ListView<Travel> travelsListView) {
Agent currentUser = (Agent) gui.getCurrentUser();
Calendar userCalendar = currentUser.getCalendarAssociation().get();
......
......@@ -22,6 +22,12 @@ public class AgentHomeController extends SceneController {
super(gui);
}
/**
* Creates a scene to show an agent when he connects.
* It displays a list of all travels and a reserve button, as well as a button
* to see all the travels booked by the current user.
* @return returns the scene to set the stage with.
*/
public Scene createScene() {
gui.setTitle("Agent Home");
......@@ -107,12 +113,20 @@ public class AgentHomeController extends SceneController {
return result;
}
/**
* Updates the content of the list of users.
* @param usersComboBox - list to update.
*/
private void updateComboBox(ComboBox usersComboBox) {
List<Travel> travelsList = gui.getTravelsDB().getAllTravel();
ObservableListImplementation<Travel> travelsObservableList = new ObservableListImplementation<>(travelsList);
usersComboBox.setItems(travelsObservableList);
}
/**
* Adds a travel to the calendar of the current user.
* @param travel - travel to book.
*/
public void handleReserve(Travel travel) {
Calendar userCalendar = new Calendar();
try {
......
......@@ -4,6 +4,11 @@ import javafx.scene.control.Alert;
public class AlertHandler {
/**
* Creates a window with a message
* @param alertType - Type of message hown
* @param message - Text displayed in the window
*/
public static void showAlert(Alert.AlertType alertType, String message) {
Alert alert = new Alert(alertType);
alert.setContentText(message);
......
......@@ -16,7 +16,11 @@ public class GUI extends Application {
private Person currentUser;
private AllTravels travelsDB;
/**
* Initializes the attributes and sets the current scene to the login form
* @param stage - the stage in which the scenes will be displayed
* @throws Exception
*/
@Override
public void start(Stage stage) throws Exception {
this.stage = stage;
......@@ -55,11 +59,15 @@ public class GUI extends Application {
this.currentUser = currentUser;
}
public void setTitle(String title) {
stage.setTitle(title);
}
public AllTravels getTravelsDB() {
return travelsDB;
}
/**
* Changes the title displayed at the top of the window
* @param title - Title to be displayed
*/
public void setTitle(String title) {
stage.setTitle(title);
}
}
\ No newline at end of file
......@@ -14,6 +14,11 @@ public class LoginFormController extends SceneController {
super(gui);
}
/**
* Creates a scene to show when someone starts the application or disconnects.
* It displays fields for username and password, as well as a login button.
* @return returns the scene to set the stage with.
*/
public Scene createScene() {
GridPane root = new GridPane();
......@@ -51,7 +56,11 @@ public class LoginFormController extends SceneController {
}
/**
* Checks if a connexion is possible with the given informations.
* @param username - pseudo given by the user.
* @param password - password given by the user.
*/
public void handleSubmission(String username, String password) {
if (username.equals("")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment