Exemplo n.º 1
0
  private void init() {
    inputParser = new ParserMain();
    storageSystem = new StorageMain();

    masterListTasks = new ArrayList<Task>();
    completeTasks = new ArrayList<Task>();
    incompleteTasks = new ArrayList<Task>();
    state = new ArrayList<ArrayList<Task>>();

    masterListTasks = new ArrayList<Task>(storageSystem.loadTask());
  }
Exemplo n.º 2
0
 /**
  * Changes file save location.
  *
  * @param taskToOp
  * @return feedback message
  */
 private String doSave(Task taskToOp) {
   String feedBack;
   String newLoc = taskToOp.get_task();
   assert newLoc != null;
   assert newLoc != SYMBOL_EMPTY;
   if (!newLoc.isEmpty()) {
     try {
       storageSystem.saveFileLocation(newLoc);
       feedBack = taskToOp.get_messageToUserSuccess();
     } catch (Exception e) {
       log.log(Level.SEVERE, e.toString(), e);
       feedBack = taskToOp.get_messageToUserFail();
     }
   } else {
     feedBack = taskToOp.get_messageToUserFail();
   }
   return feedBack;
 }
Exemplo n.º 3
0
  /**
   * Method processes user input by calling dependencies Parser and LogicHandler
   *
   * @param userInput is the input received from UI.
   * @return feedBack message generated by command.
   */
  public String processCommand(String userInput) {
    String[] formattedInput = inputParser.processInput(userInput);
    ArrayList<ArrayList<String>> dateTimeArgs = inputParser.processDateTime(userInput);
    Task newCreatedTask = LogicHandler.processCommand(formattedInput, dateTimeArgs);
    String feedbackToUI = operateOnTask(newCreatedTask);

    logList();
    if (isMutatorAndNotUndoRedo(newCreatedTask)) {
      updateState();
    }

    sortList();
    regenerateSubListsFromMasterList();

    if (!isSearchOrDisplay(newCreatedTask)) {
      updateOperating();
    }
    logList();
    storageSystem.storageWrite(masterListTasks);
    return feedbackToUI;
  }