Java 类org.eclipse.emf.ecore.change.ChangeKind 实例源码

项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
@Override
void execute() {
    ListChange listChange = null;

    if (newElement instanceof BinaryTemporalConstraint){
        listChange = createListFeatureChange(ChangeKind.ADD_LITERAL, position, (EObject)newElement);
        addToChangeDescription(parent, featureOfElement, listChange, changeDescription2);
    }
    else if(newElement instanceof TemporalChain){
        FeatureChange featureChange = createFeatureChange(parent, featureOfElement, newElement);
        addToChangeDescription(parent, featureOfElement, featureChange, changeDescription2);
    }
    else {
        listChange = createListFeatureChange(ChangeKind.ADD_LITERAL, position, (EObject)newElement);
        addToChangeDescription(parent, featureOfElement, listChange, changeDescription1);
    }
}
项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
@Override
void execute() {            
    Collection<EObject> toDelete = new ArrayList();
    toDelete.addAll((Collection<? extends EObject>) oldElements);

    Object value = parent.eGet(featureOfElement);
    if(value instanceof List) {
        List<EObject> current = (List) value;
        int currentSize = current.size();

        if(toDelete != null && !toDelete.isEmpty()) {
            for(int i = currentSize - 1; i >= 0; i--) {
                EObject iObject = current.get(i);
                if(toDelete.contains(iObject)) {
                    ListChange listChange = createListFeatureChange(ChangeKind.REMOVE_LITERAL, i, iObject);

                    if (oldElements instanceof BinaryTemporalConstraint)
                        addToChangeDescription(parent, featureOfElement, listChange, changeDescription2);
                    else
                        addToChangeDescription(parent, featureOfElement, listChange, changeDescription1);

                }
            }
        }
    }
}
项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
/** For completion. To ensure a proper FeatureChange use <i>createFeatureChange()</i> methods.
 * @param target
 * @param feature
 * @param indexToRemove
 * @return
 */
public static FeatureChange createRemoveFromListFeatureChange(EObject target, EStructuralFeature feature, int indexToRemove) {
    Object value = target.eGet(feature);
    FeatureChange fc = null;
    if(value instanceof List) {
        if ((((List) value).size() - 1) < indexToRemove)
            return null;

        fc = factory.createFeatureChange(feature, value, false);
        EObject object = (EObject) ((List) value).get(indexToRemove);
        ListChange listChange = createListFeatureChange(ChangeKind.REMOVE_LITERAL, indexToRemove, object);
        fc.getListChanges().add(listChange);
    }

    return fc;
}
项目:Vitruv    文件:ChangeDescriptionPrinter.java   
protected static void processFeatureChange(EObject affectedObj, FeatureChange fc, String prefix) {

    System.err.println(prefix + "Feature change on feature " + fc.getFeatureName());
    System.err.println("\t  Target value: " + fc.getValue());
    System.err.println("\tRollback value: " + affectedObj.eGet(fc.getFeature()));
    for (ListChange lc : fc.getListChanges()) {
        if (lc.getKind() == ChangeKind.ADD_LITERAL) {
            System.err.println(prefix + "\t - Adding Children: " + lc.getValues());
        }
        else if (lc.getKind() == ChangeKind.REMOVE_LITERAL) {
            System.err.println(prefix + "\t - Deleting Children: " + lc.getValues());
        }
    }
}
项目:OpenSPIFe    文件:PatchBuilderFeatureChange.java   
protected ListChange createAddListChange(EStructuralFeature feature, Object newObject, int index) {
    if (index < 0 || index > aggregatingSize) {
        throw new ArrayIndexOutOfBoundsException(index);
    }
    ListChange listChange = createListChange(ChangeKind.ADD_LITERAL, index);
    listChange.setFeature(feature);
    if (feature instanceof EAttribute)  {
        listChange.getValues().add(newObject);
    } else {
        listChange.getReferenceValues().add((EObject) newObject);
    }
    aggregatingSize++;
    getListChanges().add(listChange);
    return listChange;
}
项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
@Override
void execute() {            
    ListChange listChange = createListFeatureChange(ChangeKind.REMOVE_LITERAL, position, (EObject)oldElement);

    if (oldElement instanceof BinaryTemporalConstraint)
        addToChangeDescription(parent, featureOfElement, listChange, changeDescription2);
    else
        addToChangeDescription(parent, featureOfElement, listChange, changeDescription1);
}
项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
/** This method creates a ListChange with the proper ChangeKind, index and referenced object.
 * 
 * @param kind - ChangeKind (ADD or REMOVE)
 * @param index - where the change is going to happen
 * @param object - object to ADD or REMOVE
 * @return ListChange
 */
public static ListChange createListFeatureChange(ChangeKind kind, int index, EObject object) {
    ListChange listChange = factory.createListChange();
    listChange.setKind(kind);
    listChange.getReferenceValues().add(object);
    listChange.setIndex(index); 
    return listChange;
}
项目:OpenSPIFe    文件:SPIFePlanIntegrationOperation.java   
/** For completion. To ensure a proper FeatureChange use <i>createFeatureChange()</i> methods.
 * @param target
 * @param feature
 * @param objectToAdd
 * @param whereToAdd
 * @return
 */
public static FeatureChange createAddToListFeatureChange(EObject target, EStructuralFeature feature, EObject objectToAdd, int whereToAdd) {
    Object value = target.eGet(feature);
    FeatureChange fc = null;
    if(value instanceof List) {
        if ((((List) value).size() - 1) < whereToAdd)
            whereToAdd = ((List) value).size();

        fc = factory.createFeatureChange(feature, value, true);
        ListChange listChange = createListFeatureChange(ChangeKind.ADD_LITERAL, whereToAdd, objectToAdd);
        fc.getListChanges().add(listChange);
    }

    return fc;
}
项目:OpenSPIFe    文件:PatchBuilderFeatureChange.java   
protected ListChange createRemoveListChange(int index) {
    ListChange listChange = createListChange(ChangeKind.REMOVE_LITERAL, index);
    getListChanges().add(listChange);
    aggregatingSize--;
    return listChange;
}
项目:OpenSPIFe    文件:PatchBuilderFeatureChange.java   
protected ListChange createMoveListChange(int index, int toIndex) {
    ListChange listChange = createListChange(ChangeKind.MOVE_LITERAL, index);
    listChange.setMoveToIndex(toIndex);
    getListChanges().add(listChange);
    return listChange;
}
项目:OpenSPIFe    文件:PatchBuilderFeatureChange.java   
protected static ListChange createListChange(ChangeKind kind, int index) {
    ListChange listChange = ChangeFactory.eINSTANCE.createListChange();
    listChange.setKind(kind);
    listChange.setIndex(index);
    return listChange;
}