Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorytanguy2011-06-29 10:13:16 +0000
committerytanguy2011-06-29 10:13:16 +0000
commit842e5dca48feacdc453ae16ef776ca3d9ee961d6 (patch)
tree3ab982c3118301951ae9a1ea0ee75acc78b69fbb /plugins
parentdd11b81ab688ce0d8b0395bc3de65c9efb1b5b52 (diff)
downloadorg.eclipse.papyrus-842e5dca48feacdc453ae16ef776ca3d9ee961d6.tar.gz
org.eclipse.papyrus-842e5dca48feacdc453ae16ef776ca3d9ee961d6.tar.xz
org.eclipse.papyrus-842e5dca48feacdc453ae16ef776ca3d9ee961d6.zip
NEW - bug 330182: [SysML Block Definition Diagram] Papyrus shall provide an editor for SysML Block Definition Diagrams (BDD).
https://bugs.eclipse.org/bugs/show_bug.cgi?id=330182
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java38
1 files changed, 33 insertions, 5 deletions
diff --git a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java
index 05fab421a5d..6da050a884c 100644
--- a/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java
+++ b/plugins/sysml/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/CommonDiagramDragDropEditPolicy.java
@@ -19,6 +19,7 @@ package org.eclipse.papyrus.gmf.diagram.common.edit.policy;
import static org.eclipse.papyrus.gmf.diagram.common.provider.IGraphicalTypeRegistry.UNDEFINED_TYPE;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -205,11 +206,8 @@ public abstract class CommonDiagramDragDropEditPolicy extends DiagramDragDropEdi
CompositeCommand completeDropCommand = new CompositeCommand("CompleteDropEdge"); //$NON-NLS-1$
// Find views in current diagram representing source and target
- EReference[] refs = { NotationPackage.eINSTANCE.getView_Element() };
- @SuppressWarnings("unchecked")
- Collection<View> sourceViews = EMFCoreUtil.getReferencers(source, refs);
- @SuppressWarnings("unchecked")
- Collection<View> targetViews = EMFCoreUtil.getReferencers(target, refs);
+ Collection<View> sourceViews = getViews(source);
+ Collection<View> targetViews = getViews(target);
IAdaptable sourceViewAdapter = null;
IAdaptable targetViewAdapter = null;
@@ -312,4 +310,34 @@ public abstract class CommonDiagramDragDropEditPolicy extends DiagramDragDropEdi
return ((IGraphicalEditPart)getHost()).getDiagramPreferencesHint();
}
+ /**
+ * This methods looks for views representing a given EObject in the host diagram.
+ *
+ * @param eObject
+ * the {@link EObject} to look for.
+ * @return the list of {@link View} representing the eObject.
+ */
+ private Set<View> getViews(EObject eObject) {
+ Set<View> views = new HashSet<View>();
+
+ // Retrieve host diagram
+ View hostView = ((IGraphicalEditPart)getHost()).getNotationView();
+ View hostDiagram = (hostView instanceof Diagram) ? hostView : hostView.getDiagram();
+
+ // Retrieve all views for the eObject
+ EReference[] refs = { NotationPackage.eINSTANCE.getView_Element() };
+ @SuppressWarnings("unchecked")
+ Collection<View> relatedViews = EMFCoreUtil.getReferencers(eObject, refs);
+
+ // Parse and select views from host diagram only
+ Iterator<View> it = relatedViews.iterator();
+ while(it.hasNext()) {
+ View currentView = it.next();
+ if(currentView.getDiagram() == hostDiagram) {
+ views.add(currentView);
+ }
+ }
+
+ return views;
+ }
}

Back to the top