ADD:: added javadoc comments where needed for the checkstyle
EDIT:: edited some lines to fit the checkstyle fixed some indentation warnings and line length warnings
This commit is contained in:
@@ -37,17 +37,23 @@ public class Application extends javafx.application.Application {
|
|||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
||||||
|
|
||||||
// fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/dashboard.fxml"));
|
// fxmlLoader.setLocation(
|
||||||
|
// this.getClass().getClassLoader().getResource("fxml/dashboard.fxml")
|
||||||
|
// );
|
||||||
|
|
||||||
|
|
||||||
rootNode = fxmlLoader.load();
|
rootNode = fxmlLoader.load();
|
||||||
|
|
||||||
// rootNode = FXMLLoader.load(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
// rootNode = FXMLLoader.load(
|
||||||
|
// this.getClass().getClassLoader().getResource("fxml/sample.fxml")
|
||||||
|
// );
|
||||||
|
|
||||||
primaryStage.setTitle("GoGreen");
|
primaryStage.setTitle("GoGreen");
|
||||||
Scene scene = new Scene(rootNode);
|
Scene scene = new Scene(rootNode);
|
||||||
|
|
||||||
// scene.getStylesheets().add(getClass().getResource("stylesheets/dashboardStyle.css").toExternalForm());
|
// scene.getStylesheets().add(
|
||||||
|
// getClass().getResource("stylesheets/dashboardStyle.css").toExternalForm()
|
||||||
|
// );
|
||||||
|
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.effect.DropShadow;
|
import javafx.scene.effect.DropShadow;
|
||||||
import javafx.scene.input.MouseEvent;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -33,22 +32,10 @@ public class DashBoardController {
|
|||||||
|
|
||||||
DropShadow shadow = new DropShadow();
|
DropShadow shadow = new DropShadow();
|
||||||
|
|
||||||
public void handleClickAction(MouseEvent event) {
|
/**
|
||||||
if (event.getTarget() == dashboardButton) {
|
* displays the dashboard pane.
|
||||||
dashboardPane.setVisible(true);
|
* @param event the event (clicking the button)
|
||||||
userPane.setVisible(false);
|
*/
|
||||||
activitiesPane.setVisible(false);
|
|
||||||
} else if (event.getTarget() == activitiesButton){
|
|
||||||
dashboardPane.setVisible(false);
|
|
||||||
userPane.setVisible(false);
|
|
||||||
activitiesPane.setVisible(true);
|
|
||||||
} else if (event.getTarget() == userButton) {
|
|
||||||
dashboardPane.setVisible(false);
|
|
||||||
userPane.setVisible(true);
|
|
||||||
activitiesPane.setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void displayDashboard(ActionEvent event) {
|
public void displayDashboard(ActionEvent event) {
|
||||||
System.out.println("display dashboard");
|
System.out.println("display dashboard");
|
||||||
dashboardPane.setVisible(true);
|
dashboardPane.setVisible(true);
|
||||||
@@ -56,6 +43,10 @@ public class DashBoardController {
|
|||||||
activitiesPane.setVisible(false);
|
activitiesPane.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displays the activities pane.
|
||||||
|
* @param event the event (clicking the button)
|
||||||
|
*/
|
||||||
public void displayActivities(ActionEvent event) {
|
public void displayActivities(ActionEvent event) {
|
||||||
System.out.println("display activities");
|
System.out.println("display activities");
|
||||||
dashboardPane.setVisible(false);
|
dashboardPane.setVisible(false);
|
||||||
@@ -63,19 +54,23 @@ public class DashBoardController {
|
|||||||
activitiesPane.setVisible(true);
|
activitiesPane.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* displays the user profile pane.
|
||||||
|
* @param event the event (clicking the button)
|
||||||
|
*/
|
||||||
public void displayUser(ActionEvent event) {
|
public void displayUser(ActionEvent event) {
|
||||||
System.out.println("display user");
|
System.out.println("display user");
|
||||||
dashboardPane.setVisible(false);
|
dashboardPane.setVisible(false);
|
||||||
userPane.setVisible(true);
|
userPane.setVisible(true);
|
||||||
activitiesPane.setVisible(false);
|
activitiesPane.setVisible(false);
|
||||||
}
|
}
|
||||||
public void addShadow(MouseEvent event) {
|
// public void addShadow(MouseEvent event) {
|
||||||
userButton.setEffect(shadow);
|
// userButton.setEffect(shadow);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void removeShadow(MouseEvent event) {
|
// public void removeShadow(MouseEvent event) {
|
||||||
userButton.setEffect(null);
|
// userButton.setEffect(null);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class UserController {
|
|||||||
private Button signupButton;
|
private Button signupButton;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @Value("${my.url}")
|
// @Value("${my.url}")
|
||||||
// private String myUrl;
|
// private String myUrl;
|
||||||
|
|
||||||
@@ -71,30 +70,48 @@ public class UserController {
|
|||||||
userService.registerUser(usernameField.getText(), passwordField.getText());
|
userService.registerUser(usernameField.getText(), passwordField.getText());
|
||||||
|
|
||||||
// load the dashboard stage
|
// load the dashboard stage
|
||||||
// Parent parent = FXMLLoader.load(this.getClass().getClassLoader().getResource("/fxml/dashboard.fxml"));
|
// Parent parent = FXMLLoader.load(
|
||||||
|
// this.getClass().getClassLoader().getResource("/fxml/dashboard.fxml")
|
||||||
|
// );
|
||||||
//
|
//
|
||||||
// Scene scene = new Scene(parent);
|
// Scene scene = new Scene(parent);
|
||||||
// Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
// Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
// app_stage.setScene(scene);
|
// app_stage.setScene(scene);
|
||||||
// app_stage.setFullScreen(true);
|
// app_stage.setFullScreen(true);
|
||||||
// app_stage.show();
|
// app_stage.show();
|
||||||
|
|
||||||
//on,y works once, when already logged in once, need to restart client for it to work again
|
|
||||||
openDashboard();
|
openDashboard();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* opens the dashboard stage.
|
||||||
|
* @throws IOException exception if fxml file can't be found
|
||||||
|
* @author sem
|
||||||
|
*/
|
||||||
public void openDashboard() throws IOException {
|
public void openDashboard() throws IOException {
|
||||||
Parent dash = FXMLLoader.load(this.getClass().getClassLoader().getResource("fxml/Dashboard.fxml"));
|
Parent dash = FXMLLoader.load(
|
||||||
|
this.getClass().getClassLoader().getResource("fxml/Dashboard.fxml")
|
||||||
|
);
|
||||||
Scene scene = new Scene(dash);
|
Scene scene = new Scene(dash);
|
||||||
Stage app_stage = new Stage();
|
Stage appStage = new Stage();
|
||||||
app_stage.setScene(scene);
|
appStage.setScene(scene);
|
||||||
// app_stage.setFullScreen(true);
|
// app_stage.setFullScreen(true);
|
||||||
app_stage.show();
|
appStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class AlertHelper {
|
public static class AlertHelper {
|
||||||
public static void showAlert(Alert.AlertType alertType, Window owner, String title, String message) {
|
/**
|
||||||
|
* alerts for the login screen.
|
||||||
|
* @param alertType the type of alert
|
||||||
|
* @param owner the owner (window) of the alert
|
||||||
|
* @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) {
|
||||||
Alert alert = new Alert(alertType);
|
Alert alert = new Alert(alertType);
|
||||||
alert.setTitle(title);
|
alert.setTitle(title);
|
||||||
alert.setHeaderText(null);
|
alert.setHeaderText(null);
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ public class UserService {
|
|||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* registers the user.
|
||||||
|
* @param name the username of the user
|
||||||
|
* @param password the password of the user
|
||||||
|
* @return a userDTO
|
||||||
|
*/
|
||||||
public UserDTO registerUser(String name, String password) {
|
public UserDTO registerUser(String name, String password) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package gogreen.common;
|
package gogreen.common;
|
||||||
|
|
||||||
public class UserDTO {
|
public class UserDTO {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|||||||
@@ -20,20 +20,38 @@ public class User {
|
|||||||
String name;
|
String name;
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* makes a user object.
|
||||||
|
* @param id the id of the user.
|
||||||
|
* @param name the supplied username
|
||||||
|
* @param password the supplied password
|
||||||
|
*/
|
||||||
public User(Long id, String name, String password) {
|
public User(Long id, String name, String password) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the id.
|
||||||
|
* @return the id
|
||||||
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the name.
|
||||||
|
* @return the name
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the password.
|
||||||
|
* @return the password
|
||||||
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ public class UserService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
UserRepository userRepository;
|
UserRepository userRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* registers the user.
|
||||||
|
* @param name the username of the user
|
||||||
|
* @param password the password of the user
|
||||||
|
* @return a userDTO of the registered user
|
||||||
|
*/
|
||||||
public UserDTO registerUser(String name, String password) {
|
public UserDTO registerUser(String name, String password) {
|
||||||
User user = userRepository.findByName(name);
|
User user = userRepository.findByName(name);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
@@ -26,6 +32,12 @@ public class UserService {
|
|||||||
return new UserDTO(user.getId(), user.getName());
|
return new UserDTO(user.getId(), user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs the user in.
|
||||||
|
* @param name the username of the user
|
||||||
|
* @param password the password of the user
|
||||||
|
* @return a userDTO of the logged in user
|
||||||
|
*/
|
||||||
public UserDTO login(String name, String password) {
|
public UserDTO login(String name, String password) {
|
||||||
User user = userRepository.findByName(name);
|
User user = userRepository.findByName(name);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user