Search in sources :

Example 1 with ICommand

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

Example 2 with ICommand

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());
}
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) Test(org.junit.Test)

Example 3 with ICommand

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;
}
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 4 with ICommand

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();
}
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 5 with ICommand

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;
}
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