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();
}
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;
}
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;
}
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;
}
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;
}
Aggregations