Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-07-25 13:51:37 +0000
committervlorenzo2012-07-25 13:51:37 +0000
commit8dd6b4d209d4f146385548c14af384b0bb1535ae (patch)
tree6510741e79104bc1e1407a690e0d9c8f8dd7a2f7 /plugins/infra/gmfdiag
parente8fe8836b6e51aa01eb4c68aa398b69306e0bcc2 (diff)
downloadorg.eclipse.papyrus-8dd6b4d209d4f146385548c14af384b0bb1535ae.tar.gz
org.eclipse.papyrus-8dd6b4d209d4f146385548c14af384b0bb1535ae.tar.xz
org.eclipse.papyrus-8dd6b4d209d4f146385548c14af384b0bb1535ae.zip
385726: [UML Compare] Add an action in the Diagram Menu to allow the comparison between to 2 UML Element
https://bugs.eclipse.org/bugs/show_bug.cgi?id=385726 Create the AdapterFactory in gmfdiag.common in order to be able do adapt EditPart to EObject in a plugin.xml
Diffstat (limited to 'plugins/infra/gmfdiag')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml10
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/adapter/EditPartAdapterFactory.java65
2 files changed, 75 insertions, 0 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
index d3ceeda9930..eef272629d1 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/plugin.xml
@@ -82,6 +82,16 @@
class="org.eclipse.papyrus.infra.gmfdiag.common.preferences.ConnectionToolPreferenceInitializer">
</initializer>
</extension>
+<extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.gef.EditPart"
+ class="org.eclipse.papyrus.infra.gmfdiag.common.adapter.EditPartAdapterFactory">
+ <adapter
+ type="org.eclipse.emf.ecore.EObject">
+ </adapter>
+ </factory>
+</extension>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/adapter/EditPartAdapterFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/adapter/EditPartAdapterFactory.java
new file mode 100644
index 00000000000..cda10c3b3e2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/adapter/EditPartAdapterFactory.java
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ *
+ * 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:
+ * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.common.adapter;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+
+/**
+ *
+ * This factory allows to get an EObject from an EditPart
+ * It is useful in the plugin.xml
+ *
+ * handler
+ * activeWhen
+ * with
+ * selection
+ * iterate
+ * adapt to EObject
+ *
+ * -> The handler is active when the selection can be adapted to EObject
+ *
+ * It is useful for action active on the EditPart in the Diagrams
+ *
+ */
+public class EditPartAdapterFactory implements IAdapterFactory {
+
+ /**
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ *
+ * @param adaptableObject
+ * @param adapterType
+ * @return
+ */
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adaptableObject instanceof EditPart && adaptableObject instanceof IAdaptable) {
+ return ((IAdaptable)adaptableObject).getAdapter(adapterType);
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ *
+ * @return
+ */
+ public Class<?>[] getAdapterList() {
+ return new Class[]{ EObject.class };
+ }
+
+}

Back to the top