From 1ff84ce3d812e6cdb0b9300b7b96dfbff9e227aa Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:44:50 +0200 Subject: [PATCH 01/16] ADD:: Alert for taken username --- build.gradle | 6 +++--- .../client/controller/DashBoardController.java | 2 +- .../client/controller/RegisterWindowController.java | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 2b6ed72..98f5661 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -application { - mainClassName = 'greenify.server.Application' -} +//application { +// mainClassName = 'greenify.server.Application' +//} repositories { mavenCentral() diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index b43433d..13613eb 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -398,7 +398,7 @@ public class DashBoardController { } /** - * method opend addFriend scene. + * method opens addFriend scene. * @throws IOException when file is not found */ public void openAddFriend() throws IOException { diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 11cb71f..b30c137 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -2,6 +2,7 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; +import greenify.common.ApplicationException; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -228,7 +229,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, "Password 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(); From b5c834fc52e4e20df9d2cd7037727cd5d8d486e1 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:51:35 +0200 Subject: [PATCH 02/16] ADD:: Alert 'Footprint saved. Still has a bug.' --- .../greenify/client/controller/CalculatorController.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index a44e0ef..b5b4a51 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -10,12 +10,7 @@ import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.Slider; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; import javafx.stage.Stage; @@ -29,6 +24,7 @@ import java.text.DecimalFormat; @Controller public class CalculatorController { + private static UserController.AlertHelper AlertHelper; @Autowired UserService userService; @@ -497,6 +493,7 @@ public class CalculatorController { Float footprint = userService.saveFootprint(userService.currentUser.getName()); Window owner = saveButton.getScene().getWindow(); Stage current = (Stage) owner; +// CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Footprint saved!", "Your footprint is saved!"); current.close(); controller.updateLeaderboard(); } From 4b04487a250d6c349b531de164acc5c7d6274d82 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 15:33:26 +0200 Subject: [PATCH 03/16] Added class Hints, including tests --- .../src/main/java/greenify/client/Hints.java | 68 +++++++++++++++++++ .../controller/CalculatorController.java | 5 +- .../controller/DashBoardController.java | 1 + src/Client/src/test/java/HintsTest.java | 29 ++++++++ 4 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 src/Client/src/main/java/greenify/client/Hints.java create mode 100644 src/Client/src/test/java/HintsTest.java diff --git a/src/Client/src/main/java/greenify/client/Hints.java b/src/Client/src/main/java/greenify/client/Hints.java new file mode 100644 index 0000000..34aa3fb --- /dev/null +++ b/src/Client/src/main/java/greenify/client/Hints.java @@ -0,0 +1,68 @@ +package greenify.client; + +import java.util.ArrayList; +import java.util.Random; + +public class Hints { + public ArrayList hints; + + public Hints() { + this.hints = new ArrayList(); + initHints(); + } + + /** + * This method adds all the Strings to the arraylist. + */ + private void initHints() { + hints.add("Buying local produce will not only decrease your carbon " + + "footprint, but also help your local economy: A win-win!"); + hints.add("Did you know that a gas oven only uses 6% of its energy " + + "to cook? And an electric oven is not much better at 12%."); + hints.add("70% of the deforestation of the Amazon is to provide land for cattle ranches."); + hints.add("Research shows that reducing meat consumption can increase" + + " your life span by 3.6 years"); + hints.add("Vegetarians have a lower risk of getting heart disease, high blood pressure, " + + "diabetes and cancer than meat eaters."); + hints.add("Did you know? The carbon footprint of a vegetarian diet is about half " + + "that of a meat-lover’s diet!"); + hints.add("Cycling is good for the environment AND for your body, " + + "so why not grab your bike instead of your car?"); + hints.add("If we could capture all of the sun’s energy shining on the Earth for just one " + + "hour, we could power the entire world for one year!"); + hints.add("27,000 trees are cut down each day so we can have toilet paper."); + hints.add("A glass bottle made in our time will take more than 4,000 years to decompose."); + hints.add("Don't forget to turn off the lights and heating in rooms" + + " you're not using at the moment!"); + hints.add("Did you know that about 4.5% of the Dutch population does not eat meat"); + hints.add("Reuse your bags when you go grocery shopping. You will save plastic bags."); + hints.add("An estimated 250 million trees can be save each year " + + "if every published newspaper is recycled."); + hints.add("About 88,000 jobs were created in 2015 through the wind power sector."); + hints.add("You can use LED lights in your home to safe energy!"); + hints.add("If you isolate your home well, it will be warmer " + + "and you'll save energy as well!"); + hints.add("Do you have leftovers? Donate them to food kitchens. This way you won't waste " + + "food and help people at the same time."); + hints.add("A lot of coffee places give you a discount if you bring your own cup. " + + "Get rid of those disposable cups!"); + hints.add("When shopping, look for products with minimal to no packaging, " + + "or at least packaging made from recycled items. "); + hints.add("If you order food, you can ask the restaurant to not include " + + "utensils and napkins, it saves plastic and paper."); + hints.add("It takes about 66 days to form a new habit, keep going!"); + hints.add("Get yourself a nice reusable water bottle! It's cheaper and better for " + + "the environment to refill than to buy a new one every time it's empty."); + } + + /** + * This method returns a random hint from the list of hints. + * @return the random hint. + */ + public String randomHint() { + Random rand = new Random(); + int index = rand.nextInt(hints.size()); + return hints.get(index); + } + +} diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 5098636..a44e0ef 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -9,9 +9,7 @@ import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; import javafx.scene.Node; -import javafx.scene.Parent; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -338,7 +336,8 @@ public class CalculatorController { @SuppressWarnings("Duplicates") public void displayExtra(ActionEvent event) throws IOException { - // Parent extra = FXMLLoader.load(getClass().getClassLoader().getResource("fxml/extraActivities.fxml")); + // Parent extra = FXMLLoader.load(getClass().getClassLoader() + // .getResource("fxml/extraActivities.fxml")); // extraPane.getChildren().setAll(extra); getStartedPane.setVisible(false); travelPane.setVisible(false); diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index 259ed42..b43433d 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -495,4 +495,5 @@ public class DashBoardController { } } + } \ No newline at end of file diff --git a/src/Client/src/test/java/HintsTest.java b/src/Client/src/test/java/HintsTest.java new file mode 100644 index 0000000..c0e2442 --- /dev/null +++ b/src/Client/src/test/java/HintsTest.java @@ -0,0 +1,29 @@ +import static junit.framework.TestCase.assertTrue; +import static org.junit.Assert.assertFalse; + +import greenify.client.Hints; +import org.junit.Test; + +public class HintsTest { + @Test + public void initHintsTest() { + Hints test = new Hints(); + assertFalse(test.hints.isEmpty()); + } + + @Test + public void hintsContainsTest() { + Hints test = new Hints(); + assertTrue(test.hints.contains("27,000 trees are cut down " + + "each day so we can have toilet paper.")); + } + + @Test + public void randomHintTest() { + Hints test = new Hints(); + String random = test.randomHint(); + assertTrue(test.hints.contains(random)); + } +} + + From 81701758d77189db184bced8f517c28c8f1bb2d7 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:44:50 +0200 Subject: [PATCH 04/16] ADD:: Alert for taken username --- build.gradle | 6 +++--- .../client/controller/DashBoardController.java | 2 +- .../client/controller/RegisterWindowController.java | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 2b6ed72..98f5661 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -application { - mainClassName = 'greenify.server.Application' -} +//application { +// mainClassName = 'greenify.server.Application' +//} repositories { mavenCentral() diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index b43433d..13613eb 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -398,7 +398,7 @@ public class DashBoardController { } /** - * method opend addFriend scene. + * method opens addFriend scene. * @throws IOException when file is not found */ public void openAddFriend() throws IOException { diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 11cb71f..b30c137 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -2,6 +2,7 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; +import greenify.common.ApplicationException; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -228,7 +229,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, "Password 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(); From c79a98c57d7c45b0b1e67242259bbd7f7e69e5a2 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:51:35 +0200 Subject: [PATCH 05/16] ADD:: Alert 'Footprint saved. Still has a bug.' --- .../greenify/client/controller/CalculatorController.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index a44e0ef..b5b4a51 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -10,12 +10,7 @@ import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.Slider; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; import javafx.stage.Stage; @@ -29,6 +24,7 @@ import java.text.DecimalFormat; @Controller public class CalculatorController { + private static UserController.AlertHelper AlertHelper; @Autowired UserService userService; @@ -497,6 +493,7 @@ public class CalculatorController { Float footprint = userService.saveFootprint(userService.currentUser.getName()); Window owner = saveButton.getScene().getWindow(); Stage current = (Stage) owner; +// CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Footprint saved!", "Your footprint is saved!"); current.close(); controller.updateLeaderboard(); } From a55e4cecef2c3701dcb2b90b4ac0b5fd3b6e8f60 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 15:33:26 +0200 Subject: [PATCH 06/16] Added class Hints, including tests --- src/Client/src/main/java/greenify/client/Hints.java | 2 +- .../java/greenify/client/controller/DashBoardController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/Hints.java b/src/Client/src/main/java/greenify/client/Hints.java index 95f010d..34aa3fb 100644 --- a/src/Client/src/main/java/greenify/client/Hints.java +++ b/src/Client/src/main/java/greenify/client/Hints.java @@ -56,7 +56,7 @@ public class Hints { } /** - * This method gets a random hint from the list of hints. + * This method returns a random hint from the list of hints. * @return the random hint. */ public String randomHint() { diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index daeb661..a9c3118 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -527,5 +527,5 @@ public class DashBoardController { button.setOnMouseExited(e -> scaleDown.playFromStart()); } } - } + From 25a66832a5af6b3733025a48cc316f0a31441ccc Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:44:50 +0200 Subject: [PATCH 07/16] ADD:: Alert for taken username --- build.gradle | 6 +++--- .../client/controller/DashBoardController.java | 2 +- .../client/controller/RegisterWindowController.java | 10 +++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 2b6ed72..98f5661 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -application { - mainClassName = 'greenify.server.Application' -} +//application { +// mainClassName = 'greenify.server.Application' +//} repositories { mavenCentral() diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index a9c3118..18d9798 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -422,7 +422,7 @@ public class DashBoardController { } /** - * method opend addFriend scene. + * method opens addFriend scene. * @throws IOException when file is not found */ public void openAddFriend() throws IOException { diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 11cb71f..b30c137 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -2,6 +2,7 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; +import greenify.common.ApplicationException; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -228,7 +229,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, "Password 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(); From c8521feaf84b1feed1992fe6f289d41821a86c7c Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Wed, 3 Apr 2019 21:51:35 +0200 Subject: [PATCH 08/16] ADD:: Alert 'Footprint saved. Still has a bug.' --- .../greenify/client/controller/CalculatorController.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 4d3e4e7..7155506 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -14,12 +14,7 @@ import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.Slider; -import javafx.scene.control.TextField; +import javafx.scene.control.*; import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; import javafx.stage.Stage; @@ -33,6 +28,7 @@ import java.text.DecimalFormat; @Controller public class CalculatorController { + private static UserController.AlertHelper AlertHelper; @Autowired UserService userService; @@ -522,6 +518,7 @@ public class CalculatorController { Float footprint = userService.saveFootprint(userService.currentUser.getName()); Window owner = saveButton.getScene().getWindow(); Stage current = (Stage) owner; +// CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Footprint saved!", "Your footprint is saved!"); current.close(); controller.updateLeaderboard(); } From c5e7ff2884668b61eade2753455f34f592599247 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 20:35:02 +0200 Subject: [PATCH 09/16] ADD::Alert for incorrect password/username at login. --- .../greenify/client/controller/UserController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Client/src/main/java/greenify/client/controller/UserController.java b/src/Client/src/main/java/greenify/client/controller/UserController.java index a67fcf9..4693577 100644 --- a/src/Client/src/main/java/greenify/client/controller/UserController.java +++ b/src/Client/src/main/java/greenify/client/controller/UserController.java @@ -2,6 +2,7 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; +import greenify.common.ApplicationException; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Parent; @@ -16,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Objects; /** @@ -65,7 +67,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(); From b08174b2eebbef5359cd6428648aad5e5987f959 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 20:42:25 +0200 Subject: [PATCH 10/16] ADD:: Alerts: username is now your friend and calculation saved. --- .../java/greenify/client/controller/CalculatorController.java | 3 ++- .../main/java/greenify/client/controller/FriendController.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 7155506..c080071 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -518,8 +518,9 @@ public class CalculatorController { Float footprint = userService.saveFootprint(userService.currentUser.getName()); Window owner = saveButton.getScene().getWindow(); Stage current = (Stage) owner; -// CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Footprint saved!", "Your footprint is saved!"); current.close(); controller.updateLeaderboard(); + CalculatorController.AlertHelper.showAlert + (Alert.AlertType.CONFIRMATION, owner, "Footprint saved!", "Your footprint is saved!"); } } \ No newline at end of file diff --git a/src/Client/src/main/java/greenify/client/controller/FriendController.java b/src/Client/src/main/java/greenify/client/controller/FriendController.java index a623de5..aa2d455 100644 --- a/src/Client/src/main/java/greenify/client/controller/FriendController.java +++ b/src/Client/src/main/java/greenify/client/controller/FriendController.java @@ -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!"); } } From 7ac5b1efdaac69a814f48539f3ac4c4bcd0a191e Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 20:45:10 +0200 Subject: [PATCH 11/16] FIX:: Small bug fix, pipeline should now run --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 98f5661..2b6ed72 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -//application { -// mainClassName = 'greenify.server.Application' -//} +application { + mainClassName = 'greenify.server.Application' +} repositories { mavenCentral() From 4fa2707adde57e2267dfebf3ca6dca85a1008fb2 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 18:51:04 +0000 Subject: [PATCH 12/16] FIX:: Fixed small typing error in alert --- .../greenify/client/controller/RegisterWindowController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index b30c137..5963a12 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -233,7 +233,7 @@ public class RegisterWindowController { userService.registerUser(userNameText.getText(), passwordField.getText()); } catch(RuntimeException ex){ - UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!", + UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!", "This username has already been taken!"); return; } From f23fc2cbead783f087cc7516fd0f5ff04ec6ab76 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 20:54:50 +0200 Subject: [PATCH 13/16] FIX::Checkstyle errors --- build.gradle | 6 +++--- src/Client/src/main/java/greenify/client/Hints.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 2b6ed72..98f5661 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -application { - mainClassName = 'greenify.server.Application' -} +//application { +// mainClassName = 'greenify.server.Application' +//} repositories { mavenCentral() diff --git a/src/Client/src/main/java/greenify/client/Hints.java b/src/Client/src/main/java/greenify/client/Hints.java index 34aa3fb..9d41a69 100644 --- a/src/Client/src/main/java/greenify/client/Hints.java +++ b/src/Client/src/main/java/greenify/client/Hints.java @@ -56,7 +56,7 @@ public class Hints { } /** - * This method returns a random hint from the list of hints. + * This method returns a random String. * @return the random hint. */ public String randomHint() { From 1684068385d5889b6ddb6618bf76848456abc5f2 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 20:59:08 +0200 Subject: [PATCH 14/16] FIX::More CheckStyle errors --- .../client/controller/CalculatorController.java | 11 ++++++++--- .../client/controller/RegisterWindowController.java | 5 ++--- .../greenify/client/controller/UserController.java | 4 +--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index c080071..74ed99f 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -14,7 +14,12 @@ import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; -import javafx.scene.control.*; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Slider; +import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; import javafx.stage.Stage; @@ -520,7 +525,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!"); + CalculatorController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, + owner, "Footprint saved!", "Your footprint is saved!"); } } \ No newline at end of file diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java index 5963a12..9ecad09 100644 --- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java +++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java @@ -2,7 +2,6 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; -import greenify.common.ApplicationException; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -229,10 +228,10 @@ public class RegisterWindowController { } //register the user with the provided username and password - try{ + try { userService.registerUser(userNameText.getText(), passwordField.getText()); } - catch(RuntimeException ex){ + catch (RuntimeException ex) { UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!", "This username has already been taken!"); return; diff --git a/src/Client/src/main/java/greenify/client/controller/UserController.java b/src/Client/src/main/java/greenify/client/controller/UserController.java index 4693577..19af71a 100644 --- a/src/Client/src/main/java/greenify/client/controller/UserController.java +++ b/src/Client/src/main/java/greenify/client/controller/UserController.java @@ -2,7 +2,6 @@ package greenify.client.controller; import greenify.client.Application; import greenify.client.rest.UserService; -import greenify.common.ApplicationException; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Parent; @@ -17,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.util.Objects; /** @@ -70,7 +68,7 @@ public class UserController { try { userService.loginUser(usernameField.getText(), passwordField.getText()); } - catch(RuntimeException ex){ + catch (RuntimeException ex) { AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!", "Your username or password is incorrect!"); return; From 1f12291398ac169086685f4a35cef40b7df89706 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 21:00:37 +0200 Subject: [PATCH 15/16] FIX::Import error --- .../java/greenify/client/controller/CalculatorController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 74ed99f..ae837c2 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -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; From 8927b7809818503d61bdc7130a619aed9538eef2 Mon Sep 17 00:00:00 2001 From: Merel Steenbergen Date: Thu, 4 Apr 2019 21:02:06 +0200 Subject: [PATCH 16/16] FIX:: Forgot to uncomment something. Pipeline should now work --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 98f5661..2b6ed72 100644 --- a/build.gradle +++ b/build.gradle @@ -18,9 +18,9 @@ apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' apply plugin: 'application' -//application { -// mainClassName = 'greenify.server.Application' -//} +application { + mainClassName = 'greenify.server.Application' +} repositories { mavenCentral()