diff --git a/src/Client/src/main/java/greenify/client/Application.java b/src/Client/src/main/java/greenify/client/Application.java
index 29afbe3..e07f4de 100644
--- a/src/Client/src/main/java/greenify/client/Application.java
+++ b/src/Client/src/main/java/greenify/client/Application.java
@@ -4,19 +4,21 @@ import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import java.io.IOException;
+
@SpringBootApplication
public class Application extends javafx.application.Application {
private static ConfigurableApplicationContext springContext;
- private static final Logger log = LoggerFactory.getLogger(Application.class);
+ /**
+ * This (main) method starts launch.
+ * @param args the arguments
+ */
public static void main(String[] args) {
launch(args);
}
@@ -33,22 +35,34 @@ public class Application extends javafx.application.Application {
return loader.load();
}
+ /**
+ * This method initializes the application.
+ */
@Override
- public void init() throws Exception {
+ public void init() {
springContext = SpringApplication.run(Application.class);
}
+ /**
+ * This method opens the login window.
+ * @param primaryStage the login window
+ * @throws Exception in case fxml file is not found
+ */
@Override
public void start(Stage primaryStage) throws Exception {
- Parent rootNode = load(this.getClass().getClassLoader().getResource("fxml/LoginWindow.fxml"));
+ Parent rootNode = load(this.getClass().getClassLoader()
+ .getResource("fxml/LoginWindow.fxml"));
primaryStage.setTitle("Greenify");
Scene scene = new Scene(rootNode);
primaryStage.setScene(scene);
primaryStage.show();
}
+ /**
+ * This method stops the application.
+ */
@Override
public void stop() {
springContext.stop();
}
-}
\ No newline at end of file
+}
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 80918bd..bf8fecd 100644
--- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java
+++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java
@@ -22,9 +22,9 @@ import org.springframework.stereotype.Controller;
import java.io.IOException;
-//Class that controls the dashboard fxml file (the GUI Screen)
-
-
+/**
+ * Class that controls the dashboard fxml file (the GUI Screen).
+ */
@Controller
public class DashBoardController {
@Autowired
@@ -32,7 +32,6 @@ public class DashBoardController {
private FadeTransition fadeTrans; //transition for switching between the different panels
private int net;
- private int count = 0;
@FXML
private AnchorPane dashboardPane;
@@ -43,8 +42,6 @@ public class DashBoardController {
@FXML
private AnchorPane friendsPane;
@FXML
- private Label veganMealCounter;
- @FXML
private Label totalVeganMealCounter;
@FXML
private Label welcomebacktext;
@@ -65,11 +62,8 @@ public class DashBoardController {
@FXML
private Button calculateFootPrintButton;
-
-
-
/**
- * loads the the necessary things before anything else.
+ * Loads the the necessary things before anything else.
*/
public void initialize() {
//sets the text of the 'welcome back' text to include the username
@@ -90,7 +84,7 @@ public class DashBoardController {
}
/**
- * adds a fade transition for switching between the different panes.
+ * Adds a fade transition for switching between the different panes.
* @param node the node on which the transition needs to act
*/
public void addFadeTransition(Node node) {
@@ -103,7 +97,7 @@ public class DashBoardController {
/**
- * displays the dashboard pane.
+ * Displays the dashboard pane.
* @param event the event (clicking the button)
*/
public void displayDashboard(ActionEvent event) {
@@ -117,7 +111,7 @@ public class DashBoardController {
}
/**
- * displays the activities pane.
+ * Displays the activities pane.
* @param event the event (clicking the button)
*/
public void displayActivities(ActionEvent event) {
@@ -131,7 +125,7 @@ public class DashBoardController {
}
/**
- * displays the user profile pane.
+ * Displays the user profile pane.
* @param event the event (clicking the button)
*/
public void displayUser(ActionEvent event) {
@@ -144,6 +138,10 @@ public class DashBoardController {
}
+ /**
+ * Displays the friends pane.
+ * @param event the event (clicking the button)
+ */
public void displayFriends(ActionEvent event) {
addFadeTransition(friendsPane);
System.out.println("display friends");
@@ -151,6 +149,7 @@ public class DashBoardController {
userPane.setVisible(false);
activitiesPane.setVisible(false);
friendsPane.setVisible(true);
+
}
//sets the slide in transition for startup
@@ -159,11 +158,16 @@ public class DashBoardController {
pathTrans.play();
}
+ /**
+ * Opens the calculator.
+ * @throws IOException if the Application doesn't load.
+ */
public void openCalculator() throws IOException {
Parent calc = Application.load(this.getClass().getClassLoader()
.getResource("fxml/calculator.fxml"));
Scene scene = new Scene(calc);
- scene.getStylesheets().add(getClass().getClassLoader().getResource("stylesheets/calculatorStyle.css").toExternalForm());
+ scene.getStylesheets().add(getClass().getClassLoader()
+ .getResource("stylesheets/calculatorStyle.css").toExternalForm());
Stage calcStage = new Stage();
calcStage.setScene(scene);
@@ -197,4 +201,4 @@ public class DashBoardController {
}
}
-}
\ 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 c44b668..c3d3bb4 100644
--- a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
+++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
@@ -9,7 +9,6 @@ import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
-import javafx.scene.shape.Line;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
@@ -18,7 +17,9 @@ import org.springframework.stereotype.Controller;
import java.util.concurrent.TimeUnit;
-//class that controls the actions for the register window
+/**
+ * Class that controls the actions for the register window.
+ */
@Controller
public class RegisterWindowController {
@@ -32,12 +33,17 @@ public class RegisterWindowController {
@FXML
private PasswordField passwordField2;
@FXML
- private Button signupButton;
- @FXML
- private Line uNamePathLine;
+ private Button signUpButton;
+ //@FXML
+ //private Line uNamePathLine;
+ /**
+ * Initializes the animation.
+ * @throws InterruptedException exception when interrupted
+ */
public void initialize() throws InterruptedException {
- // PathTransition pathTransUName = new PathTransition(Duration.millis(1100), uNamePathLine, userNameText);
+ // PathTransition pathTransUName = new PathTransition(Duration.millis(1100),
+ // uNamePathLine, userNameText);
// pathTransUName.play();
addSlideAnimation(1100, userNameText, -300);
addSlideAnimation(1100, passwordField, 300);
@@ -46,7 +52,13 @@ public class RegisterWindowController {
}
- public void addSlideAnimation(int duration, Node node, int from) {
+ /**
+ * Adds the slide animation.
+ * @param duration the duration
+ * @param node the node
+ * @param from from where
+ */
+ private void addSlideAnimation(int duration, Node node, int from) {
TranslateTransition slideIn = new TranslateTransition(Duration.millis(duration), node);
slideIn.setFromX(from);
slideIn.setToX(0);
@@ -54,13 +66,13 @@ public class RegisterWindowController {
}
/**
- * signs the user up.
+ * Signs up the user.
* @param event the click of the sign up button
*/
@FXML
public void handleSignUpButton(ActionEvent event) {
//set the window to the current window (for displaying the alerts)
- Window owner = signupButton.getScene().getWindow();
+ Window owner = signUpButton.getScene().getWindow();
//check if the username field is empty
if (userNameText.getText().isEmpty()) {
//if so, display an alert
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 fc0f097..9c3e238 100644
--- a/src/Client/src/main/java/greenify/client/controller/UserController.java
+++ b/src/Client/src/main/java/greenify/client/controller/UserController.java
@@ -16,8 +16,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import java.io.IOException;
+import java.util.Objects;
-//class that controls the actions for the login screen
+/**
+ * Class that controls the actions for the login screen.
+ */
@Controller
public class UserController {
@Autowired
@@ -33,10 +36,10 @@ public class UserController {
private Button loginButton;
@FXML
- private Button signupButton;
+ private Button signUpButton;
/**
- * handles when the user clicks on the login button.
+ * Handles when the user clicks on the login button.
* it checks if the username and password fields are filled
* and gives alerts if they aren't filled in.
* @param event the click of the login button
@@ -75,18 +78,18 @@ public class UserController {
}
/**
- * opens the dashboard stage.
+ * Opens the dashboard stage.
* @throws IOException exception if fxml file can't be found
* @author sem
*/
- public void openDashboard() throws IOException {
+ private void openDashboard() throws IOException {
//load the fxml file
Parent dash = Application.load(this.getClass().getClassLoader()
.getResource("fxml/dashboard.fxml"));
Scene scene = new Scene(dash);
//add the stylesheet for the CSS
- scene.getStylesheets().add(getClass().getClassLoader()
- .getResource("stylesheets/dashboardStyle.css").toExternalForm());
+ scene.getStylesheets().add(Objects.requireNonNull(getClass().getClassLoader()
+ .getResource("stylesheets/dashboardStyle.css")).toExternalForm());
Stage appStage = new Stage();
appStage.setScene(scene);
//set the title
@@ -94,8 +97,10 @@ public class UserController {
appStage.show();
}
- //class for showing the alerts
- public static class AlertHelper {
+ /**
+ * Class for showing the alerts.
+ */
+ static class AlertHelper {
/**
* alerts for the login screen.
* @param alertType the type of alert
@@ -103,10 +108,10 @@ public class UserController {
* @param title the title given to the displayed alert
* @param message the message displayed in the alert
*/
- public static void showAlert(Alert.AlertType alertType,
- Window owner,
- String title,
- String message) {
+ static void showAlert(Alert.AlertType alertType,
+ Window owner,
+ String title,
+ String message) {
Alert alert = new Alert(alertType);
alert.setTitle(title);
alert.setHeaderText(null);
diff --git a/src/Client/src/main/java/greenify/client/rest/UserService.java b/src/Client/src/main/java/greenify/client/rest/UserService.java
index ba726e5..d3c5123 100644
--- a/src/Client/src/main/java/greenify/client/rest/UserService.java
+++ b/src/Client/src/main/java/greenify/client/rest/UserService.java
@@ -8,25 +8,23 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
@Service
public class UserService {
+ public UserDto currentUser;
+
@Autowired
RestTemplate restTemplate;
- public UserDto currentUser;
-
@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
/**
- * registers the user.
+ * Registers the user.
* @param name the username of the user
* @param password the password of the user
* @return a userDTO
@@ -37,7 +35,7 @@ public class UserService {
public UserDto registerUser(String name, String password) {
//headers for http
HttpHeaders headers = new HttpHeaders();
- //set the accept header in JSÖN value
+ //set the accept header in JSON value
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
//connect to the server with the needed url
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/registerUser")
@@ -47,7 +45,7 @@ public class UserService {
//getting the password from the database
//create a http entity to be sent
- HttpEntity> entity = new HttpEntity<>(headers);
+ new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri());
//the result to be sent is a userDto
@@ -59,7 +57,7 @@ public class UserService {
}
/**
- * sign ins the user.
+ * Signs in the user.
* @param name the username of the user
* @param password the password of the user
* @return a userDTO
@@ -72,7 +70,7 @@ public class UserService {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/loginUser")
.queryParam("name", name)
.queryParam("password", password);
- HttpEntity> entity = new HttpEntity<>(headers);
+ new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri());
UserDto result = this.restTemplate.getForObject(builder.build()
.encode().toUri(), UserDto.class);
@@ -80,6 +78,13 @@ public class UserService {
return result;
}
+ /**
+ * Updates the input of the user.
+ * @param name name of the user
+ * @param inputName name of the input
+ * @param value value of the input
+ * @return returns the result
+ */
@SuppressWarnings("Duplicates")
public String updateInput(String name, String inputName, String value) {
HttpHeaders headers = new HttpHeaders();
@@ -88,13 +93,18 @@ public class UserService {
.queryParam("name", name)
.queryParam("inputName", inputName)
.queryParam("value",value);
- HttpEntity> entity = new HttpEntity<>(headers);
+ new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri());
- String result = this.restTemplate.getForObject(builder.build()
+ return this.restTemplate.getForObject(builder.build()
.encode().toUri(), String.class);
- return result;
}
+ /**
+ * Adds a friend to the user.
+ * @param name the username of the current user.
+ * @param friend the username of the friend you want to add.
+ * @return a userDTO
+ */
@SuppressWarnings("Duplicates")
public String addFriend(String name, String friend) {
HttpHeaders headers = new HttpHeaders();
diff --git a/src/Client/src/main/resources/fxml/LoginWindow.fxml b/src/Client/src/main/resources/fxml/LoginWindow.fxml
index 03a3902..03b8014 100644
--- a/src/Client/src/main/resources/fxml/LoginWindow.fxml
+++ b/src/Client/src/main/resources/fxml/LoginWindow.fxml
@@ -17,7 +17,7 @@
-
+
diff --git a/src/Client/src/main/resources/fxml/RegisterWindow.fxml b/src/Client/src/main/resources/fxml/RegisterWindow.fxml
index 9daeb7f..5764438 100644
--- a/src/Client/src/main/resources/fxml/RegisterWindow.fxml
+++ b/src/Client/src/main/resources/fxml/RegisterWindow.fxml
@@ -24,7 +24,7 @@
-