Search in sources :

Example 11 with IEntity

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

Example 12 with IEntity

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;
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntity(org.whole.lang.model.IEntity)

Example 13 with IEntity

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

Example 14 with IEntity

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);
}
Also used : IEntity(org.whole.lang.model.IEntity) EntityKinds(org.whole.lang.reflect.EntityKinds)

Example 15 with IEntity

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);
}
Also used : IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

IEntity (org.whole.lang.model.IEntity)1407 ArrayList (java.util.ArrayList)604 Test (org.junit.Test)241 IBindingManager (org.whole.lang.bindings.IBindingManager)141 PathExpression (org.whole.lang.queries.model.PathExpression)68 ITemplateManager (org.whole.lang.templates.ITemplateManager)61 Grammar (org.whole.lang.grammars.model.Grammar)50 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)46 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)43 Model (org.whole.lang.models.model.Model)40 InternalIEntity (org.whole.lang.model.InternalIEntity)38 VisitException (org.whole.lang.visitors.VisitException)35 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)30 ModelsModel (org.whole.lang.models.codebase.ModelsModel)27 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)26 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)24 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)22 XmlModel (org.whole.lang.models.codebase.XmlModel)22 MissingVariableException (org.whole.lang.visitors.MissingVariableException)22 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)21