コード例 #1
0
 /**
  * This method updates the completed task list after a change is done to the task by updating the
  * line index.
  *
  * @param newList the completed task list
  */
 private void updateCompleteListFile(ArrayList<Task> newList) {
   modifier.updateIndex(newList);
   modifier.saveCompleteFile(newList);
   if (isViewModeComplete()) {
     modifier.display(newList);
   }
 }
コード例 #2
0
 /**
  * This method updates the list after a change is done to the task by sorting the list and then
  * updating the line index after that
  *
  * @param newList the task list
  */
 private void updateFile(ArrayList<Task> newList) {
   modifier.sort(newList);
   modifier.updateIndex(newList);
   TaskCheckLogic.overDateCheck(newList);
   modifier.saveFile(newList);
   modifier.display(newList);
 }
コード例 #3
0
 /** This method clears the entire list of tasks */
 public void clearAll() {
   ArrayList<Task> taskList;
   if (isViewModeComplete()) {
     taskList = modifier.getCompleteContentList();
     taskList.clear();
     updateCompleteListFile(taskList);
     LoggingLogic.logging(CLEAR_VALID);
   } else {
     taskList = modifier.getContentList();
     taskList.clear();
     updateFile(taskList);
     LoggingLogic.logging(CLEAR_VALID);
   }
 }
コード例 #4
0
 /**
  * Edits the block timeline, which has a start and end time
  *
  * @param index the line index of the task to be edited
  */
 public void editBlock(int index) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task tempTask = taskList.get(index);
   tempTask.setBlocking(false);
   taskList.set(index, tempTask);
   updateFile(taskList);
 }
コード例 #5
0
 /**
  * This method edits the importance variable of the task
  *
  * @param IndexToBeEdit the line index of the task to be edited
  * @param newImportance the edited version of the importance variable
  */
 public void editImportance(int IndexToBeEdit, int newImportance) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task task = taskList.get(IndexToBeEdit);
   task.setImportance(newImportance);
   taskList.set(IndexToBeEdit, task);
   updateFile(taskList);
 }
コード例 #6
0
 /**
  * This method edits the title of the task
  *
  * @param lineToBeEdit the line index of the task to be edited
  * @param newTitle the edited version of the title
  */
 public void editTitle(int lineToBeEdit, String newTitle) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task task = taskList.get(lineToBeEdit);
   task.setEventTitle(newTitle);
   taskList.set(lineToBeEdit, task);
   updateFile(taskList);
 }
コード例 #7
0
  /**
   * This method removes a task from the current list
   *
   * @param index the line number of the task to be removed
   */
  public void removeTask(int index) {
    assert index >= 0;

    ArrayList<Task> taskList;
    if (isViewModeComplete()) {
      taskList = modifier.getCompleteContentList();
      taskList.remove(index);
      updateCompleteListFile(taskList);
      LoggingLogic.logging(DELETE_VALID);
    } else {
      taskList = modifier.getContentList();
      taskList.remove(index);
      updateFile(taskList);
      LoggingLogic.logging(DELETE_VALID);
    }
  }
コード例 #8
0
 /**
  * This method edits the recursive tasks, by changing these variables; the period of repetition
  * and the type of repetition.
  *
  * @param index line index
  * @param newPeriod The time frame of the recursive task
  * @param repeatType the type of recursive task
  */
 public void editRepeat(int index, int newPeriod, String repeatType) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task tempTask = taskList.get(index);
   tempTask.setRepeatCycle(newPeriod);
   tempTask.setRepeatType(repeatType);
   taskList.set(index, tempTask);
   updateFile(taskList);
 }
コード例 #9
0
 /**
  * This method edits the end date variable, by checking whether it is a date object with time or
  * date without time then changes the date appropriately
  *
  * @param lineToBeEdit the line index of the task to be edited
  * @param endDate the date object, with or without time
  */
 public void editEndDate(int lineToBeEdit, String endDate) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task task = taskList.get(lineToBeEdit);
   if (endDate.contains(" ")) {
     task.setEndDateWithTime(endDate);
     task.setHasTime(true);
   } else {
     task.setEndDate(endDate);
     task.setHasTime(false);
   }
   taskList.set(lineToBeEdit, task);
   updateFile(taskList);
 }
コード例 #10
0
  /**
   * This method sends the task selected into the completed task list and removes it from the
   * current task list
   *
   * @param index the line index of the task to be moved
   */
  public void completeTask(int index) {
    ArrayList<Task> completedList = modifier.getCompleteContentList();
    ArrayList<Task> taskList = modifier.getContentList();
    Calendar calendar = Calendar.getInstance();

    Task completedTask = taskList.get(index);
    if (completedTask.getRepeat() == false) {
      completedTask.setComplete();
      completedList.add(0, completedTask);
      taskList.remove(index);
      updateFile(taskList);
      updateCompleteListFile(completedList);
    } else {
      if (completedTask.getStartDate() == null) {
        Date currentDeadline = completedTask.getEndDateInDateType();
        int repeatCycle = completedTask.getRepeatCycle();
        String repeatType = completedTask.getRepeatType();
        calendar.setTime(currentDeadline);
        Date nextDeadline = getNextDeadline(calendar, repeatCycle, repeatType);
        completedTask.setEndDateInDate(nextDeadline);
        taskList.set(index, completedTask);
        updateFile(taskList);
      } else {
        Date currentStartDate = completedTask.getStartDateInDateType();
        Date currentEndDate = completedTask.getEndDateInDateType();
        int repeatCycle = completedTask.getRepeatCycle();
        String repeatType = completedTask.getRepeatType();
        calendar.setTime(currentStartDate);
        Date nextStartDate = getNextDeadline(calendar, repeatCycle, repeatType);
        calendar.setTime(currentEndDate);
        Date nextEndDate = getNextDeadline(calendar, repeatCycle, repeatType);
        completedTask.setStartDateInDate(nextStartDate);
        completedTask.setEndDateInDate(nextEndDate);
        taskList.set(index, completedTask);
        updateFile(taskList);
      }
    }
  }
コード例 #11
0
  /**
   * This method searches the current list by title/keyword, not caring about case sensitivity
   *
   * @param keyword the keyword to be searched for
   * @return the list of tasks which contains the keyword
   */
  public ArrayList<Task> searchKeyword(String keyword) {
    ArrayList<Task> taskList = modifier.getContentList();
    ArrayList<Task> searchList = new ArrayList<Task>();

    assert keyword != null;

    for (int i = 0; i < taskList.size(); i++) {
      Task task = taskList.get(i);
      if (task.getTitle().toLowerCase().contains(keyword.toLowerCase())) {
        searchList.add(task);
      }
    }
    return searchList;
  }
コード例 #12
0
  /**
   * This method searches the current list by the importance variable
   *
   * @param searchKey The level of importance, 1, 2 or 3
   * @return the list of tasks which has that importance level
   */
  public ArrayList<Task> searchByImportance(int searchKey) {
    ArrayList<Task> taskList = modifier.getContentList();
    ArrayList<Task> searchList = new ArrayList<Task>();

    assert searchKey >= 1;
    assert searchKey <= 3;

    for (int i = 0; i < taskList.size(); i++) {
      Task task = taskList.get(i);
      if (task.getImportance() == searchKey) {
        searchList.add(task);
      }
    }
    return searchList;
  }
コード例 #13
0
  /**
   * This method adds the task to the current list of tasks
   *
   * @param newtask the task to be added into the list
   */
  public boolean addTask(Task newtask) {
    assert newtask != null;

    if (TaskCheckLogic.blockedDateCheck(newtask)) {
      ArrayList<Task> newList = modifier.getContentList();
      newList.add(newtask);
      updateFile(newList);
      LoggingLogic.logging(ADDING_SUCCESSFUL);
      return true;
    } else {
      FeedbackPane.displayInvalidAddBlocked();
      LoggingLogic.logging(ADDING_UNSUCCESSFUL);
      return false;
    }
  }
コード例 #14
0
  /**
   * This method searches the current list by the date input
   *
   * @param date the date variable
   * @return list of tasks which is on the date searched
   */
  public ArrayList<Task> searchByDate(String date) {
    ArrayList<Task> taskList = modifier.getContentList();
    ArrayList<Task> searchList = new ArrayList<Task>();

    assert date != null;

    for (int i = 0; i < taskList.size(); i++) {
      Task task = taskList.get(i);
      if (task.getEndDate() != null) {
        if (task.getDateInputForm().contains(date)) {
          searchList.add(task);
        }
      }
    }
    return searchList;
  }
コード例 #15
0
 /**
  * This method edits the entire timeline of the task, which must include both the start date as
  * well as the end date
  *
  * @param lineToBeEdit the line index of the task to be edited
  * @param startDate the start date object with or without time
  * @param endDate the end date object with or without time
  */
 public boolean editTimeline(int lineToBeEdit, String startDate, String endDate) {
   ArrayList<Task> taskList = modifier.getContentList();
   Task task = taskList.get(lineToBeEdit);
   if (startDate.contains(" ")) {
     task.setStartDateWithTime(startDate);
     task.setEndDateWithTime(endDate);
     task.setHasTime(true);
   } else {
     task.setStartDate(startDate);
     task.setEndDate(endDate);
     task.setHasTime(false);
   }
   if (TaskCheckLogic.blockedDateCheck(task)) {
     taskList.set(lineToBeEdit, task);
     updateFile(taskList);
     return true;
   } else {
     FeedbackPane.displayInvalidEditBlocked();
     return false;
   }
 }