{"action":"closed","issue":{"url":"https://api.github.com/repos/cs2103jan2015-t09-1j/main/issues/93","labels_url":"https://api.github.com/repos/cs2103jan2015-t09-1j/main/issues/93/labels{/name}","comments_url":"https://api.github.com/repos/cs2103jan2015-t09-1j/main/issues/93/comments","events_url":"https://api.github.com/repos/cs2103jan2015-t09-1j/main/issues/93/events","html_url":"https://github.com/cs2103jan2015-t09-1j/main/issues/93","id":65844644,"number":93,"title":"Undo/Redo at IO Questions...","user":{"login":"wksim91","id":10736542,"avatar_url":"https://avatars.githubusercontent.com/u/10736542?v=3","gravatar_id":"","url":"https://api.github.com/users/wksim91","html_url":"https://github.com/wksim91","followers_url":"https://api.github.com/users/wksim91/followers","following_url":"https://api.github.com/users/wksim91/following{/other_user}","gists_url":"https://api.github.com/users/wksim91/gists{/gist_id}","starred_url":"https://api.github.com/users/wksim91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wksim91/subscriptions","organizations_url":"https://api.github.com/users/wksim91/orgs","repos_url":"https://api.github.com/users/wksim91/repos","events_url":"https://api.github.com/users/wksim91/events{/privacy}","received_events_url":"https://api.github.com/users/wksim91/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-02T05:44:36Z","updated_at":"2015-04-08T10:52:44Z","closed_at":"2015-04-08T10:52:44Z","body":"\tpublic void saveToFile(ArrayList<Task> tasks) throws IOException {\r\n\t\t// Only CRUD needs to push into currentStack\r\n\t\t// Undo and Redo don't need to push into currentStack\r\n                // Create a check if its from CRUD? \r\n                // \"savetoFile(ArrayList<Task> tasks, boolean iscalledByCRUD)\"\r\n\t\tcurrentStack.push(tasks);\r\n\t\tString json = gson.toJson(tasks);\r\n\r\n\t\tOutputStream out = new BufferedOutputStream(Files.newOutputStream(\r\n\t\t\t\tstorageFile.toPath(), StandardOpenOption.WRITE,\r\n\t\t\t\tStandardOpenOption.TRUNCATE_EXISTING));\r\n\t\tout.write((json).getBytes());\r\n\t\tout.flush();\r\n\t\tout.close();\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void undoFile() throws IOException {\r\n\t\t// TODO Auto-generated method stub\r\n\t\tArrayList<Task> undoTaskList = new ArrayList<Task>();\r\n\t\t\r\n\t\tif (currentStack.isEmpty()) {\r\n\t\t\t// Return error\r\n\t\t} else {\r\n\t\t\t// Push current state into redo stack for redo-processing\r\n\t\t\tredoStack.push(currentStack.pop());\r\n\t\t\tundoTaskList = currentStack.peek();\r\n\t\t}\r\n\t\t\r\n\t\tsaveToFile(undoTaskList);\r\n\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void redoFile() throws IOException {\r\n\t\t// TODO Auto-generated method stub\r\n\t\tArrayList<Task> redoTaskList = new ArrayList<Task>();\r\n\t\t\r\n\t\tif (redoStack.isEmpty()) {\r\n\t\t\t// Return error\r\n\t\t} else {\r\n\t\t\tredoTaskList = redoStack.pop();\r\n\t\t\tundoStack.push(redoTaskList);\t\t\t\r\n\t\t}\r\n\t\t\r\n\t\tsaveToFile(redoTaskList);\r\n\t}\r\n"}}