use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AbstractConnectionCommand method connectionExists.
protected boolean connectionExists(IEntity source, FeatureDescriptor sourceFD, IEntity target, FeatureDescriptor targetFD) {
if (sourceFD != null && targetFD != null) {
IEntity sourceTransistion = source.wGet(sourceFD);
IEntity targetTransistion = target.wGet(targetFD);
return connectionExists(sourceTransistion, targetTransistion);
}
return false;
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AbstractConnectionCommand method getConnectionConnectedFeature.
protected FeatureDescriptor getConnectionConnectedFeature(IEntity node) {
FeatureDescriptor fd = null;
IEntityIterator<IEntity> i = IteratorFactory.childIterator();
i.reset(node);
for (IEntity child : i) if ((EntityUtils.isComposite(child) && child.wContains(getConnection())) || (EntityUtils.isSimple(child) && child.wEquals(getConnection())))
fd = node.wGetFeatureDescriptor(child);
return fd;
}
use of org.whole.lang.model.IEntity in project whole by wholeplatform.
the class AbstractConnectionCommand method connectionExists.
protected boolean connectionExists(IEntity sourceTransistion, IEntity targetTransistion) {
if (EntityUtils.isNotResolver(sourceTransistion) && EntityUtils.isNotResolver(targetTransistion)) {
IEntityIterator<IEntity> sourceChildrenIterator = EntityUtils.isComposite(sourceTransistion) ? IteratorFactory.childIterator() : IteratorFactory.selfIterator();
sourceChildrenIterator.reset(sourceTransistion);
IEntityIterator<IEntity> targetChildrenIterator = EntityUtils.isComposite(targetTransistion) ? IteratorFactory.childIterator() : IteratorFactory.selfIterator();
targetChildrenIterator.reset(targetTransistion);
for (IEntity sourceEntity : sourceChildrenIterator) {
for (IEntity targetEntity : targetChildrenIterator) if (sourceEntity.equals(targetEntity))
return true;
}
}
return false;
}
use of org.whole.lang.model.IEntity 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.model.IEntity in project whole by wholeplatform.
the class ConnectionReconnectCommand method canExecute.
public boolean canExecute() {
if (!canConnect(newNode, newNodeFeature))
return false;
oldNode = getConnection().wGet(getConnectionFeature(isSourceCommand() ? "source" : "target"));
if (oldNode.equals(newNode))
return false;
IEntity otherNode = getOtherEndpoint();
FeatureDescriptor otherFeature = getConnectionConnectedFeature(otherNode);
if (isSourceCommand())
return !connectionExists(newNode, newNodeFeature, otherNode, otherFeature);
else
return !connectionExists(otherNode, otherFeature, newNode, newNodeFeature);
}
Aggregations