Search in sources :

Example 6 with ICommand

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();
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Example 7 with ICommand

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;
}
Also used : ICommand(org.whole.lang.commands.ICommand) CompoundCommand(org.whole.lang.commands.CompoundCommand)

Example 8 with ICommand

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);
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Example 9 with ICommand

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;
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Example 10 with ICommand

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;
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Aggregations

ICommand (org.whole.lang.commands.ICommand)17 IEntity (org.whole.lang.model.IEntity)7 InternalIEntity (org.whole.lang.model.InternalIEntity)6 CompoundCommand (org.whole.lang.commands.CompoundCommand)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)1