use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class BindingCommandTest method testBindingCommand.
@Test
public void testBindingCommand() {
IEntity program = new ExampleTest().create();
IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
i.reset(program);
for (IEntity e : i) if (((InternalIEntity) e).wGetBindingCommand() != NullCommand.instance)
Assert.fail();
program = EntityUtils.clone(program);
i = IteratorFactory.<IEntity>descendantOrSelfIterator();
i.reset(program);
for (IEntity e : i) if (((InternalIEntity) e).wGetBindingCommand() != NullCommand.instance)
Assert.fail();
}
use of org.whole.lang.model.InternalIEntity in project whole by wholeplatform.
the class CloneOperation method applyClone.
protected IEntity applyClone(IEntity entity) {
IEntity entityClone = ((InternalIEntity) entity).wShallowClone();
setCopy(entity, entityClone);
setChildrenAndAspects(entity, entityClone);
return entityClone;
}
use of org.whole.lang.model.InternalIEntity 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.model.InternalIEntity 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.model.InternalIEntity in project whole by wholeplatform.
the class CloneOperationOld method cloneDescendantTree.
protected IEntity cloneDescendantTree(IEntity entity) {
IEntity entityClone = entityCloneMap.get(entity);
if (entityClone == null) {
entityClone = ((InternalIEntity) entity).wShallowClone();
entityCloneMap.put(entity, entityClone);
for (// TODO test was int i=entityClone.wSize()-1; i>=0; i--)
int i = 0; // TODO test was int i=entityClone.wSize()-1; i>=0; i--)
i < entityClone.wSize(); // TODO test was int i=entityClone.wSize()-1; i>=0; i--)
i++) cloneAndUpdate(entityClone, i);
for (FeatureDescriptor fd : entity.wGetAspectualFeatureDescriptors()) if (!fd.isReference())
cloneAndUpdate(entityClone, fd);
}
return entityClone;
}
Aggregations