use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class ModelTextCommand method commit.
@Override
public ICommand commit() {
ICommand command = super.commit();
finalSelection = CaretUpdater.createCU(viewer, newSelectedEntity, newSelectionStart, newSelectionEnd);
finalSelection.sheduleAsyncUpdate();
return command;
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class LifecycleAPITest method testUndoCommands.
@Test
public void testUndoCommands() {
IEntity id = model.wGet(0);
id.wSetValue("newLangName");
ICommand lastCommand = ((InternalIEntity) id).wGetLastCommand();
List<ICommand> changes = history.getUndoCommands();
ICommand command = changes.get(changes.size() - 1);
assertSame(lastCommand, command);
assertEquals(id, command.getSource());
assertEquals("newLangName", command.getNewObject());
}
use of org.whole.lang.commands.ICommand in project whole by wholeplatform.
the class AbstractEntityContext method wIndexedFeatures.
@Deprecated
public 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 AbstractEntityContext method wGetPrevVersion.
protected 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 AbstractEntity method wSet.
public boolean wSet(IEntity oldChild, IEntity newChild) {
ICommand cmd = ((InternalIEntity) oldChild).wGetBindingCommand();
while (cmd != NullCommand.instance && cmd.getSource() != this) cmd = cmd.getPrevCommand();
if (cmd == NullCommand.instance) {
int index = wIndexOf(oldChild);
if (index >= 0) {
wSet(index, newChild);
return true;
}
return false;
}
wSet(cmd.getSourceFeatureDescriptor(), newChild);
return true;
}
Aggregations