Search in sources :

Example 11 with ICommand

use of org.whole.lang.commands.ICommand in project whole by wholeplatform.

the class IntensionalEntityContext method wGetPrevVersion.

protected final IEntity wGetPrevVersion(IEntity e) {
    ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
    if (cmd.getKind().isComposite()) {
        IEntity source = cmd.getSource();
        List<IEntity> children = wIndexedFeatures(source, ((InternalIEntity) source).wGetLastCommand().getPrevCommand().getExecutionTime());
        return children.get(cmd.getSourceIndex());
    } else
        return cmd.getPrevCommand().getNewEntity();
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) ICommand(org.whole.lang.commands.ICommand) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 12 with ICommand

use of org.whole.lang.commands.ICommand in project whole by wholeplatform.

the class IntensionalEntityContext method wIndexedFeatures.

@Deprecated
public final List<IEntity> wIndexedFeatures(IEntity e, int contextTime) {
    List<IEntity> result = childrenCache.get(e);
    if (result != null && this.contextTime == contextTime)
        return result;
    result = new ArrayList<IEntity>(e.wFeatures());
    ICommand cmd = ((InternalIEntity) e).wGetLastCommand();
    while (contextTime < cmd.getExecutionTime()) {
        switch(cmd.getKind()) {
            case ADD:
                result.remove(cmd.getSourceIndex());
                break;
            case REMOVE:
                result.add(cmd.getSourceIndex(), cmd.getOldEntity());
                break;
            case CHANGE:
                result.set(cmd.getSourceIndex(), cmd.getOldEntity());
                break;
        }
        cmd = cmd.getPrevCommand();
    }
    if (this.contextTime == contextTime)
        childrenCache.put(e, result);
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) ICommand(org.whole.lang.commands.ICommand) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 13 with ICommand

use of org.whole.lang.commands.ICommand in project whole by wholeplatform.

the class AbstractOrderedCompositeEntity method wSetLastCommand.

public /*final*/
ICommand wSetLastCommand(ICommand command) {
    ICommand prevCommand = lastCommand;
    lastCommand = command;
    return prevCommand;
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Example 14 with ICommand

use of org.whole.lang.commands.ICommand in project whole by wholeplatform.

the class AbstractEntity method wGetLastCommand.

public ICommand wGetLastCommand() {
    ICommand cmd = NullCommand.instance;
    int maxTime = Integer.MIN_VALUE;
    for (int i = 0, size = wSize(); i < size; i++) {
        ICommand featureCmd = ((InternalIEntity) wGet(i)).wGetBindingCommand();
        if (maxTime < featureCmd.getExecutionTime()) {
            cmd = featureCmd;
            maxTime = featureCmd.getExecutionTime();
        }
    }
    return cmd;
}
Also used : ICommand(org.whole.lang.commands.ICommand)

Example 15 with ICommand

use of org.whole.lang.commands.ICommand in project whole by wholeplatform.

the class HistoryManager method compound.

protected CompoundCommand compound(int beginIndex) {
    CompoundCommand command = null;
    int size = lastExecutedIndex + 1 - beginIndex;
    if (size > 0) {
        List<ICommand> subList = history.subList(beginIndex, lastExecutedIndex + 1);
        command = new CompoundCommand(nextExecutionTime(), reduce(subList).toArray(new ICommand[0]));
        subList.clear();
        addCommand(command);
    }
    return command;
}
Also used : ICommand(org.whole.lang.commands.ICommand) CompoundCommand(org.whole.lang.commands.CompoundCommand)

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