/** * @author boconno3, elee3, asaini, rparames * <p>This method will, if the user has selected a task in the tree for which they are a * creator, allow them to change the owner of the task as long as the owner exists in the * database */ private void changeTaskOwner() { TreeNode node = null; if (view.getTree().getLastSelectedPathComponent() instanceof TreeNode) { node = (TreeNode) view.getTree().getLastSelectedPathComponent(); } else { return; } if (node != null) { String owner = view.showInputDialog( "Who is the new owner of the task? (User must exist in the current database)"); if (owner == null) { return; } else if (!(model.containsUser(owner))) { view.displayError("That owner is not in the database"); return; } model.changeTaskOwner((String) node.getUserObject(), owner); } }
/** * @author boconno3, elee3, asaini, rparames * <p>This method will ask the user for all of the characteristics of a task that they want to * add and will then, depending on where in the tree they have selected, insert the task in * the correct place if it is a valid move */ private void addNewTask() { TreeNode node = null; String lastSelected = ""; if (view.getTree().getLastSelectedPathComponent() instanceof TreeNode) { node = (TreeNode) view.getTree().getLastSelectedPathComponent(); } else { try { lastSelected = (String) view.getTree().getLastSelectedPathComponent().toString(); } catch (Exception exception) { return; } } if (lastSelected.equals("Project Collection")) { view.displayError("You cannot add a task here!"); } else { if (node != null) { Date date; String name = view.showInputDialog( "What is the name of the new task? (Do not use a component name that already exists)"); if (name == null) { return; } String parent = (String) node.getUserObject(); if (parent == null) { return; } String owner = view.showInputDialog( "Who is the owner of the task? (Please enter a user that exists in the current database)"); if (owner == null) { return; } else if (!(model.containsUser(owner))) { view.displayError("That owner is not in the database"); return; } String deadline = view.showInputDialog( "Please enter the date for the deadline of the task? (Use the format yyyy/mm/dd "); try { date = new Date(deadline); } catch (Exception exception) { view.displayError("An invalid date was entered"); return; } if (deadline == null) { return; } String description = view.showInputDialog("Please enter the description for the task: "); if (description == null) { return; } if (parent.equalsIgnoreCase("Project Collection")) { view.displayError("You cannot add a task here!"); } else { model.addComponent(name, "Task", parent, owner, date, description); } } else { view.displayError("Please select a subproject to add a task under"); } } }