use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class HistoryManager method toString.
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("History Manager (enabled=");
builder.append(isHistoryEnabled());
builder.append(" size=");
builder.append(getUndoSize());
builder.append('u');
builder.append(getRedoSize());
builder.append('r');
builder.append(" capacity=");
builder.append(getHistoryCapacity() == Integer.MAX_VALUE ? "*" : getHistoryCapacity());
builder.append(")\n[");
for (ICommand command : getUndoCommands()) {
builder.append("\n");
builder.append(command.toString());
}
builder.append("\n--");
for (ICommand command : getRedoCommands()) {
builder.append("\n");
builder.append(command.toString());
}
builder.append("\n]");
return builder.toString();
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class HistoryManager method mergeHistory.
// assume that subHistory will be replaced by the returned one
public IHistoryManager mergeHistory(IHistoryManager subHistory) {
int size = subHistory.getUndoSize();
if (size > 0 && !subHistory.equals(this)) {
ICommand[] changes = subHistory.getUndoCommands().toArray(new ICommand[size]);
ICommand command = new CompoundCommand(nextExecutionTime(), changes);
addCommand(command);
}
return this;
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class HistoryManager method discard.
protected void discard(int beginIndex) {
disposeRedoCommands();
boolean isEnabled = setHistoryEnabled(false);
setHistoryEvent(true);
while (lastExecutedIndex >= beginIndex) {
ICommand command = history.remove(lastExecutedIndex--);
command.undo();
command.dispose();
}
setHistoryEvent(false);
setHistoryEnabled(isEnabled, true);
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class AbstractDataEntity method wSetLastCommand.
public /*final*/
ICommand wSetLastCommand(ICommand command) {
ICommand prevCommand = lastCommand;
lastCommand = command;
return prevCommand;
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class IntensionalEntityContext method wSize.
public int wSize() {
int size = entity.wSize();
ICommand cmd = wGetLastCommand();
while (contextTime < cmd.getExecutionTime()) {
switch(cmd.getKind()) {
case ADD:
size--;
break;
case REMOVE:
size++;
break;
}
cmd = cmd.getPrevCommand();
}
return size;
}
Aggregations