@Override public WorksheetCommandHistory clone() { WorksheetCommandHistory worksheetCommandHistory = new WorksheetCommandHistory(); for (String worksheetId : getAllWorksheetId()) { worksheetCommandHistory.historyWorksheetMap.put(worksheetId, new CommandTagListMap()); } for (ICommand command : getAllCommands()) { worksheetCommandHistory.insertCommandToHistory(command); } for (String worksheetId : getAllWorksheetId()) { CommandTagListMap newMap = worksheetCommandHistory.historyWorksheetMap.get(worksheetId); CommandTagListMap oldMap = this.historyWorksheetMap.get(worksheetId); if (oldMap != null && newMap != null) { if (oldMap.currentCommand != null) { newMap.currentCommand = new RedoCommandObject( oldMap.currentCommand.getCommand(), oldMap.currentCommand.getConsolidatedCommand()); } if (oldMap.lastRedoCommand != null) { newMap.lastRedoCommand = new RedoCommandObject( oldMap.lastRedoCommand.getCommand(), oldMap.lastRedoCommand.getConsolidatedCommand()); } newMap.stale = oldMap.stale; } } return worksheetCommandHistory; }
public void clearCurrentCommand(String worksheetId) { if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap commandTagListMap = historyWorksheetMap.get(worksheetId); if (commandTagListMap != null) { commandTagListMap.currentCommand = null; } }
public void setCurrentCommand(ICommand command, Pair<ICommand, Object> consolidatedCommand) { String worksheetId = getWorksheetId(command); if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap commandTagListMap = historyWorksheetMap.get(worksheetId); if (commandTagListMap == null) { commandTagListMap = new CommandTagListMap(); historyWorksheetMap.put(worksheetId, commandTagListMap); } commandTagListMap.currentCommand = new RedoCommandObject(command, consolidatedCommand); }