use ActivityDeepCopyConfigurator for deep copy operation
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditorActionBarContributor.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditorActionBarContributor.java
index f0dff27..21efc9c 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditorActionBarContributor.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/editors/ProcessEditorActionBarContributor.java
@@ -74,6 +74,7 @@
import org.eclipse.epf.diagram.ui.service.DiagramEditorHelper;
import org.eclipse.epf.diagram.wpdd.part.WPDDImages;
import org.eclipse.epf.library.LibraryService;
+import org.eclipse.epf.library.configuration.ActivityDeepCopyConfigurator;
import org.eclipse.epf.library.edit.IFilter;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
@@ -1249,7 +1250,7 @@
ActivityDropCommand cmd = new ActivityDropCommand(
selectedActivity, selection, null,
- getAdapterFactory());
+ getAdapterFactory(),new ActivityDeepCopyConfigurator(config,null));
cmd.setType(IActionTypeProvider.DEEP_COPY);
getActionManager().execute(cmd);
diff --git a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ProcessTreeViewer.java b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ProcessTreeViewer.java
index 70224fa..3f78d80 100644
--- a/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ProcessTreeViewer.java
+++ b/2.0/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/ProcessTreeViewer.java
@@ -16,6 +16,7 @@
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.epf.authoring.ui.AuthoringUIResources;
import org.eclipse.epf.authoring.ui.editors.ColumnDescriptor;
+import org.eclipse.epf.library.configuration.ActivityDeepCopyConfigurator;
import org.eclipse.epf.library.edit.command.IActionManager;
import org.eclipse.epf.library.edit.command.IResourceAwareCommand;
import org.eclipse.epf.library.edit.process.IBSItemProvider;
@@ -272,6 +273,11 @@
ActivityDropCommand cmd = ((ActivityDropCommand) command);
cmd.setType(ProcessTreeViewer.this.actionType);
cmd.setLabel(text);
+
+ if (ProcessTreeViewer.this.actionType == DEEP_COPY ) {
+ cmd.setActivityDeepCopyConfigurator(new ActivityDeepCopyConfigurator());
+ }
+
}
if (actionManager != null
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDeepCopyCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDeepCopyCommand.java
index 3f4d38a..be036b3 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDeepCopyCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDeepCopyCommand.java
@@ -24,6 +24,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAttribute;
@@ -42,6 +43,7 @@
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.Providers;
import org.eclipse.epf.library.edit.TngAdapterFactory;
+import org.eclipse.epf.library.edit.VariabilityInfo;
import org.eclipse.epf.library.edit.process.BreakdownElementWrapperItemProvider;
import org.eclipse.epf.library.edit.util.ConfigurationSetter;
import org.eclipse.epf.library.edit.util.ConstraintManager;
@@ -114,6 +116,111 @@
}
}
+ @Override
+ protected void addCreateCopyCommands(CompoundCommand compoundCommand,
+ EObject object) {
+
+ // Operation to handle copy replacers
+ //
+ if (object instanceof ProcessPackage && object != this.activity.eContainer() ) {
+ ProcessPackage pkg = (ProcessPackage)object;
+ boolean isReplaced = false;
+ Activity replacer = null;
+ Activity orignalActivity = null;
+ for(Object procesElement : pkg.getProcessElements()){
+ if (procesElement instanceof Activity) {
+ replacer = getReplacer( (Activity)procesElement );
+ if (replacer != null ) {
+ isReplaced = true;
+ orignalActivity = (Activity)procesElement;
+ break;
+ }
+ }
+ }
+ if (isReplaced) {
+ copyHelper.decrementDeferredInitializationCount();
+ ActivityDeepCopyCommand cmd = new ActivityDeepCopyCommand(replacer, (CopyHelper)copyHelper, config,
+ targetProcess, monitor, false,activityDeepCopyConfigurator);
+ cmd.guidList = new LinkedList<String>(ActivityDeepCopyCommand.this.guidList);
+ cmd.guidList.addAll(ProcessUtil.getGuidList(ActivityDeepCopyCommand.this.activity, orignalActivity));
+ try {
+ cmd.execute();
+ ProcessPackage pkgCopy = cmd.pkgCopy;
+ //basic put: original prc pkg to copied pkg based on replaced package.
+ ((CopyHelper)copyHelper).basicPut(object, pkgCopy);
+ //basic put original activity to the copy of replacer activity.
+ ((CopyHelper)copyHelper).basicPut(orignalActivity, copyHelper.get(replacer));
+ }finally{
+ cmd.dispose();
+ }
+ copyHelper.incrementDeferredInitializationCount();
+ return;
+ }
+ }
+
+ super.addCreateCopyCommands(compoundCommand, object);
+
+ }
+
+ /**
+ * Checks for the replacer of activity in the copy based configuration.
+ *
+ * @param activity target activity
+ * @return replcacer or null if it doesn't have one
+ */
+ protected Activity getReplacer(Activity activity){
+ ConfigurationSetter configSetter = new ConfigurationSetter(getAdapterFactory());
+ try {
+ if (activityDeepCopyConfigurator != null ) {
+ MethodConfiguration currentConfig = configSetter.getOldConfiguration();
+ MethodConfiguration copyConfig = config == null ? (currentConfig != null ? currentConfig
+ : targetProcess.getDefaultContext())
+ : config;
+ activityDeepCopyConfigurator.setMethodConfiguration(copyConfig);
+
+ VariabilityInfo variabilityInfo = activityDeepCopyConfigurator.getVariabilityInfo(activity);
+
+ if (variabilityInfo != null && ! variabilityInfo.getInheritanceList().isEmpty() ) {
+ Activity replacer = (Activity)variabilityInfo.getInheritanceList().get(0);
+ return replacer == activity ? null : replacer;
+ }
+ }
+ return null;
+ } finally{
+ if (configSetter != null ) {
+ configSetter.restore();
+ }
+ }
+ }
+
+ /**
+ * Checks for the contributors of activity in the copy based configuration.
+ * @param activity
+ * @return a list including contributors or empty list
+ */
+ protected List getContributors(Activity activity){
+ ConfigurationSetter configSetter = new ConfigurationSetter(getAdapterFactory());
+ try {
+ if (activityDeepCopyConfigurator != null ) {
+ MethodConfiguration currentConfig = configSetter.getOldConfiguration();
+ MethodConfiguration copyConfig = config == null ? (currentConfig != null ? currentConfig
+ : targetProcess.getDefaultContext())
+ : config;
+ activityDeepCopyConfigurator.setMethodConfiguration(copyConfig);
+
+ VariabilityInfo variabilityInfo = activityDeepCopyConfigurator.getVariabilityInfo(activity);
+
+ if (variabilityInfo != null ) {
+ return variabilityInfo.getContributors();
+ }
+ }
+ return Collections.EMPTY_LIST;
+ } finally{
+ if (configSetter != null ) {
+ configSetter.restore();
+ }
+ }
+ }
private class CreateDeepCopyCommand extends CreateCopyCommand {
/**
@@ -225,7 +332,7 @@
}
}
- ActivityDeepCopyCommand cmd = new ActivityDeepCopyCommand(base, helper, config, targetProcess, monitor, false);
+ ActivityDeepCopyCommand cmd = new ActivityDeepCopyCommand(base, helper, config, targetProcess, monitor, false,activityDeepCopyConfigurator);
cmd.guidList = new LinkedList<String>(ActivityDeepCopyCommand.this.guidList);
cmd.guidList.addAll(ProcessUtil.getGuidList(ActivityDeepCopyCommand.this.activity, activity));
try {
@@ -350,6 +457,22 @@
activityCopy.setVariabilityBasedOnElement(null);
activityCopy.setVariabilityType(null);
}
+
+ //copy contributors
+ if (owner instanceof Activity && copyContributors ) {
+ Activity activity = (Activity)owner;
+ List contributors = getContributors(activity);
+ if (!contributors.isEmpty()) {
+ doCopyContributors(contributors,activity);
+ }
+ }
+
+ // clear the variability data of replacer
+ //
+ if (copy instanceof Activity && TngUtil.isReplacer((VariabilityElement)copy)) {
+ ((Activity)copy).setVariabilityBasedOnElement(null);
+ ((Activity)copy).setVariabilityType(null);
+ }
}
finally {
if(configSetter != null) {
@@ -367,7 +490,76 @@
EcoreUtil.remove(rule);
}
}
- }
+ }
+
+
+ /**
+ * Copy contributors
+ * @param contributors
+ */
+ protected void doCopyContributors(List contributors, Activity owner ) {
+ ConfigurationSetter configSetter = new ConfigurationSetter(getAdapterFactory());
+ try {
+ MethodConfiguration currentConfig = configSetter.getOldConfiguration();
+ MethodConfiguration copyConfig = config == null ? (currentConfig != null ? currentConfig
+ : targetProcess.getDefaultContext())
+ : config;
+ configSetter.set(copyConfig);
+ IConfigurator configurator = configSetter.getConfigurator();
+ for (Iterator iterator = contributors.iterator(); iterator.hasNext();) {
+ Activity contributedActivity = (Activity) iterator.next();
+ CopyHelper helper = (CopyHelper)copyHelper;
+ Activity contributorCopy = (Activity) helper.get(contributedActivity);
+ ActivityDeepCopyCommand cmd = new ActivityDeepCopyCommand(contributedActivity, helper,
+ config, targetProcess, monitor, false,activityDeepCopyConfigurator);
+ cmd.copyContributors = false;
+ cmd.guidList = new LinkedList<String>(ActivityDeepCopyCommand.this.guidList);
+ cmd.guidList.addAll(ProcessUtil.getGuidList(ActivityDeepCopyCommand.this.activity, owner));
+ try {
+ cmd.execute();
+
+ contributorCopy = (Activity) helper.get(contributedActivity);
+
+ Activity activityCopy = (Activity) copy;
+
+ // remove the copies of base diagram if the activity already have diagram of the same type
+ //
+ for (int i = 0; i < diagramTypes.length; i++) {
+ int type = diagramTypes[i];
+ if(diagramMgr.getDiagram(activity, type) != null) {
+ Diagram diagram = diagramMgr.getDiagram(activityCopy, type);
+ if(diagram != null) {
+ EcoreUtil.remove(diagram);
+ }
+ }
+ }
+
+ // move content of base package over to the activity's package
+ //
+ moveContent(cmd.pkgCopy, activityCopy);
+
+ List<BreakdownElement> breakdownElements = new ArrayList<BreakdownElement>();
+ for (Iterator<BreakdownElement> iter = contributorCopy.getBreakdownElements().iterator(); iter.hasNext();) {
+ BreakdownElement e = iter.next();
+ if(configurator == null || configurator.accept(e)){
+ breakdownElements.add(e);
+ }
+ }
+ activityCopy.getBreakdownElements().addAll(breakdownElements);
+ contributorCopy.setSuperActivities(null);
+ EcoreUtil.remove(contributorCopy);
+
+ }
+ finally {
+ cmd.dispose();
+ }
+ }
+ }finally{
+ if (configSetter != null ) {
+ configSetter.restore();
+ }
+ }
+ }
}
protected ProcessPackage pkgCopy;
@@ -384,9 +576,15 @@
private BreakdownElementWrapperItemProvider wrapper;
+ //used to retrieve replacers and contributors
+ private IConfigurator activityDeepCopyConfigurator;
+
+ //
+ private boolean copyContributors = true;
+
private ActivityDeepCopyCommand(Activity activity, CopyHelper copyHelper,
MethodConfiguration config, Process targetProcess,
- IProgressMonitor monitor, boolean initGuidList) {
+ IProgressMonitor monitor, boolean initGuidList,IConfigurator activityDeepCopyConfigurator) {
super(null, activity.eContainer(), copyHelper);
Assert.isTrue(activity.eContainer() instanceof ProcessPackage, "Activity's container must be a ProcessPackage"); //$NON-NLS-1$
this.activity = activity;
@@ -399,17 +597,19 @@
if(initGuidList) {
guidList = ProcessUtil.getGuidList(null, this.activity);
}
+ this.activityDeepCopyConfigurator = activityDeepCopyConfigurator;
}
public ActivityDeepCopyCommand(Activity activity, CopyHelper copyHelper,
MethodConfiguration config, Process targetProcess,
- IProgressMonitor monitor) {
- this(activity, copyHelper, config, targetProcess, monitor, true);
+ IProgressMonitor monitor, IConfigurator activityDeepCopyConfigurator) {
+ this(activity, copyHelper, config, targetProcess, monitor, true,activityDeepCopyConfigurator);
}
- public ActivityDeepCopyCommand(Object activityOrWrapper, CopyHelper copyHelper, MethodConfiguration config, Process targetProcess, IProgressMonitor monitor) {
+ public ActivityDeepCopyCommand(Object activityOrWrapper, CopyHelper copyHelper, MethodConfiguration config,
+ Process targetProcess, IProgressMonitor monitor, IConfigurator activityDeepCopyConfigurator) {
this((Activity)TngUtil.unwrap(activityOrWrapper), copyHelper, config, targetProcess, monitor,
- activityOrWrapper instanceof Activity);
+ activityOrWrapper instanceof Activity,activityDeepCopyConfigurator);
if(activityOrWrapper instanceof BreakdownElementWrapperItemProvider) {
wrapper = (BreakdownElementWrapperItemProvider) activityOrWrapper;
guidList = ProcessUtil.getGuidList(wrapper);
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
index dde3964..400b0b3 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ActivityDropCommand.java
@@ -25,6 +25,7 @@
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.util.AbstractTreeIterator;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.LibraryEditResources;
import org.eclipse.epf.library.edit.TngAdapterFactory;
@@ -79,6 +80,8 @@
protected boolean preExecuted;
protected HashSet<?> addedObjects;
+
+ protected IConfigurator activityDeepCopyConfigurator;
public ActivityDropCommand(Activity target, List activities, Viewer viewer, AdapterFactory adapterFactory) {
super(target, activities);
@@ -94,6 +97,12 @@
}
}
+ public ActivityDropCommand(Activity target, List activities, Viewer viewer,
+ AdapterFactory adapterFactory,IConfigurator deepCopyConfigurator){
+ this(target, activities, viewer, adapterFactory);
+ this.activityDeepCopyConfigurator = deepCopyConfigurator;
+ }
+
@Override
protected void prepareDropElements() {
// remove any drop element that is suppress
@@ -245,6 +254,9 @@
activityHandler.setDeepCopyConfig(deepCopyConfig);
activityHandler.setTargetProcess(targetProcess);
+ // Set a configurator to resovle and deep copy contributors and replacers
+ activityHandler.setActivityDeepCopyConfigurator(activityDeepCopyConfigurator);
+
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
@@ -619,6 +631,11 @@
public int getType(){
return type;
}
+
+ public void setActivityDeepCopyConfigurator(
+ IConfigurator activityDeepCopyConfigurator) {
+ this.activityDeepCopyConfigurator = activityDeepCopyConfigurator;
+ }
}
\ No newline at end of file
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ProcessDeepCopyCommand.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ProcessDeepCopyCommand.java
index 1b50f68..36bf044 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ProcessDeepCopyCommand.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/process/command/ProcessDeepCopyCommand.java
@@ -15,6 +15,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.LibraryEditPlugin;
import org.eclipse.epf.library.edit.command.NestedCommandExcecutor;
import org.eclipse.epf.services.ILibraryPersister;
@@ -43,9 +44,11 @@
private String newProcessName;
private NestedCommandExcecutor nestedCommandExecutor;
- public ProcessDeepCopyCommand(org.eclipse.epf.uma.Process process, String newProcessName, CopyHelper copyHelper, MethodConfiguration config, ProcessPackage targetPackage, IProgressMonitor monitor) {
+ public ProcessDeepCopyCommand(org.eclipse.epf.uma.Process process, String newProcessName,
+ CopyHelper copyHelper, MethodConfiguration config, ProcessPackage targetPackage,
+ IProgressMonitor monitor,IConfigurator configurator) {
- super(process, copyHelper, config, null, monitor);
+ super(process, copyHelper, config, null, monitor, configurator);
this.newProcessName = newProcessName;
this.targetPackage = targetPackage;
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ActivityHandler.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ActivityHandler.java
index 7f041df..f87b4d6 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ActivityHandler.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ActivityHandler.java
@@ -33,6 +33,7 @@
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.provider.AdapterFactoryTreeIterator;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+import org.eclipse.epf.library.edit.IConfigurator;
import org.eclipse.epf.library.edit.TngAdapterFactory;
import org.eclipse.epf.library.edit.process.IBSItemProvider;
import org.eclipse.epf.library.edit.process.command.ActivityDeepCopyCommand;
@@ -80,6 +81,8 @@
private Process targetProcess;
private IProgressMonitor monitor;
+
+ private IConfigurator activityDeepCopyConfigurator;
/**
* Constructs a new ActivityHandler
@@ -162,7 +165,7 @@
}
for (Object act : activitiesToDeepCopy) {
ActivityDeepCopyCommand cmd = new ActivityDeepCopyCommand(
- act, getDeepCopyHelper(), deepCopyConfig, targetProcess, monitor);
+ act, getDeepCopyHelper(), deepCopyConfig, targetProcess, monitor,activityDeepCopyConfigurator);
try {
long time = 0;
if (TngUtil.DEBUG) {
@@ -351,4 +354,11 @@
}
return deepCopyHelper;
}
+
+ public void setActivityDeepCopyConfigurator(
+ IConfigurator activityDeepCopyConfigurator) {
+ this.activityDeepCopyConfigurator = activityDeepCopyConfigurator;
+ }
+
+
}
diff --git a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
index 5c19db2..8727bee 100644
--- a/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
+++ b/2.0/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/ProcessUtil.java
@@ -3366,30 +3366,30 @@
return false;
}
- /**
- * Creates a deep copy of a process to the specified process package.
- *
- * @param monitor
- * @param process
- * @prarm newProcessName
- * @param deepCopyConfig
- * @param targetPackage
- * @return Process the newly created process
- */
- public static org.eclipse.epf.uma.Process deepCopy(
- IProgressMonitor monitor,
- org.eclipse.epf.uma.Process process,
- String newProcessName,
- MethodConfiguration deepCopyConfig,
- ProcessPackage targetPackage) {
- CopyHelper helper = new CopyHelper();
- try {
- return deepCopy(monitor, process, newProcessName, deepCopyConfig, targetPackage, helper);
- }
- finally {
- helper.clear();
- }
- }
+// /**
+// * Creates a deep copy of a process to the specified process package.
+// *
+// * @param monitor
+// * @param process
+// * @prarm newProcessName
+// * @param deepCopyConfig
+// * @param targetPackage
+// * @return Process the newly created process
+// */
+// public static org.eclipse.epf.uma.Process deepCopy(
+// IProgressMonitor monitor,
+// org.eclipse.epf.uma.Process process,
+// String newProcessName,
+// MethodConfiguration deepCopyConfig,
+// ProcessPackage targetPackage) {
+// CopyHelper helper = new CopyHelper();
+// try {
+// return deepCopy(monitor, process, newProcessName, deepCopyConfig, targetPackage, helper);
+// }
+// finally {
+// helper.clear();
+// }
+// }
public static Process deepCopy(
IProgressMonitor monitor,
@@ -3397,7 +3397,8 @@
String newProcessName,
MethodConfiguration deepCopyConfig,
ProcessPackage targetPackage,
- CopyHelper copyHelper) {
+ CopyHelper copyHelper,
+ IConfigurator configurator) {
// if the targetPackage is null, use the same package of the source process
if ( targetPackage == null ) {
targetPackage = (ProcessPackage)process.eContainer().eContainer();
@@ -3410,7 +3411,8 @@
monitor = new NullProgressMonitor();
}
- ProcessDeepCopyCommand cmd = new ProcessDeepCopyCommand(process, newProcessName, copyHelper, deepCopyConfig, targetPackage, monitor);
+ ProcessDeepCopyCommand cmd = new ProcessDeepCopyCommand(process, newProcessName,
+ copyHelper, deepCopyConfig, targetPackage, monitor,configurator);
try {
cmd.execute();
Collection result = cmd.getResult();
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ActivityDeepCopyConfigurator.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ActivityDeepCopyConfigurator.java
new file mode 100644
index 0000000..5558b78
--- /dev/null
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ActivityDeepCopyConfigurator.java
@@ -0,0 +1,62 @@
+package org.eclipse.epf.library.configuration;
+
+import org.eclipse.epf.library.edit.VariabilityInfo;
+import org.eclipse.epf.uma.MethodConfiguration;
+import org.eclipse.epf.uma.MethodElement;
+import org.eclipse.epf.uma.VariabilityElement;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * A configurator used by activity deep copy command to resovle and deep copy contributors and
+ * replacers of activity in a metohd configuration.
+ *
+ */
+public class ActivityDeepCopyConfigurator extends ConfigurationFilter{
+
+
+ /**
+ * constructor
+ * @param methodConfig a <code>MethodConfiguration</code>
+ * @param viewer a <code>Viewer</code>
+ */
+ public ActivityDeepCopyConfigurator(MethodConfiguration methodConfig,
+ Viewer viewer) {
+ super(methodConfig, viewer);
+ }
+
+
+ /**
+ * Constructs with null methodConfig which could be set later.
+ */
+ public ActivityDeepCopyConfigurator() {
+ this(null, null);
+ }
+
+
+ @Override
+ public VariabilityInfo getVariabilityInfo(VariabilityElement ve) {
+
+ // calculate the element first
+ ElementRealizer realizer = new DefaultElementRealizer(methodConfig, false, true){
+ @Override
+ public boolean canShow(MethodElement element) {
+ return true;
+ }
+ };
+ return getVariabilityInfo(ve, realizer);
+ }
+
+ /**
+ * Overrides the super method for not resolving the base to include additional contributors.
+ */
+ @Override
+ protected void resolveElementVariabilityList(VariabilityElement element,
+ VariabilityInfo info, boolean includeBase, ElementRealizer realizer) {
+
+ if (methodConfig == null) {
+ return;
+ }
+ //resolve to include contributors
+ resolveElementContributors(element,info,realizer);
+ }
+}
diff --git a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationFilter.java b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationFilter.java
index 770f191..90753d2 100644
--- a/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationFilter.java
+++ b/2.0/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationFilter.java
@@ -172,21 +172,9 @@
if (methodConfig == null) {
return;
}
-
- // if the element has contributors in the configuration, get the
- // reference properties
- // if a contributor has replacer, it's replacer is used
- List items = ConfigurationHelper.getContributors(element, methodConfig);
- if (items != null && items.size() > 0) {
- for (Iterator it = items.iterator(); it.hasNext();) {
- VariabilityElement e = (VariabilityElement) it.next();
- List values = info.getContributors();
- if (!values.contains(e)) {
- values.add(e);
- }
- resolveElementVariabilityList(e, info, false, realizer);
- }
- }
+
+ //resolve to include contributors
+ resolveElementContributors(element,info,realizer);
// if the element is an extended element, get the base element's
// contributors
@@ -212,6 +200,24 @@
}
}
+
+ protected void resolveElementContributors(VariabilityElement element,
+ VariabilityInfo info, ElementRealizer realizer){
+ // if the element has contributors in the configuration, get the
+ // reference properties
+ // if a contributor has replacer, it's replacer is used
+ List items = ConfigurationHelper.getContributors(element, methodConfig);
+ if (items != null && items.size() > 0) {
+ for (Iterator it = items.iterator(); it.hasNext();) {
+ VariabilityElement e = (VariabilityElement) it.next();
+ List values = info.getContributors();
+ if (!values.contains(e)) {
+ values.add(e);
+ }
+ resolveElementVariabilityList(e, info, false, realizer);
+ }
+ }
+ }
/*
* resolve the variability of the element and get a list of contributors.