Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Dumoulin2014-05-06 15:03:48 +0000
committerCedric Dumoulin2014-05-06 15:20:05 +0000
commitc6e0b98caf775fa59411f8e6e20f16222751ab29 (patch)
tree01cad1ec988e8419267a9a750a4df21f80b5a946 /plugins/facet
parent36dc555dbc2fa432bdd79caa9f9750b3d49ed67d (diff)
downloadorg.eclipse.papyrus-c6e0b98caf775fa59411f8e6e20f16222751ab29.tar.gz
org.eclipse.papyrus-c6e0b98caf775fa59411f8e6e20f16222751ab29.tar.xz
org.eclipse.papyrus-c6e0b98caf775fa59411f8e6e20f16222751ab29.zip
434133: [ModelExplorer] ModelExplorer items should be IAdaptable
Improve adaptation for EObjectTReeElement.
Diffstat (limited to 'plugins/facet')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EAttributeTreeElementImpl.java20
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EObjectTreeElementImpl.java25
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EReferenceTreeElementImpl.java21
3 files changed, 53 insertions, 13 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EAttributeTreeElementImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EAttributeTreeElementImpl.java
index 47ec925a971..97a184ce9d7 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EAttributeTreeElementImpl.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EAttributeTreeElementImpl.java
@@ -159,12 +159,24 @@ public class EAttributeTreeElementImpl extends EStructuralFeatureTreeElementImpl
return super.eIsSet(featureID);
}
+ /**
+ * Try to adapt this object to the requested type.
+ * Check if the underlying EObject ({@link #getEObject()}) can be adapted to the requested type.
+ *
+ * @param key
+ * @return
+ */
@Override
- public Object getAdapter(Class adapter) {
- if (adapter == EAttribute.class){
- return getEAttribute();
+ public Object getAdapter(Class key) {
+ // Check if the underlying EObject can request to the adaptation
+ Object model = getEAttribute();
+
+ if (key.isInstance(model)){
+ return model;
+ }
+ else {
+ return super.getAdapter(key);
}
- return super.getAdapter(adapter);
}
} //EAttributeTreeElementImpl
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EObjectTreeElementImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EObjectTreeElementImpl.java
index bcdf38b550a..ed817847d08 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EObjectTreeElementImpl.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EObjectTreeElementImpl.java
@@ -13,6 +13,7 @@ package org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy
import java.util.Collection;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
@@ -22,7 +23,6 @@ import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EObjectTreeElement;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.EStructuralFeatureTreeElement;
@@ -303,11 +303,26 @@ public class EObjectTreeElementImpl extends TreeElementImpl implements EObjectTr
return super.eIsSet(featureID);
}
- public Object getAdapter(Class adapter) {
- if (adapter == EObject.class){
- return getEObject();
+ /**
+ * Try to adapt this object to the requested type.
+ * Check if the underlying EObject ({@link #getEObject()}) can be adapted to the requested type.
+ *
+ * @param key
+ * @return
+ */
+ public Object getAdapter(Class key) {
+
+ // Check if the underlying EObject can request to the adaptation
+ Object model = getEObject();
+
+ if (key.isInstance(model)){
+ return model;
+ }
+ else {
+ // Try the platform process
+// return Platform.getAdapterManager().getAdapter(model, key);
+ return null;
}
- return null;
}
} //EObjectTreeElementImpl
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EReferenceTreeElementImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EReferenceTreeElementImpl.java
index 146d55ea358..386dadcf6c7 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EReferenceTreeElementImpl.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.metamodel/src/org/eclipse/papyrus/emf/facet/custom/metamodel/v0_2_0/internal/treeproxy/impl/EReferenceTreeElementImpl.java
@@ -159,12 +159,25 @@ public class EReferenceTreeElementImpl extends EStructuralFeatureTreeElementImpl
return super.eIsSet(featureID);
}
+ /**
+ * Try to adapt this object to the requested type.
+ * Check if the underlying EObject ({@link #getEObject()}) can be adapted to the requested type.
+ *
+ * @param key
+ * @return
+ */
@Override
- public Object getAdapter(Class adapter) {
- if (adapter == EReference.class){
- return getEReference();
+ public Object getAdapter(Class key) {
+ // Check if the underlying EObject can request to the adaptation
+ Object model = getEReference();
+
+ if (key.isInstance(model)){
+ return model;
}
- return super.getAdapter(adapter);
+ else {
+ return super.getAdapter(key);
+ }
+
}
} //EReferenceTreeElementImpl

Back to the top