Search in sources :

Example 36 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyChanged.

protected final void notifyChanged(Object oldValue, Object newValue) {
    if (newValue == oldValue || (newValue != null && oldValue != null && newValue.equals(oldValue)))
        return;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.data_value;
    wGetEntityChangeEventHandler().notifyChanged(this, fd, oldValue, newValue);
    wGetCompoundChangeEventHandler().notifyChanged(this, fd, oldValue, newValue);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 37 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyRequested.

protected final Date notifyRequested(Date value) {
    if (requestNotificationDisabled)
        return value;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.data_value;
    Date result = wGetEntityRequestEventHandler().notifyRequested(this, fd, value);
    return wGetCompoundRequestEventHandler().notifyRequested(this, fd, result);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) Date(java.util.Date)

Example 38 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyRequested.

protected final double notifyRequested(double value) {
    if (requestNotificationDisabled)
        return value;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.data_value;
    double result = wGetEntityRequestEventHandler().notifyRequested(this, fd, value);
    return wGetCompoundRequestEventHandler().notifyRequested(this, fd, result);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 39 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyRequested.

@SuppressWarnings("unchecked")
protected final <E extends IEntity> E notifyRequested(int index, E value) {
    if (requestNotificationDisabled)
        return value;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.composite_element;
    IEntity value0 = value.wGetAdaptee(false);
    IEntity result = wGetEntityRequestEventHandler().notifyRequested(this, fd, index, value0);
    result = wGetCompoundRequestEventHandler().notifyRequested(this, fd, index, result);
    return result == value0 ? value : (E) result;
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 40 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractEntity method notifyChanged.

protected final void notifyChanged(FeatureDescriptor fd, IEntity oldValue, IEntity newValue, boolean isContainment) {
    if (oldValue == null)
        oldValue = NullEntity.instance;
    final IEntity oldValue0 = oldValue.wGetAdaptee(false);
    final IEntity newValue0 = newValue.wGetAdaptee(false);
    if (newValue0 == oldValue0)
        return;
    final InternalIEntity internalOldValue = (InternalIEntity) oldValue;
    final InternalIEntity internalNewValue = (InternalIEntity) newValue;
    EntityDescriptor<?> thisEd = wGetEntityDescriptor();
    FeatureDescriptor oppositeFd;
    if (thisEd.has(fd))
        // getOppositeFeatureDescriptor(fd);
        oppositeFd = thisEd.getEntityFeatureDescriptor(fd).getOppositeFeatureDescriptor();
    else {
        EntityDescriptor<?> oppositeEd = newValue.wGetEntityDescriptor();
        oppositeFd = oppositeEd.getDirectFeatureDescriptor(fd);
        if (oppositeFd != null)
            thisEd = oppositeEd.getEntityDescriptor(oppositeFd);
    }
    if (oppositeFd != null) {
        final EntityDescriptor<?> featureEd = thisEd.getEntityDescriptor(fd);
        final boolean isToMany = featureEd.isToManyRelationship();
        final boolean wasToManyImpl = isToMany && Matcher.matchImpl(featureEd, oldValue);
        final boolean isToManyImpl = isToMany && Matcher.matchImpl(featureEd, newValue);
        if (wasToManyImpl)
            for (int i = 0, size = oldValue.wSize(); i < size; i++) oldValue.wGet(i).wRemove(oppositeFd, this);
        else
            oldValue.wRemove(oppositeFd, this);
        if (isToManyImpl)
            for (int i = 0, size = newValue.wSize(); i < size; i++) newValue.wGet(i).wAdd(oppositeFd, this, true);
        else
            newValue.wAdd(oppositeFd, this, true);
    }
    if (isContainment) {
        internalOldValue.wRemoveParent(this);
        internalNewValue.wSetModel(wGetActualModel());
        internalNewValue.wSetParent(this);
    } else {
        internalOldValue.wRemoveInverseAdjacent(this);
        if (!EntityUtils.hasParent(newValue))
            internalNewValue.wSetModel(wGetActualModel());
        internalNewValue.wAddInverseAdjacent(this);
    }
    wGetEntityChangeEventHandler().notifyChanged(this, fd, oldValue0, newValue0);
    wGetCompoundChangeEventHandler().notifyChanged(this, fd, oldValue0, newValue0);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)100 IEntity (org.whole.lang.model.IEntity)43 InternalIEntity (org.whole.lang.model.InternalIEntity)6 ILanguageKit (org.whole.lang.reflect.ILanguageKit)6 HashSet (java.util.HashSet)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 ActionsVisibleWhen (org.whole.lang.e4.ui.expressions.ActionsVisibleWhen)5 VisibilityExpression (org.whole.lang.e4.ui.expressions.VisibilityExpression)5 ActionsCompositeContributionItem (org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IdentityRequestEventHandler (org.whole.lang.events.IdentityRequestEventHandler)3 IMappingStrategy (org.whole.lang.xsd.codebase.IMappingStrategy)3 IEntityFactory (org.whole.lang.factories.IEntityFactory)2 ArrayType (org.whole.lang.pojo.model.ArrayType)2 CollectionType (org.whole.lang.pojo.model.CollectionType)2 MapType (org.whole.lang.pojo.model.MapType)2