@Override public Command createCommand(HttpServletRequest request, Workspace workspace) { String nodeId = request.getParameter(Arguments.nodeId.name()); String newValue = request.getParameter(Arguments.value.name()); String selectionName = request.getParameter(Arguments.selectionName.name()); return new EditCellCommand(getNewId(workspace), Command.NEW_MODEL, getWorksheetId(request, workspace), nodeId, newValue, selectionName); }
@Override public String getDescription() { if (isExecuted()) { if (newValueArg.asString().length() > 20) return "Set value to " + newValueArg.asString().substring(0, 19) + "..."; return "Set value to " + newValueArg.asString(); } return ""; }
@Override public UpdateContainer doIt(Workspace workspace) throws CommandException { Node node = workspace.getFactory().getNode(nodeIdArg); SuperSelection sel = getSuperSelection(workspace); inputColumns.clear(); outputColumns.clear(); inputColumns.add(node.getHNodeId()); outputColumns.add(node.getHNodeId()); previousValue = node.getValue(); previousStatus = node.getStatus(); if (node.hasNestedTable()) { throw new CommandException(this, "Cell " + nodeIdArg + " has a nested table. It cannot be edited."); } node.setValue(newValueArg, Node.NodeStatus.edited, workspace.getFactory()); WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this); UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, sel, workspace.getContextId()); uc.add(new NodeChangedUpdate(worksheetId, nodeIdArg, newValueArg, Node.NodeStatus.edited)); return uc; }
@Override public UpdateContainer undoIt(Workspace workspace) { Node node = workspace.getFactory().getNode(nodeIdArg); SuperSelection sel = getSuperSelection(workspace); node.setValue(previousValue, previousStatus, workspace.getFactory()); UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, sel, workspace.getContextId()); uc.add(new NodeChangedUpdate(worksheetId, nodeIdArg, previousValue, previousStatus)); return uc; }