Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCéline Janssens2015-10-22 17:34:44 +0000
committerRemi Schnekenburger2015-10-23 12:23:13 +0000
commitbe72f874723165caebfe2e4e398e4fc1be23a604 (patch)
tree08878a4056df3b887027fde88dcb977abebf0f17
parentd093e96d7331379913e0bb336926451f6f4ca565 (diff)
downloadorg.eclipse.papyrus-be72f874723165caebfe2e4e398e4fc1be23a604.tar.gz
org.eclipse.papyrus-be72f874723165caebfe2e4e398e4fc1be23a604.tar.xz
org.eclipse.papyrus-be72f874723165caebfe2e4e398e4fc1be23a604.zip
Bug 479425: [Tooling] Copy and paste of a protocol does not work
https://bugs.eclipse.org/bugs/show_bug.cgi?id=479425 - Modify The CopyStrategy API - Allow to modify the copied Elements list from the selection list Change-Id: I05f2ffaeb294a0fac9b4baf237ba2c6a588e754d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=479425 Signed-off-by: Céline Janssens <Celine.Janssens@all4tec.net> (cherry picked from commit 31543f45918e421e6dead5b848024ee171e9481b)
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/AbstractCopyStrategy.java102
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/ICopyStrategy.java22
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/AbstractPasteStrategy.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/AllContentCopyStrategy.java29
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/RootOnlyCopyStrategy.java29
-rw-r--r--plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java11
6 files changed, 143 insertions, 51 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/AbstractCopyStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/AbstractCopyStrategy.java
new file mode 100644
index 00000000000..a0904c356ba
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/AbstractCopyStrategy.java
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * Copyright (c) 2015 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Abstract Class for the Copy Strategy, implement ICopyStrategy
+ *
+ * @author Céline JANSSENS
+ *
+ */
+public abstract class AbstractCopyStrategy implements ICopyStrategy {
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getLabel()
+ *
+ * @return the Label
+ */
+ @Override
+ public String getLabel() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getDescription()
+ *
+ * @return the Description
+ */
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getImage()
+ *
+ * @return the Image
+ */
+ @Override
+ public Image getImage() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getID()
+ *
+ * @return the Id
+ */
+ @Override
+ public String getID() {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getCommand(org.eclipse.gef.Request, org.eclipse.gef.EditPart)
+ */
+ @Override
+ public Command getCommand(Request request, EditPart targetEditPart) {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#getPriority()
+ *
+ * @return
+ * @deprecated
+ */
+ @Deprecated
+ @Override
+ public int getPriority() {
+ return 0;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy#prepareElementsInClipboard(java.util.List, java.util.Collection)
+ */
+ @Override
+ public void prepareElementsInClipboard(List<EObject> elementsInClipboard, Collection<EObject> selectedElements) {
+ // By default do nothing
+
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/ICopyStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/ICopyStrategy.java
index 53abda504b2..40eef4151fc 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/ICopyStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/copy/ICopyStrategy.java
@@ -1,4 +1,4 @@
-/*****************************************************************************
+/***************************************************************************************************
* Copyright (c) 2014 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
@@ -8,9 +8,14 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
- *****************************************************************************/
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Add the prepareElementInClipboard Method
+ ***************************************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
@@ -63,7 +68,7 @@ public interface ICopyStrategy extends IStrategy {
* @param targetEditPart
* The target edit part
* @return
- * A command, or null if the strategy cannot handle the request
+ * A command, or null if the strategy cannot handle the request
*/
public Command getCommand(Request request, EditPart targetEditPart);
@@ -78,5 +83,16 @@ public interface ICopyStrategy extends IStrategy {
@Deprecated
public int getPriority();
+ /**
+ * This method allows to modify the elements list in the ClipBoard before being Paste
+ *
+ * @param elementsInClipboard
+ * The list of Objects in the clipBoard to be modified, same as selectedElements by default
+ * @param selectedElements
+ * The selected Elements
+ */
+ public void prepareElementsInClipboard(List<EObject> elementsInClipboard, Collection<EObject> selectedElements);
+
+
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/AbstractPasteStrategy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/AbstractPasteStrategy.java
index 250b7d8f1a9..9fe2cb43ec3 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/AbstractPasteStrategy.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/strategy/paste/AbstractPasteStrategy.java
@@ -127,4 +127,5 @@ public abstract class AbstractPasteStrategy implements IPasteStrategy {
return 1;
}
+
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/AllContentCopyStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/AllContentCopyStrategy.java
index 57e68078fe0..f363fd25ff8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/AllContentCopyStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/AllContentCopyStrategy.java
@@ -8,22 +8,19 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Extends the Abstract Class
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.strategy.copy;
import java.util.Map;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy;
+import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.AbstractCopyStrategy;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.swt.graphics.Image;
/**
- *
+ * Copy all the content of a compartment into a Classifier
*/
-public class AllContentCopyStrategy implements ICopyStrategy {
+public class AllContentCopyStrategy extends AbstractCopyStrategy {
@Override
public String getLabel() {
@@ -32,7 +29,7 @@ public class AllContentCopyStrategy implements ICopyStrategy {
@Override
public String getID() {
- return Activator.ID + ".AllContentCopyStrategy";//".ClassifierToStructureCompDrop"; //$NON-NLS-1$
+ return Activator.ID + ".AllContentCopyStrategy";// ".ClassifierToStructureCompDrop"; //$NON-NLS-1$
}
@Override
@@ -48,25 +45,9 @@ public class AllContentCopyStrategy implements ICopyStrategy {
return "Select elements to copy"; //$NON-NLS-1$
}
- @Override
- public Image getImage() {
- return null;
- }
-
- @Override
- public int getPriority() {
- return 0;
- }
-
public void setOptions(Map<String, Object> options) {
// Nothing
}
- @Override
- public Command getCommand(Request request, EditPart targetEditPart) {
- // TODO Auto-generated method stub
- return null;
- }
-
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/RootOnlyCopyStrategy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/RootOnlyCopyStrategy.java
index e7dcbaef0a8..0e23441d4e6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/RootOnlyCopyStrategy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/strategy/copy/RootOnlyCopyStrategy.java
@@ -8,22 +8,19 @@
*
* Contributors:
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Initial API and implementation
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Extends Abstract Class
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.strategy.copy;
import java.util.Map;
-import org.eclipse.gef.EditPart;
-import org.eclipse.gef.Request;
-import org.eclipse.gef.commands.Command;
-import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy;
+import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.AbstractCopyStrategy;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.swt.graphics.Image;
/**
- *
+ * Copy Strategy to Copy only the Root of an element.
*/
-public class RootOnlyCopyStrategy implements ICopyStrategy {
+public class RootOnlyCopyStrategy extends AbstractCopyStrategy {
@Override
public String getLabel() {
@@ -32,12 +29,12 @@ public class RootOnlyCopyStrategy implements ICopyStrategy {
@Override
public String getID() {
- return Activator.ID + ".RootOnlyCopyStrategy";//".ClassifierToStructureCompDrop"; //$NON-NLS-1$
+ return Activator.ID + ".RootOnlyCopyStrategy";// ".ClassifierToStructureCompDrop"; //$NON-NLS-1$
}
@Override
public String getDescription() {
- return "Copopy only root of the selected element"; //$NON-NLS-1$
+ return "Copy only root of the selected element"; //$NON-NLS-1$
}
public String getCategoryID() {
@@ -48,25 +45,11 @@ public class RootOnlyCopyStrategy implements ICopyStrategy {
return "Select elements to copy"; //$NON-NLS-1$
}
- @Override
- public Image getImage() {
- return null;
- }
-
- @Override
- public int getPriority() {
- return 0;
- }
public void setOptions(Map<String, Object> options) {
// Nothing
}
- @Override
- public Command getCommand(Request request, EditPart targetEditPart) {
- // TODO Auto-generated method stub
- return null;
- }
}
diff --git a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
index 4a70180661d..af3ee17acd6 100644
--- a/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
+++ b/plugins/views/modelexplorer/org.eclipse.papyrus.views.modelexplorer/src/org/eclipse/papyrus/views/modelexplorer/handler/CopyHandler.java
@@ -10,6 +10,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Benoit Maggi (CEA LIST) benoit.maggi@cea.fr - Use of a paste strategies
+ * Celine Janssens (ALL4TEC) celine.janssens@all4tec.net - Use the Copy Strategies
*****************************************************************************/
package org.eclipse.papyrus.views.modelexplorer.handler;
@@ -23,6 +24,8 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.core.clipboard.PapyrusClipboard;
import org.eclipse.papyrus.infra.gmfdiag.common.commands.DefaultCopyCommand;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.IStrategy;
+import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.CopyStrategyManager;
+import org.eclipse.papyrus.infra.gmfdiag.common.strategy.copy.ICopyStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.IPasteStrategy;
import org.eclipse.papyrus.infra.gmfdiag.common.strategy.paste.PasteStrategyManager;
@@ -42,7 +45,13 @@ public class CopyHandler extends AbstractCommandHandler {
}
protected static List<EObject> getElementsToPutInClipboard(Collection<EObject> selectedElements) {
- return new ArrayList<EObject>(selectedElements);
+ List<EObject> elementsInClipboard = new ArrayList<EObject>(selectedElements);
+ List<IStrategy> allStrategies = CopyStrategyManager.getInstance().getAllStrategies();
+ for (IStrategy iStrategy : allStrategies) {
+ ICopyStrategy iCopyStrategy = (ICopyStrategy) iStrategy;
+ iCopyStrategy.prepareElementsInClipboard(elementsInClipboard, selectedElements);
+ }
+ return elementsInClipboard;
}
/**

Back to the top