Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mesji/bacheloroppgave_2022
1 result
Show changes
Commits on Source (15)
Showing
with 503 additions and 627 deletions
...@@ -55,16 +55,15 @@ ...@@ -55,16 +55,15 @@
<orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.9" level="project" /> <orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.9" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" />
<orderEntry type="library" name="Maven: org.jblas:jblas:1.2.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.9.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.9.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.9.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.9.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.9.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.9.0-M1" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
Bachelor oppgave vår 2022 #Bachelor Thesis Spring 2022
Awesome teamates:
This application visualize live- and historical data and calculates an estimate based on logistic regression that the drying operator can choose to follow in order to minimize over-drying.
The development team:
* #### Eilert Tunheim
* #### Mads Greni Arnesen
* #### Karin Pettersen
Link to repo: https://git.gvk.idi.ntnu.no/mesji/bacheloroppgave_2022
## Deployment Instructions
The java .jar file is located under `out\artifacts\Bachelor_application`
In order to run the jar file, please use the following command:
`java -jar Bachelor_application.jar`
Karin
Mads
Eilert
...@@ -40,14 +40,8 @@ ...@@ -40,14 +40,8 @@
<artifactId>joda-time</artifactId> <artifactId>joda-time</artifactId>
<version>2.10.14</version> <version>2.10.14</version>
</dependency> </dependency>
<dependency>
<groupId>org.jblas</groupId>
<artifactId>jblas</artifactId>
<version>1.2.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx --> <!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId> <artifactId>javafx</artifactId>
...@@ -72,8 +66,6 @@ ...@@ -72,8 +66,6 @@
<version>RELEASE</version> <version>RELEASE</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
......
...@@ -5,12 +5,24 @@ import com.application.GUI.PopUpWindows.NotificationPopUp; ...@@ -5,12 +5,24 @@ import com.application.GUI.PopUpWindows.NotificationPopUp;
import com.google.cloud.bigquery.FieldValueList; import com.google.cloud.bigquery.FieldValueList;
import com.google.cloud.bigquery.TableResult; import com.google.cloud.bigquery.TableResult;
import static com.application.DB.Constants.*;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
import static com.application.GUI.PopUpWindows.LoginPopup.getPasswordTextField; import static com.application.GUI.PopUpWindows.LoginPopup.getPasswordTextField;
/**
* This class handles the login system and all related functionality
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class AccountHandler { public class AccountHandler {
/**
* This function iterates through the results and sets the information
*
* @param username input parameter for the username
* @param password input parameter for the password
* @throws Exception throws exception if anything goes wrong
*/
public static void getAccountInformation(String username, String password) throws Exception { public static void getAccountInformation(String username, String password) throws Exception {
TableResult result = logIn(username,password); TableResult result = logIn(username,password);
...@@ -20,19 +32,19 @@ public class AccountHandler { ...@@ -20,19 +32,19 @@ public class AccountHandler {
if (row.get("Username").getValue().equals(username)) { if (row.get("Username").getValue().equals(username)) {
CreateLogoBar.getLogin().setText(username); CreateLogoBar.getLogin().setText(username);
setUserName(username); HelpingFunctions.setUserName(username);
if (!row.get("Phone_no").isNull()) { if (!row.get("Phone_no").isNull()) {
setPhoneNo(row.get("Phone_no").getStringValue()); HelpingFunctions.setPhoneNo(row.get("Phone_no").getStringValue());
} }
if (!row.get("First_name").isNull()) { if (!row.get("First_name").isNull()) {
setFirstName(row.get("First_name").getStringValue()); HelpingFunctions.setFirstName(row.get("First_name").getStringValue());
} }
if (!row.get("Last_name").isNull()) { if (!row.get("Last_name").isNull()) {
setLastName(row.get("Last_name").getStringValue()); HelpingFunctions.setLastName(row.get("Last_name").getStringValue());
} }
if (!row.get("Admin").isNull()) { if (!row.get("Admin").isNull()) {
setIsAdmin(row.get("Admin").getBooleanValue()); HelpingFunctions.setIsAdmin(row.get("Admin").getBooleanValue());
} }
} }
} }
...@@ -42,6 +54,14 @@ public class AccountHandler { ...@@ -42,6 +54,14 @@ public class AccountHandler {
} }
} }
/**
* This function creates the login sql statement and returns a TableResult to be iterated through
*
* @param username input parameter for the username
* @param password input parameter for the password
* @return a TableResult that can be iterated through
* @throws Exception throws exception if anything goes wrong
*/
public static TableResult logIn(String username, String password) throws Exception { public static TableResult logIn(String username, String password) throws Exception {
// Sqlstatement // Sqlstatement
...@@ -56,6 +76,13 @@ public class AccountHandler { ...@@ -56,6 +76,13 @@ public class AccountHandler {
return HelpingFunctions.createQueryJob(sqlStatement); return HelpingFunctions.createQueryJob(sqlStatement);
} }
/**
* Retrieves information regarding an account based on the username input
*
* @param username input parameter for the username
* @return a TableResult that can be iterated through
* @throws Exception throws exception if anything goes wrong
*/
public static TableResult getAccount(String username) throws Exception { public static TableResult getAccount(String username) throws Exception {
// Sqlstatement // Sqlstatement
...@@ -70,6 +97,18 @@ public class AccountHandler { ...@@ -70,6 +97,18 @@ public class AccountHandler {
return HelpingFunctions.createQueryJob(sqlStatement); return HelpingFunctions.createQueryJob(sqlStatement);
} }
/**
* This function takes a number of parameters as input and creates a user in the database
*
* @param firstName input parameter for firstname
* @param lastName input parameter for lastName
* @param phoneNo input parameter for phoneNo
* @param username input parameter for username
* @param password input parameter for password
* @param isAdmin input parameter from the checkbox is the account is admin or not
* @return a boolean if the user was added or not
* @throws Exception throws exception if anything goes wrong
*/
public static boolean addUser(String firstName, String lastName, String phoneNo, String username, String password, boolean isAdmin) throws Exception { public static boolean addUser(String firstName, String lastName, String phoneNo, String username, String password, boolean isAdmin) throws Exception {
if(getAccount(username).getTotalRows() == 0) { if(getAccount(username).getTotalRows() == 0) {
...@@ -87,6 +126,13 @@ public class AccountHandler { ...@@ -87,6 +126,13 @@ public class AccountHandler {
} }
} }
/**
* This function deletes an account based on the username input parameter
*
* @param username input parameter for username
* @return a boolean if the user was deleted or not
* @throws Exception throws exception if anything goes wrong
*/
public static boolean deleteUser(String username) throws Exception { public static boolean deleteUser(String username) throws Exception {
if(getAccount(username).getTotalRows() != 0){ if(getAccount(username).getTotalRows() != 0){
...@@ -102,5 +148,4 @@ public class AccountHandler { ...@@ -102,5 +148,4 @@ public class AccountHandler {
return false; return false;
} }
} }
} }
package com.application.DB; package com.application.DB;
/**
* This class contain a number of constants used throughout the application
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class Constants { public class Constants {
// Key name file for the database access
public static String KEY_FILE_NAME = "sf-drying-optimization-8a2e1b7ffc14.json";
// Time related constants // Time related constants
public static String START_TIME = ""; public static String START_TIME = "";
public static String STOP_TIME = ""; public static String STOP_TIME = "";
...@@ -22,60 +25,9 @@ public class Constants { ...@@ -22,60 +25,9 @@ public class Constants {
public static String SAWSET = ""; public static String SAWSET = "";
public static String MOISTURE_GOAL = ""; public static String MOISTURE_GOAL = "";
// Number of manual moisture checks
public static int NUMBER_OF_CHECKS = 1;
// Max number of input characters for sql injection prevention
public static int MAX_USER_INPUT_CHARACTERS = 10;
// Boolean constants to toggle default launch selected or not for checkboxes for showing graphs // Boolean constants to toggle default launch selected or not for checkboxes for showing graphs
public static boolean DEFAULT_IS_SELECTED_LIVE_DATA = true; public static boolean DEFAULT_IS_SELECTED_LIVE_DATA = true;
public static boolean DEFAULT_IS_SELECTED_REGRESSION = true; public static boolean DEFAULT_IS_SELECTED_REGRESSION = true;
public static boolean DEFAULT_IS_SELECTED_REGRESSION_SHADOW = false; public static boolean DEFAULT_IS_SELECTED_REGRESSION_SHADOW = false;
public static boolean DEFAULT_IS_SELECTED_PREVIOUS_DATA = true; public static boolean DEFAULT_IS_SELECTED_PREVIOUS_DATA = true;
// Account constants
private static boolean isAdmin = false;
private static String firstName;
private static String lastName;
private static String userName;
private static String phoneNo;
public static String getUserName() { return userName;}
public static void setUserName(String userName) {
Constants.userName = userName;
}
public static String getPhoneNo() {
return phoneNo;
}
public static void setPhoneNo(String phoneNo) {
Constants.phoneNo = phoneNo;
}
public static boolean isIsAdmin() {
return isAdmin;
}
public static void setIsAdmin(boolean isAdmin) {
Constants.isAdmin = isAdmin;
}
public static String getFirstName() {
return firstName;
}
public static void setFirstName(String firstName) {
Constants.firstName = firstName;
}
public static String getLastName() {
return lastName;
}
public static void setLastName(String lastName) {
Constants.lastName = lastName;
}
} }
...@@ -13,36 +13,28 @@ import static com.application.DB.HelpingFunctions.getNoOfChambers; ...@@ -13,36 +13,28 @@ import static com.application.DB.HelpingFunctions.getNoOfChambers;
* This class is responsible for handling database related activities * This class is responsible for handling database related activities
* *
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen * @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0 * @version 1.0.0
*/ */
public class DB { public class DB {
/** /**
* Launching the functions * This function gathers all input parameters from the user and search for data
* *
* @param args default param * @return a map containing drying cycles
* @throws Exception throws exception in case of error * @throws Exception throws exception if error occurs
*/ */
public static void main(String[] args) throws Exception {
//getKwh();
//getName();
//getZeroPointDate();
//System.out.println(setInputParameters());
//getNoOfChambers();
}
public static Map<Integer, Map<String, Number>> setInputParameters() throws Exception { public static Map<Integer, Map<String, Number>> setInputParameters() throws Exception {
// Map to store data
Map<Integer, Map<String, Number>> allDryingPeriods = new HashMap<>(); Map<Integer, Map<String, Number>> allDryingPeriods = new HashMap<>();
// Variables to indicate if the parameters have been deleted or not
boolean sawsetRemoved = false; boolean sawsetRemoved = false;
boolean treespeciesRemoved = false; boolean treespeciesRemoved = false;
boolean dimensionsRemoved = false; boolean dimensionsRemoved = false;
boolean moistureRemoved = false; boolean moistureRemoved = false;
// Defining variables
HashMap<java.lang.String, java.lang.String> locationTables = null; HashMap<java.lang.String, java.lang.String> locationTables = null;
ArrayList<Integer> valmeticsChamberIDS = null; ArrayList<Integer> valmeticsChamberIDS = null;
ArrayList<Integer> kwhChamberIDS = null; ArrayList<Integer> kwhChamberIDS = null;
...@@ -76,11 +68,13 @@ public class DB { ...@@ -76,11 +68,13 @@ public class DB {
getNoOfChambers(); getNoOfChambers();
int chamberNo = 1; int chamberNo = 1;
// While loop that check for data
while(true){ while(true){
// Map to store data
Map<Integer, Map<String, Number>> intermediateHashMap = new HashMap<>(); Map<Integer, Map<String, Number>> intermediateHashMap = new HashMap<>();
// Iterating through all the sawmills
for (HashMap.Entry<Integer, HashMap<String, HashMap<String, String>>> location : Settings.getSawmills().entrySet()) { for (HashMap.Entry<Integer, HashMap<String, HashMap<String, String>>> location : Settings.getSawmills().entrySet()) {
// Clears the extraInputs variable // Clears the extraInputs variable
...@@ -89,12 +83,9 @@ public class DB { ...@@ -89,12 +83,9 @@ public class DB {
System.out.printf("\nLocation ID: \t%s\t\t\tRest of map: \t%s\n", location.getKey(), location.getValue()); System.out.printf("\nLocation ID: \t%s\t\t\tRest of map: \t%s\n", location.getKey(), location.getValue());
System.out.println("Number of sawmills: "+ Settings.getSawmills().size()); System.out.println("Number of sawmills: "+ Settings.getSawmills().size());
//allDryingPeriods = new TreeMap<>();
locationID = location.getKey(); locationID = location.getKey();
//System.out.println(location.getValue()); // If the location is 124, "Furu" is stored as "Fura" in the database, swedish
if (location.getKey() == 124) { if (location.getKey() == 124) {
// If location is Valasen, then the database stores furu as fura, swedish. // If location is Valasen, then the database stores furu as fura, swedish.
if (Constants.TREE_SPECIES.equalsIgnoreCase("Furu")) { if (Constants.TREE_SPECIES.equalsIgnoreCase("Furu")) {
...@@ -226,6 +217,7 @@ public class DB { ...@@ -226,6 +217,7 @@ public class DB {
} }
} }
// Prints all the drying periods
System.out.println(allDryingPeriods.size()); System.out.println(allDryingPeriods.size());
for (Map.Entry<Integer, Map<String, Number>> entry : allDryingPeriods.entrySet()) { for (Map.Entry<Integer, Map<String, Number>> entry : allDryingPeriods.entrySet()) {
System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n", entry.getKey(), entry.getValue()); System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n", entry.getKey(), entry.getValue());
...@@ -283,7 +275,7 @@ public class DB { ...@@ -283,7 +275,7 @@ public class DB {
finalResults.put(index, sortedData); finalResults.put(index, sortedData);
index += 1; index += 1;
// entry.value burde matche med en av de og går igjennom alle // checks for manual moisture
for (Map.Entry<String, String> moistureEntry : HelpingFunctions.getManMoist().entrySet()) { for (Map.Entry<String, String> moistureEntry : HelpingFunctions.getManMoist().entrySet()) {
if(moistureEntry.getKey().equals(entry.getValue())){ if(moistureEntry.getKey().equals(entry.getValue())){
...@@ -304,17 +296,7 @@ public class DB { ...@@ -304,17 +296,7 @@ public class DB {
// Defining a treemap to sort the data incrementally // Defining a treemap to sort the data incrementally
NavigableMap<Integer, Map<String, Number>> sortedFinalResults = new TreeMap<>(finalResults); NavigableMap<Integer, Map<String, Number>> sortedFinalResults = new TreeMap<>(finalResults);
for (Map.Entry<Integer, Map<String, Number>> entry : sortedFinalResults.entrySet()) { // Prints the values
Map<String, Number> data = entry.getValue();
for (Map.Entry<String, Number> moistureEntry : data.entrySet()) {
//System.out.println("Data key: "+moistureEntry.getKey()); // Key = datetime: 2022-01-18 20:23:36
//System.out.println("Data Value: "+moistureEntry.getValue()); // Value = kwh: 5422
}
}
for (Map.Entry<Integer, Map<String, Number>> entry : sortedFinalResults.entrySet()) { for (Map.Entry<Integer, Map<String, Number>> entry : sortedFinalResults.entrySet()) {
System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n", entry.getKey(), entry.getValue()); System.out.printf("Timestamp: \t%s\t\t\tkWh: \t%s\n", entry.getKey(), entry.getValue());
} }
...@@ -388,8 +370,6 @@ public class DB { ...@@ -388,8 +370,6 @@ public class DB {
kilinID += 1; kilinID += 1;
} }
// Retrieves the results from the queryjob // Retrieves the results from the queryjob
TableResult result = HelpingFunctions.createQueryJob(sqlStatement); TableResult result = HelpingFunctions.createQueryJob(sqlStatement);
...@@ -420,11 +400,6 @@ public class DB { ...@@ -420,11 +400,6 @@ public class DB {
} }
} }
//System.out.println("Start: "+row.get("DryingStarted").getTimestampValue());
//System.out.println("Stop: "+row.get("DryingCompleted").getTimestampValue());
// Retrieving the data // Retrieving the data
// DryingStarted: // DryingStarted:
if(!row.get("DryingStarted").isNull()){ if(!row.get("DryingStarted").isNull()){
...@@ -451,14 +426,8 @@ public class DB { ...@@ -451,14 +426,8 @@ public class DB {
} }
else formatedInTidTork = row.get("DryingStarted").getValue().toString(); else formatedInTidTork = row.get("DryingStarted").getValue().toString();
} }
// Checks if response is given in a string date format
//if(row.get("DryingStarted").getValue().equals(Long.parseLong(row.get("DryingStarted").getValue().toString()))) {
} }
// CalculatedStop:
// DryingCompleted: // DryingCompleted:
// Check if response is given in millis // Check if response is given in millis
try{ try{
...@@ -481,8 +450,6 @@ public class DB { ...@@ -481,8 +450,6 @@ public class DB {
} }
// Getting manual measurement: // Getting manual measurement:
// Adding days to search between // Adding days to search between
String date = formatedUtTidTork.split(" ")[0]; String date = formatedUtTidTork.split(" ")[0];
...@@ -529,18 +496,11 @@ public class DB { ...@@ -529,18 +496,11 @@ public class DB {
*/ */
//System.out.println("Inn formated: "+formatedInTidTork);
//System.out.println("Ut formated: "+formatedUtTidTork+"\n");
// Checks if intidtork or outtidtork is empty, if so they are ignored and not added to the list // Checks if intidtork or outtidtork is empty, if so they are ignored and not added to the list
if (!formatedInTidTork.isEmpty() && !formatedUtTidTork.isEmpty()){ if (!formatedInTidTork.isEmpty() && !formatedUtTidTork.isEmpty()){
// Adds the data to the dates map // Adds the data to the dates map
dates.put(formatedInTidTork,formatedUtTidTork); dates.put(formatedInTidTork,formatedUtTidTork);
} }
//System.out.printf("%s\t\t\t%s\n",formatedInTidTork,formatedUtTidTork);
} }
// Defining a treemap to sort the data incrementally // Defining a treemap to sort the data incrementally
...@@ -566,6 +526,12 @@ public class DB { ...@@ -566,6 +526,12 @@ public class DB {
} }
/**
* This function push the manual moisture level
*
* @param moisture input parameter for measured value
* @throws Exception throws exception in case of error
*/
public static void pushManMoisture(String moisture) throws Exception { public static void pushManMoisture(String moisture) throws Exception {
String startTime = null; String startTime = null;
...@@ -606,7 +572,7 @@ public class DB { ...@@ -606,7 +572,7 @@ public class DB {
// Sqlstatement // Sqlstatement
final String sqlStatement = final String sqlStatement =
"INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + MAN_MOISTURE_TABLE + "(moisture,tree_species,dimensions,sawset,moisture_goal,no_moisture_check,start_time,stop_time,finished) " + "INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + MAN_MOISTURE_TABLE + "(moisture,tree_species,dimensions,sawset,moisture_goal,no_moisture_check,start_time,stop_time,finished) " +
"VALUES("+moisture+","+treeSpecies+","+dimensions+","+sawset+","+moistureGoal+","+ Constants.NUMBER_OF_CHECKS+","+startTime+","+stopTime+","+IS_FINISHED+") "; "VALUES("+moisture+","+treeSpecies+","+dimensions+","+sawset+","+moistureGoal+","+ NUMBER_OF_CHECKS+","+startTime+","+stopTime+","+IS_FINISHED+") ";
System.out.println(sqlStatement); System.out.println(sqlStatement);
...@@ -639,11 +605,8 @@ public class DB { ...@@ -639,11 +605,8 @@ public class DB {
// Retrieves the results from the queryjob // Retrieves the results from the queryjob
TableResult result = HelpingFunctions.createQueryJob(sqlStatement); TableResult result = HelpingFunctions.createQueryJob(sqlStatement);
//System.out.println("InTidTork\t\t\tUtTidTork");
// Iterating through the results // Iterating through the results
HelpingFunctions.iterateKwhValues(data, result, KWH_NAME_PARAMETER, KWH_TIMESTAMP_NAME_PARAMETER); HelpingFunctions.iterateKwhValues(data, result, KWH_NAME_PARAMETER, KWH_TIMESTAMP_NAME_PARAMETER);
return new TreeMap<>(data); return new TreeMap<>(data);
} }
} }
...@@ -4,7 +4,6 @@ import com.application.GUI.PopUpWindows.NotificationPopUp; ...@@ -4,7 +4,6 @@ import com.application.GUI.PopUpWindows.NotificationPopUp;
import com.google.auth.oauth2.GoogleCredentials; import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.bigquery.*; import com.google.cloud.bigquery.*;
import io.opencensus.internal.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -13,18 +12,32 @@ import java.util.HashMap; ...@@ -13,18 +12,32 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import static com.application.DB.Constants.KEY_FILE_NAME;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
/**
* This class contain a number of helping function that is accessed throughout the application
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class HelpingFunctions { public class HelpingFunctions {
// Key name file for the database access
public static String KEY_FILE_NAME = "sf-drying-optimization-8a2e1b7ffc14.json";
// Map to store manual moisture
static Map<String,String> manMoist = new HashMap<>(); static Map<String,String> manMoist = new HashMap<>();
// Account constants
static boolean isAdmin = false;
static String firstName;
static String lastName;
static String userName;
static String phoneNo;
/** /**
* Creates a simple date format to use for converting millis in numbers to a usefull date format * Creates a simple date format to use for converting millis in numbers to a useful date format
* *
* @return returns the date format * @return returns the date format
*/ */
...@@ -150,6 +163,11 @@ public class HelpingFunctions { ...@@ -150,6 +163,11 @@ public class HelpingFunctions {
} }
} }
/**
* This function gets the total number of chambers that are searched for
*
* @return an integer indecating the total number of chambers
*/
public static int getNoOfChambers(){ public static int getNoOfChambers(){
int valmeticsChamberIDS = 0; int valmeticsChamberIDS = 0;
int kwhChamberIDS = 0; int kwhChamberIDS = 0;
...@@ -170,6 +188,24 @@ public class HelpingFunctions { ...@@ -170,6 +188,24 @@ public class HelpingFunctions {
return noOfChambers; return noOfChambers;
} }
/**
* This function handles input validation
*
* @param input string of input parameter from the user to be checked
* @return a boolean to indicate if the input is accepted or not
*/
public static boolean isValidInput (String input){
if(input.length() > MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
return true;
}
else if(input.toLowerCase().contains("union")){
NotificationPopUp.displayNotificationWindow("Keyword: 'UNION' is not allowed");
return true;
}
else return false;
}
public static boolean isLoadedData() { public static boolean isLoadedData() {
return Constants.LOADED_DATA; return Constants.LOADED_DATA;
} }
...@@ -178,21 +214,41 @@ public class HelpingFunctions { ...@@ -178,21 +214,41 @@ public class HelpingFunctions {
Constants.LOADED_DATA = loadedData; Constants.LOADED_DATA = loadedData;
} }
public static String getUserName() { return userName;}
public static boolean isValidInput (String input){ public static void setUserName(String userName) {
if(input.length() > Constants.MAX_USER_INPUT_CHARACTERS) { HelpingFunctions.userName = userName;
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
return true;
} }
else if(input.contains("UNION")){
NotificationPopUp.displayNotificationWindow("Keyword: 'UNION' is not allowed"); public static String getPhoneNo() {
return true; return phoneNo;
} }
else return false;
}
public static void setPhoneNo(String phoneNo) {
HelpingFunctions.phoneNo = phoneNo;
}
public static boolean isIsAdmin() {
return isAdmin;
}
public static void setIsAdmin(boolean isAdmin) {
HelpingFunctions.isAdmin = isAdmin;
}
public static String getFirstName() {
return firstName;
}
public static void setFirstName(String firstName) {
HelpingFunctions.firstName = firstName;
}
public static String getLastName() {
return lastName;
}
public static void setLastName(String lastName) {
HelpingFunctions.lastName = lastName;
}
} }
...@@ -5,7 +5,10 @@ import java.util.Arrays; ...@@ -5,7 +5,10 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
/** /**
* This class contains constants to be used related to database activities * This class contains changeable settings for the application
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/ */
public final class Settings { public final class Settings {
...@@ -13,6 +16,11 @@ public final class Settings { ...@@ -13,6 +16,11 @@ public final class Settings {
// Empty constructor // Empty constructor
} }
// Number of manual moisture checks
public static int NUMBER_OF_CHECKS = 1;
// Max number of input characters for sql injection prevention
public static int MAX_USER_INPUT_CHARACTERS = 15;
// Number of wanted drying periods // Number of wanted drying periods
public static int NUMBER_OF_PERIODS = 2; public static int NUMBER_OF_PERIODS = 2;
......
...@@ -8,6 +8,12 @@ import javafx.scene.control.CheckBox; ...@@ -8,6 +8,12 @@ import javafx.scene.control.CheckBox;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
/**
* This class creates the bottombar
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class CreateBottomBar { public class CreateBottomBar {
private final Main main; private final Main main;
...@@ -15,6 +21,11 @@ public class CreateBottomBar { ...@@ -15,6 +21,11 @@ public class CreateBottomBar {
this.main = main; this.main = main;
} }
/**
* This function create the bottombar
*
* @return the finished bottombar
*/
public HBox createBottomBar() { public HBox createBottomBar() {
HBox hBox = new HBox(); HBox hBox = new HBox();
...@@ -72,7 +83,7 @@ public class CreateBottomBar { ...@@ -72,7 +83,7 @@ public class CreateBottomBar {
} }
}); });
// Adds all the components to the HBox
hBox.getChildren().addAll(liveDataText, Main.getLiveDataBox(), regressionText, Main.getRegressionBox(), regressionConfidenceIntervalText, Main.getRegressionConfidenceIntervalBox(), previousText, Main.getPreviousBox()); hBox.getChildren().addAll(liveDataText, Main.getLiveDataBox(), regressionText, Main.getRegressionBox(), regressionConfidenceIntervalText, Main.getRegressionConfidenceIntervalBox(), previousText, Main.getPreviousBox());
hBox.setAlignment(Pos.CENTER_RIGHT); hBox.setAlignment(Pos.CENTER_RIGHT);
hBox.setSpacing(5); hBox.setSpacing(5);
......
...@@ -11,17 +11,24 @@ import javafx.scene.layout.Region; ...@@ -11,17 +11,24 @@ import javafx.scene.layout.Region;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import static com.application.DB.Constants.isIsAdmin; import static com.application.DB.HelpingFunctions.isIsAdmin;
/**
* This class creates the logobar
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class CreateLogoBar { public class CreateLogoBar {
// The login button
private static Button login = new Button("Login"); private static Button login = new Button("Login");
/** /**
* This function imports the logos and defines the alignments * This function imports the logos and defines the alignments
* *
* @return a logoBar containing the logos in proper alignments * @return a logoBar containing the logos in proper alignments
* @throws FileNotFoundException * @throws FileNotFoundException throws exception if an error occurs
*/ */
public HBox createLogoBar() throws FileNotFoundException { public HBox createLogoBar() throws FileNotFoundException {
// Defining the image paths // Defining the image paths
......
...@@ -8,6 +8,12 @@ import javafx.scene.control.CheckMenuItem; ...@@ -8,6 +8,12 @@ import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Menu; import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem; import javafx.scene.control.MenuItem;
/**
* This class creates the menubar
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class CreateMenuBar { public class CreateMenuBar {
private final Main main; private final Main main;
...@@ -19,7 +25,7 @@ public class CreateMenuBar { ...@@ -19,7 +25,7 @@ public class CreateMenuBar {
* Creates the menubar with buttons. * Creates the menubar with buttons.
* Defines each action when button is clicked. * Defines each action when button is clicked.
* *
* @return MenuBar as a HBox * @return MenuBar as a menubar
*/ */
public javafx.scene.control.MenuBar createMenuBar() { public javafx.scene.control.MenuBar createMenuBar() {
...@@ -31,19 +37,23 @@ public class CreateMenuBar { ...@@ -31,19 +37,23 @@ public class CreateMenuBar {
Menu menuView = new Menu("View"); Menu menuView = new Menu("View");
Menu menuHelp = new Menu("Help"); Menu menuHelp = new Menu("Help");
// Adds menu item for file
MenuItem menuFileExit = new MenuItem("Exit"); MenuItem menuFileExit = new MenuItem("Exit");
menuFileExit.setOnAction(event -> Main.exitApplication()); menuFileExit.setOnAction(event -> Main.exitApplication());
// Adds menu item for view
Main.setMenuViewLiveData(new CheckMenuItem("Live Data")); Main.setMenuViewLiveData(new CheckMenuItem("Live Data"));
main.setMenuViewRegression(new CheckMenuItem("Regression")); main.setMenuViewRegression(new CheckMenuItem("Regression"));
main.setMenuViewRegressionShadow(new CheckMenuItem("Regression Shadow")); main.setMenuViewRegressionShadow(new CheckMenuItem("Regression Shadow"));
main.setMenuViewPreviousData(new CheckMenuItem("Previous Data")); main.setMenuViewPreviousData(new CheckMenuItem("Previous Data"));
// Sets the default values
Main.getMenuViewLiveData().setSelected(Constants.DEFAULT_IS_SELECTED_LIVE_DATA); Main.getMenuViewLiveData().setSelected(Constants.DEFAULT_IS_SELECTED_LIVE_DATA);
Main.getMenuViewRegression().setSelected(Constants.DEFAULT_IS_SELECTED_REGRESSION); Main.getMenuViewRegression().setSelected(Constants.DEFAULT_IS_SELECTED_REGRESSION);
Main.getMenuViewRegressionShadow().setSelected(Constants.DEFAULT_IS_SELECTED_REGRESSION_SHADOW); Main.getMenuViewRegressionShadow().setSelected(Constants.DEFAULT_IS_SELECTED_REGRESSION_SHADOW);
Main.getMenuViewPreviousData().setSelected(Constants.DEFAULT_IS_SELECTED_PREVIOUS_DATA); Main.getMenuViewPreviousData().setSelected(Constants.DEFAULT_IS_SELECTED_PREVIOUS_DATA);
// Sets the updated value when the box is checked or unchecked
Main.getMenuViewLiveData().setOnAction(event -> { Main.getMenuViewLiveData().setOnAction(event -> {
if (Main.getMenuViewLiveData().isSelected()) { if (Main.getMenuViewLiveData().isSelected()) {
LineChartFunctionality.setPrintLiveData(true); LineChartFunctionality.setPrintLiveData(true);
...@@ -53,6 +63,8 @@ public class CreateMenuBar { ...@@ -53,6 +63,8 @@ public class CreateMenuBar {
LineChartFunctionality.printGraphs(); LineChartFunctionality.printGraphs();
} }
}); });
// Sets the updated value when the box is checked or unchecked
Main.getMenuViewRegression().setOnAction(event -> { Main.getMenuViewRegression().setOnAction(event -> {
if (Main.getMenuViewRegression().isSelected()) { if (Main.getMenuViewRegression().isSelected()) {
LineChartFunctionality.setPrintRegression(true); LineChartFunctionality.setPrintRegression(true);
...@@ -62,6 +74,8 @@ public class CreateMenuBar { ...@@ -62,6 +74,8 @@ public class CreateMenuBar {
LineChartFunctionality.printGraphs(); LineChartFunctionality.printGraphs();
} }
}); });
// Sets the updated value when the box is checked or unchecked
Main.getMenuViewRegressionShadow().setOnAction(event -> { Main.getMenuViewRegressionShadow().setOnAction(event -> {
if (Main.getMenuViewRegressionShadow().isSelected()) { if (Main.getMenuViewRegressionShadow().isSelected()) {
LineChartFunctionality.setPrintRegressionConfidenceInterval(true); LineChartFunctionality.setPrintRegressionConfidenceInterval(true);
...@@ -71,6 +85,8 @@ public class CreateMenuBar { ...@@ -71,6 +85,8 @@ public class CreateMenuBar {
LineChartFunctionality.printGraphs(); LineChartFunctionality.printGraphs();
} }
}); });
// Sets the updated value when the box is checked or unchecked
Main.getMenuViewPreviousData().setOnAction(event -> { Main.getMenuViewPreviousData().setOnAction(event -> {
if (Main.getMenuViewPreviousData().isSelected()) { if (Main.getMenuViewPreviousData().isSelected()) {
LineChartFunctionality.setPrintPreviousData(true); LineChartFunctionality.setPrintPreviousData(true);
...@@ -81,12 +97,13 @@ public class CreateMenuBar { ...@@ -81,12 +97,13 @@ public class CreateMenuBar {
} }
}); });
// Adds menu item for Help
MenuItem aboutUs = new MenuItem("About Us"); MenuItem aboutUs = new MenuItem("About Us");
aboutUs.setOnAction(event -> getAboutUs()); aboutUs.setOnAction(event -> getAboutUs());
MenuItem help = new MenuItem("Help"); MenuItem help = new MenuItem("Help");
help.setOnAction(event -> getHelp()); help.setOnAction(event -> getHelp());
// Adds all components to the menus
menuFile.getItems().addAll(menuFileExit); menuFile.getItems().addAll(menuFileExit);
menuView.getItems().addAll(Main.getMenuViewLiveData(), Main.getMenuViewRegression(), Main.getMenuViewRegressionShadow(), Main.getMenuViewPreviousData()); menuView.getItems().addAll(Main.getMenuViewLiveData(), Main.getMenuViewRegression(), Main.getMenuViewRegressionShadow(), Main.getMenuViewPreviousData());
menuHelp.getItems().addAll(aboutUs, help); menuHelp.getItems().addAll(aboutUs, help);
......
...@@ -20,16 +20,28 @@ import static com.application.GUI.LineChartFunctionality.getDataPointsXAxis; ...@@ -20,16 +20,28 @@ import static com.application.GUI.LineChartFunctionality.getDataPointsXAxis;
import static com.application.GUI.LineChartFunctionality.getLiveData; import static com.application.GUI.LineChartFunctionality.getLiveData;
import static java.util.logging.Level.SEVERE; import static java.util.logging.Level.SEVERE;
/**
* This class creates the sidebar
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class CreateSideBar { public class CreateSideBar {
public CreateSideBar(Main main) { public CreateSideBar(Main main) {
} }
/**
* This function creates the sidebar
*
* @return the finished sidebar
*/
public VBox createSideBar() { public VBox createSideBar() {
// Creating a vbox // Creating a vbox
VBox sideBarVBox = new VBox(); VBox sideBarVBox = new VBox();
// Defining label and text-field for tree species
Label treeSpeciesLabel = new Label("Tree Species"); Label treeSpeciesLabel = new Label("Tree Species");
treeSpeciesLabel.setId("sideBarLabelText"); treeSpeciesLabel.setId("sideBarLabelText");
Main.setTreeSpeciesText(new TextField()); Main.setTreeSpeciesText(new TextField());
...@@ -38,6 +50,7 @@ public class CreateSideBar { ...@@ -38,6 +50,7 @@ public class CreateSideBar {
Main.getTreeSpeciesText().setText(Constants.TREE_SPECIES); Main.getTreeSpeciesText().setText(Constants.TREE_SPECIES);
Main.getTreeSpeciesText().setEditable(false); Main.getTreeSpeciesText().setEditable(false);
// Defining label and text-field for dimensions
Label dimensionsLabel = new Label("Width x Height"); Label dimensionsLabel = new Label("Width x Height");
dimensionsLabel.setId("sideBarLabelText"); dimensionsLabel.setId("sideBarLabelText");
Main.setDimensionsText(new TextField()); Main.setDimensionsText(new TextField());
...@@ -46,6 +59,7 @@ public class CreateSideBar { ...@@ -46,6 +59,7 @@ public class CreateSideBar {
Main.getDimensionsText().setText(Constants.DIMENSIONS); Main.getDimensionsText().setText(Constants.DIMENSIONS);
Main.getDimensionsText().setEditable(false); Main.getDimensionsText().setEditable(false);
// Defining label and text-field for sawset
Label sawsetLabel = new Label("Sawset"); Label sawsetLabel = new Label("Sawset");
sawsetLabel.setId("sideBarLabelText"); sawsetLabel.setId("sideBarLabelText");
Main.setSawsetText(new TextField()); Main.setSawsetText(new TextField());
...@@ -54,6 +68,7 @@ public class CreateSideBar { ...@@ -54,6 +68,7 @@ public class CreateSideBar {
Main.getSawsetText().setText(Constants.SAWSET); Main.getSawsetText().setText(Constants.SAWSET);
Main.getSawsetText().setEditable(false); Main.getSawsetText().setEditable(false);
// Defining label and text-field for moisture goal
Label moistureGoalLabel = new Label("Moisture Goal"); Label moistureGoalLabel = new Label("Moisture Goal");
moistureGoalLabel.setId("sideBarLabelText"); moistureGoalLabel.setId("sideBarLabelText");
Main.setMoistureGoalText(new TextField()); Main.setMoistureGoalText(new TextField());
...@@ -62,6 +77,7 @@ public class CreateSideBar { ...@@ -62,6 +77,7 @@ public class CreateSideBar {
Main.getMoistureGoalText().setText(Constants.MOISTURE_GOAL); Main.getMoistureGoalText().setText(Constants.MOISTURE_GOAL);
Main.getMoistureGoalText().setEditable(false); Main.getMoistureGoalText().setEditable(false);
// Defining label and text-field timeleft
Label timeLeftLabel = new Label("Time Left"); Label timeLeftLabel = new Label("Time Left");
timeLeftLabel.setId("sideBarLabelText"); timeLeftLabel.setId("sideBarLabelText");
Main.setTimeLeftText(new TextField()); Main.setTimeLeftText(new TextField());
...@@ -70,6 +86,7 @@ public class CreateSideBar { ...@@ -70,6 +86,7 @@ public class CreateSideBar {
Main.getTimeLeftText().setText(Constants.TIME_LEFT); Main.getTimeLeftText().setText(Constants.TIME_LEFT);
Main.getTimeLeftText().setEditable(false); Main.getTimeLeftText().setEditable(false);
// Define buttons
Button inputParametersButton = new Button("Input Parameters"); Button inputParametersButton = new Button("Input Parameters");
inputParametersButton.setId("sideBarButtonInputParameters"); inputParametersButton.setId("sideBarButtonInputParameters");
inputParametersButton.setOnAction(e -> InputPopup.display()); inputParametersButton.setOnAction(e -> InputPopup.display());
...@@ -89,6 +106,7 @@ public class CreateSideBar { ...@@ -89,6 +106,7 @@ public class CreateSideBar {
ringProgressIndicator.makeIndeterminate(); ringProgressIndicator.makeIndeterminate();
ringProgressIndicator.setId("progressBar"); ringProgressIndicator.setId("progressBar");
// Defines thread for updating the circular progressbar
class WorkerThread extends Thread{ class WorkerThread extends Thread{
RingProgressIndicator rpi; RingProgressIndicator rpi;
int progress = 0; int progress = 0;
...@@ -126,10 +144,9 @@ public class CreateSideBar { ...@@ -126,10 +144,9 @@ public class CreateSideBar {
} }
} }
} }
new WorkerThread(ringProgressIndicator).start(); new WorkerThread(ringProgressIndicator).start();
// Adds all the components to the VBox
sideBarVBox.getChildren().addAll(ringProgressIndicator, treeSpeciesLabel, Main.getTreeSpeciesText(), dimensionsLabel, Main.getDimensionsText(), sideBarVBox.getChildren().addAll(ringProgressIndicator, treeSpeciesLabel, Main.getTreeSpeciesText(), dimensionsLabel, Main.getDimensionsText(),
sawsetLabel, Main.getSawsetText(), moistureGoalLabel, Main.getMoistureGoalText(), timeLeftLabel, Main.getTimeLeftText(), inputParametersButton, finishButton, exitButton); sawsetLabel, Main.getSawsetText(), moistureGoalLabel, Main.getMoistureGoalText(), timeLeftLabel, Main.getTimeLeftText(), inputParametersButton, finishButton, exitButton);
......
...@@ -17,7 +17,6 @@ import java.util.Map; ...@@ -17,7 +17,6 @@ import java.util.Map;
import static com.application.DB.HelpingFunctions.isValidInput; import static com.application.DB.HelpingFunctions.isValidInput;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
import static com.application.DB.DB.getCurrentDrying; import static com.application.DB.DB.getCurrentDrying;
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.GUI.Panes.CreateLogoBar.getLogin;
...@@ -33,6 +32,9 @@ import static com.application.DB.DB.setInputParameters; ...@@ -33,6 +32,9 @@ import static com.application.DB.DB.setInputParameters;
*/ */
public class InputPopup { public class InputPopup {
/**
* This function displays the input parameter window
*/
public static void display() { public static void display() {
Stage window = new Stage(); Stage window = new Stage();
...@@ -128,52 +130,44 @@ public class InputPopup { ...@@ -128,52 +130,44 @@ public class InputPopup {
Constants.MOISTURE_GOAL = moistureList.getValue(); Constants.MOISTURE_GOAL = moistureList.getValue();
} }
boolean err = false; boolean err = false;
// If an account is not logged in, then the search is not started
if(getLogin().getText().equals("Login")){ if(getLogin().getText().equals("Login")){
err = true; err = true;
NotificationPopUp.displayNotificationWindow("Please login!");
} }
// 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 = "";
} else if (isValidInput(treeSpeciesList.getValue())) {
treeSpeciesList.setValue("");
err = true;
} }
if (dimensionsList.getValue() == null) { if (dimensionsList.getValue() == null) {
Constants.DIMENSIONS = ""; Constants.DIMENSIONS = "";
} else if (dimensionsList.getValue().length() > MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
dimensionsList.setValue("");
err = true;
} }
if (sawsetList.getValue() == null) { if (sawsetList.getValue() == null) {
Constants.SAWSET = ""; Constants.SAWSET = "";
} else if (sawsetList.getValue().length() > MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
sawsetList.setValue("");
err = true;
} }
if (moistureList.getValue() == null) { if (moistureList.getValue() == null) {
Constants.MOISTURE_GOAL = ""; Constants.MOISTURE_GOAL = "";
} else if (moistureList.getValue().length() > MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
moistureList.setValue("");
err = true;
} }
// Validates inputs
if(isValidInput(Constants.TREE_SPECIES) ||
isValidInput(Constants.DIMENSIONS) ||
isValidInput(Constants.SAWSET) ||
isValidInput(Constants.MOISTURE_GOAL)) {
err = true;
treeSpeciesList.setValue("");
dimensionsList.setValue("");
sawsetList.setValue("");
moistureList.setValue("");
}
// Checks if there is an error, if so the search is not started
if (!err) { if (!err) {
// Sets the values in the text-fields
setTreeSpeciesText(Constants.TREE_SPECIES); setTreeSpeciesText(Constants.TREE_SPECIES);
setDimensionsText(Constants.DIMENSIONS); setDimensionsText(Constants.DIMENSIONS);
setSawsetText(Constants.SAWSET); setSawsetText(Constants.SAWSET);
...@@ -181,11 +175,7 @@ public class InputPopup { ...@@ -181,11 +175,7 @@ public class InputPopup {
window.close(); window.close();
// Gather data thread
// Fungerende ny thread!!@@@@@
// Gather data
try { try {
Thread thread = new Thread(() -> { Thread thread = new Thread(() -> {
...@@ -209,9 +199,7 @@ public class InputPopup { ...@@ -209,9 +199,7 @@ public class InputPopup {
thread.setDaemon(true); thread.setDaemon(true);
thread.interrupt(); thread.interrupt();
thread.join(); thread.join();
//Platform.exit();
thread.start(); thread.start();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
...@@ -241,101 +229,14 @@ public class InputPopup { ...@@ -241,101 +229,14 @@ public class InputPopup {
liveDataThread.setDaemon(true); liveDataThread.setDaemon(true);
liveDataThread.interrupt(); liveDataThread.interrupt();
liveDataThread.join(); liveDataThread.join();
//Platform.exit();
liveDataThread.start(); liveDataThread.start();
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
}
});
} else { // Adds all the components to the VBox
NotificationPopUp.displayNotificationWindow("Please login!");
}
}
);
/*
// Fungerende ny thread!!@@@@@
try{
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
// Henter her data fra databasen
loadSingleSeries(setInputParameters());
//loadSingleSeries();
//loadMultipleSeries();
} catch (Exception ex) {
ex.printStackTrace();
}
}
});
thread.start();
} catch (Exception ex) {
ex.printStackTrace();
}
}
);
*/
/*
class KwhThread implements Runnable {
Map<Integer, Map<String, Number>> dataVariable;
private volatile boolean finished;
@Override
public void run() {
try{
dataVariable = setInputParameters();
} catch (Exception ex) {
ex.printStackTrace();
}
finished = true;
synchronized (this){
this.notify();
}
}
public Map<Integer, Map<String, Number>> getDataVariable() throws InterruptedException {
synchronized (this){
if(!finished)
this.wait();
}
return dataVariable;
}
}
KwhThread kwhThread = new KwhThread();
Thread thread = new Thread(kwhThread);
thread.setName("GetKwhThread");
thread.start();
try {
loadSingleSeries(kwhThread.getDataVariable());
} catch (Exception ex) {
ex.printStackTrace();
}
*/
/*
*/
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.getChildren().addAll(inputLabel, treeSpeciesInputLabel, treeSpeciesList, dimensionsInputLabel, dimensionsList, layout.getChildren().addAll(inputLabel, treeSpeciesInputLabel, treeSpeciesList, dimensionsInputLabel, dimensionsList,
sawsetInputLabel, sawsetList, moistureGoalInputLabel, moistureList, startButton); sawsetInputLabel, sawsetList, moistureGoalInputLabel, moistureList, startButton);
......
package com.application.GUI.PopUpWindows; package com.application.GUI.PopUpWindows;
import javafx.event.EventHandler; import com.application.DB.HelpingFunctions;
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.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;
...@@ -14,16 +13,23 @@ import java.nio.charset.StandardCharsets; ...@@ -14,16 +13,23 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import static com.application.DB.AccountHandler.*; import static com.application.DB.AccountHandler.*;
import static com.application.DB.Constants.*; import static com.application.DB.HelpingFunctions.isValidInput;
import static com.application.GUI.Panes.CreateLogoBar.getLogin; import static com.application.GUI.Panes.CreateLogoBar.getLogin;
/**
* This class handles all login functionality
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class LoginPopup { public class LoginPopup {
// Defines input fields
private static PasswordField PASSWORD_TEXT_FIELD = new PasswordField(); private static PasswordField PASSWORD_TEXT_FIELD = new PasswordField();
private static TextField USERNAME_TEXT_FIELD = new TextField(); private static TextField USERNAME_TEXT_FIELD = new TextField();
/** /**
* Tries to login * Tries to log in
* *
* @return a boolean if an error should be thrown or not. True gives no error, false throws an error. * @return a boolean if an error should be thrown or not. True gives no error, false throws an error.
*/ */
...@@ -42,6 +48,9 @@ public class LoginPopup { ...@@ -42,6 +48,9 @@ public class LoginPopup {
} }
/**
* This function adds all components to the login window
*/
public static void login(){ public static void login(){
Stage window = new Stage(); Stage window = new Stage();
...@@ -55,23 +64,30 @@ public class LoginPopup { ...@@ -55,23 +64,30 @@ public class LoginPopup {
Button loginButton = new Button("Login"); Button loginButton = new Button("Login");
getPasswordTextField().clear(); getPasswordTextField().clear();
// Closes the window if the close button is pressed
closeButton.setOnAction(event -> window.close()); closeButton.setOnAction(event -> window.close());
// Handles login if enter is pressed on the keyboard in the password field
getPasswordTextField().setOnKeyPressed( event -> { getPasswordTextField().setOnKeyPressed( event -> {
if( event.getCode() == KeyCode.ENTER ) { if (event.getCode() == KeyCode.ENTER) {
if(loginButtonPressed()){ if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) {
window.close(); if (loginButtonPressed()) {
window.close();
}
} }
} }
}); });
// Handles login if the login button is pressed
loginButton.setOnAction(event -> { loginButton.setOnAction(event -> {
if(loginButtonPressed()){ if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) {
window.close(); if (loginButtonPressed()) {
window.close();
}
} }
}); });
// Adds all components
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(userNameLabel, getUsernameTextField(), passwordLabel, getPasswordTextField(), loginButton, closeButton); layout.getChildren().addAll(userNameLabel, getUsernameTextField(), passwordLabel, getPasswordTextField(), loginButton, closeButton);
...@@ -82,22 +98,28 @@ public class LoginPopup { ...@@ -82,22 +98,28 @@ public class LoginPopup {
window.showAndWait(); window.showAndWait();
} }
/**
* This function handles admin window functionality
*/
public static void adminPopup(){ public static void adminPopup(){
Stage window = new Stage(); Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Admin window"); window.setTitle("Admin window");
// Information fields
Label usernameLabel = new Label("Username: "); Label usernameLabel = new Label("Username: ");
TextField usernameTextfield = new TextField(); TextField usernameTextfield = new TextField();
usernameTextfield.setText(getUserName()); usernameTextfield.setText(HelpingFunctions.getUserName());
usernameTextfield.setEditable(false); usernameTextfield.setEditable(false);
// Defines all buttons
Button addUser = new Button("Add User"); Button addUser = new Button("Add User");
Button deleteUser = new Button("Delete User"); Button deleteUser = new Button("Delete User");
Button logout = new Button("Logout"); Button logout = new Button("Logout");
Button close = new Button("Close"); Button close = new Button("Close");
// Handles functionality for each button
addUser.setOnAction(event -> { addUser.setOnAction(event -> {
adminAddUser(); adminAddUser();
}); });
...@@ -110,7 +132,7 @@ public class LoginPopup { ...@@ -110,7 +132,7 @@ public class LoginPopup {
}); });
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
// adds all components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(usernameLabel, usernameTextfield, addUser, deleteUser, logout, close); layout.getChildren().addAll(usernameLabel, usernameTextfield, addUser, deleteUser, logout, close);
...@@ -121,12 +143,16 @@ public class LoginPopup { ...@@ -121,12 +143,16 @@ public class LoginPopup {
window.showAndWait(); window.showAndWait();
} }
/**
* This function adds a user to the database based on the input parameters given by the user
*/
public static void adminAddUser(){ public static void adminAddUser(){
Stage window = new Stage(); Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Admin window"); window.setTitle("Admin window");
// Defines all labels
Label firstNameLabel = new Label("First Name: "); Label firstNameLabel = new Label("First Name: ");
Label lastNameLabel = new Label("Last Name: "); Label lastNameLabel = new Label("Last Name: ");
Label phoneNoLabel = new Label("Phone No: "); Label phoneNoLabel = new Label("Phone No: ");
...@@ -135,6 +161,7 @@ public class LoginPopup { ...@@ -135,6 +161,7 @@ public class LoginPopup {
Label passwordSecondLabel = new Label("Password Repeat: "); Label passwordSecondLabel = new Label("Password Repeat: ");
Label isAdminLabel = new Label("Is Admin: "); Label isAdminLabel = new Label("Is Admin: ");
// Defines all input fields
TextField firstNameTextField = new TextField(); TextField firstNameTextField = new TextField();
TextField lastNameTextField = new TextField(); TextField lastNameTextField = new TextField();
TextField phoneNoTextField = new TextField(); TextField phoneNoTextField = new TextField();
...@@ -144,13 +171,23 @@ public class LoginPopup { ...@@ -144,13 +171,23 @@ public class LoginPopup {
CheckBox isAdminBox = new CheckBox(); CheckBox isAdminBox = new CheckBox();
isAdminBox.setSelected(false); isAdminBox.setSelected(false);
// Defines all buttons
Button close = new Button("Close"); Button close = new Button("Close");
Button addUser = new Button("Add User"); Button addUser = new Button("Add User");
// Handles the functionality for each button
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
addUser.setOnAction(event -> { addUser.setOnAction(event -> {
// If the passwords match each other, add the user, if not display an errormessage // Validate input parameters
if(!isValidInput(firstNameTextField.getText()) &&
!isValidInput(lastNameTextField.getText()) &&
!isValidInput(phoneNoTextField.getText()) &&
!isValidInput(usernameTextField.getText()) &&
!isValidInput(passwordFirstField.getText()) &&
!isValidInput(passwordSecondField.getText())) {
// If the passwords match each other, add the user, if not, display an error message
if(passwordFirstField.getText().contentEquals(passwordSecondField.getText())){ if(passwordFirstField.getText().contentEquals(passwordSecondField.getText())){
// Hashing the password if they match. // Hashing the password if they match.
...@@ -166,7 +203,7 @@ public class LoginPopup { ...@@ -166,7 +203,7 @@ public class LoginPopup {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } }else {
NotificationPopUp.displayNotificationWindow("Passwords does not match!"); NotificationPopUp.displayNotificationWindow("Passwords does not match!");
passwordFirstField.clear(); passwordFirstField.clear();
passwordSecondField.clear(); passwordSecondField.clear();
...@@ -174,7 +211,7 @@ public class LoginPopup { ...@@ -174,7 +211,7 @@ public class LoginPopup {
}); });
// Adds all components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(firstNameLabel, firstNameTextField, lastNameLabel, lastNameTextField, layout.getChildren().addAll(firstNameLabel, firstNameTextField, lastNameLabel, lastNameTextField,
...@@ -188,34 +225,45 @@ public class LoginPopup { ...@@ -188,34 +225,45 @@ public class LoginPopup {
window.showAndWait(); window.showAndWait();
} }
/**
* This function handles deleting an account
*/
public static void adminDeleteUser(){ public static void adminDeleteUser(){
Stage window = new Stage(); Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Admin window"); window.setTitle("Admin window");
// Defines the input field
Label usernameLabel = new Label("Username: "); Label usernameLabel = new Label("Username: ");
TextField usernameTextField = new TextField(); TextField usernameTextField = new TextField();
// Defines all buttons
Button close = new Button("Close"); Button close = new Button("Close");
Button delete = new Button("Delete User"); Button delete = new Button("Delete User");
// Handle the functionality for each button
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
delete.setOnAction(event -> { delete.setOnAction(event -> {
try { // Validate the input parameter
boolean results = deleteUser(usernameTextField.getText()); if(!isValidInput(usernameTextField.getText())) {
if(results){ try {
NotificationPopUp.displayNotificationWindow(usernameTextField.getText()+" was successfully deleted!"); // Checks if the user is deleted
window.close(); boolean results = deleteUser(usernameTextField.getText());
} else { if (results) {
NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText()); NotificationPopUp.displayNotificationWindow(usernameTextField.getText() + " was successfully deleted!");
usernameTextField.clear(); window.close();
} else {
NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText());
usernameTextField.clear();
}
} catch (Exception e) {
e.printStackTrace();
} }
} catch (Exception e) {
e.printStackTrace();
} }
}); });
// Adds the components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(usernameLabel, usernameTextField, delete, close); layout.getChildren().addAll(usernameLabel, usernameTextField, delete, close);
...@@ -226,43 +274,53 @@ public class LoginPopup { ...@@ -226,43 +274,53 @@ public class LoginPopup {
window.showAndWait(); window.showAndWait();
} }
/**
* This function handles logout functionality
*/
public static void logout(){ public static void logout(){
getLogin().setText("Login"); getLogin().setText("Login");
setFirstName(""); HelpingFunctions.setFirstName("");
setLastName(""); HelpingFunctions.setLastName("");
setIsAdmin(false); HelpingFunctions.setIsAdmin(false);
setPhoneNo(""); HelpingFunctions.setPhoneNo("");
setUserName(""); HelpingFunctions.setUserName("");
} }
/**
* This function handles popup screen for a normal user
*/
public static void userPopup(){ public static void userPopup(){
Stage window = new Stage(); Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("User window"); window.setTitle("User window");
// Defines labels
Label nameLabel = new Label("Name: "); Label nameLabel = new Label("Name: ");
Label phoneNoLabel = new Label("Phone no: "); Label phoneNoLabel = new Label("Phone no: ");
// Defines information fields
TextField nameTextfield = new TextField(); TextField nameTextfield = new TextField();
TextField phoneNoTextField = new TextField(); TextField phoneNoTextField = new TextField();
nameTextfield.setEditable(false); nameTextfield.setEditable(false);
phoneNoTextField.setEditable(false); phoneNoTextField.setEditable(false);
nameTextfield.setText(getFirstName() + " " + getLastName()); // Sets the values
phoneNoTextField.setText(getPhoneNo()); nameTextfield.setText(HelpingFunctions.getFirstName() + " " + HelpingFunctions.getLastName());
phoneNoTextField.setText(HelpingFunctions.getPhoneNo());
// Define buttons
Button close = new Button("Close"); Button close = new Button("Close");
Button logout = new Button("Logout"); Button logout = new Button("Logout");
// Handle each button
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
logout.setOnAction(event -> { logout.setOnAction(event -> {
logout(); logout();
window.close(); window.close();
}); });
// Adds all components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(nameLabel, nameTextfield, phoneNoLabel, phoneNoTextField, logout, close); layout.getChildren().addAll(nameLabel, nameTextfield, phoneNoLabel, phoneNoTextField, logout, close);
...@@ -273,6 +331,12 @@ public class LoginPopup { ...@@ -273,6 +331,12 @@ public class LoginPopup {
window.showAndWait(); window.showAndWait();
} }
/**
* This function hash the password using the SHA-512 algorithm
*
* @param password input parameter for the password
* @return a 64-bit hashed string
*/
public static String hashPassword(String password){ public static String hashPassword(String password){
try { try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512"); MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
......
...@@ -10,19 +10,32 @@ import javafx.scene.text.TextAlignment; ...@@ -10,19 +10,32 @@ import javafx.scene.text.TextAlignment;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
/**
* This class handles functionality regarding a notification window
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class NotificationPopUp { public class NotificationPopUp {
/**
* This function displays the notification window
*
* @param message input parameter for what to display in the window
*/
public static void displayNotificationWindow(String message){ public static void displayNotificationWindow(String message){
Stage window = new Stage(); Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL); window.initModality(Modality.APPLICATION_MODAL);
window.setTitle("Notification window"); window.setTitle("Notification window");
// Defines label
Label messageLabel = new Label(); Label messageLabel = new Label();
messageLabel.setText(message); messageLabel.setText(message);
messageLabel.setWrapText(true); messageLabel.setWrapText(true);
messageLabel.setTextAlignment(TextAlignment.CENTER); messageLabel.setTextAlignment(TextAlignment.CENTER);
// Define buttons and handles functionality
Button close = new Button("Close"); Button close = new Button("Close");
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
...@@ -32,6 +45,7 @@ public class NotificationPopUp { ...@@ -32,6 +45,7 @@ public class NotificationPopUp {
} }
}); });
// Adds the components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(messageLabel,close); layout.getChildren().addAll(messageLabel,close);
......
...@@ -2,6 +2,7 @@ package com.application.GUI.PopUpWindows; ...@@ -2,6 +2,7 @@ package com.application.GUI.PopUpWindows;
import com.application.DB.Constants; import com.application.DB.Constants;
import com.application.DB.DB; import com.application.DB.DB;
import com.application.DB.Settings;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
...@@ -15,10 +16,20 @@ import java.time.LocalDateTime; ...@@ -15,10 +16,20 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import static com.application.DB.Constants.IS_FINISHED; import static com.application.DB.Constants.IS_FINISHED;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS; import static com.application.DB.Settings.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.HelpingFunctions.isValidInput;
/**
* This class handles the output window for sending the resulted manual moisture levels
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class OutputPopup { public class OutputPopup {
/**
* This function handles the output window and it's functionality
*/
public static void displayOutputWindow(){ public static void displayOutputWindow(){
Stage window = new Stage(); Stage window = new Stage();
...@@ -47,23 +58,24 @@ public class OutputPopup { ...@@ -47,23 +58,24 @@ public class OutputPopup {
boolean err = false; boolean err = false;
if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ // Validates inputs
if(isValidInput(moistureCheckTextField.getText())){
err = true; err = true;
} }
// Checks if there is an error
if(!err){ if(!err){
if(!moistureCheckTextField.getCharacters().toString().isEmpty() && if(!moistureCheckTextField.getCharacters().toString().isEmpty() &&
!moistureCheckTextField.getCharacters().toString().equals("Please enter a value")) { !moistureCheckTextField.getCharacters().toString().equals("Please enter a value")) {
Constants.STOP_TIME = null; Constants.STOP_TIME = null;
DB.pushManMoisture(moistureCheckTextField.getCharacters().toString()); DB.pushManMoisture(moistureCheckTextField.getCharacters().toString());
Constants.NUMBER_OF_CHECKS++; Settings.NUMBER_OF_CHECKS++;
window.close(); window.close();
} else { } else {
NotificationPopUp.displayNotificationWindow("Please enter a value!"); NotificationPopUp.displayNotificationWindow("Please enter a value!");
moistureCheckTextField.setPromptText("Please enter a value"); moistureCheckTextField.setPromptText("Please enter a value");
} }
} else { } else {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
moistureCheckTextField.setText(""); moistureCheckTextField.setText("");
moistureCheckTextField.setPromptText("Please enter a value"); moistureCheckTextField.setPromptText("Please enter a value");
} }
...@@ -82,10 +94,12 @@ public class OutputPopup { ...@@ -82,10 +94,12 @@ public class OutputPopup {
boolean err = false; boolean err = false;
if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ // Validates inputs
if(isValidInput(moistureCheckTextField.getText())){
err = true; err = true;
} }
// Checks if there is an error
if(!err) { if(!err) {
if (!moistureCheckTextField.getCharacters().toString().isEmpty() && if (!moistureCheckTextField.getCharacters().toString().isEmpty() &&
!moistureCheckTextField.getCharacters().toString().equals("Please enter a value")) { !moistureCheckTextField.getCharacters().toString().equals("Please enter a value")) {
...@@ -98,7 +112,6 @@ public class OutputPopup { ...@@ -98,7 +112,6 @@ public class OutputPopup {
moistureCheckTextField.setPromptText("Please enter a value"); moistureCheckTextField.setPromptText("Please enter a value");
} }
} else { } else {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
moistureCheckTextField.setText(""); moistureCheckTextField.setText("");
moistureCheckTextField.setPromptText("Please enter a value"); moistureCheckTextField.setPromptText("Please enter a value");
} }
...@@ -107,7 +120,7 @@ public class OutputPopup { ...@@ -107,7 +120,7 @@ public class OutputPopup {
} }
}); });
// Adds the components to the VBox
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.setSpacing(10); layout.setSpacing(10);
......
...@@ -56,13 +56,16 @@ public class Main extends Application { ...@@ -56,13 +56,16 @@ public class Main extends Application {
/** /**
* Starts the application * Starts the application
* *
* @param args * @param args input parameter
* @throws IOException * @throws IOException throws exception if an error occurs
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
launch(args); launch(args);
} }
/**
* This function exists the application and stops all threads
*/
public static void exitApplication(){ public static void exitApplication(){
Platform.exit(); Platform.exit();
System.exit(0); System.exit(0);
...@@ -89,8 +92,8 @@ public class Main extends Application { ...@@ -89,8 +92,8 @@ public class Main extends Application {
/** /**
* Sets the primaryStage and sets the scene for the window. * Sets the primaryStage and sets the scene for the window.
* *
* @param primaryStage * @param primaryStage The main stage
* @throws Exception * @throws Exception throws exception if an error occurs
*/ */
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
...@@ -143,6 +146,7 @@ public class Main extends Application { ...@@ -143,6 +146,7 @@ public class Main extends Application {
InputPopup.display(); InputPopup.display();
} }
// Getters and setters
public static void setTreeSpeciesText(String treeSpeciesText) { public static void setTreeSpeciesText(String treeSpeciesText) {
Main.treeSpeciesText.setText(treeSpeciesText); Main.treeSpeciesText.setText(treeSpeciesText);
} }
......
Manifest-Version: 1.0
Main-Class: com.application.Main
Manifest-Version: 1.0
Main-Class: com.application.Main