Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2012-05-01 23:44:52 +0000
committermgolubev2012-05-02 01:40:42 +0000
commit3a6d132dccb97353c674846f416a87135dacb8fd (patch)
treeff6410175d78e91a50c335061421a44bd92a38f9
parent8d005934f61f58e0eb05e3552d0a47998273b575 (diff)
downloadorg.eclipse.gmf-tooling-3a6d132dccb97353c674846f416a87135dacb8fd.tar.gz
org.eclipse.gmf-tooling-3a6d132dccb97353c674846f416a87135dacb8fd.tar.xz
org.eclipse.gmf-tooling-3a6d132dccb97353c674846f416a87135dacb8fd.zip
[237059] - fix for drag-drop (reparenting) problems back-ported to
GMF from UML2 Tools with help of new API to VisualIdRegistry, custom code removed from samples
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java19
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java33
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java5
-rw-r--r--examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java48
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/CreationEditPolicyWithCustomReparent.java (renamed from examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java)39
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/MoveViewCommand.java (renamed from examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java)33
6 files changed, 53 insertions, 124 deletions
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java
deleted file mode 100644
index 3a69f9488..000000000
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/IVisualIDRegistry.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.View;
-
-public interface IVisualIDRegistry {
-
- public int getVisualID(View view);
-
- public String getModelID(View view);
-
- public int getNodeVisualID(View containerView, EObject domainElement);
-
- public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate);
-
- public boolean isCompartmentVisualID(int visualID);
-
- public boolean isSemanticLeafVisualID(int visualID);
-}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java
deleted file mode 100644
index 8efa10d0e..000000000
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveRequestWithParentInfo.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
-
-/**
- * @see #237059
- */
-public class MoveRequestWithParentInfo extends MoveRequest {
-
- private final Map<EObject, EObject> myElement2ActualParent = new HashMap<EObject, EObject>();
-
- public MoveRequestWithParentInfo(TransactionalEditingDomain editingDomain, EObject targetContainer, EObject elementToMove) {
- super(editingDomain, targetContainer, elementToMove);
- }
-
- public void registerActualContainer(EObject elementToMove, EObject actualContainer) {
- if (actualContainer != null) {
- myElement2ActualParent.put(elementToMove, actualContainer);
- } else {
- myElement2ActualParent.remove(elementToMove);
- }
- }
-
- public EObject getActualContainer(EObject movedElement) {
- return myElement2ActualParent.get(movedElement);
- }
-
-}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java
index db4c76f8b..6190fae9c 100644
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java
+++ b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOECreationEditPolicyWithCustomReparent.java
@@ -1,9 +1,12 @@
package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
+import org.eclipse.gmf.tooling.runtime.edit.policies.reparent.CreationEditPolicyWithCustomReparent;
+
public class TOECreationEditPolicyWithCustomReparent extends CreationEditPolicyWithCustomReparent {
public TOECreationEditPolicyWithCustomReparent() {
- super(new TOEVisualIDRegistryImpl());
+ super(TOEVisualIDRegistry.TYPED_INSTANCE);
}
}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java b/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java
deleted file mode 100644
index 49d27135e..000000000
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/TOEVisualIDRegistryImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staff2EditPart;
-import org.eclipse.gmf.examples.ocldriven.toe.diagram.edit.parts.DepartmentDepartment_staffEditPart;
-import org.eclipse.gmf.examples.ocldriven.toe.diagram.part.TOEVisualIDRegistry;
-import org.eclipse.gmf.runtime.notation.View;
-
-public class TOEVisualIDRegistryImpl implements IVisualIDRegistry {
-
- @Override
- public int getVisualID(View view) {
- return TOEVisualIDRegistry.getVisualID(view);
- }
-
- @Override
- public String getModelID(View view) {
- return TOEVisualIDRegistry.getModelID(view);
- }
-
- @Override
- public int getNodeVisualID(View containerView, EObject domainElement) {
- return TOEVisualIDRegistry.getNodeVisualID(containerView, domainElement);
- }
-
- @Override
- public boolean checkNodeVisualID(View containerView, EObject domainElement, int candidate) {
- return getNodeVisualID(containerView, domainElement) == candidate;
- }
-
- @Override
- public boolean isCompartmentVisualID(int visualID) {
- switch (visualID) {
- case DepartmentDepartment_staff2EditPart.VISUAL_ID:
- case DepartmentDepartment_staffEditPart.VISUAL_ID:
- return true;
-
- default:
- return false;
- }
- }
-
- @Override
- public boolean isSemanticLeafVisualID(int visualID) {
- return false;
- }
-
-}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/CreationEditPolicyWithCustomReparent.java
index 5112a77dc..a8966884c 100644
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/CreationEditPolicyWithCustomReparent.java
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/CreationEditPolicyWithCustomReparent.java
@@ -1,6 +1,8 @@
-package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+package org.eclipse.gmf.tooling.runtime.edit.policies.reparent;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -16,17 +18,19 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
+import org.eclipse.gmf.runtime.emf.type.core.requests.MoveRequest;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
/**
- * @see #237059
+ * @see #237059, backported to GMF from UML2Tools
*/
public class CreationEditPolicyWithCustomReparent extends CreationEditPolicy {
- private final IVisualIDRegistry myVisualIdRegistry;
+ private final DiagramStructure myDiagramStructure;
- public CreationEditPolicyWithCustomReparent(IVisualIDRegistry visualIdRegistry) {
- myVisualIdRegistry = visualIdRegistry;
+ public CreationEditPolicyWithCustomReparent(DiagramStructure diagramStructure) {
+ myDiagramStructure = diagramStructure;
}
@Override
@@ -74,6 +78,7 @@ public class CreationEditPolicyWithCustomReparent extends CreationEditPolicy {
* MoveRequestWithParentInfo instead of MoveRequest and configuring it with
* info about actual semantic element of moved element's container
*/
+ @Override
protected ICommand getReparentGroupCommand(GroupEditPart groupEP) {
CompositeCommand cc = new CompositeCommand(DiagramUIMessages.AddCommand_Label);
View container = (View) getHost().getModel();
@@ -120,7 +125,7 @@ public class CreationEditPolicyWithCustomReparent extends CreationEditPolicy {
View container = (View) getHost().getModel();
View view = (View) gep.getModel();
MoveViewCommand result = new MoveViewCommand(gep.getEditingDomain(), new EObjectAdapter(container), new EObjectAdapter(view), getHostImpl().getDiagramPreferencesHint());
- result.setVisualIDRegistry(myVisualIdRegistry);
+ result.setVisualIDRegistry(myDiagramStructure);
return result;
}
@@ -128,4 +133,26 @@ public class CreationEditPolicyWithCustomReparent extends CreationEditPolicy {
return (IGraphicalEditPart) getHost();
}
+ public static class MoveRequestWithParentInfo extends MoveRequest {
+
+ private final Map<EObject, EObject> myElement2ActualParent = new HashMap<EObject, EObject>();
+
+ public MoveRequestWithParentInfo(TransactionalEditingDomain editingDomain, EObject targetContainer, EObject elementToMove) {
+ super(editingDomain, targetContainer, elementToMove);
+ }
+
+ public void registerActualContainer(EObject elementToMove, EObject actualContainer) {
+ if (actualContainer != null) {
+ myElement2ActualParent.put(elementToMove, actualContainer);
+ } else {
+ myElement2ActualParent.remove(elementToMove);
+ }
+ }
+
+ public EObject getActualContainer(EObject movedElement) {
+ return myElement2ActualParent.get(movedElement);
+ }
+
+ }
+
}
diff --git a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/MoveViewCommand.java
index e01622caf..80ddb4e13 100644
--- a/examples/org.eclipse.gmf.examples.ocldriven.diagram/custom-src/org/eclipse/gmf/examples/ocldriven/diagram/custom/policies/MoveViewCommand.java
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/edit/policies/reparent/MoveViewCommand.java
@@ -1,4 +1,4 @@
-package org.eclipse.gmf.examples.ocldriven.diagram.custom.policies;
+package org.eclipse.gmf.tooling.runtime.edit.policies.reparent;
import java.util.ArrayList;
import java.util.List;
@@ -19,6 +19,7 @@ import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.tooling.runtime.structure.DiagramStructure;
public class MoveViewCommand extends AbstractTransactionalCommand {
@@ -30,7 +31,7 @@ public class MoveViewCommand extends AbstractTransactionalCommand {
private final PreferencesHint myPreferences;
- private IVisualIDRegistry myVisualIDRegistry;
+ private DiagramStructure myDiagramStructure;
public MoveViewCommand(TransactionalEditingDomain editingDomain, IAdaptable parent, IAdaptable child, PreferencesHint preferencesHint) {
this(editingDomain, parent, child, ViewUtil.APPEND, preferencesHint);
@@ -44,10 +45,11 @@ public class MoveViewCommand extends AbstractTransactionalCommand {
myPreferences = preferences;
}
- public void setVisualIDRegistry(IVisualIDRegistry visualIDRegistry) {
- myVisualIDRegistry = visualIDRegistry;
+ public void setVisualIDRegistry(DiagramStructure diagramStructure) {
+ myDiagramStructure = diagramStructure;
}
+ @Override
public List<?> getAffectedFiles() {
View view = (View) myParent.getAdapter(View.class);
if (view != null) {
@@ -63,11 +65,11 @@ public class MoveViewCommand extends AbstractTransactionalCommand {
}
protected boolean checkCanMoveView(View parentView, View childView, EObject child) {
- if (myVisualIDRegistry == null) {
+ if (myDiagramStructure == null) {
return false;
}
- int actualVisualId = myVisualIDRegistry.getVisualID(childView);
- return myVisualIDRegistry.checkNodeVisualID(parentView, child, actualVisualId);
+ int actualVisualId = myDiagramStructure.getVisualID(childView);
+ return myDiagramStructure.checkNodeVisualID(parentView, child, actualVisualId);
}
@Override
@@ -88,18 +90,16 @@ public class MoveViewCommand extends AbstractTransactionalCommand {
return CommandResult.newOKCommandResult();
}
- /**
- * Just a hook, default implementation does nothing
- */
- protected void importStyles(View newView, View childView) {
- //
+ @SuppressWarnings("unchecked")
+ protected void moveStyles(View newViewWillBeIgnored, View oldChildViewWillBeReused) {
+ oldChildViewWillBeReused.getStyles().clear();
+ oldChildViewWillBeReused.getStyles().addAll(newViewWillBeIgnored.getStyles());
}
protected View basicCreateNewView(View parentView, View childView, EObject child) {
IAdaptable semanticAdapter = new EObjectAdapter(child);
String semanticHint = null;
- View result = ViewService.getInstance().createView(
- //
+ View result = ViewService.getInstance().createView(//
Node.class, semanticAdapter, parentView, semanticHint, myIndex, true, myPreferences);
return result;
}
@@ -128,10 +128,9 @@ public class MoveViewCommand extends AbstractTransactionalCommand {
for (View childView : edgesToAndFromHierarchy) {
ViewUtil.destroy(childView);
}
+
+ moveStyles(newView, oldChildView);
- oldChildView.getStyles().clear();
-
- oldChildView.getStyles().addAll(newView.getStyles());
oldChildView.getPersistedChildren().addAll(newView.getPersistedChildren());
oldChildView.getTransientChildren().addAll(newView.getTransientChildren());
oldChildView.getSourceEdges().addAll(newView.getSourceEdges());

Back to the top