Merge branch 'Add_registering_GUI' into 'master'
merge registering GUI branch into master See merge request cse1105/2018-2019/oopp-group-43/template!15
This commit is contained in:
@@ -31,9 +31,12 @@ public class Application extends javafx.application.Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
||||
|
||||
rootNode = fxmlLoader.load();
|
||||
|
||||
primaryStage.setTitle("GoGreen");
|
||||
Scene scene = new Scene(rootNode);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class RegisterWindowController {
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@FXML
|
||||
private TextField userNameText;
|
||||
@FXML
|
||||
private PasswordField passwordField;
|
||||
@FXML
|
||||
private PasswordField passwordField2;
|
||||
@FXML
|
||||
private Button signupButton;
|
||||
|
||||
/**
|
||||
* signs the user up.
|
||||
* @param event the click of the signup button
|
||||
*/
|
||||
@FXML
|
||||
public void handleSignUpButton(ActionEvent event) {
|
||||
// System.out.println("pressed sign up button!");
|
||||
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = signupButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
if (userNameText.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"Please enter a username!");
|
||||
return;
|
||||
}
|
||||
// else {
|
||||
// System.out.println("username is " + userNameText.getText());
|
||||
// }
|
||||
|
||||
//check if the password field is empty
|
||||
if (passwordField.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
|
||||
"Please enter a password!");
|
||||
return;
|
||||
}
|
||||
// else {
|
||||
// System.out.println("password is " + passwordField.getText());
|
||||
// }
|
||||
|
||||
//check if the two password fields are equal
|
||||
if (!passwordField.getText().equals(passwordField2.getText())) {
|
||||
//if not, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
|
||||
"Please make sure the passwords entered are the same!");
|
||||
return;
|
||||
}
|
||||
// else {
|
||||
// System.out.println("registered user with username:"
|
||||
// + userNameText.getText()
|
||||
// + ", and password:" + passwordField.getText());
|
||||
// }
|
||||
|
||||
userService.registerUser(userNameText.getText(), passwordField.getText());
|
||||
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,20 @@ public class UserController {
|
||||
}
|
||||
|
||||
userService.registerUser(usernameField.getText(), passwordField.getText());
|
||||
|
||||
// load the dashboard stage
|
||||
// Parent parent = FXMLLoader.load(
|
||||
// this.getClass().getClassLoader().getResource("/fxml/dashboard.fxml")
|
||||
// );
|
||||
//
|
||||
// Scene scene = new Scene(parent);
|
||||
// Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||
// app_stage.setScene(scene);
|
||||
// app_stage.setFullScreen(true);
|
||||
// app_stage.show();
|
||||
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
openDashboard();
|
||||
|
||||
}
|
||||
@@ -98,4 +112,19 @@ public class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
//method to open the register window
|
||||
public void handleRegisterButtonAction(ActionEvent event) throws Exception{
|
||||
//load the fxml file
|
||||
Parent registerWindow = FXMLLoader.load (
|
||||
this.getClass().getClassLoader().getResource("fxml/RegisterWindow.fxml")
|
||||
);
|
||||
//make the window use the scene
|
||||
Scene registerscene = new Scene(registerWindow);
|
||||
Stage registerStage = new Stage();
|
||||
//open the window
|
||||
registerStage.setScene(registerscene);
|
||||
registerStage.setTitle("Enter register credentials");
|
||||
registerStage.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
45
src/Client/src/main/resources/fxml/RegisterWindow.fxml
Normal file
45
src/Client/src/main/resources/fxml/RegisterWindow.fxml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import java.util.*?>
|
||||
<?import javafx.scene.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
|
||||
<AnchorPane prefHeight="300.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.RegisterWindowController">
|
||||
<children>
|
||||
<ImageView fitHeight="312.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../registerBackground.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Text fill="#00650d" layoutX="103.0" layoutY="42.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Register">
|
||||
<font>
|
||||
<Font size="26.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<TextField fx:id="userNameText" layoutX="69.0" layoutY="94.0" promptText="Username">
|
||||
<font>
|
||||
<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">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<PasswordField fx:id="passwordField" layoutX="69.0" layoutY="138.0" promptText="Password">
|
||||
<font>
|
||||
<Font size="13.0" />
|
||||
</font>
|
||||
</PasswordField>
|
||||
<PasswordField fx:id="passwordField2" layoutX="69.0" layoutY="182.0" promptText="Re-enter password">
|
||||
<font>
|
||||
<Font size="13.0" />
|
||||
</font>
|
||||
</PasswordField>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Hyperlink?>
|
||||
<?import javafx.scene.control.PasswordField?>
|
||||
@@ -10,7 +15,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane fx:controller="greenify.client.controller.UserController" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="574.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="574.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.UserController">
|
||||
<children>
|
||||
<ImageView fitHeight="574.0" fitWidth="943.0" layoutX="-1.0" pickOnBounds="true">
|
||||
<image>
|
||||
@@ -21,8 +26,8 @@
|
||||
<Font name="Californian FB" size="72.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="loginButton" layoutX="419.0" layoutY="274.0" mnemonicParsing="false" prefHeight="26.0" prefWidth="96.0" text="Login" textAlignment="CENTER" onAction="#handleLoginButtonAction"/>
|
||||
<Button fx:id="signupButton" layoutX="49.0" layoutY="52.0" mnemonicParsing="false" prefHeight="6.0" prefWidth="61.0" text="Sign UP"/>
|
||||
<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="49.0" layoutY="52.0" mnemonicParsing="false" onAction="#handleRegisterButtonAction" prefHeight="6.0" prefWidth="61.0" text="Sign up!" />
|
||||
<PasswordField fx:id="passwordField" layoutX="318.0" layoutY="210.0" prefHeight="42.0" prefWidth="303.0" promptText="Password" />
|
||||
<Hyperlink layoutX="392.0" layoutY="308.0" prefHeight="42.0" prefWidth="173.0" text="Forgot Password?" textAlignment="CENTER" textFill="WHITE" textOverrun="LEADING_WORD_ELLIPSIS">
|
||||
<font>
|
||||
|
||||
BIN
src/Client/src/main/resources/registerBackground.png
Normal file
BIN
src/Client/src/main/resources/registerBackground.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
@@ -52,4 +52,3 @@
|
||||
#activitiesButton:pressed {
|
||||
-fx-background-color: #b7e2c2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user