Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvlorenzo2012-12-17 15:45:20 +0000
committervlorenzo2012-12-17 15:45:20 +0000
commit126e1ac1a8b2a8679096a4c3fdf557d3c74d3c48 (patch)
tree498acb925b4e9d31c1a4eb692726d8762e4de0b6 /extraplugins/uml
parent9a0a06f399b243beef4b0b9aea7dd6680582de15 (diff)
downloadorg.eclipse.papyrus-126e1ac1a8b2a8679096a4c3fdf557d3c74d3c48.tar.gz
org.eclipse.papyrus-126e1ac1a8b2a8679096a4c3fdf557d3c74d3c48.tar.xz
org.eclipse.papyrus-126e1ac1a8b2a8679096a4c3fdf557d3c74d3c48.zip
395133: [Compare] StackOverFlow Error when showing the detail of an error
https://bugs.eclipse.org/bugs/show_bug.cgi?id=395133 add the parameter Collection<DiffElement> alreadyManaged to : - getApplyInOriginCommand - getUndoInTargetCommand - getMergeRequiredDifferencesCommand
Diffstat (limited to 'extraplugins/uml')
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java26
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java9
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/merge/ITransactionalMerger.java15
-rw-r--r--extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/service/TransactionalMergeService.java8
4 files changed, 38 insertions, 20 deletions
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
index c92cc4cc6fd..52eaf63e37b 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DefaultTransactionalMerger.java
@@ -14,6 +14,8 @@
package org.eclipse.papyrus.infra.emf.compare.diff.internal.merger;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -21,6 +23,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.command.IdentityCommand;
@@ -51,9 +54,11 @@ import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.xmi.XMIResource;
+import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
@@ -73,13 +78,13 @@ import org.eclipse.papyrus.infra.emf.compare.diff.utils.PapyrusOptionsAdapter;
public class DefaultTransactionalMerger extends AbstractDefaultMerger implements ITransactionalMerger {
//---------------------These methods comes from ITransactionalMerger
- public Command getApplyInOriginCommand(TransactionalEditingDomain domain) {
+ public Command getApplyInOriginCommand(TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
final PapyrusOptionsAdapter adapter = PapyrusCompareOptionsUtils.getPapyrusOptionsAdapter(diff);
//cf bug 396267: [UML Compare] it is not possible to merge a difference on a stereotype property
//final CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff)); //$NON-NLS-1$
final CompoundCommand cmd = new CompoundCommand(NLS.bind("Apply in Origin Command for {0}", this.diff.getClass())); //$NON-NLS-1$
if(adapter==null || adapter.canApplyInOrigin()) {
- cmd.append(getMergeRequiredDifferencesCommand(domain, true));
+ cmd.append(getMergeRequiredDifferencesCommand(domain, true, alreadyManaged));
cmd.append(getDoApplyInOriginCommand(domain));
cmd.append(getPostProcessCommand(domain));
} else {
@@ -88,13 +93,13 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
return cmd;
}
- public Command getUndoInTargetCommand(TransactionalEditingDomain domain) {
+ public Command getUndoInTargetCommand(TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
final PapyrusOptionsAdapter adapter = PapyrusCompareOptionsUtils.getPapyrusOptionsAdapter(diff);
//cf bug 396267: [UML Compare] it is not possible to merge a difference on a stereotype property
//final CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff)); //$NON-NLS-1$
final CompoundCommand cmd = new CompoundCommand(NLS.bind("Undo in Target Command for {0}", this.diff.getClass())); //$NON-NLS-1$
if(adapter == null || adapter.canUndoInTarget()) {
- cmd.append(getMergeRequiredDifferencesCommand(domain, false));
+ cmd.append(getMergeRequiredDifferencesCommand(domain, false, alreadyManaged));
cmd.append(getDoUndoInTargetCommand(domain));
cmd.append(getPostProcessCommand(domain));
} else {
@@ -111,7 +116,7 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
return UnexecutableCommand.INSTANCE;
}
- public Command getMergeRequiredDifferencesCommand(TransactionalEditingDomain domain, boolean applyInOrigin) {
+ public Command getMergeRequiredDifferencesCommand(TransactionalEditingDomain domain, boolean applyInOrigin, Collection<DiffElement> alreadyManaged) {
CompoundCommand cmd = new CompoundCommand("Merge required differences"); //$NON-NLS-1$
// if(mergedDiffs == null) { //we need to clean it, to avoid that the command creation duplicate elements in this list
mergedDiffs = new ArrayList<DiffElement>();
@@ -124,12 +129,13 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
mergedDiffs.add(diff);
for(DiffElement requiredDiff : getDependencies(applyInOrigin)) {
- if(requiredDiff.eContainer() != null && !mergedDiffs.contains(requiredDiff)) {
+ if(requiredDiff.eContainer() != null && !alreadyManaged.contains(requiredDiff)) {
final ITransactionalMerger merger = TransactionalMergeFactory.createMerger(requiredDiff);
+ alreadyManaged.add(requiredDiff);
if(applyInOrigin) {
- cmd.append(((ITransactionalMerger)merger).getApplyInOriginCommand(domain));
+ cmd.append(((ITransactionalMerger)merger).getApplyInOriginCommand(domain, alreadyManaged));
} else {
- cmd.append(((ITransactionalMerger)merger).getUndoInTargetCommand(domain));
+ cmd.append(((ITransactionalMerger)merger).getUndoInTargetCommand(domain, alreadyManaged));
}
}
}
@@ -190,12 +196,12 @@ public class DefaultTransactionalMerger extends AbstractDefaultMerger implements
}
public boolean canApplyInOrigin() {
- return getApplyInOriginCommand(getTransactionalEditingDomain(diff)).canExecute();
+ return getApplyInOriginCommand(getTransactionalEditingDomain(diff), new ArrayList<DiffElement>()).canExecute();
}
public boolean canUndoInTarget() {
- return getUndoInTargetCommand(getTransactionalEditingDomain(diff)).canExecute();
+ return getUndoInTargetCommand(getTransactionalEditingDomain(diff), new ArrayList<DiffElement>()).canExecute();
}
//---------------------from Here to the end : duplicated and adapted code from DefaultMerger
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java
index 9e4ac353c4c..5aa5b3e36c7 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/internal/merger/DiffGroupTransactionalMerger.java
@@ -13,6 +13,7 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.compare.diff.internal.merger;
+import java.util.Collection;
import java.util.Iterator;
import org.eclipse.emf.common.command.Command;
@@ -32,12 +33,12 @@ public class DiffGroupTransactionalMerger extends DefaultTransactionalMerger {
/**
*
- * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getApplyInOriginCommand(org.eclipse.emf.transaction.TransactionalEditingDomain)
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getApplyInOriginCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, Collection)
*
* @param domain
* @return
*/
- public Command getApplyInOriginCommand(final TransactionalEditingDomain domain) {
+ public Command getApplyInOriginCommand(final TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
if(somethingToMerge((DiffGroup)diff)) {
return TransactionalMergeService.getMergeCommand(domain, diff.getSubDiffElements(), false);
}
@@ -46,12 +47,12 @@ public class DiffGroupTransactionalMerger extends DefaultTransactionalMerger {
/**
*
- * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getUndoInTargetCommand(org.eclipse.emf.transaction.TransactionalEditingDomain)
+ * @see org.eclipse.papyrus.infra.emf.compare.diff.internal.merger.DefaultTransactionalMerger#getUndoInTargetCommand(org.eclipse.emf.transaction.TransactionalEditingDomain, Collection)
*
* @param domain
* @return
*/
- public Command getUndoInTargetCommand(final TransactionalEditingDomain domain) {
+ public Command getUndoInTargetCommand(final TransactionalEditingDomain domain, Collection<DiffElement> alreadyManaged) {
if(somethingToMerge((DiffGroup)diff)) {
return TransactionalMergeService.getMergeCommand(domain, diff.getSubDiffElements(), true); // doUndoInTarget();
}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/merge/ITransactionalMerger.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/merge/ITransactionalMerger.java
index 4f2454e4f94..2a34daeba32 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/merge/ITransactionalMerger.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/merge/ITransactionalMerger.java
@@ -13,7 +13,10 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.compare.diff.merge;
+import java.util.Collection;
+
import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.compare.diff.merge.DefaultMerger;
import org.eclipse.emf.compare.diff.metamodel.DiffElement;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -28,19 +31,23 @@ public interface ITransactionalMerger {
/**
* This command should have the same behavior as {@link DefaultMerger#applyInOrigin()}
*
+ * @param alreadyManaged
+ * the list of the DiffElement already managed buy the command that we are creating
* @return
* the command to do the action
*/
- public Command getApplyInOriginCommand(final TransactionalEditingDomain domain);
+ public Command getApplyInOriginCommand(final TransactionalEditingDomain domain, final Collection<DiffElement> alreadyManaged);
/**
* This command should have the same behavior as {@link DefaultMerger#undoInTarget()}
*
* @param domain
+ * @param alreadyManaged
+ * the list of the DiffElement already managed buy the command that we are creating
* @return
* the command to do the action
*/
- public Command getUndoInTargetCommand(final TransactionalEditingDomain domain);
+ public Command getUndoInTargetCommand(final TransactionalEditingDomain domain, final Collection<DiffElement> alreadyManaged);
/**
* This command should have the same behavior as {@link DefaultMerger#doApplyInOrigin}
@@ -65,10 +72,12 @@ public interface ITransactionalMerger {
*
* @param domain
* @param applyInOrigin
+ * @param alreadyManaged
+ * the list of the DiffElement already managed buy the command that we are creating
* @return
* the command to do the action
*/
- public Command getMergeRequiredDifferencesCommand(final TransactionalEditingDomain domain, final boolean applyInOrigin);
+ public Command getMergeRequiredDifferencesCommand(final TransactionalEditingDomain domain, final boolean applyInOrigin, final Collection<DiffElement> alreadyManaged);
/**
* This command should have the same behavior as {@link DefaultMerger#postProcess}
diff --git a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/service/TransactionalMergeService.java b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/service/TransactionalMergeService.java
index c6771519fcb..438190c7724 100644
--- a/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/service/TransactionalMergeService.java
+++ b/extraplugins/uml/compare/org.eclipse.papyrus.infra.emf.compare.diff/src/org/eclipse/papyrus/infra/emf/compare/diff/service/TransactionalMergeService.java
@@ -14,6 +14,7 @@
package org.eclipse.papyrus.infra.emf.compare.diff.service;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.eclipse.emf.common.command.Command;
@@ -124,16 +125,17 @@ public class TransactionalMergeService {
} else {
merger = TransactionalMergeFactory.createMerger(element);
}
+ final Collection<DiffElement> alreadyManaged = new ArrayList<DiffElement>();
if(merger instanceof ITransactionalMerger) {
if(leftToRight) {
- cmd.append(((ITransactionalMerger)merger).getUndoInTargetCommand(domain));
+ cmd.append(((ITransactionalMerger)merger).getUndoInTargetCommand(domain, alreadyManaged));
} else {
- cmd.append(((ITransactionalMerger)merger).getApplyInOriginCommand(domain));
+ cmd.append(((ITransactionalMerger)merger).getApplyInOriginCommand(domain, alreadyManaged));
}
} else {
throw new UnsupportedOperationException(NLS.bind("I can't found the Papyrus Merger for {0}.", element)); //$NON-NLS-1$
}
-
+ alreadyManaged.clear();
cmd.append(new FireMergeDiffEndCommand(element, getMergeListeners()));
return cmd;
}

Back to the top