summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoit Maggi2014-04-08 04:52:43 (EDT)
committerBenoit Maggi2014-04-09 04:40:22 (EDT)
commitd0d8ea87b4fad82360e628b4a75366c3eacd3fe0 (patch)
tree3a416da105d60cc9d0a29a118ff62a6cfa9da6e9
parent0ce37a39dba64587bd210442fc6f80b63d84081e (diff)
downloadorg.eclipse.papyrus-d0d8ea87b4fad82360e628b4a75366c3eacd3fe0.zip
org.eclipse.papyrus-d0d8ea87b4fad82360e628b4a75366c3eacd3fe0.tar.gz
org.eclipse.papyrus-d0d8ea87b4fad82360e628b4a75366c3eacd3fe0.tar.bz2
Bug 290261: Correct Rename strategy for contained elementsrefs/changes/17/24617/2
Change-Id: Ic0d337cbaf101e0e8357ed3deeb2484c22a472e3 Signed-off-by: Benoit Maggi <benoit.maggi@cea.fr>
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java12
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/RenamePasteStrategy.java20
2 files changed, 21 insertions, 11 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
index e9cbaae..8f84365 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/clipboard/PapyrusClipboard.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.infra.core.clipboard;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -164,5 +165,14 @@ public class PapyrusClipboard<E> extends ArrayList<E> {
public EObject getTragetCopyFromInternalClipboardCopy(Object object) {
return internalClipboardToTargetCopy.get(object);
}
-
+
+ /**
+ * Iterate on the copy selection
+ * (Use by paste strategy to prepare IAdditionalData)
+ * @return
+ */
+ public Collection<EObject> getTarget() {
+ return internalClipboardToTargetCopy.values();
+ }
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/RenamePasteStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/RenamePasteStrategy.java
index 74f77e8..85cd2c6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/RenamePasteStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/paste/RenamePasteStrategy.java
@@ -12,10 +12,12 @@
package org.eclipse.papyrus.uml.diagram.common.strategy.paste;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.commands.Command;
@@ -131,11 +133,10 @@ public class RenamePasteStrategy implements IPasteStrategy {
@Override
public org.eclipse.emf.common.command.Command getSemanticCommand(EditingDomain domain, EObject targetOwner, PapyrusClipboard<Object> papyrusClipboard) {
CompoundCommand compoundCommand = new CompoundCommand("Rename root paste elements"); //$NON-NLS-1$
- for(Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
- Object object = (Object)iterator.next();
- // get target Element
- EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object);
- if(target != null && target instanceof NamedElement) {
+ List<EObject> filterDescendants = EcoreUtil.filterDescendants(papyrusClipboard.getTarget());
+ for(Iterator<EObject> iterator = filterDescendants.iterator(); iterator.hasNext();) {
+ EObject target = (EObject)iterator.next();
+ if(target instanceof NamedElement) {
NamedElement namedElement = (NamedElement)target;
if(namedElement.getName() != null) {
String defaultCopyNameWithIncrement = NamedElementUtil.getDefaultCopyNameWithIncrement(namedElement, targetOwner.eContents());
@@ -162,11 +163,10 @@ public class RenamePasteStrategy implements IPasteStrategy {
org.eclipse.gef.commands.CompoundCommand compoundCommand = new org.eclipse.gef.commands.CompoundCommand("Stereotype Semantic And Graphical paste"); //$NON-NLS-1$
View view = (View)targetEditPart.getModel();
EObject modelTargetOwner = (EObject)view.getElement();
- for(Iterator<Object> iterator = papyrusClipboard.iterator(); iterator.hasNext();) {
- Object object = (Object)iterator.next();
- // get target Element
- EObject target = papyrusClipboard.getTragetCopyFromInternalClipboardCopy(object);
- if(target != null && target instanceof NamedElement) {
+ List<EObject> filterDescendants = EcoreUtil.filterDescendants(papyrusClipboard.getTarget());
+ for(Iterator<EObject> iterator = filterDescendants.iterator(); iterator.hasNext();) {
+ EObject target = (EObject)iterator.next();
+ if(target instanceof NamedElement) {
NamedElement namedElement = (NamedElement)target;
if(namedElement.getName() != null) {
String defaultCopyNameWithIncrement = NamedElementUtil.getDefaultCopyNameWithIncrement(namedElement, modelTargetOwner.eContents());