FIX:: checkstyle 'client'

This commit is contained in:
mlwauben
2019-03-26 11:34:53 +01:00
parent bd21e30f26
commit 8677ac94ef
8 changed files with 88 additions and 65 deletions

View File

@@ -16,7 +16,7 @@ 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);
//private static final Logger log = LoggerFactory.getLogger(Application.class);
/**
* This (main) method starts launch.
@@ -53,7 +53,8 @@ public class Application extends javafx.application.Application {
*/
@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);

View File

@@ -16,18 +16,14 @@ import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
//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
UserService userService;
private FadeTransition fadeTrans; //transition for switching between the different panels
private int net;
private int count = 0;
@FXML
private AnchorPane dashboardPane;
@FXML
@@ -36,12 +32,12 @@ public class DashBoardController {
private AnchorPane activitiesPane;
@FXML
private AnchorPane friendsPane;
@FXML
private Label veganMealCounter;
//@FXML
//private Label veganMealCounter;
@FXML
private Label totalVeganMealCounter;
@FXML
private Label welcomebacktext;
private Label welcomeBackText;
@FXML
private Button dashboardButton;
@FXML
@@ -54,17 +50,17 @@ public class DashBoardController {
private Line pathLine;
@FXML
private AnchorPane menuBar;
@FXML
private Button addNewActivityButton;
//@FXML
//private Button addNewActivityButton;
/**
* 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
welcomebacktext.setText("Welcome back, " + userService.currentUser.getName() + "!");
welcomeBackText.setText("Welcome back, " + userService.currentUser.getName() + "!");
//adds the slide transition to the menu bar
addSlideTransition(menuBar, pathLine);
//adds animations to the navigation buttons
@@ -75,20 +71,22 @@ 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) {
private void addFadeTransition(Node node) {
fadeTrans = new FadeTransition(Duration.millis(400), node);
// FadeTransition is now a local variable
// net is now a local variable
//transition for switching between the different panels
FadeTransition fadeTrans = new FadeTransition(Duration.millis(400), node);
fadeTrans.setFromValue(0);
fadeTrans.setToValue(1.0);
fadeTrans.play();
}
/**
* displays the dashboard pane.
* Displays the dashboard pane.
* @param event the event (clicking the button)
*/
public void displayDashboard(ActionEvent event) {
@@ -98,15 +96,15 @@ public class DashBoardController {
userPane.setVisible(false);
activitiesPane.setVisible(false);
friendsPane.setVisible(false);
}
/**
* displays the activities pane.
* Displays the activities pane.
* @param event the event (clicking the button)
*/
public void displayActivities(ActionEvent event) {
addFadeTransition(activitiesPane);
int net = 0;
totalVeganMealCounter.setText("" + net);
System.out.println("display activities");
dashboardPane.setVisible(false);
@@ -116,7 +114,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) {
@@ -126,9 +124,12 @@ public class DashBoardController {
userPane.setVisible(true);
activitiesPane.setVisible(false);
friendsPane.setVisible(false);
}
/**
* Displays the friends pane.
* @param event the event (clicking the button)
*/
public void displayFriends(ActionEvent event) {
addFadeTransition(friendsPane);
System.out.println("display friends");
@@ -136,11 +137,10 @@ public class DashBoardController {
userPane.setVisible(false);
activitiesPane.setVisible(false);
friendsPane.setVisible(true);
}
//sets the slide in transition for startup
public void addSlideTransition(Node node, Line path1) {
private void addSlideTransition(Node node, Line path1) {
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
pathTrans.play();
}
@@ -153,7 +153,7 @@ public class DashBoardController {
* and scales down when you stop hovering over it.
* @param button the button to add the animation to
*/
public MyButtonSkin(Button button) {
MyButtonSkin(Button button) {
//inherit the button properties
super(button);
//transition to scale up on hover

View File

@@ -9,7 +9,7 @@ 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.scene.shape.Line;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
@@ -18,7 +18,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 +34,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 +53,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 +67,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

View File

@@ -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);

View File

@@ -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,10 +93,9 @@ 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;
}
}

View File

@@ -17,7 +17,7 @@
</font>
</Text>
<Button fx:id="loginButton" layoutX="419.0" layoutY="274.0" mnemonicParsing="false" onAction="#handleLoginButtonAction" prefHeight="26.0" prefWidth="96.0" text="Login" textAlignment="CENTER" />
<Button fx:id="signupButton" layoutX="42.0" layoutY="52.0" mnemonicParsing="false" onAction="#handleRegisterButtonAction" prefHeight="10.0" prefWidth="96.0" text="Sign up!" />
<Button fx:id="signUpButton" layoutX="42.0" layoutY="52.0" mnemonicParsing="false" onAction="#handleRegisterButtonAction" prefHeight="10.0" prefWidth="96.0" text="Sign up!" />
<PasswordField fx:id="passwordField" layoutX="318.0" layoutY="210.0" prefHeight="42.0" prefWidth="303.0" promptText="Password" />
<Hyperlink alignment="CENTER" layoutX="384.0" layoutY="301.0" prefHeight="42.0" prefWidth="173.0" text="Forgot Password?" textAlignment="CENTER" textFill="#3db25a" textOverrun="LEADING_WORD_ELLIPSIS">
<font>

View File

@@ -24,7 +24,7 @@
<Font size="13.0" />
</font>
</TextField>
<Button fx:id="signupButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" style="-fx-background-color: #005e07;" text="Sign up!" textFill="#c4eec9">
<Button fx:id="signUpButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" style="-fx-background-color: #005e07;" text="Sign up!" textFill="#c4eec9">
<font>
<Font name="Corbel Bold" size="14.0" />
</font>

View File

@@ -185,7 +185,7 @@
<AnchorPane fx:id="dashboardPane" layoutX="215.0" prefHeight="603.0" prefWidth="711.0" visible="false">
<children>
<HBox layoutX="97.0" layoutY="124.0" prefHeight="100.0" prefWidth="200.0" />
<Label fx:id="welcomebacktext" layoutX="69.0" layoutY="53.0" text="Welcome back user!" AnchorPane.leftAnchor="60.0" AnchorPane.topAnchor="40.0">
<Label fx:id="welcomeBacktext" layoutX="69.0" layoutY="53.0" text="Welcome back user!" AnchorPane.leftAnchor="60.0" AnchorPane.topAnchor="40.0">
<font>
<Font size="30.0" />
</font>