use of org.eclipse.emf.compare.Match in project InformationSystem by ObeoNetwork.
the class DBDiffImpl method setMatch.
/**
*Copied from DiffSpec
*/
@Override
public void setMatch(Match newMatch) {
Match oldMatch = basicGetMatch();
if (newMatch != null) {
EList<Diff> differences = newMatch.getDifferences();
differences.add(this);
eNotify(new ENotificationImpl(this, Notification.SET, ComparePackage.DIFF__MATCH, oldMatch, newMatch));
} else if (eContainer() instanceof Match) {
EList<Diff> differences = ((Match) eContainer()).getDifferences();
differences.remove(this);
eNotify(new ENotificationImpl(this, Notification.UNSET, ComparePackage.DIFF__MATCH, oldMatch, newMatch));
}
}
use of org.eclipse.emf.compare.Match in project InformationSystem by ObeoNetwork.
the class ChangeBuilder method handle.
public Diff handle(EObject comparisonElement) {
Diff createdDiffElement = null;
if (comparisonElement instanceof Diff) {
Diff diff = (Diff) comparisonElement;
if (isReferenceAdd(diff)) {
createdDiffElement = handleAddChange((ReferenceChange) diff);
} else if (isReferenceDelete(diff)) {
createdDiffElement = handleRemoveChange((ReferenceChange) diff);
} else if (diff.getKind() == DifferenceKind.CHANGE) {
if (diff instanceof AttributeChange) {
AttributeChange attributeChange = (AttributeChange) diff;
// Ignore TechID
if (DatabasePackage.eINSTANCE.getDatabaseElement_TechID() != attributeChange.getAttribute()) {
createdDiffElement = handleAlterChange(attributeChange);
}
}
if (diff instanceof ReferenceChange) {
createdDiffElement = handleAlterChange((ReferenceChange) diff);
}
}
// Attach newly created element to its parent
if (createdDiffElement != null) {
createdDiffElement.getRefinedBy().add(diff);
diff.getMatch().getDifferences().add(createdDiffElement);
}
} else if (comparisonElement instanceof Match) {
Match match = (Match) comparisonElement;
if (match.getAllDifferences().iterator().hasNext()) {
// There is at least one Diff in this match or one of its submatches,
// thus we created a Diff that marks that there is some update to perform inside the match's contents.
createdDiffElement = handleAlterChange((Match) comparisonElement);
}
if (createdDiffElement != null) {
Match parent = null;
EObject container = match.eContainer();
if (container instanceof Match) {
parent = (Match) container;
} else {
parent = (Match) comparisonElement;
}
parent.getDifferences().add(createdDiffElement);
}
}
return createdDiffElement;
}
Aggregations