Reformated code

main
Thomas Battermann 10 years ago committed by thomasba
parent c7ccfb6543
commit 45cd818c2f

@ -14,7 +14,7 @@ import java.util.TreeMap;
/** /**
* Export the user data in a CSV file * Export the user data in a CSV file
* * <p>
* File format: * File format:
* USER,uuid,username,password,email * USER,uuid,username,password,email
* TODOLIST,username,uuid,name,changeable * TODOLIST,username,uuid,name,changeable

@ -16,7 +16,9 @@ import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.*; import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class Controller { public class Controller {
private Map<String, User> users = null; private Map<String, User> users = null;
@ -33,26 +35,6 @@ public class Controller {
showLoadFileDialog(); showLoadFileDialog();
} }
static class TodoListCell extends ListCell<Todo> {
@Override
public void updateItem(Todo item, boolean empty) {
super.updateItem(item, empty);
if ( !empty && item != null ) {
if ( item.isPrio() && !item.isDone() ) {
this.setStyle("-fx-graphic:url(/de/t_battermann/dhbw/todolist/star.png);");
}else{
this.setStyle("-fx-graphic:null;");
}
this.setTextFill(Paint.valueOf(item.isDone() ? "#999999" : (item.pastDue() ? "#aa0000" :"#000000") ));
this.setText(item.getTitle() + (item.getDueDate() != null ? " (due: "+item.getDateTime()+")" : ""));
}else{
this.setStyle("-fx-graphic:null;");
this.setTextFill(Paint.valueOf("#000000"));
this.setText("");
}
}
}
/** /**
* Initialize new empty * Initialize new empty
*/ */
@ -1085,6 +1067,7 @@ public class Controller {
/** /**
* Notify a list about a changed item * Notify a list about a changed item
* Taken from: http://stackoverflow.com/a/21435063 * Taken from: http://stackoverflow.com/a/21435063
*
* @param list the list containing the changed item * @param list the list containing the changed item
* @param changedItem the item itself * @param changedItem the item itself
*/ */
@ -1099,4 +1082,24 @@ public class Controller {
} }
} }
static class TodoListCell extends ListCell<Todo> {
@Override
public void updateItem(Todo item, boolean empty) {
super.updateItem(item, empty);
if (!empty && item != null) {
if (item.isPrio() && !item.isDone()) {
this.setStyle("-fx-graphic:url(/de/t_battermann/dhbw/todolist/star.png);");
} else {
this.setStyle("-fx-graphic:null;");
}
this.setTextFill(Paint.valueOf(item.isDone() ? "#999999" : (item.pastDue() ? "#aa0000" : "#000000")));
this.setText(item.getTitle() + (item.getDueDate() != null ? " (due: " + item.getDateTime() + ")" : ""));
} else {
this.setStyle("-fx-graphic:null;");
this.setTextFill(Paint.valueOf("#000000"));
this.setText("");
}
}
}
} }

@ -5,13 +5,12 @@ import javafx.stage.Stage;
public class Main extends Application { public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
new Controller(primaryStage); new Controller(primaryStage);
} }
public static void main(String[] args) {
launch(args);
}
} }

@ -1,6 +1,8 @@
package de.t_battermann.dhbw.todolist; package de.t_battermann.dhbw.todolist;
import java.util.*; import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
/** /**
* This class contains a todo list with all its items. * This class contains a todo list with all its items.

@ -3,7 +3,9 @@ package de.t_battermann.dhbw.todolist;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.validator.routines.EmailValidator; import org.apache.commons.validator.routines.EmailValidator;
import java.util.*; import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
/** /**
* This class contains all the users data. * This class contains all the users data.
@ -48,6 +50,24 @@ public class User {
this.todoLists = new LinkedList<>(); this.todoLists = new LinkedList<>();
} }
/**
* Checks if eMail has correct syntax
*
* @param email string containing a eMail address
* @return true if valid syntax
*/
public static boolean checkEmail(String email) {
return email.length() != 0 && EmailValidator.getInstance().isValid(email);
}
public static boolean checkUsername(String username) {
return username.matches("[a-zA-Z0-9_-]{3,}");
}
public static boolean checkPassword(String password) {
return password.length() > 6 && password.matches(".*[A-Z].*") && password.matches(".*[a-z].*") && password.matches(".*[0-9].*");
}
/** /**
* Gets username. * Gets username.
* *
@ -66,6 +86,15 @@ public class User {
return this.password; return this.password;
} }
/**
* Update the users password
*
* @param password the password (cleartext)
*/
public void setPassword(String password) {
this.password = hashPassword(password);
}
/** /**
* Gets uuid. * Gets uuid.
* *
@ -139,15 +168,6 @@ public class User {
return false; return false;
} }
/**
* Update the users password
*
* @param password the password (cleartext)
*/
public void setPassword(String password) {
this.password = hashPassword(password);
}
/** /**
* Sets email. * Sets email.
* *
@ -172,20 +192,4 @@ public class User {
private String hashPassword(String password) { private String hashPassword(String password) {
return DigestUtils.sha256Hex(uuid + password); return DigestUtils.sha256Hex(uuid + password);
} }
/**
* Checks if eMail has correct syntax
* @param email string containing a eMail address
* @return true if valid syntax
*/
public static boolean checkEmail(String email) {
return email.length() != 0 && EmailValidator.getInstance().isValid(email);
}
public static boolean checkUsername(String username) {
return username.matches("[a-zA-Z0-9_-]{3,}");
}
public static boolean checkPassword(String password) {
return password.length() > 6 && password.matches(".*[A-Z].*") && password.matches(".*[a-z].*") && password.matches(".*[0-9].*");
}
} }

@ -19,7 +19,10 @@ import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Map;
import java.util.TreeMap;
/** /**
* This class implement the ExportHandler interface. It converts the data to XML and vice versa. * This class implement the ExportHandler interface. It converts the data to XML and vice versa.

Loading…
Cancel
Save