public void insertCommandToHistoryAfterCommand(ICommand newCommand, ICommand afterCommand) { String worksheetId = getWorksheetId(afterCommand); if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap commandTagListMap = historyWorksheetMap.get(worksheetId); if (commandTagListMap != null) { for (Map.Entry<ICommand.CommandTag, List<ICommand>> entry : commandTagListMap.commandTagListHashMap.entrySet()) { int index = entry.getValue().indexOf(afterCommand); if (index != -1) { entry.getValue().add(index+1, newCommand); } } } }
public void replaceCommandFromHistory(ICommand oldCommand, ICommand newCommand) { String worksheetId = getWorksheetId(oldCommand); if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap commandTagListMap = historyWorksheetMap.get(worksheetId); if (commandTagListMap != null) { for (Map.Entry<ICommand.CommandTag, List<ICommand>> entry : commandTagListMap.commandTagListHashMap.entrySet()) { int index = entry.getValue().indexOf(oldCommand); if (index != -1) { entry.getValue().set(index, newCommand); } } } }
public void insertCommandToHistory(ICommand command) { 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.addCommandToHistory(command); }
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); }
public void setLastRedoCommandObject(RedoCommandObject command) { String worksheetId = getWorksheetId(command.getCommand()); if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap commandTagListMap = historyWorksheetMap.get(worksheetId); if (commandTagListMap == null) { commandTagListMap = new CommandTagListMap(); historyWorksheetMap.put(worksheetId, commandTagListMap); } if (commandTagListMap.lastRedoCommand == null) { commandTagListMap.lastRedoCommand = command; } }
public List<ICommand> getCommandsAfterCommand(ICommand command, ICommand.CommandTag commandTag) { List<ICommand> commands = new ArrayList<>(); String worksheetId = getWorksheetId(command); if (worksheetId == null) { worksheetId = IMPORT_COMMANDS; } CommandTagListMap map = historyWorksheetMap.get(worksheetId); if (map != null) { List<ICommand> tagCommands = map.getCommands(commandTag); boolean start = false; for(ICommand cmd : tagCommands) { if(cmd.equals(command)) { start = true; continue; } if(start) commands.add(cmd); } commands.addAll(map.getCommands(commandTag)); } return commands; }
Pair<ICommand, Object> consolidatedCommand = null; String consolidatorName = null; String worksheetId = worksheetCommandHistory.getWorksheetId(command); RepFactory factory = workspace.getFactory(); List<ICommand> potentialConsolidateCommands = worksheetCommandHistory.getCommandsFromWorksheetIdAndCommandTag(worksheetId, command.getTagFromPriority()); worksheetId = worksheetCommandHistory.getWorksheetId(command); worksheetCommandHistory.clearRedoCommand(worksheetId); worksheetCommandHistory.setCurrentCommand(command, consolidatedCommand);