Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-06-11 13:43:19 +0000
committercletavernie2013-06-11 13:43:19 +0000
commit319e35336603c8e232bb1c8887cc945d27bcedf2 (patch)
tree411a7cd8b28026d62514cd5694f832f6f9f433b2
parenta9ae330748acd1381bcd15ae49f75fb63a2bc5a9 (diff)
downloadorg.eclipse.papyrus-319e35336603c8e232bb1c8887cc945d27bcedf2.tar.gz
org.eclipse.papyrus-319e35336603c8e232bb1c8887cc945d27bcedf2.tar.xz
org.eclipse.papyrus-319e35336603c8e232bb1c8887cc945d27bcedf2.zip
410461: [Profile Diagram] Profile sometimes load resources from other Papyrus models
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410461
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java61
2 files changed, 32 insertions, 35 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
index 3ac70085a92..23cc84c2507 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/resource/AbstractModelWithSharedResource.java
@@ -95,12 +95,12 @@ public abstract class AbstractModelWithSharedResource<T extends EObject> extends
* Lookup for the resource in the resourceSet.
*
* @param uri
- * the URI of the resource to look for
+ * the URI (without extension) of the resource to look for
*/
- private void lookupResource(URI uri) {
+ private void lookupResource(URI uriWithoutExtension) {
// Compute model URI
- resourceURI = uri.trimFileExtension().appendFileExtension(getModelFileExtension());
+ resourceURI = uriWithoutExtension.appendFileExtension(getModelFileExtension());
resource = getResourceSet().getResource(resourceURI, false);
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
index d9f663d2059..01be0c76b9e 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.markerlistener/src/org/eclipse/papyrus/infra/services/markerlistener/util/MarkerListenerUtils.java
@@ -47,17 +47,16 @@ import org.eclipse.papyrus.infra.services.markerlistener.providers.MarkerProvide
*/
public class MarkerListenerUtils {
- public static EclipseResourcesUtil eclipseResourcesUtil =
- EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ? new EclipseResourcesUtil() : null;
-
+ public static EclipseResourcesUtil eclipseResourcesUtil = EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE ? new EclipseResourcesUtil() : null;
+
private static final Map<String, String> MARKER_LABELS = new java.util.HashMap<String, String>();
-
+
private static final Map<String, Set<String>> MARKER_HIERARCHY = new java.util.HashMap<String, Set<String>>();
-
+
static {
loadMarkerTypes();
}
-
+
/**
* E object from marker or map.
*
@@ -82,7 +81,8 @@ public class MarkerListenerUtils {
if(uriAttribute != null) {
URI uriOfMarker = URI.createURI(uriAttribute);
try {
- return domain.getResourceSet().getEObject(uriOfMarker, true);
+ //Bug 410461: Do not load external objects in the current resource set!!
+ return domain.getResourceSet().getEObject(uriOfMarker, false);
} catch (MissingResourceException e) {
// happens after renaming of the file containing the marker (or a parent folder)
// try to retrieve eObject via fragment only (assuming that no two elements within resource-set share
@@ -129,32 +129,29 @@ public class MarkerListenerUtils {
URI uri = resource.getURI();
ResourceSet rset = resource.getResourceSet();
- if (rset != null) {
+ if(rset != null) {
uri = rset.getURIConverter().normalize(uri);
}
- IFile result = uri.isPlatformResource()
- ? ResourcesPlugin.getWorkspace().getRoot()
- .getFile(new Path(uri.toPlatformString(true)))
- : null;
+ IFile result = uri.isPlatformResource() ? ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true))) : null;
- if ((result != null) && !result.exists()) {
+ if((result != null) && !result.exists()) {
result = null;
}
return result;
}
-
+
public static String getMarkerTypeLabel(String type) {
String result = MARKER_LABELS.get(type);
-
- if (result == null) {
+
+ if(result == null) {
result = type;
}
-
+
return result;
}
-
+
private static void loadMarkerTypes() {
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS);
@@ -172,46 +169,46 @@ public class MarkerListenerUtils {
}
}
}
-
+
MARKER_HIERARCHY.put(type, Collections.unmodifiableSet(superTypes));
}
}
-
+
public static boolean isMarkerTypeSubtypeOf(String subtype, String supertype) {
boolean result = false;
-
+
Set<String> supertypes = MARKER_HIERARCHY.get(subtype);
- if (supertypes != null) {
+ if(supertypes != null) {
result = supertypes.contains(supertype);
- if (!result) {
+ if(!result) {
// recursive
Set<String> cycleDetect = new java.util.HashSet<String>();
cycleDetect.add(subtype);
result = isAnyMarkerTypeSubtypeOf(supertypes, supertype, cycleDetect);
}
}
-
+
return result;
}
-
+
private static boolean isAnyMarkerTypeSubtypeOf(Set<String> subtypes, String supertype, Set<String> cycleDetect) {
boolean result = false;
-
- for (String subtype : subtypes) {
- if (cycleDetect.add(subtype)) {
+
+ for(String subtype : subtypes) {
+ if(cycleDetect.add(subtype)) {
Set<String> supertypes = MARKER_HIERARCHY.get(subtype);
- if (supertypes != null) {
+ if(supertypes != null) {
result = supertypes.contains(supertype);
- if (!result) {
+ if(!result) {
result = isAnyMarkerTypeSubtypeOf(supertypes, supertype, cycleDetect);
}
- if (result) {
+ if(result) {
break;
}
}
}
}
-
+
return result;
}
}

Back to the top