diff --git a/Task_Managment_application/.classpath b/Task_Managment_application/.classpath new file mode 100644 index 0000000..144797c --- /dev/null +++ b/Task_Managment_application/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Task_Managment_application/.project b/Task_Managment_application/.project new file mode 100644 index 0000000..3516172 --- /dev/null +++ b/Task_Managment_application/.project @@ -0,0 +1,17 @@ + + + Task_Managment_Application + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Task_Managment_application/.settings/org.eclipse.jdt.core.prefs b/Task_Managment_application/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..a698e59 --- /dev/null +++ b/Task_Managment_application/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Task_Managment_application/bin/Account_Module$1.class b/Task_Managment_application/bin/Account_Module$1.class new file mode 100644 index 0000000..d03284f Binary files /dev/null and b/Task_Managment_application/bin/Account_Module$1.class differ diff --git a/Task_Managment_application/bin/Account_Module$2.class b/Task_Managment_application/bin/Account_Module$2.class new file mode 100644 index 0000000..4fd2937 Binary files /dev/null and b/Task_Managment_application/bin/Account_Module$2.class differ diff --git a/Task_Managment_application/bin/Account_Module$User.class b/Task_Managment_application/bin/Account_Module$User.class new file mode 100644 index 0000000..020e868 Binary files /dev/null and b/Task_Managment_application/bin/Account_Module$User.class differ diff --git a/Task_Managment_application/bin/Account_Module.class b/Task_Managment_application/bin/Account_Module.class new file mode 100644 index 0000000..0b9a087 Binary files /dev/null and b/Task_Managment_application/bin/Account_Module.class differ diff --git a/Task_Managment_application/bin/Main.class b/Task_Managment_application/bin/Main.class new file mode 100644 index 0000000..6eae8e3 Binary files /dev/null and b/Task_Managment_application/bin/Main.class differ diff --git a/Task_Managment_application/bin/Manager_Module$1.class b/Task_Managment_application/bin/Manager_Module$1.class new file mode 100644 index 0000000..13b5c66 Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$1.class differ diff --git a/Task_Managment_application/bin/Manager_Module$2.class b/Task_Managment_application/bin/Manager_Module$2.class new file mode 100644 index 0000000..1a0dd7e Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$2.class differ diff --git a/Task_Managment_application/bin/Manager_Module$3.class b/Task_Managment_application/bin/Manager_Module$3.class new file mode 100644 index 0000000..1608a18 Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$3.class differ diff --git a/Task_Managment_application/bin/Manager_Module$Direction_Button$1.class b/Task_Managment_application/bin/Manager_Module$Direction_Button$1.class new file mode 100644 index 0000000..b451dac Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$Direction_Button$1.class differ diff --git a/Task_Managment_application/bin/Manager_Module$Direction_Button.class b/Task_Managment_application/bin/Manager_Module$Direction_Button.class new file mode 100644 index 0000000..dbee025 Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$Direction_Button.class differ diff --git a/Task_Managment_application/bin/Manager_Module$Task_Container.class b/Task_Managment_application/bin/Manager_Module$Task_Container.class new file mode 100644 index 0000000..8516341 Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module$Task_Container.class differ diff --git a/Task_Managment_application/bin/Manager_Module.class b/Task_Managment_application/bin/Manager_Module.class new file mode 100644 index 0000000..e2fe42d Binary files /dev/null and b/Task_Managment_application/bin/Manager_Module.class differ diff --git a/Task_Managment_application/david_data.txt b/Task_Managment_application/david_data.txt new file mode 100644 index 0000000..387cec0 --- /dev/null +++ b/Task_Managment_application/david_data.txt @@ -0,0 +1,3 @@ +,s +,Enter task here +hellworld,Enter task here,rhdrh \ No newline at end of file diff --git a/Task_Managment_application/rohane_data.txt b/Task_Managment_application/rohane_data.txt new file mode 100644 index 0000000..e69de29 diff --git a/Task_Managment_application/src/Account_Module.java b/Task_Managment_application/src/Account_Module.java new file mode 100644 index 0000000..5d95c00 --- /dev/null +++ b/Task_Managment_application/src/Account_Module.java @@ -0,0 +1,273 @@ +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.LinkedList; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; + +public class Account_Module extends VBox +{ + private class User + { + private String username; + private String password; + + User() + { + + } + User(String username, String password) + { + this.username = username; + this.password = password; + } + + public String get_password() + { + return password; + } + + public String get_username() + { + return username; + } + + public void set_password(String password) + { + this.password = password; + } + + public void set_username(String username) + { + this.username = username; + } + } + + final File FILE; + final boolean DEBUG; + private LinkedList user_list; + + + Account_Module() + { + + DEBUG = true; + FILE = new File("user_data.txt"); + user_list = new LinkedList(); + + this.setPadding(new Insets(15, 15, 15, 15)); + this.setStyle("-fx-background-color: #336699;"); + this.setSpacing(11); + this.setMinSize(500, 500); + + TextField usernameField = new TextField(); + PasswordField passwordField = new PasswordField(); + Button registerButton = new Button(); + Button loginButton = new Button(); + + passwordField.setText("Enter Password"); + usernameField.setText("Enter Username"); + loginButton.setText("Login"); + registerButton.setText("Register"); + + registerButton.setOnAction(new EventHandler() + { + @Override + public void handle(ActionEvent arg0) + { + try + { + add_user_to_list(usernameField.getText(), passwordField.getText()); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + }); + + loginButton.setOnAction(new EventHandler() + + { + + @Override + public void handle(ActionEvent event) + { + try + { + if (attemptLogin(usernameField.getText(), passwordField.getText())) + { + + if(DEBUG)System.out.println("Attempted login"); + Manager_Module hbox = new Manager_Module(usernameField.getText()); + System.out.println("LOGIN SUCCESS"); + Scene mod_scene = new Scene(hbox, 600, 600); + Main.get_stage().setScene(mod_scene); + + + + } else + { + if (DEBUG) + System.out.println("LOGIN FAIL"); + } + } catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + }); + // if(this.getScene() != null) + + + HBox buttonContainer = new HBox(); + buttonContainer.getChildren().addAll(registerButton, loginButton); + buttonContainer.setSpacing(10); + this.getChildren().addAll(usernameField, passwordField, buttonContainer); + + + + + + } + + + private boolean add_user_to_list(String username, String password) throws IOException + { + User user = new User(username, password); + refresh_user_list(); + if (user_list.isEmpty()) + { + if (DEBUG) + System.out.println("user list is empty"); + user_list.add(user); + } else + { + if (DEBUG) + System.out.println("user list is not empty"); + for (int i = 0; i < user_list.size(); ++i) + { + if (user_list.get(i).get_username().equalsIgnoreCase(user.get_username())) + { + if (DEBUG) + System.out.println("user name already exists, not adding"); + return false; + } + } + if (DEBUG) + System.out.println("Adding user to list"); + user_list.add(user); + } + save_user_list(); + + return true; + } + + private boolean attemptLogin(String username, String password) throws IOException + { + refresh_user_list(); + for (int i = 0; i < user_list.size(); ++i) + { + if (user_list.get(i).get_username().equalsIgnoreCase(username)) + { + if (user_list.get(i).get_password().equals(password)) + { + return true; + } + + } + } + return false; + } + + private void debug_print_list() + { + for (int i = 0; i < user_list.size(); ++i) + { + System.out.println("size is " + i); + System.out.print(user_list.get(i).get_username() + ' '); + System.out.println(user_list.get(i).get_password()); + } + } + + + private void refresh_user_list() throws IOException + { + if (DEBUG) + System.out.println("getting user list"); + + user_list.clear(); + + if (!FILE.exists()) + { + user_list.clear(); + System.out.println("file wasnt found"); + return; + } + else + { + System.out.println("file was found"); + BufferedReader bufferedReader = new BufferedReader(new FileReader(FILE)); + String line; + line = bufferedReader.readLine(); + while (line != null) + { + User temp = new User(); + + temp.set_username(line.substring(0, line.indexOf(','))); + temp.set_password(line.substring(line.indexOf(',') + 1)); + if (DEBUG) + System.out.println(temp.get_username()); + if (DEBUG) + System.out.println(temp.get_password()); + user_list.add(temp); + line = bufferedReader.readLine(); + } + bufferedReader.close(); + } + } + + private void save_user_list() throws IOException + { + + + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(FILE)); + for (int i = 0; i < user_list.size(); ++i) + { + if (DEBUG) + System.out.println("size is " + i); + if (DEBUG) + debug_print_list(); + if (i != 0) + { + bufferedWriter.write('\n'); + } + bufferedWriter.write(user_list.get(i).get_username()); + bufferedWriter.write(','); + bufferedWriter.write(user_list.get(i).get_password()); + } + bufferedWriter.close(); + + } + +} \ No newline at end of file diff --git a/Task_Managment_application/src/Main.java b/Task_Managment_application/src/Main.java new file mode 100644 index 0000000..97913e7 --- /dev/null +++ b/Task_Managment_application/src/Main.java @@ -0,0 +1,36 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application +{ + private static Stage stage; + public static void main(String [] args) + { + launch(); + } + + @Override + public void start(Stage stage) throws Exception + { + set_stage(stage); + Account_Module account_mod = new Account_Module(); + Scene account_scene = new Scene(account_mod); + stage.sizeToScene(); + stage.setScene(account_scene); + stage.setTitle("Task Manager Application"); + stage.show(); + + + } + + public static Stage get_stage() + { + return stage; + } + + public void set_stage(Stage stage) + { + this.stage = stage; + } +} diff --git a/Task_Managment_application/src/Manager_Module.java b/Task_Managment_application/src/Manager_Module.java new file mode 100644 index 0000000..8c68d25 --- /dev/null +++ b/Task_Managment_application/src/Manager_Module.java @@ -0,0 +1,374 @@ + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.LinkedList; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ListView; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.Border; +import javafx.scene.layout.BorderStroke; +import javafx.scene.layout.CornerRadii; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.paint.Paint; +import javafx.stage.Popup; + +public class Manager_Module extends HBox +{ + class Direction_Button extends Button + { + Direction_Button(Task_Container from, Task_Container to, String button_text, Manager_Module mm) + { + this.setText(button_text); + this.setMinSize(30, 10); + this.setOnAction(new EventHandler(){ + + @Override + public void handle(ActionEvent event) + { + if(!from.get_list_view().getSelectionModel().isEmpty()) + { + int selected_index = from.get_list_view().getSelectionModel().getSelectedIndex(); + String current_task = from.get_task_list().get(selected_index); + from.remove_task(current_task); + to.add_task(current_task); + from.get_list_view().getSelectionModel().clearSelection(); + to.get_list_view().getSelectionModel().clearSelection(); + try + { + mm.save(); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } + + }); + } + } + + class Task_Container extends VBox + { + + ListView task_view; + private String title; + ObservableList task_list; + + Task_Container(String title) + { + task_list = FXCollections.observableArrayList(); + task_view = new ListView(); + task_view.setOrientation(Orientation.VERTICAL); + task_view.setItems(task_list); + this.title = title; + Label title_label = new Label(); + title_label.setText(title); + title_label.setPrefWidth(100); + + + this.getChildren().addAll(title_label, task_view); + + + } + + + public void add_task(String task) + { + task_list.add(task); + task_view.setItems(task_list); + + } + + public void remove_task(String task) + { + for(int i = 0; i < task_list.size(); ++i) + { + if(task_list.get(i).equals(task)) + { + task_list.remove(i); + i = task_list.size(); + } + } + task_view.setItems(task_list); + + } + + public ObservableList get_task_list() + { + return task_list; + } + + public ListView get_list_view() + { + return task_view; + } + + public String get_title() + { + return title; + } + + public void set_task_list(ObservableList task_list) + { + this.task_list = task_list; + if(task_list != null && !task_list.isEmpty()) + task_view.setItems(task_list); + + } + public void set_title(String title) + { + this.title = title; + } + + } + + + + final boolean DEBUG; + final File FILE; + Task_Container todo_container; + Task_Container doing_container; + Task_Container done_container; + + + + public Manager_Module(String username) + { + DEBUG = true; + FILE = new File(username + "_data.txt"); + + Manager_Module mm = this; + this.setPadding(new Insets(10,10,10,10)); + this.setBackground(new Background(new BackgroundFill(Color.TAN, CornerRadii.EMPTY, Insets.EMPTY))); + this.setSpacing(11); + this.setMinSize(500, 500); + + todo_container = new Task_Container("To Do"); + doing_container = new Task_Container("In Progress"); + done_container = new Task_Container("Done"); + + Button add_task_button = new Button(); + Button remove_task_button = new Button(); + add_task_button.setText("Add task"); + remove_task_button.setText("Remove Completed Task"); + + + Popup popup = new Popup(); + popup.setX(505); + popup.setY(405); + VBox popup_box = new VBox(); + popup_box.setLayoutX(500); + popup_box.setLayoutY(400); + popup_box.setMinHeight(100); + popup_box.setMinWidth(100); + TextField task_textfield = new TextField("Enter task here"); + Button ok_popup = new Button(); + ok_popup.setMinWidth(50); + ok_popup.setText("ADD"); + popup_box.getChildren().addAll(task_textfield, ok_popup); + popup.getContent().add(popup_box); + + + VBox transitions1 = new VBox(); + transitions1.getChildren().add(new Direction_Button(todo_container, doing_container, "->", this)); + transitions1.getChildren().add(new Direction_Button(doing_container, todo_container, "<-", this)); + + VBox transitions2 = new VBox(); + transitions2.getChildren().add(new Direction_Button(doing_container, done_container, "->", this)); + transitions2.getChildren().add(new Direction_Button(done_container, doing_container, "<-", this)); + + + + ok_popup.setOnAction(new EventHandler() + { + + @Override + public void handle(ActionEvent event) + { + String next_task = new String(); + next_task = task_textfield.getText(); + todo_container.add_task(next_task); + task_textfield.clear(); + try + { + save(); + } catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + popup.hide(); + } + + }); + add_task_button.setOnAction(new EventHandler() + { + + @Override + public void handle(ActionEvent arg0) + { + if(DEBUG) System.out.println("Add task button click"); + popup.show(mm, mm.getLayoutX(), mm.getLayoutY()); + } + + }); + remove_task_button.setOnAction(new EventHandler() + { + @Override + public void handle(ActionEvent event) + { + if(!done_container.get_list_view().getSelectionModel().isEmpty()) + { + int remove_index = done_container.get_list_view().getSelectionModel().getSelectedIndex(); + done_container.get_task_list().remove(remove_index); + done_container.get_list_view().setItems(done_container.get_task_list()); + try + { + save(); + } + catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + done_container.get_list_view().getSelectionModel().clearSelection(); + + + } + + }); + todo_container.getChildren().add(add_task_button); + done_container.getChildren().add(remove_task_button); + try + { + load(); + } catch (IOException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.getChildren().addAll(todo_container, transitions1, doing_container, transitions2, done_container); + } + + private void load() throws IOException + { + + if(!FILE.exists()) + { + return; + } + BufferedReader bufferedReader = new BufferedReader(new FileReader(FILE)); + ObservableList temp_list = FXCollections.observableArrayList(); + String line = bufferedReader.readLine(); + String[] task_desc = null; + if(line != null) + { + task_desc = line.split(","); + for(int i = 0; i < task_desc.length; ++i) + { + temp_list.add(task_desc[i]); + } + todo_container.set_task_list(temp_list); + } + else + { + todo_container.set_task_list(null); + } + temp_list = FXCollections.observableArrayList(); + line = bufferedReader.readLine(); + task_desc = null; + if(line != null) + { + task_desc = line.split(","); + + for(int i = 0; i < task_desc.length; ++i) + { + temp_list.add(task_desc[i]); + } + doing_container.set_task_list(temp_list); + } + else + { + doing_container.set_task_list(null); + } + temp_list = FXCollections.observableArrayList(); + line = bufferedReader.readLine(); + task_desc = null; + if(line != null) + { + task_desc = line.split(","); + for(int i = 0; i < task_desc.length; ++i) + { + temp_list.add(task_desc[i]); + } + done_container.set_task_list(temp_list); + } + else + { + done_container.set_task_list(null); + } + bufferedReader.close(); + + } + + private void save() throws IOException + { + + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(FILE)); + ObservableList temp = todo_container.get_task_list(); + for(int i = 0; i < temp.size(); ++i) + { + if(i != 0) + bufferedWriter.write(','); + bufferedWriter.write(temp.get(i)); + + } + bufferedWriter.write('\n'); + temp = doing_container.get_task_list(); + for(int i = 0; i < temp.size(); ++i) + { + if(i != 0) + bufferedWriter.write(','); + bufferedWriter.write(temp.get(i)); + + } + bufferedWriter.write('\n'); + temp = done_container.get_task_list(); + for(int i = 0; i < temp.size(); ++i) + { + if(i != 0) + bufferedWriter.write(','); + bufferedWriter.write(temp.get(i)); + + } + bufferedWriter.close(); + } + + + + + + +} diff --git a/Task_Managment_application/user_data.txt b/Task_Managment_application/user_data.txt new file mode 100644 index 0000000..983647a --- /dev/null +++ b/Task_Managment_application/user_data.txt @@ -0,0 +1,2 @@ +david,w +rohane,rohane \ No newline at end of file diff --git a/tma_westgate.jar b/tma_westgate.jar new file mode 100644 index 0000000..3684268 Binary files /dev/null and b/tma_westgate.jar differ