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
}
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);
}
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);
}
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);
}
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);
}
Aggregations