Search in sources :

Example 76 with FeatureDescriptor

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

the class HistoryManager method reduce.

// TODO called by model to delta Stream if changes.size > model.size
protected List<ICommand> reduce(List<ICommand> commands) {
    if (commands.isEmpty())
        return commands;
    List<ICommand> list = new ArrayList<ICommand>();
    for (int i = 0, size = commands.size(); i < size; i++) {
        ICommand command = commands.get(i);
        if (CommandKind.COMPOUND == command.getKind()) {
            for (ICommand child : ((CompoundCommand) command).commands) list.add(child);
        } else
            list.add(command);
    }
    int index = list.size() - 1;
    while (index > 0) {
        ICommand lastCommand = list.get(index--);
        if (CommandKind.CHANGE == lastCommand.getKind()) {
            IEntity lastSource = lastCommand.getSource();
            FeatureDescriptor lastSourceFD = lastCommand.getSourceFeatureDescriptor();
            int firstIndex = index;
            while (firstIndex >= 0) {
                ICommand firstCommand = list.get(firstIndex);
                if (CommandKind.CHANGE != firstCommand.getKind() || firstCommand.getSource() != lastSource || firstCommand.getSourceFeatureDescriptor() != lastSourceFD)
                    break;
                else
                    firstIndex--;
            }
            if (firstIndex < index) {
                if (lastSourceFD == null)
                    lastCommand.setOldObject(list.get(firstIndex + 1).getOldObject());
                else
                    lastCommand.setOldEntity(list.get(firstIndex + 1).getOldEntity());
                for (int i = firstIndex + 1; i <= index; i++) list.remove(firstIndex + 1).dispose();
                index = firstIndex;
            }
        }
    }
    return list;
// iterate over model tree to exclude overridden commands
// for each command discard overridden prevCommands
}
Also used : IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ICommand(org.whole.lang.commands.ICommand) ArrayList(java.util.ArrayList) CompoundCommand(org.whole.lang.commands.CompoundCommand)

Example 77 with FeatureDescriptor

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

the class AbstractEntity method notifyRequested.

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

Example 78 with FeatureDescriptor

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

the class AbstractEntity method notifyChanged.

protected final void notifyChanged(int index, IEntity oldValue, IEntity newValue, boolean isContainment) {
    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;
    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);
    }
    FeatureDescriptor fd = wGetFeatureDescriptor(index);
    wGetEntityChangeEventHandler().notifyChanged(this, fd, index, oldValue0, newValue0);
    // wGetFragmentChangeEventHandler().notifyChanged(this, fd, index, oldValue0, newValue0);
    wGetCompoundChangeEventHandler().notifyChanged(this, fd, index, oldValue0, newValue0);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Example 79 with FeatureDescriptor

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

the class AbstractEntity method notifyChanged.

protected final void notifyChanged(boolean oldValue, boolean newValue) {
    if (newValue == 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 80 with FeatureDescriptor

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

the class AbstractEntity method notifyRequested.

protected final boolean notifyRequested(boolean value) {
    if (requestNotificationDisabled)
        return value;
    FeatureDescriptor fd = CommonsFeatureDescriptorEnum.data_value;
    boolean result = wGetEntityRequestEventHandler().notifyRequested(this, fd, value);
    return wGetCompoundRequestEventHandler().notifyRequested(this, fd, result);
}
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