Skip to content
Snippets Groups Projects
Commit 8a012211 authored by Karin Pettersen's avatar Karin Pettersen
Browse files

Added feature to press enter on keyboard when logging in

parent d017e351
No related branches found
No related tags found
No related merge requests found
Showing
with 50 additions and 18 deletions
...@@ -318,6 +318,7 @@ public class LineChartFunctionality { ...@@ -318,6 +318,7 @@ public class LineChartFunctionality {
} }
} }
getRegressionSeriesConfidenceInterval().getData().clear();
Map<Integer, ArrayList<Double>> confidenceIntervalShadow = statistics(multiMap,true); Map<Integer, ArrayList<Double>> confidenceIntervalShadow = statistics(multiMap,true);
for ( Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalShadow.entrySet()) { for ( Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalShadow.entrySet()) {
for (int i = 0; i < entry.getValue().size(); i++) { for (int i = 0; i < entry.getValue().size(); i++) {
......
...@@ -20,6 +20,7 @@ import static com.application.DB.DB.getCurrentDrying; ...@@ -20,6 +20,7 @@ import static com.application.DB.DB.getCurrentDrying;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS; import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.HelpingFunctions.setLoadedData; import static com.application.DB.HelpingFunctions.setLoadedData;
import static com.application.GUI.LineChartFunctionality.*; import static com.application.GUI.LineChartFunctionality.*;
import static com.application.GUI.Panes.CreateLogoBar.getLogin;
import static com.application.Main.*; import static com.application.Main.*;
import static com.application.DB.DB.setInputParameters; import static com.application.DB.DB.setInputParameters;
...@@ -32,7 +33,6 @@ import static com.application.DB.DB.setInputParameters; ...@@ -32,7 +33,6 @@ import static com.application.DB.DB.setInputParameters;
*/ */
public class InputPopup { public class InputPopup {
public static void display() { public static void display() {
Stage window = new Stage(); Stage window = new Stage();
...@@ -132,6 +132,10 @@ public class InputPopup { ...@@ -132,6 +132,10 @@ public class InputPopup {
boolean err = false; boolean err = false;
if(getLogin().getText().equals("Login")){
err = true;
}
// If the input is null, sets the value to be empty // If the input is null, sets the value to be empty
if (treeSpeciesList.getValue() == null) { if (treeSpeciesList.getValue() == null) {
Constants.TREE_SPECIES = ""; Constants.TREE_SPECIES = "";
...@@ -244,7 +248,9 @@ public class InputPopup { ...@@ -244,7 +248,9 @@ public class InputPopup {
ex.printStackTrace(); ex.printStackTrace();
} }
} } else {
NotificationPopUp.displayNotificationWindow("Please login!");
}
} }
); );
......
package com.application.GUI.PopUpWindows; package com.application.GUI.PopUpWindows;
import javafx.event.EventHandler;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -16,7 +19,28 @@ import static com.application.GUI.Panes.CreateLogoBar.getLogin; ...@@ -16,7 +19,28 @@ import static com.application.GUI.Panes.CreateLogoBar.getLogin;
public class LoginPopup { public class LoginPopup {
public static PasswordField PASSWORD_TEXT_FIELD = new PasswordField(); private static PasswordField PASSWORD_TEXT_FIELD = new PasswordField();
private static TextField USERNAME_TEXT_FIELD = new TextField();
/**
* Tries to login
*
* @return a boolean if an error should be thrown or not. True gives no error, false throws an error.
*/
private static boolean loginButtonPressed(){
try {
getAccountInformation(getUsernameTextField().getText(), hashPassword(getPasswordTextField().getText()));
if(getLogin().getText().equals("Admin")) {
LoginPopup.adminPopup();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return !getLogin().getText().equals("Login");
}
public static void login(){ public static void login(){
...@@ -27,36 +51,33 @@ public class LoginPopup { ...@@ -27,36 +51,33 @@ public class LoginPopup {
Label userNameLabel = new Label("Username:"); Label userNameLabel = new Label("Username:");
Label passwordLabel = new Label("Password:"); Label passwordLabel = new Label("Password:");
TextField userNameTextField = new TextField();
getPasswordTextField().clear();
Button closeButton = new Button("Close"); Button closeButton = new Button("Close");
Button loginButton = new Button("Login"); Button loginButton = new Button("Login");
getPasswordTextField().clear();
closeButton.setOnAction(event -> window.close()); closeButton.setOnAction(event -> window.close());
loginButton.setOnAction(event -> {
try { getPasswordTextField().setOnKeyPressed( event -> {
getAccountInformation(userNameTextField.getText(), hashPassword(getPasswordTextField().getText())); if( event.getCode() == KeyCode.ENTER ) {
if(getLogin().getText().equals("Admin")) { if(loginButtonPressed()){
LoginPopup.adminPopup(); window.close();
window.close(); }
}
} catch (Exception e) {
e.printStackTrace();
} }
});
if(!getLogin().getText().equals("Login")){ loginButton.setOnAction(event -> {
if(loginButtonPressed()){
window.close(); window.close();
} }
}); });
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(userNameLabel, userNameTextField, passwordLabel, getPasswordTextField(), loginButton, closeButton); layout.getChildren().addAll(userNameLabel, getUsernameTextField(), passwordLabel, getPasswordTextField(), loginButton, closeButton);
Scene scene = new Scene(layout, 500, 300); Scene scene = new Scene(layout, 500, 300);
scene.getStylesheets().add(InputPopup.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm()); scene.getStylesheets().add(InputPopup.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm());
...@@ -281,4 +302,8 @@ public class LoginPopup { ...@@ -281,4 +302,8 @@ public class LoginPopup {
public static PasswordField getPasswordTextField() { public static PasswordField getPasswordTextField() {
return PASSWORD_TEXT_FIELD; return PASSWORD_TEXT_FIELD;
} }
public static TextField getUsernameTextField() {
return USERNAME_TEXT_FIELD;
}
} }
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File deleted
File deleted
File deleted
File deleted
File deleted
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment