Skip to content

Commit

Permalink
Merge pull request #187 from CS2103AUG2016-T11-C1/ammendmentsDheeraj
Browse files Browse the repository at this point in the history
Ammendments dheeraj
  • Loading branch information
dheerajaraj authored Nov 2, 2016
2 parents 4c4737c + 7719d84 commit afa91bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/main/java/seedu/tasklist/commons/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ public String getUserPrefsFilePath() {
public void setUserPrefsFilePath(String userPrefsFilePath) {
this.userPrefsFilePath = userPrefsFilePath;
}


/* @@author A0135769N */
public String getTaskListFilePath() {
return taskListFilePath;
}


// Method replaces the existing file path with the new file path specified by user.
public void setTaskListFilePath(String taskListFilePath) throws JSONException, IOException, ParseException {
//JSONObject obj = (JSONObject) new JSONParser().parse(read);
//String result = (String) obj.get("taskListFilePath");
//JSONObject tasklist = (JSONObject) obj.get("taskListFilePath");
//System.out.println("Result: "+ result);
JSONObject obj = new JSONObject();
obj.put("taskListFilePath", taskListFilePath);
obj.put("userPrefsFilePath", "preferences.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SetStorageCommand extends Command {
+ "Example: " + COMMAND_WORD + " src/main/java/seedu/tasklist/logic/commands/tasklist.xml";

public static final String MESSAGE_SUCCESS = "Changed file path to: ";
public static final String SET_STORAGE_FAILURE = "File path not found. Please enter a valid file path.";
public static final String MESSAGE_STORAGE_FAILURE = "File path not found. Please enter a valid file path.";

protected Storage storage;
private static String filePath;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/tasklist/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,9 @@ public LinkedList<UndoInfo> getRedoStack() {
}
/* @@author A0135769N */
@Override
/* Method checks for the file path and the previously entered file path is saved in the
* undo command stack.
*/
public void changeFileStorage(String filePath) throws IOException, ParseException, JSONException {
String currentFilePath = setStoragePath(filePath);
addToUndoStack(UndoCommand.STR_CMD_ID, currentFilePath);
Expand All @@ -537,6 +540,10 @@ public String checkFileSpecification(String filePath){
return filePath;
}

/* Method validates whether file path given is for a file or a directory. Current file path is read from
* config.json file. Once the file is moved to the target location, the target location file path
* is automatically stored in config.json file.
*/
private String setStoragePath(String filePath)
throws FileNotFoundException, IOException, ParseException, JSONException {
if (filePath.equals("default")) {
Expand Down

0 comments on commit afa91bb

Please sign in to comment.