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

项目:xtext-core    文件:ChangeTreeProvider.java   
public ResourceChange getResourceChange() {
    return resourceChange;
}
项目:OpenSPIFe    文件:TransactionRecordingUndoableOperation.java   
@Override
public void applyAndReverse() {
    preApply(true);

    List<EObject> objectsBeforeApply = new UniqueEList.FastCompare<EObject>();
    List<EObject> objectsAfterApply = new UniqueEList.FastCompare<EObject>();

    // Apply the change and reverse the change information.
    //
    for (Map.Entry<EObject, EList<FeatureChange>> entry : getObjectChanges()) {
        try {
            applyAndReverseObjectChanges(entry, objectsBeforeApply, objectsAfterApply);
        } catch (Exception e) {
            LogUtil.errorOnce("applying object change: " + e.getMessage());
        }
    }

    for (ResourceChange resourceChange : getResourceChanges()) {
        Resource resource = resourceChange.getResource();
        if (resource != null) {
            objectsBeforeApply.addAll(resource.getContents());
        }
        resourceChange.applyAndReverse();
        if (resource != null) {
            objectsAfterApply.addAll(resource.getContents());
        }
    }

    // The next line leaves objectsBeforeApply with all the objects that
    // were
    // added during the last recording.
    objectsBeforeApply.removeAll(objectsAfterApply);

    // Reverse the objects to attach and detach lists.
    //
    getObjectsToAttach().clear();
    for (EObject eObject : objectsBeforeApply) {
        if (eObject.eContainer() == null && eObject.eResource() == null) {
            getObjectsToAttach().add(eObject);
        }
    }
    oldContainmentInformation = null;
}