summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjcadavid2014-04-10 04:51:03 (EDT)
committerjcadavid2014-04-11 05:09:51 (EDT)
commit4c6a8f14125d5f9f5bc7c82c8f7def3182e5b47f (patch)
tree3c7084b82893ca1d83aa8814895c750ad4eed342
parentb17bd6b9496e67793d3194c9571f68fb134bf99f (diff)
downloadorg.eclipse.papyrus-4c6a8f14125d5f9f5bc7c82c8f7def3182e5b47f.zip
org.eclipse.papyrus-4c6a8f14125d5f9f5bc7c82c8f7def3182e5b47f.tar.gz
org.eclipse.papyrus-4c6a8f14125d5f9f5bc7c82c8f7def3182e5b47f.tar.bz2
Correction of oep.infra.services.resourceloading.util.LoadingTester,refs/changes/99/24799/3
used by the "load" and "unload" actions of the model explorer, since selected objects are no longer IAdaptable. Change-Id: I915598a9344c10dc9bddc324bb55373aae4d1372 Signed-off-by: jcadavid <juan.cadavid@cea.fr>
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/META-INF/MANIFEST.MF3
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingTester.java75
2 files changed, 38 insertions, 40 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/META-INF/MANIFEST.MF
index cfc6e8d..bc2fd89 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/META-INF/MANIFEST.MF
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.papyrus.infra.core;bundle-version="1.0.0",
org.eclipse.ui.ide;bundle-version="3.8.0",
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="1.0.0",
- org.eclipse.papyrus.uml.tools;bundle-version="1.0.0"
+ org.eclipse.papyrus.uml.tools;bundle-version="1.0.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.0"
Bundle-Vendor: %providerName
Bundle-ActivationPolicy: lazy
Bundle-Version: 1.0.0.qualifier
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingTester.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingTester.java
index 59876ae..6d1c36b 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingTester.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading/src/org/eclipse/papyrus/infra/services/resourceloading/util/LoadingTester.java
@@ -25,15 +25,20 @@ import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
/**
- * This class provides test to perform on resources to know their loading status.
+ * This class provides test to perform on resources to know their loading
+ * status.
*/
public class LoadingTester extends PropertyTester {
- /** property to test if the selected elements are in loaded resources (at least one other than the opened one) */
+ /**
+ * property to test if the selected elements are in loaded resources (at
+ * least one other than the opened one)
+ */
public static final String IS_ALL_LOADED = "isAllLoaded"; //$NON-NLS-1$
/** property to test if the selected elements are in not loaded resources */
@@ -67,7 +72,8 @@ public class LoadingTester extends PropertyTester {
*
* @param selection
* selected elements
- * @return <code>true</code> if all selected elements are in loaded resources ; <code>false</code otherwise or if empty selection
+ * @return <code>true</code> if all selected elements are in loaded
+ * resources ; <code>false</code otherwise or if empty selection
*/
private boolean isInLoadedResource(IStructuredSelection selection) {
if(!selection.isEmpty()) {
@@ -76,37 +82,31 @@ public class LoadingTester extends PropertyTester {
Iterator<?> iter = selection.iterator();
while(iter.hasNext()) {
Object obj = iter.next();
- if(obj instanceof IAdaptable) {
- View view = (View)((IAdaptable)obj).getAdapter(View.class);
- EObject eObject;
- if(view != null) {
- eObject = view.getElement();
- } else {
- eObject = (EObject)((IAdaptable)obj).getAdapter(EObject.class);
- }
- if(eObject != null && !eObject.eIsProxy()) {
- // test that there is at least one not loaded resource object
- if(!atLeastOneInSubmodel) {
- Resource containingResource = eObject.eResource();
- if(mainURI == null && containingResource != null && containingResource.getResourceSet() instanceof ModelSet) {
+ EObject eObject = EMFHelper.getEObject(obj);
+ if(eObject != null && !eObject.eIsProxy()) {
+ // test that there is at least one not loaded resource
+ // object
+ if(!atLeastOneInSubmodel) {
+ Resource containingResource = eObject.eResource();
+ if(mainURI == null && containingResource != null && containingResource.getResourceSet() instanceof ModelSet) {
- //Bug 366709: Add tests to avoid NPEs
- NotationModel notationModel = NotationUtils.getNotationModel((ModelSet)containingResource.getResourceSet());
- if(notationModel != null) {
- URI notationModelURI = notationModel.getResourceURI();
- if(notationModelURI != null) {
- mainURI = notationModelURI.trimFileExtension();
- }
+ // Bug 366709: Add tests to avoid NPEs
+ NotationModel notationModel = NotationUtils.getNotationModel((ModelSet)containingResource.getResourceSet());
+ if(notationModel != null) {
+ URI notationModelURI = notationModel.getResourceURI();
+ if(notationModelURI != null) {
+ mainURI = notationModelURI.trimFileExtension();
}
}
- if(mainURI != null) {
- URI uriTrim = containingResource.getURI().trimFileExtension();
- atLeastOneInSubmodel = !uriTrim.equals(mainURI);
- }
}
- continue;
+ if(mainURI != null) {
+ URI uriTrim = containingResource.getURI().trimFileExtension();
+ atLeastOneInSubmodel = !uriTrim.equals(mainURI);
+ }
}
+ continue;
}
+
// a step failed
return false;
}
@@ -120,24 +120,21 @@ public class LoadingTester extends PropertyTester {
*
* @param selection
* selected elements
- * @return <code>true</code> if all selected elements are in not loaded resources ; <code>false</code otherwise or if empty selection
+ * @return <code>true</code> if all selected elements are in not loaded
+ * resources ; <code>false</code otherwise or if empty selection
*/
private boolean isInNotLoadedResource(IStructuredSelection selection) {
if(!selection.isEmpty()) {
Iterator<?> iter = selection.iterator();
while(iter.hasNext()) {
Object obj = iter.next();
- if(obj instanceof IAdaptable) {
+ EObject eObject = EMFHelper.getEObject(obj);
+ if(eObject != null && eObject.eIsProxy()) {
+ continue;
+ } else if(obj instanceof IAdaptable) {
View view = (View)((IAdaptable)obj).getAdapter(View.class);
- EObject eObject;
- if(view != null) {
- eObject = view.getElement();
- } else {
- eObject = (EObject)((IAdaptable)obj).getAdapter(EObject.class);
- }
- if(eObject != null && eObject.eIsProxy()) {
- continue;
- } else if(view instanceof Edge) {
+
+ if(view instanceof Edge) {
View target = ((Edge)view).getTarget();
if(target != null && ViewUtil.resolveSemanticElement(target) == null) {
// there is a backslash decorator