Notification system code revision
Signed-off-by: Dusan Kalanj <kalanj@chalmers.se>
diff --git a/org.eclipse.capra.handler.cdt/src/org/eclipse/capra/handler/cdt/notification/CElementChangeListener.java b/org.eclipse.capra.handler.cdt/src/org/eclipse/capra/handler/cdt/notification/CElementChangeListener.java
index 2d8a782..c92c2fa 100644
--- a/org.eclipse.capra.handler.cdt/src/org/eclipse/capra/handler/cdt/notification/CElementChangeListener.java
+++ b/org.eclipse.capra.handler.cdt/src/org/eclipse/capra/handler/cdt/notification/CElementChangeListener.java
@@ -65,17 +65,17 @@
new WorkspaceJob(CapraNotificationHelper.NOTIFICATION_JOB) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- visit(event.getDelta(), cArtifacts, wrapperContainer);
+ handleDelta(event.getDelta(), cArtifacts, wrapperContainer);
return Status.OK_STATUS;
}
}.schedule();
-
}
- private void visit(ICElementDelta delta, List<ArtifactWrapper> cArtifacts, IFile wrapperContainer) {
+ private void handleDelta(ICElementDelta delta, List<ArtifactWrapper> cArtifacts, IFile wrapperContainer) {
+
// Visit all the affected children of affected element
for (ICElementDelta subDelta : delta.getAffectedChildren())
- visit(subDelta, cArtifacts, wrapperContainer);
+ handleDelta(subDelta, cArtifacts, wrapperContainer);
int flags = delta.getFlags();
int changeType = delta.getKind();
@@ -118,16 +118,16 @@
// "rename"), consider making the marker for the affected
// element as well as its children, who's URIs have changed
// and need updating.
- String[] markersToDelete = null;
+ IssueType[] markersToDelete = null;
String deleteMarkerUri = "";
if (issueType == IssueType.MOVED || issueType == IssueType.RENAMED) {
deleteMarkerUri = delta.getMovedToElement().getHandleIdentifier();
- markersToDelete = new String[] { "moved", "renamed", "deleted" };
+ markersToDelete = new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.DELETED };
} else if (issueType == IssueType.DELETED) {
- markersToDelete = new String[] { "moved", "renamed", "changed" };
+ markersToDelete = new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.CHANGED };
deleteMarkerUri = affectedElementUri;
} else if (issueType == IssueType.ADDED) {
- markersToDelete = new String[] { "moved", "renamed", "deleted" };
+ markersToDelete = new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.DELETED };
deleteMarkerUri = affectedElementUri;
}
@@ -136,9 +136,7 @@
if (artifactUri.contains(affectedElementUri)) {
HashMap<String, String> markerInfo = generateMarkerInfo(aw, delta, issueType);
-
- if (markerInfo != null)
- CapraNotificationHelper.createCapraMarker(markerInfo, wrapperContainer);
+ CapraNotificationHelper.createCapraMarker(markerInfo, wrapperContainer);
}
}
}
@@ -216,9 +214,6 @@
break;
}
- if (message.isEmpty())
- return null;
-
if (newAffectedElementUri != null) {
// The affected element has been renamed or moved.
String newArtifactUri;
diff --git a/org.eclipse.capra.handler.emf/src/org/eclipse/capra/handler/emf/notification/ModelChangeListener.java b/org.eclipse.capra.handler.emf/src/org/eclipse/capra/handler/emf/notification/ModelChangeListener.java
index ce4d69c..e9f0253 100644
--- a/org.eclipse.capra.handler.emf/src/org/eclipse/capra/handler/emf/notification/ModelChangeListener.java
+++ b/org.eclipse.capra.handler.emf/src/org/eclipse/capra/handler/emf/notification/ModelChangeListener.java
@@ -122,10 +122,23 @@
if (diffKind != null) {
EObject oldObject = match.getRight();
- if (oldObject != null && oldObject.equals(tracedItem))
+ if (oldObject != null && oldObject.equals(tracedItem)) {
// If the match or a parent match contains a difference that
// affects the tracedItem, produce a marker.
- createCapraMarker(tracedItem, match, diffKind, traceContainer);
+
+ IssueType issueType = null;
+ if (diffKind.equals(DifferenceKind.DELETE))
+ issueType = IssueType.DELETED;
+ else if (diffKind.equals(DifferenceKind.MOVE))
+ issueType = IssueType.MOVED;
+ else if (diffKind.equals(DifferenceKind.ADD))
+ issueType = IssueType.ADDED;
+ else if (diffKind.equals(DifferenceKind.CHANGE))
+ issueType = IssueType.RENAMED;
+
+ if (issueType != null)
+ createCapraMarker(tracedItem, match, issueType, traceContainer);
+ }
}
}
@@ -146,7 +159,7 @@
* @param file
* the file to which the marker will be attached
*/
- private void createCapraMarker(EObject tracedItem, Match match, DifferenceKind diffKind, IFile file) {
+ private void createCapraMarker(EObject tracedItem, Match match, IssueType issueType, IFile file) {
String oldUri = CapraNotificationHelper.getFileUri(tracedItem).toString();
String oldName = (String) tracedItem.eGet(tracedItem.eClass().getEStructuralFeature("name"));
@@ -159,29 +172,25 @@
}
String message = "";
- IssueType issueType = null;
- switch (diffKind) {
- case DELETE:
- if (changedObject == null) {
- issueType = IssueType.DELETED;
+ switch (issueType) {
+ case DELETED:
+ if (changedObject == null)
message = oldUri + " has been deleted.";
- }
break;
- case MOVE:
- if (!oldUri.equals(newUri)) {
- issueType = IssueType.MOVED;
+ case MOVED:
+ if (!oldUri.equals(newUri))
message = oldName + " has been moved to " + newUri + ".";
- }
break;
- case CHANGE:
- issueType = IssueType.RENAMED;
+ case RENAMED:
if (!newName.equals(oldName))
message = oldUri + " has been renamed to " + newName + ".";
else
message = "An ancestor of " + oldName + " has been renamed." + " The new URI of the element is "
+ newUri;
break;
- case ADD:
+ case ADDED:
+ break;
+ case CHANGED:
break;
}
diff --git a/org.eclipse.capra.handler.file/src/org/eclipse/capra/handler/file/notification/FileChangeListener.java b/org.eclipse.capra.handler.file/src/org/eclipse/capra/handler/file/notification/FileChangeListener.java
index 5b81765..45d61e7 100644
--- a/org.eclipse.capra.handler.file/src/org/eclipse/capra/handler/file/notification/FileChangeListener.java
+++ b/org.eclipse.capra.handler.file/src/org/eclipse/capra/handler/file/notification/FileChangeListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-<< * Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs and others.
+ * Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -74,6 +74,7 @@
return true;
}
};
+
try {
IResourceDelta delta = event.getDelta();
if (delta != null)
@@ -118,7 +119,8 @@
if (issueType == IssueType.ADDED)
CapraNotificationHelper.deleteCapraMarker(aw.getUri(),
- new String[] { "moved", "renamed", "deleted" }, wrapperContainer);
+ new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.DELETED },
+ wrapperContainer);
else {
HashMap<String, String> markerInfo = generateMarkerInfo(aw, delta, issueType);
CapraNotificationHelper.createCapraMarker(markerInfo, wrapperContainer);
@@ -164,14 +166,12 @@
break;
}
- if (!message.isEmpty()) {
- markerInfo.put(CapraNotificationHelper.ISSUE_TYPE, issueType.getValue());
- markerInfo.put(CapraNotificationHelper.MESSAGE, message);
- markerInfo.put(CapraNotificationHelper.OLD_URI, oldArtifactUri);
- if (newArtifactUri != null) {
- markerInfo.put(CapraNotificationHelper.NEW_URI, newArtifactUri.toString());
- markerInfo.put(CapraNotificationHelper.NEW_NAME, newArtifactUri.toFile().getName());
- }
+ markerInfo.put(CapraNotificationHelper.ISSUE_TYPE, issueType.getValue());
+ markerInfo.put(CapraNotificationHelper.MESSAGE, message);
+ markerInfo.put(CapraNotificationHelper.OLD_URI, oldArtifactUri);
+ if (newArtifactUri != null) {
+ markerInfo.put(CapraNotificationHelper.NEW_URI, newArtifactUri.toString());
+ markerInfo.put(CapraNotificationHelper.NEW_NAME, newArtifactUri.toFile().getName());
}
return markerInfo;
diff --git a/org.eclipse.capra.handler.jdt/src/org/eclipse/capra/handler/jdt/notification/JavaElementChangeListener.java b/org.eclipse.capra.handler.jdt/src/org/eclipse/capra/handler/jdt/notification/JavaElementChangeListener.java
index 5441421..54b3b81 100644
--- a/org.eclipse.capra.handler.jdt/src/org/eclipse/capra/handler/jdt/notification/JavaElementChangeListener.java
+++ b/org.eclipse.capra.handler.jdt/src/org/eclipse/capra/handler/jdt/notification/JavaElementChangeListener.java
@@ -8,7 +8,6 @@
* Contributors:
* Chalmers | University of Gothenburg and rt-labs - initial API and implementation and/or initial documentation
*******************************************************************************/
-
package org.eclipse.capra.handler.jdt.notification;
import java.util.HashMap;
@@ -51,11 +50,6 @@
*/
public class JavaElementChangeListener implements IElementChangedListener {
- // TODO Before checking (inside this method) if any markers should be
- // created, would it also make sense to check, if any of the markers should
- // be deleted (as a result of undo operations)? For example, if there are
- // existing markers that say that a file has been deleted, there could be a
- // simple exists() check on the element. If it does, remove the marker.
@Override
public void elementChanged(ElementChangedEvent event) {
@@ -74,13 +68,13 @@
new WorkspaceJob(CapraNotificationHelper.NOTIFICATION_JOB) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
- visit(event.getDelta(), javaArtifacts, wrapperContainer);
+ handleDelta(event.getDelta(), javaArtifacts, wrapperContainer);
return Status.OK_STATUS;
}
}.schedule();
}
- private void visit(IJavaElementDelta delta, List<ArtifactWrapper> javaArtifacts, IFile wrapperContainer) {
+ private void handleDelta(IJavaElementDelta delta, List<ArtifactWrapper> javaArtifacts, IFile wrapperContainer) {
// If the changes are not made manually (by typing in the
// editor) this recursion only goes as far as the source file. The
@@ -92,7 +86,7 @@
if (!(delta.getElement() instanceof ICompilationUnit))
// Only go as far as the source file
for (IJavaElementDelta subDelta : delta.getAffectedChildren())
- visit(subDelta, javaArtifacts, wrapperContainer);
+ handleDelta(subDelta, javaArtifacts, wrapperContainer);
int flags = delta.getFlags();
int changeType = delta.getKind();
@@ -123,14 +117,14 @@
// method/variable/class... has changed inside of a source
// file.
- String[] markersToDelete = null;
+ IssueType[] markersToDelete = null;
String deleteMarkerUri = "";
IJavaElement element = JavaCore.create(artifactUri);
if (element != null && element.exists()) {
deleteMarkerUri = artifactUri;
- markersToDelete = new String[] { "moved", "renamed", "deleted" };
+ markersToDelete = new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.DELETED };
} else if (issueType == IssueType.DELETED) {
- markersToDelete = new String[] { "moved", "renamed", "changed" };
+ markersToDelete = new IssueType[] { IssueType.MOVED, IssueType.RENAMED, IssueType.CHANGED };
deleteMarkerUri = affectedElementUri;
}
@@ -139,9 +133,7 @@
if (artifactUri.contains(affectedElementUri)) {
HashMap<String, String> markerInfo = generateMarkerInfo(aw, delta, issueType);
-
- if (!markerInfo.isEmpty())
- CapraNotificationHelper.createCapraMarker(markerInfo, wrapperContainer);
+ CapraNotificationHelper.createCapraMarker(markerInfo, wrapperContainer);
}
}
}
@@ -230,53 +222,52 @@
break;
}
- if (!message.isEmpty()) {
- // The affected element has been renamed or moved.
- if (newAffectedElementUri != null) {
+ // The affected element has been renamed or moved.
+ if (newAffectedElementUri != null) {
- String newArtifactUri;
- String newArtifactName;
- if (oldArtifactUri.equals(oldAffectedElementUri)) {
- // The element in the wrapper is the affected element.
- newArtifactUri = newAffectedElementUri;
- newArtifactName = newAffectedElementName;
- } else {
- // The element in the wrapper is a child of the affected
- // element.
+ String newArtifactUri;
+ String newArtifactName;
+ if (oldArtifactUri.equals(oldAffectedElementUri)) {
+ // The element in the wrapper is the affected element.
+ newArtifactUri = newAffectedElementUri;
+ newArtifactName = newAffectedElementName;
+ } else {
+ // The element in the wrapper is a child of the affected
+ // element.
- // Build new uri for the moved class
- newArtifactUri = oldArtifactUri.replace(oldAffectedElementUri, newAffectedElementUri);
- newArtifactName = oldArtifactName;
+ // Build new uri for the moved class
+ newArtifactUri = oldArtifactUri.replace(oldAffectedElementUri, newAffectedElementUri);
+ newArtifactName = oldArtifactName;
- // Check if artifact belongs to the public class (because
- // the
- // public class changes with the file name)
- if (newAffectedElement instanceof ICompilationUnit) {
- String oldPublicClassName = oldAffectedElementName.replace(".java", "");
- String newPublicClassName = newAffectedElementName.replace(".java", "");
+ // Check if artifact belongs to the public class (because
+ // the
+ // public class changes with the file name)
+ if (newAffectedElement instanceof ICompilationUnit) {
+ String oldPublicClassName = oldAffectedElementName.replace(".java", "");
+ String newPublicClassName = newAffectedElementName.replace(".java", "");
- int classStartIndex = newAffectedElementUri.length() + 1;
- int classEndIndex = classStartIndex + oldPublicClassName.length();
+ int classStartIndex = newAffectedElementUri.length() + 1;
+ int classEndIndex = classStartIndex + oldPublicClassName.length();
- if (newArtifactUri.substring(classStartIndex, classEndIndex).equals(oldPublicClassName))
- newArtifactUri = newArtifactUri.substring(0, classStartIndex) + newPublicClassName
- + newArtifactUri.substring(classEndIndex);
+ if (newArtifactUri.substring(classStartIndex, classEndIndex).equals(oldPublicClassName))
+ newArtifactUri = newArtifactUri.substring(0, classStartIndex) + newPublicClassName
+ + newArtifactUri.substring(classEndIndex);
- // The object in the artifact is the public class
- // declaration.
- if (newArtifactName.contentEquals(oldPublicClassName))
- newArtifactName = newPublicClassName;
- }
+ // The object in the artifact is the public class
+ // declaration.
+ if (newArtifactName.contentEquals(oldPublicClassName))
+ newArtifactName = newPublicClassName;
}
-
- markerInfo.put(CapraNotificationHelper.NEW_URI, newArtifactUri);
- markerInfo.put(CapraNotificationHelper.NEW_NAME, newArtifactName);
}
- markerInfo.put(CapraNotificationHelper.ISSUE_TYPE, issueType.getValue());
- markerInfo.put(CapraNotificationHelper.OLD_URI, oldArtifactUri);
- markerInfo.put(CapraNotificationHelper.MESSAGE, message);
+ markerInfo.put(CapraNotificationHelper.NEW_URI, newArtifactUri);
+ markerInfo.put(CapraNotificationHelper.NEW_NAME, newArtifactName);
}
+
+ markerInfo.put(CapraNotificationHelper.ISSUE_TYPE, issueType.getValue());
+ markerInfo.put(CapraNotificationHelper.OLD_URI, oldArtifactUri);
+ markerInfo.put(CapraNotificationHelper.MESSAGE, message);
+
return markerInfo;
}
diff --git a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/CapraNotificationHelper.java b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/CapraNotificationHelper.java
index 6f366e7..92332ea 100644
--- a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/CapraNotificationHelper.java
+++ b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/CapraNotificationHelper.java
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Chalmers | University of Gothenburg, rt-labs and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Chalmers|Gothenburg University and rt-labs - initial API and implementation and/or initial documentation
+ *******************************************************************************/
package org.eclipse.capra.ui.notification;
import java.util.HashMap;
@@ -13,6 +23,11 @@
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
+/**
+ * Contains methods that support the Capra notification (marker) solution.
+ *
+ * @author Dusan Kalanj
+ */
public class CapraNotificationHelper {
/**
@@ -20,6 +35,9 @@
*/
public static final String CAPRA_PROBLEM_MARKER_ID = "org.eclipse.capra.ui.notification.capraProblemMarker";
+ /**
+ * Custom enum that describes possible changes made to a traced element.
+ */
public enum IssueType {
RENAMED("renamed"), MOVED("moved"), DELETED("deleted"), CHANGED("changed"), ADDED("added");
@@ -34,11 +52,34 @@
}
}
+ /**
+ * Job ID for the capra notification solution.
+ */
public static final String NOTIFICATION_JOB = "CapraNotificationJob";
+
+ /**
+ * Key to be used to specify IssueType value in markerInfo HashMap
+ */
public static final String ISSUE_TYPE = "issueType";
+
+ /**
+ * Key to be used to specify oldArtifactUri value in markerInfo HashMap
+ */
public static final String OLD_URI = "oldArtifactUri";
+
+ /**
+ * Key to be used to specify newArtifactUri value in markerInfo HashMap
+ */
public static final String NEW_URI = "newArtifactUri";
+
+ /**
+ * Key to be used to specify newArtifactName value in markerInfo HashMap
+ */
public static final String NEW_NAME = "newArtifactName";
+
+ /**
+ * Key to be used to specify message value in markerInfo HashMap
+ */
public static final String MESSAGE = "message";
// TODO necessary to specify all the fields that have to be filled out in
@@ -51,19 +92,16 @@
* @param markerInfo
* contains attributes that are to be assigned to the created
* marker
- * @param wrapperContainer
- * file that contains the artifact model and to which the markers
- * will be attached to
+ * @param container
+ * file that the created marker will be attached to
*/
- public static void createCapraMarker(HashMap<String, String> markerInfo, IFile wrapperContainer) {
- if (markerInfo.isEmpty())
- return;
+ public static void createCapraMarker(HashMap<String, String> markerInfo, IFile container) {
try {
String newMarkerIssue = markerInfo.get(ISSUE_TYPE);
String newMarkerUri = markerInfo.get(OLD_URI);
- IMarker[] existingMarkers = wrapperContainer.findMarkers(CAPRA_PROBLEM_MARKER_ID, false, 0);
+ IMarker[] existingMarkers = container.findMarkers(CAPRA_PROBLEM_MARKER_ID, false, 0);
for (IMarker existingMarker : existingMarkers) {
String existingMarkerIssue = existingMarker.getAttribute(ISSUE_TYPE, null);
String existingMarkerUri = existingMarker.getAttribute(OLD_URI, null);
@@ -83,23 +121,42 @@
if (existingMarkerUri.equals(newMarkerUri) && existingMarkerIssue.equals(IssueType.DELETED.getValue())
&& newMarkerIssue.matches(IssueType.RENAMED.getValue() + "|" + IssueType.MOVED.getValue()))
existingMarker.delete();
+
+ if (existingMarkerUri.equals(newMarkerUri) && newMarkerIssue.equals(IssueType.ADDED))
+ existingMarker.delete();
}
+
+ String message = markerInfo.get(MESSAGE);
+ if (message == null || message.isEmpty())
+ return;
- IMarker marker = wrapperContainer.createMarker(CAPRA_PROBLEM_MARKER_ID);
+ IMarker marker = container.createMarker(CAPRA_PROBLEM_MARKER_ID);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
- marker.setAttribute(IMarker.MESSAGE, markerInfo.get(MESSAGE));
+ marker.setAttribute(IMarker.MESSAGE, message);
markerInfo.remove(MESSAGE);
for (Entry<String, String> entry : markerInfo.entrySet())
marker.setAttribute(entry.getKey(), entry.getValue());
} catch (CoreException e) {
- if (wrapperContainer.exists())
+ if (container.exists())
e.printStackTrace();
}
}
- public static void deleteCapraMarker(String uri, String[] issues, IFile containingFile) {
+ /**
+ * Deletes an existing marker.
+ *
+ * @param uri
+ * the uri of the artifact/element that the marker points to
+ * @param issues
+ * an array of issues - only markers that describe the provided
+ * issues will be deleted. If null is provided, all will be
+ * deleted.
+ * @param containingFile
+ * the file that contains the marker to be deleted
+ */
+ public static void deleteCapraMarker(String uri, IssueType[] issues, IFile containingFile) {
try {
IMarker[] markers = containingFile.findMarkers(CAPRA_PROBLEM_MARKER_ID, true, 0);
@@ -111,8 +168,8 @@
if (issues == null)
marker.delete();
else
- for (String issue : issues)
- if (existingMarkerIssue.equals(issue))
+ for (IssueType issue : issues)
+ if (existingMarkerIssue.equals(issue.getValue()))
marker.delete();
}
} catch (CoreException e) {
diff --git a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/DeleteQuickFix.java b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/DeleteQuickFix.java
index 452cc90..3348153 100644
--- a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/DeleteQuickFix.java
+++ b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/DeleteQuickFix.java
@@ -73,6 +73,7 @@
String markerUri = marker.getAttribute(CapraNotificationHelper.OLD_URI, null);
if (markerContainerFileName.equals(artifactContainerFileName)) {
+ // The element that the marker points to is a Capra artifact.
int index = 0;
for (ArtifactWrapper aw : artifacts) {
if (aw.getUri().equals(markerUri)) {
@@ -87,6 +88,7 @@
index++;
}
+ // Delete selected artifacts.
ArtifactWrapper toRemove = awc.getArtifacts().get(index);
EcoreUtil.delete(toRemove);
URI artifactModelURI = EcoreUtil.getURI(awc);
@@ -99,6 +101,8 @@
e.printStackTrace();
}
} else {
+ // The element that the marker points to is an EObject and is not
+ // contained in the Capra artifact model.
URI deletedEObjectUri = URI.createURI(markerUri);
for (RelatedTo trace : traceModel.getTraces()) {
for (EObject item : trace.getItem()) {
@@ -111,6 +115,7 @@
}
}
+ // Delete selected traces.
traces.removeAll(toDelete);
GenericTraceModel newTraceModel = GenericTraceMetaModelFactory.eINSTANCE.createGenericTraceModel();
newTraceModel.getTraces().addAll(traces);
diff --git a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/RenameOrMoveQuickFix.java b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/RenameOrMoveQuickFix.java
index 502f991..5cd5064 100644
--- a/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/RenameOrMoveQuickFix.java
+++ b/org.eclipse.capra.ui.notification/src/org/eclipse/capra/ui/notification/RenameOrMoveQuickFix.java
@@ -60,6 +60,7 @@
String markerFileName = new File(marker.getResource().toString()).getName();
if (markerFileName.equals(artifactContainerFileName)) {
+ // The element that the marker points to is a Capra artifact.
List<ArtifactWrapper> artifacts = ((ArtifactWrapperContainer) model).getArtifacts();
String oldArtifactUri = marker.getAttribute(CapraNotificationHelper.OLD_URI, null);
for (ArtifactWrapper aw : artifacts) {
@@ -73,6 +74,8 @@
}
} else {
+ // The element that the marker points to is an EObject and is not
+ // contained in the Capra artifact model.
model = tracePersistenceAdapter.getTraceModel(resourceSet);
List<RelatedTo> traces = ((GenericTraceModel) model).getTraces();
String oldArtifactUri = marker.getAttribute(CapraNotificationHelper.OLD_URI, null);
@@ -88,6 +91,7 @@
}
}
+ // Update references inside the model (can be artifact or trace model).
Resource resource = resourceSet.createResource(EcoreUtil.getURI(model));
resource.getContents().add(model);