Merge branch 'Feature/alerts' into 'master'
Feature/alerts See merge request cse1105/2018-2019/oopp-group-43/template!64
This commit is contained in:
@@ -56,7 +56,7 @@ public class Hints {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method gets a random hint from the list of hints.
|
||||
* This method returns a random String.
|
||||
* @return the random hint.
|
||||
*/
|
||||
public String randomHint() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.Label;
|
||||
@@ -33,6 +34,7 @@ import java.text.DecimalFormat;
|
||||
|
||||
@Controller
|
||||
public class CalculatorController {
|
||||
private static UserController.AlertHelper AlertHelper;
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@@ -524,5 +526,7 @@ public class CalculatorController {
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
controller.updateLeaderboard();
|
||||
CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
}
|
||||
}
|
||||
@@ -432,7 +432,7 @@ public class DashBoardController {
|
||||
}
|
||||
|
||||
/**
|
||||
* method opend addFriend scene.
|
||||
* method opens addFriend scene.
|
||||
* @throws IOException when file is not found
|
||||
*/
|
||||
public void openAddFriend() throws IOException {
|
||||
@@ -579,3 +579,4 @@ public class DashBoardController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,10 @@ public class FriendController {
|
||||
//add friend to the current user
|
||||
userService.addFriend(userService.currentUser.getName(), userNameText.getText());
|
||||
//close the register window after the user has entered all the credentials
|
||||
String friendName = userNameText.getText();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend added!",
|
||||
userNameText.getText() + " is now your friend!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,14 @@ public class RegisterWindowController {
|
||||
}
|
||||
|
||||
//register the user with the provided username and password
|
||||
userService.registerUser(userNameText.getText(), passwordField.getText());
|
||||
try {
|
||||
userService.registerUser(userNameText.getText(), passwordField.getText());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"This username has already been taken!");
|
||||
return;
|
||||
}
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
|
||||
@@ -65,7 +65,14 @@ public class UserController {
|
||||
System.out.println("Password is " + passwordField.getText());
|
||||
}
|
||||
//log the user in with the userService method
|
||||
userService.loginUser(usernameField.getText(), passwordField.getText());
|
||||
try {
|
||||
userService.loginUser(usernameField.getText(), passwordField.getText());
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
"Your username or password is incorrect!");
|
||||
return;
|
||||
}
|
||||
Stage current = (Stage) owner;
|
||||
//after logging in, close the login window
|
||||
current.close();
|
||||
|
||||
Reference in New Issue
Block a user