/** Checks if task at the top of the view is in the manager, and removes it if it isn't. */
 public void checkTopTask() {
   if (!singleTasksInView.isEmpty()
       && !TaskManager.getInstance().listTasks().contains(singleTasksInView.get(0))) {
     removeTaskFromView(singleTasksInView.get(0));
   }
   if (!groupTasksInView.isEmpty()
       && !TaskManager.getInstance().listTasks().contains(groupTasksInView.get(0).get(0))) {
     removeTaskFromView(groupTasksInView.get(0).get(0));
   }
   return;
 }
 /**
  * Runs the task macro with associated value, that is adds all the tasks in the macro to the task
  * manager.
  *
  * @param value Value of the macro to run.
  */
 public void runTaskMacro(String value) {
   if (value != null) {
     for (AbstractTask task : recordedTaskMacros.get(value)) {
       TaskManager.getInstance().addTask(task.copy());
     }
   }
 }
 /**
  * Moves a list of tasks to the bottom of the task manager model and view.
  *
  * @param tasks List of tasks to move to the bottom.
  */
 public void moveToBottomPane(ArrayList<AbstractTask> tasks) {
   if (tasks.size() == 1) {
     if (singleTasksInView.contains(tasks.get(0))) {
       singleTasksInView.remove(tasks.get(0));
       singleTasksInView.add(tasks.get(0));
     }
     // is a single task
     if (TaskManager.getInstance().listTasks().get(0) != tasks.get(0)) {
       TaskManager.getInstance().moveTask(tasks.get(0), "down");
     }
   } else {
     // is a task stack
     if (groupTasksInView.contains(tasks)) {
       groupTasksInView.remove(tasks);
       groupTasksInView.add(tasks);
     }
     for (AbstractTask task : tasks) {
       ArrayList<AbstractTask> singleTaskList = new ArrayList<AbstractTask>();
       singleTaskList.add(task);
       moveToBottomPane(singleTaskList);
     }
   }
 }
 /**
  * Moves a list of tasks to the top of the task manager model and view.
  *
  * @param tasks List of tasks to move to the top.
  */
 public void moveToTopPane(ArrayList<AbstractTask> tasks) {
   if (tasks.size() == 1) {
     if (singleTasksInView.contains(tasks.get(0))) {
       singleTasksInView.remove(tasks.get(0));
       singleTasksInView.add(0, tasks.get(0));
     }
     // is a single task
     if (TaskManager.getInstance().listTasks().get(0) != tasks.get(0)) {
       TaskManager.getInstance().moveTask(tasks.get(0), "up");
     }
   } else {
     // is a task stack
     if (groupTasksInView.contains(tasks)) {
       groupTasksInView.remove(tasks);
       groupTasksInView.add(0, tasks);
     }
     for (int i = tasks.size() - 1; i >= 0; i--) {
       AbstractTask task = tasks.get(i);
       ArrayList<AbstractTask> singleTaskList = new ArrayList<AbstractTask>();
       singleTaskList.add(task);
       moveToTopPane(singleTaskList);
     }
   }
 }
 /**
  * Removes the tasks contained in a TaskPane from the TaskManager.
  *
  * @param taskPane The TaskPane containing tasks to be removed.
  */
 public void removeTaskPane(TaskPane taskPane) {
   for (AbstractTask t : taskPane.getTasks()) {
     TaskManager.getInstance().removeTask(t);
   }
 }