use of org.whole.lang.reflect.EntityKinds in project whole by wholeplatform.
the class ModelLabelProvider method getText.
public String getText(Object element) {
if (element instanceof IEntity) {
IEntity entity = (IEntity) element;
StringBuilder sb = new StringBuilder(entity.wGetEntityDescriptor().getName());
EntityKinds kind = entity.wGetEntityKind();
if (kind.isComposite()) {
sb.append('[');
sb.append(entity.wSize());
sb.append(']');
} else if (kind.isData()) {
sb.append(": ");
sb.append(entity.wGetValue());
}
return sb.toString();
} else
return super.getText(element);
}
use of org.whole.lang.reflect.EntityKinds in project whole by wholeplatform.
the class DefaultCopyTransformer method transform.
public void transform(IEntity oldEntity, IEntity newEntity) {
// if (newEntity.wGetEntityDescriptor().equals(oldEntity.wGetEntityDescriptor()))
// return;
EntityKinds oldKind = oldEntity.wGetEntityKind();
EntityKinds newKind = newEntity.wGetEntityKind();
if ((oldKind.isSimple() && newKind.isSimple()) || (EntityUtils.isVariable(oldEntity) && EntityUtils.isVariable(newEntity))) {
// TODO workaround
List<FeatureDescriptor> oldFeatures = oldEntity.wGetEntityDescriptor().getEntityFeatureDescriptors();
Set<FeatureDescriptor> commonFeatures = new HashSet<FeatureDescriptor>();
for (FeatureDescriptor fd : newEntity.wGetEntityDescriptor().getEntityFeatureDescriptors()) if (oldFeatures.contains(fd.getFeatureDescriptor()))
commonFeatures.add(fd);
for (FeatureDescriptor fd : commonFeatures) {
IEntity oldChild = oldEntity.wGet(fd.getFeatureDescriptor());
if (fd.getEntityDescriptor().isPlatformSupertypeOf(oldChild.wGetEntityDescriptor()))
newEntity.wSet(fd, EntityUtils.clone(oldChild));
}
} else if (oldKind.isComposite() && newKind.isComposite()) {
EntityDescriptor<?> newComponentDescriptor = newEntity.wGetEntityDescriptor(0);
for (int i = 0, size = oldEntity.wSize(); i < size; i++) {
IEntity oldChild = oldEntity.wGet(i);
if (newComponentDescriptor.isPlatformSupertypeOf(oldChild.wGetEntityDescriptor()))
newEntity.wSet(i, EntityUtils.clone(oldChild));
}
} else if (EntityUtils.isFragment(oldEntity) && EntityUtils.isFragment(newEntity)) {
// TODO workaround
newEntity.wSet(0, EntityUtils.clone(oldEntity.wGet(0)));
}
}
use of org.whole.lang.reflect.EntityKinds in project whole by wholeplatform.
the class DefaultWrapWithinTransformer method transform.
public void transform(IEntity oldEntity, IEntity newEntity) {
EntityKinds newKind = newEntity.wGetEntityKind();
if (newKind.isData())
return;
IEntity containerEntity;
if (featureDescriptor != null)
containerEntity = newEntity.wGet(featureDescriptor);
else
containerEntity = newEntity;
if (!EntityUtils.isComposite(containerEntity))
return;
if (containerEntity.wGetEntityDescriptor(0).isPlatformSupertypeOf(oldEntity.wGetEntityDescriptor())) {
IEntity clone = EntityUtils.clone(oldEntity);
containerEntity.wSet(0, clone);
}
}
use of org.whole.lang.reflect.EntityKinds in project whole by wholeplatform.
the class TestsInterpreterVisitor method visit.
@Override
public void visit(HasKind entity) {
EntityKinds kind = EntityKinds.valueOf(entity.getKind().getValue().getName());
setResultVisitor(GenericMatcherFactory.instance.hasKindMatcher(kind).withSourceEntity(entity));
}
use of org.whole.lang.reflect.EntityKinds in project whole by wholeplatform.
the class QueriesDynamicCompilerVisitor method visit.
@Override
public void visit(KindTest entity) {
Value kind = entity.getValue();
switch(kind.getOrdinal()) {
case KindTestEnum.IMPL_ord:
setResultIterator(IteratorFactory.isImplIterator().withSourceEntity(entity));
break;
case KindTestEnum.FRAGMENT_ord:
setResultIterator(IteratorFactory.isFragmentIterator().withSourceEntity(entity));
break;
case KindTestEnum.VARIABLE_ord:
setResultIterator(IteratorFactory.isVariableIterator().withSourceEntity(entity));
break;
case KindTestEnum.RESOLVER_ord:
setResultIterator(IteratorFactory.isResolverIterator().withSourceEntity(entity));
break;
default:
EntityKinds ekind = EntityKinds.valueOf(kind.getName());
setResultIterator(IteratorFactory.hasKindIterator(ekind).withSourceEntity(entity));
}
}
Aggregations