Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcbrun2015-05-05 20:06:20 +0000
committerMaxime Porhel2015-05-11 12:00:19 +0000
commit9e8e0e378e9a7ec6827cafe75fa0a805d42bb1f5 (patch)
treef859a366d7db98c28e08598b03fff80b0364ba94
parentdc7bcde6a598c5402c4acef970f456e94eca4915 (diff)
downloadorg.eclipse.sirius-9e8e0e378e9a7ec6827cafe75fa0a805d42bb1f5.tar.gz
org.eclipse.sirius-9e8e0e378e9a7ec6827cafe75fa0a805d42bb1f5.tar.xz
org.eclipse.sirius-9e8e0e378e9a7ec6827cafe75fa0a805d42bb1f5.zip
[466455] Replace RefreshIDFactory static calls with a scoped holder
Now that MinimalEObjectImpl is being used for Sirius's model the approach of attaching IDs to every EObject through eAdapters() became more CPU intensive than desired representing 17 to 18% of the time spent refreshing a diagram (You can check the logic in org.eclipse.emf.ecore.impl.MinimalEObjectImpl.eAdapters()) This commit changes this approach by introducing a non-static holder for such IDs which is scoped to a given representation (RefreshIdsHolder). The holder itself still is an adapter and clear its state when its being detached from the representation (on Resource.unload for instance). This commit changes both the Diagram and Table algorithms which were making use of the RefreshIDFactory. Notable change of this (besides some API) is that a RefreshID is now unique only in the scope of given representation - which can actually be expected from its name. Bug: 466455 Change-Id: I2aca1c435bb17de42e972ea8c3061eda18834460 Signed-off-by: Cedric Brun <cedric.brun@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/CartesianProduct.java9
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/EObjectCouple.java8
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIDFactory.java88
-rw-r--r--plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIdsHolder.java132
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/query/AbstractDNodeQuery.java22
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/AbstractDNodeCandidate.java18
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DDiagramSynchronizer.java37
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeCandidate.java20
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeSynchronizerHelper.java10
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DNodeSynchronizerHelper.java8
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/MappingsUpdater.java21
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateContainerTask.java3
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateDNodeTask.java3
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/operations/CreateViewTask.java7
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/description/operations/AbstractNodeMappingSpecOperations.java3
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/ContainerMappingHelper.java3
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/NodeMappingHelper.java17
-rwxr-xr-xplugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/AbstractDNodeSpecOperations.java3
-rw-r--r--plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/view/CreateDDiagramElementCommand.java5
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.html14
-rw-r--r--plugins/org.eclipse.sirius.doc/doc/Release Notes.textile2
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DCellCandidate.java24
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DFeatureColumnCandidate.java20
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DLineCandidate.java23
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java30
-rw-r--r--plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTargetColumnCandidate.java21
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java4
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/mappings/NodeMappingTest.java5
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/CartesianProductTestCase.java13
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/AbstractDNodeCandidateTest.java15
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/DEdgeCandidateTest.java15
-rw-r--r--plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIdsHolderTest.java (renamed from plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIDFactoryTest.java)19
32 files changed, 382 insertions, 240 deletions
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/CartesianProduct.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/CartesianProduct.java
index 466d459f2c..838963c7f0 100644
--- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/CartesianProduct.java
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/CartesianProduct.java
@@ -33,6 +33,8 @@ public class CartesianProduct implements Iterable<EObjectCouple>, Iterator<EObje
private Object obj1;
+ private RefreshIdsHolder ids;
+
/**
* Build an iterator providing a cartesian product of two collections.
*
@@ -40,10 +42,13 @@ public class CartesianProduct implements Iterable<EObjectCouple>, Iterator<EObje
* first set
* @param set2
* second set
+ * @param ids
+ * the holder of refresh ids.
*/
- public CartesianProduct(final Collection<?> set1, final Collection<?> set2) {
+ public CartesianProduct(final Collection<?> set1, final Collection<?> set2, RefreshIdsHolder ids) {
this.set2 = set2;
it1 = set1.iterator();
+ this.ids = ids;
}
/**
@@ -69,7 +74,7 @@ public class CartesianProduct implements Iterable<EObjectCouple>, Iterator<EObje
it2 = set2.iterator();
}
obj2 = it2.next();
- final EObjectCouple couple = new EObjectCouple((EObject) obj1, (EObject) obj2);
+ final EObjectCouple couple = new EObjectCouple((EObject) obj1, (EObject) obj2, ids);
if (!it2.hasNext()) {
obj1 = null;
it2 = null;
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/EObjectCouple.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/EObjectCouple.java
index 5cba388e95..b1fd140c31 100644
--- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/EObjectCouple.java
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/EObjectCouple.java
@@ -40,8 +40,10 @@ public class EObjectCouple {
* the first {@link EObject}.
* @param obj2
* the second {@link EObject}.
+ * @param ids
+ * the holder of refresh ids.
*/
- public EObjectCouple(final EObject obj1, final EObject obj2) {
+ public EObjectCouple(final EObject obj1, final EObject obj2, RefreshIdsHolder ids) {
if (obj1 == null) {
throw new IllegalArgumentException("the first eObject is null");
}
@@ -50,8 +52,8 @@ public class EObjectCouple {
}
this.obj1 = obj1;
this.obj2 = obj2;
- this.int1 = RefreshIDFactory.getOrCreateID(obj1);
- this.int2 = RefreshIDFactory.getOrCreateID(obj2);
+ this.int1 = ids.getOrCreateID(obj1);
+ this.int2 = ids.getOrCreateID(obj2);
}
/**
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIDFactory.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIDFactory.java
deleted file mode 100644
index 5901c4a045..0000000000
--- a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIDFactory.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 THALES GLOBAL SERVICES.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.common.tools.api.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * This class is responsible for providing an ID used during the refresh to
- * match candidates and existing elements. We used to use EcoreUtil.getURI() but
- * it was not performing well enough.
- *
- * The ID is associated with the element through the eAdapters mechanism and as
- * such is stable as long as the element is there.
- *
- * @author cbrun
- *
- */
-public final class RefreshIDFactory {
-
- private static Integer lastID = 0;
-
- private RefreshIDFactory() {
-
- }
-
- /**
- * Return the element Id if there is one, create a new one if it's not
- * already here.
- *
- * @param any
- * any EObject.
- * @return the existing Id or the new one.
- */
- public static Integer getOrCreateID(final EObject any) {
- Integer id = RefreshIDFactory.findID(any);
- if (id == null) {
- id = lastID++;
- any.eAdapters().add(new IDAdapter(id));
- }
- return id;
- }
-
- private static Integer findID(final EObject any) {
- for (final Adapter adapter : any.eAdapters()) {
- if (adapter instanceof IDAdapter) {
- return ((IDAdapter) adapter).getID();
- }
- }
- return null;
- }
-
-}
-
-/**
- * Adapter used to keep track of the ID.
- *
- * @author cbrun
- *
- */
-class IDAdapter extends AdapterImpl {
-
- private final Integer id;
-
- /**
- * Create the adapter.
- *
- * @param id
- * element ID.
- */
- public IDAdapter(final Integer id) {
- this.id = id;
- }
-
- public Integer getID() {
- return id;
- }
-
-}
diff --git a/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIdsHolder.java b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIdsHolder.java
new file mode 100644
index 0000000000..96abb676fb
--- /dev/null
+++ b/plugins/org.eclipse.sirius.common/src/org/eclipse/sirius/common/tools/api/util/RefreshIdsHolder.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2015 THALES GLOBAL SERVICES 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.common.tools.api.util;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+
+import com.google.common.collect.Maps;
+
+/**
+ * This class is responsible for providing an ID used during the refresh to
+ * match candidates and existing elements. We used to use EcoreUtil.getURI() but
+ * it was not performing well enough.
+ *
+ * The ID is associated with the element through the eAdapters mechanism and as
+ * such is stable as long as the element is there.
+ *
+ * @author cbrun
+ * @since 3.0
+ *
+ */
+public final class RefreshIdsHolder {
+
+ private static Integer lastID = 0;
+
+ private Map<EObject, Integer> knownObjects = Maps.newHashMap();
+
+ /**
+ * Return the element Id if there is one, create a new one if it's not
+ * already here.
+ *
+ * @param any
+ * any EObject.
+ * @return the existing Id or the new one.
+ */
+ public Integer getOrCreateID(final EObject any) {
+ Integer id = knownObjects.get(any);
+ if (id == null) {
+ id = lastID++;
+ knownObjects.put(any, id);
+ }
+ return id;
+ }
+
+ /**
+ * clear the internal state.
+ */
+ public void dispose() {
+ this.knownObjects.clear();
+ }
+
+ /**
+ * Return the IDs holderif there is one, create a new one if it's not
+ * already here.
+ *
+ * Note that the holder is associated to the given EObject through the
+ * EAdapter mechanism and will clear its state when the eAdapter is removed
+ * from the EObject (during Resource.unload() for instance).
+ *
+ * @param any
+ * any EObject serving as delimiting the context of what is bein
+ * refreshed (a representation for instance.
+ * @return the existing Holder or the new one.
+ */
+ public static RefreshIdsHolder getOrCreateHolder(final EObject any) {
+ RefreshIdsHolder factory = RefreshIdsHolder.findHolder(any);
+ if (factory == null) {
+ factory = new RefreshIdsHolder();
+ any.eAdapters().add(new StateFullIDFactoryAdapter(factory));
+ }
+ return factory;
+ }
+
+ private static RefreshIdsHolder findHolder(final EObject any) {
+ Iterator<Adapter> it = any.eAdapters().iterator();
+ while (it.hasNext()) {
+ Adapter adapter = it.next();
+ if (adapter instanceof StateFullIDFactoryAdapter) {
+ return ((StateFullIDFactoryAdapter) adapter).getID();
+ }
+ }
+ return null;
+ }
+
+}
+
+/**
+ * Adapter used to keep track of the ID.
+ *
+ * @author cbrun
+ *
+ */
+class StateFullIDFactoryAdapter extends AdapterImpl {
+
+ private final RefreshIdsHolder id;
+
+ /**
+ * Create the adapter.
+ *
+ * @param id
+ * element ID.
+ */
+ public StateFullIDFactoryAdapter(final RefreshIdsHolder id) {
+ this.id = id;
+ }
+
+ public RefreshIdsHolder getID() {
+ return id;
+ }
+
+ @Override
+ public void notifyChanged(Notification msg) {
+ super.notifyChanged(msg);
+ if (msg.getEventType() == Notification.REMOVING_ADAPTER && msg.getOldValue() == this) {
+ getID().dispose();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/query/AbstractDNodeQuery.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/query/AbstractDNodeQuery.java
index 122c278666..fd52a962c5 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/query/AbstractDNodeQuery.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/api/query/AbstractDNodeQuery.java
@@ -12,7 +12,6 @@ package org.eclipse.sirius.diagram.business.api.query;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.DiagramPackage;
-import org.eclipse.sirius.diagram.business.internal.experimental.sync.AbstractDNodeCandidate;
/**
* A class aggregating all the queries (read-only!) having a
@@ -36,27 +35,6 @@ public class AbstractDNodeQuery {
}
/**
- * Check if two AbstractDNode are the same.
- *
- * @param eObj
- * the second AbstractDNode to compare
- * @return <code>true</code> if they are equals, <code>false</code>
- * otherwise. If the two objects are both <code>null</code> return
- * <code>true</code>, otherwise if only one of them is null, return
- * <code>false</code>
- */
- public boolean equalsTo(final AbstractDNode eObj) {
- boolean result = false;
-
- if (node == eObj) {
- result = true;
- } else if (node != null && eObj != null) {
- result = new AbstractDNodeCandidate(node).equals(new AbstractDNodeCandidate(eObj));
- }
- return result;
- }
-
- /**
* Indicates if the AbtractDNode is a bordered node.
*
* @return true if the AbtractDNode is a bordered node, false otherwise
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/AbstractDNodeCandidate.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/AbstractDNodeCandidate.java
index a5ffafb3bb..6ac771f3c6 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/AbstractDNodeCandidate.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/AbstractDNodeCandidate.java
@@ -11,7 +11,7 @@
package org.eclipse.sirius.diagram.business.internal.experimental.sync;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.DragAndDropTarget;
import org.eclipse.sirius.diagram.description.AbstractNodeMapping;
@@ -42,6 +42,8 @@ public class AbstractDNodeCandidate {
*/
private AbstractDNode element;
+ private RefreshIdsHolder ids;
+
/**
* Create a new candidate.
*
@@ -51,9 +53,12 @@ public class AbstractDNodeCandidate {
* the target semantic element.
* @param viewContainer
* the view container.
+ * @param ids
+ * the refresh ids holder.
*/
- public AbstractDNodeCandidate(final AbstractNodeMapping mapping, final EObject semanticElement, final DragAndDropTarget viewContainer) {
+ public AbstractDNodeCandidate(final AbstractNodeMapping mapping, final EObject semanticElement, final DragAndDropTarget viewContainer, RefreshIdsHolder ids) {
super();
+ this.ids = ids;
this.mapping = mapping;
this.semantic = semanticElement;
this.viewContainer = viewContainer;
@@ -65,8 +70,11 @@ public class AbstractDNodeCandidate {
*
* @param diagElement
* an existing diagram element.
+ * @param ids
+ * the refresh ids holder.
*/
- public AbstractDNodeCandidate(final AbstractDNode diagElement) {
+ public AbstractDNodeCandidate(final AbstractDNode diagElement, RefreshIdsHolder ids) {
+ this.ids = ids;
this.mapping = (AbstractNodeMapping) diagElement.getMapping();
this.semantic = diagElement.getTarget();
this.viewContainer = (DragAndDropTarget) diagElement.eContainer();
@@ -117,7 +125,7 @@ public class AbstractDNodeCandidate {
if (semantic == null) {
return Id.invalid();
}
- return new Id(RefreshIDFactory.getOrCreateID(viewContainer));
+ return new Id(this.ids.getOrCreateID(viewContainer));
}
/**
@@ -129,7 +137,7 @@ public class AbstractDNodeCandidate {
if (semantic == null) {
return Id.invalid();
}
- return new Id(RefreshIDFactory.getOrCreateID(semantic));
+ return new Id(this.ids.getOrCreateID(semantic));
}
/**
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DDiagramSynchronizer.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DDiagramSynchronizer.java
index b2607fee47..924b3f083b 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DDiagramSynchronizer.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DDiagramSynchronizer.java
@@ -39,6 +39,7 @@ import org.eclipse.sirius.common.tools.api.listener.Notification;
import org.eclipse.sirius.common.tools.api.listener.NotificationUtil;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
import org.eclipse.sirius.common.tools.api.util.EqualityHelper;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.ComputedStyleDescriptionRegistry;
import org.eclipse.sirius.diagram.DDiagram;
@@ -159,6 +160,8 @@ public class DDiagramSynchronizer {
private boolean forceRetrieve;
+ private RefreshIdsHolder ids;
+
/**
* Create a new synchronizer.
*
@@ -184,6 +187,10 @@ public class DDiagramSynchronizer {
return this.diagram;
}
+ public RefreshIdsHolder getFactory() {
+ return this.ids;
+ }
+
/**
* return the diagram.
*
@@ -263,10 +270,12 @@ public class DDiagramSynchronizer {
}
private void initDiagramRelatedFields() {
+ this.ids = RefreshIdsHolder.getOrCreateHolder(diagram);
this.edgeHelper = new DEdgeSynchronizerHelper(this, diagram, accessor);
this.nodHelper = new DNodeSynchronizerHelper(this, diagram, accessor);
this.diagramMappingsManager = DiagramMappingsManagerRegistry.INSTANCE.getDiagramMappingsManager(session, diagram);
- this.mappingsUpdater = new MappingsUpdater(diagram, diagramMappingsManager, this);
+ this.mappingsUpdater = new MappingsUpdater(diagram, diagramMappingsManager, this, ids);
+
}
private void activateInitialLayers() {
@@ -545,7 +554,7 @@ public class DDiagramSynchronizer {
private void handleImportersIssues() {
for (final DiagramElementMapping mapping : this.diagramMappingsManager.getOtherImportersMappings()) {
- EObjectCouple key = new EObjectCouple(this.diagram, mapping);
+ EObjectCouple key = new EObjectCouple(this.diagram, mapping, ids);
this.ignoredDuringRefreshProcess.remove(key);
final Collection<DDiagramElement> elements = previousCandidatesCache.get(key);
@@ -555,7 +564,7 @@ public class DDiagramSynchronizer {
for (final DiagramElementMapping subMapping : mapping.getAllMappings()) {
for (final DDiagramElement element : elements) {
- key = new EObjectCouple(element, subMapping);
+ key = new EObjectCouple(element, subMapping, ids);
this.ignoredDuringRefreshProcess.remove(key);
}
}
@@ -680,7 +689,7 @@ public class DDiagramSynchronizer {
private AbstractDNode handleListAttributeChangeOnMapping(final AbstractDNode node, final ContainerMapping containerMapping, final DragAndDropTarget viewContainer, IProgressMonitor monitor) {
final boolean isListContainer = new ContainerMappingQuery(containerMapping).isListContainer();
if ((node instanceof DNodeContainer && isListContainer) || (node instanceof DNodeList && !isListContainer)) {
- final AbstractDNodeCandidate newCandidate = new AbstractDNodeCandidate(containerMapping, node.getTarget(), viewContainer);
+ final AbstractDNodeCandidate newCandidate = new AbstractDNodeCandidate(containerMapping, node.getTarget(), viewContainer, ids);
final Set<AbstractDNodeCandidate> newCandidates = new HashSet<AbstractDNodeCandidate>(1);
newCandidates.add(newCandidate);
@@ -736,7 +745,7 @@ public class DDiagramSynchronizer {
final ContainerMapping containerMapping = diagramElementContainer.getActualMapping();
final boolean isListContainer = new ContainerMappingQuery(containerMapping).isListContainer();
if ((node instanceof DNode && isListContainer) || (node instanceof DNodeListElement && !isListContainer)) {
- final AbstractDNodeCandidate newCandidate = new AbstractDNodeCandidate(nodeMapping, node.getTarget(), diagramElementContainer);
+ final AbstractDNodeCandidate newCandidate = new AbstractDNodeCandidate(nodeMapping, node.getTarget(), diagramElementContainer, ids);
final Set<AbstractDNodeCandidate> newCandidates = new HashSet<AbstractDNodeCandidate>(1);
newCandidates.add(newCandidate);
@@ -1099,7 +1108,7 @@ public class DDiagramSynchronizer {
}
return previousDiagramElements;
} else {
- final EObjectCouple key = new EObjectCouple(container, mapping);
+ final EObjectCouple key = new EObjectCouple(container, mapping, ids);
// when Unsynchronized mode is active, NPE occurs because
// previousCandidatesCache is null
if (previousCandidatesCache == null) {
@@ -1146,7 +1155,7 @@ public class DDiagramSynchronizer {
* @return all node candidates
*/
public Collection<AbstractDNodeCandidate> computeNodeCandidates(final DragAndDropTarget container, final AbstractNodeMapping mapping, final Set<AbstractDNodeCandidate> semanticFilter) {
- return nodHelper.computeNodeCandidates(container, mapping, semanticFilter);
+ return nodHelper.computeNodeCandidates(container, mapping, semanticFilter, ids);
}
/**
@@ -1165,9 +1174,9 @@ public class DDiagramSynchronizer {
// We need a non-null argument to create the EObjectCouple, as
// the element needs to be registered as a "previous candidate"
// or it will not be removed from the diagram.
- key = new EObjectCouple(container, DDiagramSynchronizer.FAKE_MAPPING);
+ key = new EObjectCouple(container, DDiagramSynchronizer.FAKE_MAPPING, ids);
} else {
- key = new EObjectCouple(container, child.getMapping());
+ key = new EObjectCouple(container, child.getMapping(), ids);
}
candidates.put(key, child);
/*
@@ -1191,7 +1200,7 @@ public class DDiagramSynchronizer {
* mapping of the elements to add in the status.
*/
private void addPreviousCandidates(final SetIntersection<AbstractDNodeCandidate> biSet, final DragAndDropTarget container, final AbstractNodeMapping mapping) {
- final EObjectCouple key = new EObjectCouple(container, mapping);
+ final EObjectCouple key = new EObjectCouple(container, mapping, ids);
this.ignoredDuringRefreshProcess.remove(key);
Collection<DDiagramElement> candidates = previousCandidatesCache.get(key);
if (candidates == null) {
@@ -1206,7 +1215,7 @@ public class DDiagramSynchronizer {
final DDiagramElement element = it.next();
final DiagramElementMapping elementMapping = element.getDiagramElementMapping();
if (EqualityHelper.areEquals(elementMapping, mapping) || mapping.eResource() == null) {
- final AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate((AbstractDNode) element);
+ final AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate((AbstractDNode) element, ids);
biSet.addInOld(abstractDNodeCandidate);
}
}
@@ -1327,7 +1336,7 @@ public class DDiagramSynchronizer {
private SetIntersection<DEdgeCandidate> createEdgeCandidates(final Map<DiagramElementMapping, Collection<EdgeTarget>> mappingsToEdgeTargets, final EdgeMapping mapping,
final Map<EdgeMapping, Collection<MappingBasedDecoration>> edgeToMappingBasedDecoration, final Map<String, Collection<SemanticBasedDecoration>> edgeToSemanticBasedDecoration) {
final SetIntersection<DEdgeCandidate> status = new GSetIntersection<DEdgeCandidate>();
- final EObjectCouple key = new EObjectCouple(diagram, mapping);
+ final EObjectCouple key = new EObjectCouple(diagram, mapping, ids);
this.ignoredDuringRefreshProcess.remove(key);
// Remove also the sub mapping if mapping is ImportedMapping and the
// superMapping
@@ -1340,7 +1349,7 @@ public class DDiagramSynchronizer {
* Collect existing edges.
*/
for (final DEdge edge : this.diagram.getEdgesFromMapping(mapping)) {
- final DEdgeCandidate edgeCandidate = new DEdgeCandidate(edge);
+ final DEdgeCandidate edgeCandidate = new DEdgeCandidate(edge, ids);
if (edgeCandidate.isInvalid()) {
invalidCandidates.add(edgeCandidate);
} else {
@@ -1400,7 +1409,7 @@ public class DDiagramSynchronizer {
private void handleSubMappings(final IEdgeMapping mapping) {
if (mapping instanceof EdgeMappingImport) {
final IEdgeMapping importedEdgeMaping = ((EdgeMappingImport) mapping).getImportedMapping();
- final EObjectCouple key = new EObjectCouple(diagram, importedEdgeMaping);
+ final EObjectCouple key = new EObjectCouple(diagram, importedEdgeMaping, ids);
this.ignoredDuringRefreshProcess.remove(key);
handleSubMappings(importedEdgeMaping);
}
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeCandidate.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeCandidate.java
index 56d6b948e3..c4b5423bec 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeCandidate.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeCandidate.java
@@ -11,7 +11,7 @@
package org.eclipse.sirius.diagram.business.internal.experimental.sync;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.EdgeTarget;
@@ -46,19 +46,24 @@ public class DEdgeCandidate {
private final int hashCode;
+ private RefreshIdsHolder factory;
+
/**
* Create a new EdgeCandidate from an existing element.
*
* @param element
* a DEdge.
+ * @param factory
+ * the factory.
*/
- public DEdgeCandidate(final DEdge element) {
+ public DEdgeCandidate(final DEdge element, RefreshIdsHolder factory) {
this.element = element;
this.semantic = element.getTarget();
this.mapping = element.getActualMapping();
this.sourceView = element.getSourceNode();
this.targetView = element.getTargetNode();
this.rootMapping = getRootMapping(this.mapping);
+ this.factory = factory;
this.hashCode = computeHashCode();
}
@@ -73,8 +78,10 @@ public class DEdgeCandidate {
* the source view.
* @param targetView
* the target view.
+ * @param factory
+ * the factory.
*/
- public DEdgeCandidate(final EdgeMapping mapping, final EObject semantic, final EdgeTarget sourceView, final EdgeTarget targetView) {
+ public DEdgeCandidate(final EdgeMapping mapping, final EObject semantic, final EdgeTarget sourceView, final EdgeTarget targetView, RefreshIdsHolder factory) {
if (mapping instanceof EdgeMappingImportWrapper) {
this.mapping = ((EdgeMappingImportWrapper) mapping).getWrappedEdgeMappingImport();
} else {
@@ -84,6 +91,7 @@ public class DEdgeCandidate {
this.sourceView = sourceView;
this.targetView = targetView;
this.rootMapping = getRootMapping(this.mapping);
+ this.factory = factory;
this.hashCode = computeHashCode();
}
@@ -164,15 +172,15 @@ public class DEdgeCandidate {
}
private Integer getTargetViewURI() {
- return RefreshIDFactory.getOrCreateID(targetView);
+ return this.factory.getOrCreateID(targetView);
}
private Integer getSourceViewURI() {
- return RefreshIDFactory.getOrCreateID(sourceView);
+ return this.factory.getOrCreateID(sourceView);
}
private Integer getSemanticURI() {
- return RefreshIDFactory.getOrCreateID(semantic);
+ return this.factory.getOrCreateID(semantic);
}
/**
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeSynchronizerHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeSynchronizerHelper.java
index 0c633d9006..f97b40c28d 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeSynchronizerHelper.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DEdgeSynchronizerHelper.java
@@ -174,7 +174,7 @@ public class DEdgeSynchronizerHelper extends AbstractSynchronizerHelper {
EObject target = prevDEdge.getTarget();
if (edgeMappingQuery.evaluatePrecondition(diagram, diagram, interpreter, target, (DSemanticDecorator) sourceView, (DSemanticDecorator) targetView)) {
- result.add(new DEdgeCandidate(mapping, target, sourceView, targetView));
+ result.add(new DEdgeCandidate(mapping, target, sourceView, targetView, sync.getFactory()));
}
}
}
@@ -194,19 +194,19 @@ public class DEdgeSynchronizerHelper extends AbstractSynchronizerHelper {
Collection<EObject> edgeSourceSemantics = edgeMappingQuery.evaluateSourceFinderExpression(diagram, interpreter, target);
Collection<EObject> edgeTargetSemantics = edgeMappingQuery.evaluateTargetFinderExpression(diagram, interpreter, target);
- for (final EObjectCouple couple : new CartesianProduct(edgeSourceSemantics, edgeTargetSemantics)) {
+ for (final EObjectCouple couple : new CartesianProduct(edgeSourceSemantics, edgeTargetSemantics, sync.getFactory())) {
final Collection<EdgeTarget> sourceViews = sourceViewsSemantics.get(couple.getObj1());
if (sourceViews != null) {
final Collection<EdgeTarget> targetViews = targetViewsSemantics.get(couple.getObj2());
if (targetViews != null) {
- for (final EObjectCouple viewsCouple : new CartesianProduct(sourceViews, targetViews)) {
+ for (final EObjectCouple viewsCouple : new CartesianProduct(sourceViews, targetViews, sync.getFactory())) {
final EdgeTarget sourceView = (EdgeTarget) viewsCouple.getObj1();
final EdgeTarget targetView = (EdgeTarget) viewsCouple.getObj2();
if (edgeMappingQuery.evaluatePrecondition(diagram, diagram, interpreter, target, (DSemanticDecorator) sourceView, (DSemanticDecorator) targetView)) {
- result.add(new DEdgeCandidate(mapping, target, sourceView, targetView));
+ result.add(new DEdgeCandidate(mapping, target, sourceView, targetView, sync.getFactory()));
}
}
}
@@ -271,7 +271,7 @@ public class DEdgeSynchronizerHelper extends AbstractSynchronizerHelper {
minimize.add(potentialTargetSemantic);
for (final EdgeTarget targetView : targetEdgeTarget) {
if (edgeMappingQuery.evaluatePrecondition(diagram, diagram, interpreter, sourceSemantic, (DSemanticDecorator) sourceView, (DSemanticDecorator) targetView)) {
- result.add(new DEdgeCandidate(mapping, sourceSemantic, sourceView, targetView));
+ result.add(new DEdgeCandidate(mapping, sourceSemantic, sourceView, targetView, sync.getFactory()));
}
}
}
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DNodeSynchronizerHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DNodeSynchronizerHelper.java
index c37d8cca45..0d8484fed8 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DNodeSynchronizerHelper.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/DNodeSynchronizerHelper.java
@@ -13,6 +13,7 @@ package org.eclipse.sirius.diagram.business.internal.experimental.sync;
import java.util.Collection;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DSemanticDiagram;
import org.eclipse.sirius.diagram.DragAndDropTarget;
import org.eclipse.sirius.diagram.business.api.query.AbstractNodeMappingQuery;
@@ -53,9 +54,12 @@ public class DNodeSynchronizerHelper extends AbstractSynchronizerHelper {
* @param candidateFilter
* the filter which contains candidates to not add in the
* returned collection
+ * @param ids
+ * the refresh ids holder.
* @return all node candidates
*/
- public Collection<AbstractDNodeCandidate> computeNodeCandidates(final DragAndDropTarget container, final AbstractNodeMapping mapping, final Collection<AbstractDNodeCandidate> candidateFilter) {
+ public Collection<AbstractDNodeCandidate> computeNodeCandidates(final DragAndDropTarget container, final AbstractNodeMapping mapping, final Collection<AbstractDNodeCandidate> candidateFilter,
+ RefreshIdsHolder ids) {
final Collection<AbstractDNodeCandidate> nowCandidates = Lists.newArrayList();
final Iterable<EObject> semantics = getSemanticCandidates(container, mapping);
@@ -64,7 +68,7 @@ public class DNodeSynchronizerHelper extends AbstractSynchronizerHelper {
* produce the candidates states if the precondition is valid.
*/
for (final EObject semantic : semantics) {
- final AbstractDNodeCandidate candidate = new AbstractDNodeCandidate(mapping, semantic, container);
+ final AbstractDNodeCandidate candidate = new AbstractDNodeCandidate(mapping, semantic, container, ids);
if (candidateFilter == null || !candidateFilter.contains(candidate)) {
AbstractNodeMappingQuery abstractNodeMappingQuery = new AbstractNodeMappingQuery(mapping);
if (abstractNodeMappingQuery.evaluatePrecondition(diagram, container, interpreter, semantic)) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/MappingsUpdater.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/MappingsUpdater.java
index 37b74adcf3..c2f440b260 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/MappingsUpdater.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/experimental/sync/MappingsUpdater.java
@@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.sirius.business.internal.query.DSemanticDecoratorQuery;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DragAndDropTarget;
@@ -48,6 +49,8 @@ public class MappingsUpdater {
private DDiagramSynchronizer synchronizer;
+ private RefreshIdsHolder ids;
+
/**
* .
*
@@ -56,12 +59,15 @@ public class MappingsUpdater {
* @param mappingsManager
* .
* @param synchronizer
- * .
+ * the synchronizer.
+ * @param ids
+ * the refresh ids holder.
*/
- public MappingsUpdater(final DDiagram diagram, final DiagramMappingsManager mappingsManager, final DDiagramSynchronizer synchronizer) {
+ public MappingsUpdater(final DDiagram diagram, final DiagramMappingsManager mappingsManager, final DDiagramSynchronizer synchronizer, RefreshIdsHolder ids) {
this.diagram = diagram;
this.mappingsManager = mappingsManager;
this.synchronizer = synchronizer;
+ this.ids = ids;
}
/**
@@ -89,7 +95,7 @@ public class MappingsUpdater {
}
private void safeUpdateMappings(DragAndDropTarget container) {
- mappingsManager.iterate(new MappingUpdateVisitor(container), container);
+ mappingsManager.iterate(new MappingUpdateVisitor(container, ids), container);
for (final DDiagramElement child : DiagramElementsHierarchyVisitor.INSTANCE.getChildren(container)) {
if (child instanceof DragAndDropTarget) {
updateMappings((DragAndDropTarget) child);
@@ -106,14 +112,17 @@ public class MappingsUpdater {
private DragAndDropTarget container;
+ private RefreshIdsHolder factory;
+
/**
* Create a new instance
*
* @param container
* the container
*/
- public MappingUpdateVisitor(final DragAndDropTarget container) {
+ public MappingUpdateVisitor(final DragAndDropTarget container, RefreshIdsHolder factory) {
this.container = container;
+ this.factory = factory;
}
/**
@@ -151,7 +160,7 @@ public class MappingsUpdater {
result = Sets.newHashSet(Collections2.transform(semanticElementsDone, new Function<EObject, AbstractDNodeCandidate>() {
public AbstractDNodeCandidate apply(final EObject from) {
- return new AbstractDNodeCandidate(mapping, from, container);
+ return new AbstractDNodeCandidate(mapping, from, container, factory);
}
}));
} else {
@@ -183,7 +192,7 @@ public class MappingsUpdater {
}
if (areInSameHiearchy) {
- result = new AbstractDNodeCandidate(mapping, from.getSemantic(), container);
+ result = new AbstractDNodeCandidate(mapping, from.getSemantic(), container, factory);
}
return result;
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateContainerTask.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateContainerTask.java
index 436cee9337..33c75f6ab0 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateContainerTask.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateContainerTask.java
@@ -20,6 +20,7 @@ import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
import org.eclipse.sirius.business.api.helper.task.ICreationTask;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.ArrangeConstraint;
import org.eclipse.sirius.diagram.DDiagram;
@@ -103,7 +104,7 @@ public class CreateContainerTask extends AbstractCommandTask implements ICreatio
BestMappingGetter bestMappingGetter = new BestMappingGetter((DSemanticDecorator) containerView, semanticElt);
ContainerMapping bestMapping = bestMappingGetter.getBestContainerMapping(tool.getContainerMappings());
if (bestMapping != null) {
- AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(bestMapping, semanticElt, containerView);
+ AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(bestMapping, semanticElt, containerView, RefreshIdsHolder.getOrCreateHolder(dSemanticDiagram));
AbstractDNode createdAbstractDNode = dDiagramElementSynchronizer.createNewNode(mappingManager, abstractDNodeCandidate, false);
if (createdAbstractDNode != null) {
AbstractNodeMappingSpecOperations.createBorderingNodes(bestMapping, semanticElt, createdAbstractDNode, Collections.emptyList(), dSemanticDiagram);
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateDNodeTask.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateDNodeTask.java
index b864227339..e9a74fd432 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateDNodeTask.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/CreateDNodeTask.java
@@ -20,6 +20,7 @@ import org.eclipse.sirius.business.api.helper.task.AbstractCommandTask;
import org.eclipse.sirius.business.api.helper.task.ICreationTask;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.ArrangeConstraint;
import org.eclipse.sirius.diagram.DSemanticDiagram;
@@ -108,7 +109,7 @@ public class CreateDNodeTask extends AbstractCommandTask implements ICreationTas
BestMappingGetter bestMappingGetter = new BestMappingGetter(containerViewDSemanticDecorator, semanticElt);
NodeMapping bestMapping = bestMappingGetter.getBestNodeMapping(tool.getNodeMappings());
if (bestMapping != null) {
- AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(bestMapping, semanticElt, containerView);
+ AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(bestMapping, semanticElt, containerView, RefreshIdsHolder.getOrCreateHolder(dSemanticDiagram));
AbstractDNode createdAbstractDNode = dDiagramElementSynchronizer.createNewNode(mappingManager, abstractDNodeCandidate,
bestMapping.eContainingFeature() == DescriptionPackage.Literals.ABSTRACT_NODE_MAPPING__BORDERED_NODE_MAPPINGS);
if (createdAbstractDNode != null) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/operations/CreateViewTask.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/operations/CreateViewTask.java
index 36686630ca..8d6e13ecee 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/operations/CreateViewTask.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/helper/task/operations/CreateViewTask.java
@@ -28,6 +28,7 @@ import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.business.internal.helper.task.operations.AbstractOperationTask;
import org.eclipse.sirius.business.internal.helper.task.operations.InterpretedExpressionVariableTask;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.ArrangeConstraint;
@@ -160,7 +161,8 @@ public class CreateViewTask extends AbstractOperationTask {
if (bestMapping instanceof AbstractNodeMapping) {
AbstractNodeMapping abstractNodeMapping = (AbstractNodeMapping) bestMapping;
if (extPackage.eInstanceOf(semanticElt, abstractNodeMapping.getDomainClass())) {
- AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(abstractNodeMapping, semanticElt, (DragAndDropTarget) containerView);
+ AbstractDNodeCandidate abstractDNodeCandidate = new AbstractDNodeCandidate(abstractNodeMapping, semanticElt, (DragAndDropTarget) containerView,
+ RefreshIdsHolder.getOrCreateHolder(parentDDiagram));
DDiagramElementSynchronizer dDiagramElementSynchronizer = new DDiagramElementSynchronizer(parentDDiagram, interpreter, extPackage);
DiagramMappingsManager mappingManager = DiagramMappingsManagerRegistry.INSTANCE.getDiagramMappingsManager(session, parentDDiagram);
AbstractDNode createdAbstractDNode = dDiagramElementSynchronizer.createNewNode(mappingManager, abstractDNodeCandidate,
@@ -252,7 +254,8 @@ public class CreateViewTask extends AbstractOperationTask {
if (edgeMapping == null && createEdgeView.getMapping() instanceof EdgeMapping) {
edgeMapping = (EdgeMapping) createEdgeView.getMapping();
}
- DEdgeCandidate dEdgeCandidate = new DEdgeCandidate(edgeMapping, context.getCurrentTarget(), sourceEdgeTarget, targetEdgeTarget);
+ DEdgeCandidate dEdgeCandidate = new DEdgeCandidate(edgeMapping, context.getCurrentTarget(), sourceEdgeTarget, targetEdgeTarget,
+ RefreshIdsHolder.getOrCreateHolder(parentDDiagram));
DiagramMappingsManager mappingManager = DiagramMappingsManagerRegistry.INSTANCE.getDiagramMappingsManager(session, parentDDiagram);
createdDEdge = dDiagramElementSynchronizer.createNewEdge(mappingManager, dEdgeCandidate, mappingsToEdgeTargets, edgeToMappingBasedDecoration, edgeToSemanticBasedDecoration);
if (needsPathUpdate) {
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/description/operations/AbstractNodeMappingSpecOperations.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/description/operations/AbstractNodeMappingSpecOperations.java
index f09c4469a9..5db27eb111 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/description/operations/AbstractNodeMappingSpecOperations.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/description/operations/AbstractNodeMappingSpecOperations.java
@@ -26,6 +26,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterSiriusVariables;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
@@ -134,7 +135,7 @@ public final class AbstractNodeMappingSpecOperations {
while (it2.hasNext()) {
final EObject eObj = it2.next();
if (eObj != null) {
- final EObjectCouple couple = new EObjectCouple(eObj, borderMapping);
+ final EObjectCouple couple = new EObjectCouple(eObj, borderMapping, RefreshIdsHolder.getOrCreateHolder(diagram));
if (AbstractNodeMappingSpecOperations.isInstanceOf(mapping, eObj, borderMapping.getDomainClass())
&& SiriusElementMappingSpecOperations.checkPrecondition(borderMapping, eObj, modelElement, dDiagramElement) && !filterSemantic.contains(couple)) {
final DNode newBorderNode = borderMapping.createNode(eObj, containerVariable, diagram);
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/ContainerMappingHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/ContainerMappingHelper.java
index 8045e0d071..4047cb35ed 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/ContainerMappingHelper.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/ContainerMappingHelper.java
@@ -24,6 +24,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterSiriusVariables;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.ContainerStyle;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
@@ -172,7 +173,7 @@ public final class ContainerMappingHelper {
} else {
safeContainer = container;
}
- final EObjectCouple couple = new EObjectCouple(semanticOrigin, safeContainer);
+ final EObjectCouple couple = new EObjectCouple(semanticOrigin, safeContainer, RefreshIdsHolder.getOrCreateHolder(parentVp));
EList<EObject> result = self.getCandidatesCache().get(couple);
if (result == null) {
result = new UniqueEList<EObject>();
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/NodeMappingHelper.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/NodeMappingHelper.java
index f071b6a28d..117f2cddcb 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/NodeMappingHelper.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/helper/NodeMappingHelper.java
@@ -23,6 +23,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.EvaluationException;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterSiriusVariables;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
@@ -107,18 +108,18 @@ public final class NodeMappingHelper {
safeContainer = container;
}
- final EObjectCouple couple = new EObjectCouple(semanticOrigin, safeContainer);
+ DDiagram diagram = null;
+ if (containerView instanceof DDiagramElement) {
+ diagram = ((DDiagramElement) containerView).getParentDiagram();
+ } else if (containerView instanceof DDiagram) {
+ diagram = (DDiagram) containerView;
+ }
+ final EObjectCouple couple = new EObjectCouple(semanticOrigin, safeContainer, RefreshIdsHolder.getOrCreateHolder(diagram));
EList<EObject> result = self.getCandidatesCache().get(couple);
if (result == null) {
result = new UniqueEList<EObject>();
Iterator<EObject> it;
- DDiagram viewPoint = null;
- if (containerView instanceof DDiagramElement) {
- viewPoint = ((DDiagramElement) containerView).getParentDiagram();
- } else if (containerView instanceof DDiagram) {
- viewPoint = (DDiagram) containerView;
- }
- it = DiagramElementMappingHelper.getSemanticIterator(self, semanticOrigin, viewPoint);
+ it = DiagramElementMappingHelper.getSemanticIterator(self, semanticOrigin, diagram);
if (self.getDomainClass() != null) {
while (it.hasNext()) {
final EObject eObj = it.next();
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/AbstractDNodeSpecOperations.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/AbstractDNodeSpecOperations.java
index b00c46cb9a..730045c0a8 100755
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/AbstractDNodeSpecOperations.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/business/internal/metamodel/operations/AbstractDNodeSpecOperations.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.HashSet;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.AbstractDNode;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.business.internal.metamodel.description.operations.AbstractNodeMappingSpecOperations;
@@ -48,7 +49,7 @@ public final class AbstractDNodeSpecOperations {
final Collection<EObjectCouple> managedBorderingNodes = new HashSet<EObjectCouple>();
for (DNode n : adn.getOwnedBorderedNodes()) {
n.refresh();
- managedBorderingNodes.add(new EObjectCouple(n.getTarget(), n.getActualMapping()));
+ managedBorderingNodes.add(new EObjectCouple(n.getTarget(), n.getActualMapping(), RefreshIdsHolder.getOrCreateHolder(adn.getParentDiagram())));
}
/*
* create the non managed bordering nodes
diff --git a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/view/CreateDDiagramElementCommand.java b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/view/CreateDDiagramElementCommand.java
index 6bfd02bdb0..4dcfb65aa6 100644
--- a/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/view/CreateDDiagramElementCommand.java
+++ b/plugins/org.eclipse.sirius.diagram/src-core/org/eclipse/sirius/diagram/tools/api/command/view/CreateDDiagramElementCommand.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DSemanticDiagram;
@@ -70,8 +71,8 @@ public class CreateDDiagramElementCommand extends RecordingCommand {
*/
public CreateDDiagramElementCommand(final TransactionalEditingDomain domain, final EObject semantic, final AbstractNodeMapping mapping, final DragAndDropTarget container) {
this(domain, semantic);
- nodeCandidate = new AbstractDNodeCandidate(mapping, semantic, container);
this.container = container;
+ nodeCandidate = new AbstractDNodeCandidate(mapping, semantic, container, RefreshIdsHolder.getOrCreateHolder(getParentDiagram()));
}
/**
@@ -90,9 +91,9 @@ public class CreateDDiagramElementCommand extends RecordingCommand {
*/
public CreateDDiagramElementCommand(final TransactionalEditingDomain domain, final EObject semantic, final EdgeMapping mapping, final EdgeTarget source, final EdgeTarget target) {
this(domain, semantic);
- edgeCandidate = new DEdgeCandidate(mapping, semantic, source, target);
/* store source as container to retrieve later parent diagram */
this.container = (DragAndDropTarget) source;
+ edgeCandidate = new DEdgeCandidate(mapping, semantic, source, target, RefreshIdsHolder.getOrCreateHolder(getParentDiagram()));
}
private CreateDDiagramElementCommand(final TransactionalEditingDomain domain, final EObject semantic) {
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
index 019d9afb90..7b85a36934 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.html
@@ -306,6 +306,14 @@
<code>org.eclipse.sirius.business.api.dialect.description.MultiLanguagesValidator</code> has been introduced to provide a safe and more efficient way to switch to the proper
<code>IInterpreter</code> instance when validating expressions.
</li>
+ <li>The class
+ <code>org.eclipse.sirius.common.tools.api.util.RefreshIdFactory</code> has been replaced with
+ <code>org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder</code> which no longer rely on a global singleton but attach information to an EObject representing the current scope. This impacts
+ <code>org.eclipse.sirius.diagram.business.api.query.AbstractDNodeQuery</code> ,
+ <code>org.eclipse.sirius.common.tools.api.util.CartesianProduct</code> and
+ <code>org.eclipse.sirius.common.tools.api.util.EObjectCouple</code> which are now requiring now a
+ <code>RefreshIdsHolder</code> instance.
+ </li>
</ul>
<h4 id="Changesinorg.eclipse.sirius.common.ui">Changes in
<code>org.eclipse.sirius.common.ui</code>
@@ -507,6 +515,12 @@
<code>StyleDescription</code> we directly look for them in the
<code>ComputedStyleDescriptionRegistry.computedStyleDescriptions</code> list.
</p>
+ <ul>
+ <li>
+ <code>org.eclipse.sirius.diagram.business.api.query.AbstractDNodeQuery</code> now requires a
+ <code>org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder</code> to check for equality in the context of a refresh operation.
+ </li>
+ </ul>
<h4 id="Changesinorg.eclipse.sirius.diagram.ui">Changes in
<code>org.eclipse.sirius.diagram.ui</code>
</h4>
diff --git a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
index 46396a2acd..d518804116 100644
--- a/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
+++ b/plugins/org.eclipse.sirius.doc/doc/Release Notes.textile
@@ -88,6 +88,7 @@ h4. Changes in @org.eclipse.sirius.common@
* The class @org.eclipse.sirius.common.tools.api.interpreter.VariableType@ has been introduced to represent the possible types a variable can have in a Viewpoint specification model.
* The utility class @org.eclipse.sirius.common.tools.api.interpreter.IInterpreterContextUtils@ has been introduced to factorize code related to managing @IInterpreterContext@ instances.
* The class @org.eclipse.sirius.business.api.dialect.description.MultiLanguagesValidator@ has been introduced to provide a safe and more efficient way to switch to the proper @IInterpreter@ instance when validating expressions.
+* The class @org.eclipse.sirius.common.tools.api.util.RefreshIdFactory@ has been replaced with @org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder@ which no longer rely on a global singleton but attach information to an EObject representing the current scope. This impacts @org.eclipse.sirius.diagram.business.api.query.AbstractDNodeQuery@ , @org.eclipse.sirius.common.tools.api.util.CartesianProduct@ and @org.eclipse.sirius.common.tools.api.util.EObjectCouple@ which are now requiring now a @RefreshIdsHolder@ instance.
h4. Changes in @org.eclipse.sirius.common.ui@
@@ -151,6 +152,7 @@ h4. Changes in @org.eclipse.sirius.diagram@
* The method @org.eclipse.sirius.diagram.business.api.diagramtype.IDiagramDescriptionProvider.completeToolTipText(String, EObject, EStructuralFeature)@ has been added to customize the tooltip displayed in the VSM editor by using the feature of the current object. The old method @org.eclipse.sirius.diagram.business.api.diagramtype.IDiagramDescriptionProvider.completeToolTipText(String, EObject)@ has been deprecated.
* The @DNodeList.lineWidth@ attribute has been removed from the metamodel, the corresponding generated elements do not exist anymore: @org.eclipse.sirius.diagram.DNodeList.getLineWidth()@, @org.eclipse.sirius.diagram.DNodeList.setLineWidth()@, @org.eclipse.sirius.diagram.DiagramPackage.DNODE_LIST__LINE_WIDTH@, @org.eclipse.sirius.diagram.DiagramPackage.getDNodeList_LineWidth()@, @org.eclipse.sirius.diagram.DiagramPackage.Literals.DNODE_LIST__LINE_WIDTH()@.
@org.eclipse.sirius.diagram.ComputedStyleDescriptionRegistry.cache@ reference has been removed from the metamodel as it is no more useful, to limit memory consumed by computed @StyleDescription@ we directly look for them in the @ComputedStyleDescriptionRegistry.computedStyleDescriptions@ list.
+* @org.eclipse.sirius.diagram.business.api.query.AbstractDNodeQuery@ now requires a @org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder@ to check for equality in the context of a refresh operation.
h4. Changes in @org.eclipse.sirius.diagram.ui@
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DCellCandidate.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DCellCandidate.java
index eb474112f2..66ecd54a64 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DCellCandidate.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DCellCandidate.java
@@ -11,7 +11,7 @@
package org.eclipse.sirius.table.business.internal.refresh;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.table.metamodel.table.DCell;
import org.eclipse.sirius.table.metamodel.table.DColumn;
import org.eclipse.sirius.table.metamodel.table.DLine;
@@ -42,6 +42,8 @@ public class DCellCandidate {
private int hashcode;
+ private RefreshIdsHolder ids;
+
/**
* Create a new candidate.
*
@@ -53,12 +55,15 @@ public class DCellCandidate {
* the cell line.
* @param column
* the cell column.
+ * @param ids
+ * the holder of refresh ids.
*/
- public DCellCandidate(final ColumnMapping mapping, final EObject semanticElement, final DLine line, final DColumn column) {
+ public DCellCandidate(final ColumnMapping mapping, final EObject semanticElement, final DLine line, final DColumn column, RefreshIdsHolder ids) {
this.mapping = mapping;
this.semantic = semanticElement;
this.line = line;
this.column = column;
+ this.ids = ids;
this.hashcode = computeHashCode();
}
@@ -67,9 +72,12 @@ public class DCellCandidate {
*
* @param tableElement
* an existing diagram element.
+ *
+ * @param ids
+ * the holder of refresh ids.
*/
- public DCellCandidate(final DCell tableElement) {
- this((tableElement.getColumn() != null) ? tableElement.getColumn().getOriginMapping() : null, tableElement.getTarget(), tableElement.getLine(), tableElement.getColumn());
+ public DCellCandidate(final DCell tableElement, RefreshIdsHolder ids) {
+ this((tableElement.getColumn() != null) ? tableElement.getColumn().getOriginMapping() : null, tableElement.getTarget(), tableElement.getLine(), tableElement.getColumn(), ids);
this.element = tableElement;
}
@@ -155,19 +163,19 @@ public class DCellCandidate {
}
private Integer getColumnID() {
- return RefreshIDFactory.getOrCreateID(column);
+ return this.ids.getOrCreateID(column);
}
private Integer getLineID() {
- return RefreshIDFactory.getOrCreateID(line);
+ return this.ids.getOrCreateID(line);
}
private Integer getSemanticID() {
- return RefreshIDFactory.getOrCreateID(semantic);
+ return this.ids.getOrCreateID(semantic);
}
private Integer getMappingID() {
- return RefreshIDFactory.getOrCreateID(mapping);
+ return this.ids.getOrCreateID(mapping);
}
public ColumnMapping getMapping() {
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DFeatureColumnCandidate.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DFeatureColumnCandidate.java
index 96d7c357b5..f7bc33667b 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DFeatureColumnCandidate.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DFeatureColumnCandidate.java
@@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.sirius.table.business.internal.refresh;
-import com.google.common.base.Objects;
-
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.table.metamodel.table.DFeatureColumn;
import org.eclipse.sirius.table.metamodel.table.description.ColumnMapping;
+import com.google.common.base.Objects;
+
/**
* This class represents a candidate for a DColumn, a candidate is a "possible"
* DColumn which has not been confirmed yet by validation and preconditions.
@@ -37,6 +37,8 @@ public class DFeatureColumnCandidate {
private final int hashCode;
+ private RefreshIdsHolder ids;
+
/**
* Create a new candidate.
*
@@ -44,10 +46,13 @@ public class DFeatureColumnCandidate {
* the column mapping.
* @param featureName
* the target feature name.
+ * @param ids
+ * the holder of refresh ids.
*/
- public DFeatureColumnCandidate(final ColumnMapping mapping, final String featureName) {
+ public DFeatureColumnCandidate(final ColumnMapping mapping, final String featureName, RefreshIdsHolder ids) {
this.mapping = mapping;
this.featureName = featureName;
+ this.ids = ids;
this.hashCode = computeHashCode();
}
@@ -56,8 +61,11 @@ public class DFeatureColumnCandidate {
*
* @param tableElement
* an existing diagram element.
+ * @param ids
+ * the holder of refresh ids.
*/
- public DFeatureColumnCandidate(final DFeatureColumn tableElement) {
+ public DFeatureColumnCandidate(final DFeatureColumn tableElement, RefreshIdsHolder ids) {
+ this.ids = ids;
this.mapping = tableElement.getOriginMapping();
this.featureName = tableElement.getFeatureName();
this.element = tableElement;
@@ -102,7 +110,7 @@ public class DFeatureColumnCandidate {
}
private Integer getMappingID() {
- return RefreshIDFactory.getOrCreateID(mapping);
+ return ids.getOrCreateID(mapping);
}
/**
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DLineCandidate.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DLineCandidate.java
index 65efcf5f41..fb9a47382d 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DLineCandidate.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DLineCandidate.java
@@ -11,7 +11,7 @@
package org.eclipse.sirius.table.business.internal.refresh;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.table.metamodel.table.DLine;
import org.eclipse.sirius.table.metamodel.table.LineContainer;
import org.eclipse.sirius.table.metamodel.table.description.LineMapping;
@@ -38,6 +38,8 @@ public class DLineCandidate {
private int hashcode;
+ private RefreshIdsHolder ids;
+
/**
* Create a new candidate.
*
@@ -47,11 +49,14 @@ public class DLineCandidate {
* the target semantic element.
* @param viewContainer
* the view container.
+ * @param ids
+ * the holder of the refresh ids.
*/
- public DLineCandidate(final LineMapping mapping, final EObject semanticElement, final LineContainer viewContainer) {
+ public DLineCandidate(final LineMapping mapping, final EObject semanticElement, final LineContainer viewContainer, RefreshIdsHolder ids) {
this.mapping = mapping;
this.semantic = semanticElement;
this.viewContainer = viewContainer;
+ this.ids = ids;
this.hashcode = computeHashCode();
}
@@ -60,9 +65,11 @@ public class DLineCandidate {
*
* @param tableElement
* an existing diagram element.
+ * @param ids
+ * the holder of the refresh ids.
*/
- public DLineCandidate(final DLine tableElement) {
- this(tableElement.getOriginMapping(), tableElement.getTarget(), (LineContainer) tableElement.eContainer());
+ public DLineCandidate(final DLine tableElement, RefreshIdsHolder ids) {
+ this(tableElement.getOriginMapping(), tableElement.getTarget(), (LineContainer) tableElement.eContainer(), ids);
this.element = tableElement;
}
@@ -160,7 +167,7 @@ public class DLineCandidate {
if (viewContainer == null) {
return -1;
}
- return RefreshIDFactory.getOrCreateID(viewContainer);
+ return this.ids.getOrCreateID(viewContainer);
}
/**
@@ -172,11 +179,11 @@ public class DLineCandidate {
if (semantic == null) {
return -1;
}
- return RefreshIDFactory.getOrCreateID(semantic);
+ return this.ids.getOrCreateID(semantic);
}
-
+
private Integer getMappingID() {
- return RefreshIDFactory.getOrCreateID(mapping);
+ return this.ids.getOrCreateID(mapping);
}
public LineMapping getMapping() {
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
index 0833c79b3a..e523372f67 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTableSynchronizerImpl.java
@@ -29,6 +29,7 @@ import org.eclipse.sirius.common.tools.api.interpreter.IInterpreter;
import org.eclipse.sirius.common.tools.api.interpreter.IInterpreterSiriusVariables;
import org.eclipse.sirius.common.tools.api.util.CartesianProduct;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.common.tools.api.util.StringUtil;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ModelAccessor;
import org.eclipse.sirius.ext.base.Option;
@@ -85,6 +86,8 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
private final DTableElementSynchronizerSpec sync;
+ private RefreshIdsHolder ids;
+
/**
* Create a new {@link DTableSynchronizer} for an EditionTable.
*
@@ -263,7 +266,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
* let's keep the "now" status.
*/
for (final DCell cell : line.getCells()) {
- status.addInOld(new DCellCandidate(cell));
+ status.addInOld(new DCellCandidate(cell, this.ids));
}
for (final DColumn column : table.getColumns()) {
@@ -275,7 +278,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
} else {
target = line.getTarget();
}
- status.addInNew(new DCellCandidate(mapping, target, line, column));
+ status.addInNew(new DCellCandidate(mapping, target, line, column, this.ids));
}
/*
@@ -480,7 +483,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
for (final DColumn column : table.getColumns()) {
if (column.getOriginMapping() == mapping) {
if (column instanceof DTargetColumn) {
- status.addInOld(new DTargetColumnCandidate((DTargetColumn) column));
+ status.addInOld(new DTargetColumnCandidate((DTargetColumn) column, this.ids));
}
}
}
@@ -511,7 +514,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
*/
for (final EObject semantic : semantics) {
if (this.accessor.eInstanceOf(semantic, mapping.getDomainClass())) {
- status.addInNew(new DTargetColumnCandidate(mapping, semantic));
+ status.addInNew(new DTargetColumnCandidate(mapping, semantic, this.ids));
}
}
return status;
@@ -563,10 +566,10 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
for (final DColumn column : table.getColumns()) {
boolean mappingIsObsolete = TableDialectServices.isHandledByMovida(table) ? false : (column.getOriginMapping().eResource() == null || column.getOriginMapping().eIsProxy());
if (mappingIsObsolete || (column.getOriginMapping() == mapping && column instanceof DFeatureColumn)) {
- status.addInOld(new DFeatureColumnCandidate((DFeatureColumn) column));
+ status.addInOld(new DFeatureColumnCandidate((DFeatureColumn) column, this.ids));
}
}
- status.addInNew(new DFeatureColumnCandidate(mapping, mapping.getFeatureName()));
+ status.addInNew(new DFeatureColumnCandidate(mapping, mapping.getFeatureName(), this.ids));
return status;
}
@@ -693,7 +696,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
for (final DCell cell : new DTableQuery(table).getCells()) {
boolean mappingIsObsolete = TableDialectServices.isHandledByMovida(table) ? false : (cell.getIntersectionMapping() == null || cell.getIntersectionMapping().eResource() == null);
if (iMapping.equals(cell.getIntersectionMapping()) || mappingIsObsolete) {
- status.addInOld(new DCellCandidate(cell));
+ status.addInOld(new DCellCandidate(cell, this.ids));
}
}
@@ -745,13 +748,13 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
final Collection<DColumn> targetViews = columnSemantics.get(columnSemantic);
if (targetViews != null) {
- for (final EObjectCouple viewsCouple : new CartesianProduct(sourceViews, targetViews)) {
+ for (final EObjectCouple viewsCouple : new CartesianProduct(sourceViews, targetViews, ids)) {
final DLine line = (DLine) viewsCouple.getObj1();
final DColumn column = (DColumn) viewsCouple.getObj2();
if (checkIntersectionPrecondition(column.getTarget(), line, column, iMapping.getPreconditionExpression())) {
- status.addInNew(new DCellCandidate(iMapping.getColumnMapping(), target, line, column));
+ status.addInNew(new DCellCandidate(iMapping.getColumnMapping(), target, line, column, this.ids));
}
}
@@ -853,7 +856,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
for (final DCell cell : new DTableQuery(table).getCells()) {
boolean mappingIsObsolete = TableDialectServices.isHandledByMovida(table) ? false : (cell.getIntersectionMapping() == null || cell.getIntersectionMapping().eResource() == null);
if (iMapping.equals(cell.getIntersectionMapping()) || mappingIsObsolete) {
- status.addInOld(new DCellCandidate(cell));
+ status.addInOld(new DCellCandidate(cell, this.ids));
}
}
@@ -882,7 +885,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
linesToColumnSemantics.put(line, columnSemantics);
}
if (columnSemantics.contains(column.getTarget()) && checkIntersectionPrecondition(column.getTarget(), line, column, iMapping.getPreconditionExpression())) {
- status.addInNew(new DCellCandidate(iMapping.getColumnMapping(), line.getTarget(), line, column));
+ status.addInNew(new DCellCandidate(iMapping.getColumnMapping(), line.getTarget(), line, column, this.ids));
}
}
}
@@ -1081,7 +1084,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
for (final DLine line : container.getLines()) {
boolean mappingIsObsolete = TableDialectServices.isHandledByMovida(table) ? false : (line.getOriginMapping().eResource() == null);
if (line.getOriginMapping() == mapping || mappingIsObsolete) {
- status.addInOld(new DLineCandidate(line));
+ status.addInOld(new DLineCandidate(line, this.ids));
}
}
final MultipleCollection<EObject> semantics = new MultipleCollection<EObject>();
@@ -1110,7 +1113,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
*/
for (final EObject semantic : semantics) {
if (this.accessor.eInstanceOf(semantic, mapping.getDomainClass())) {
- status.addInNew(new DLineCandidate(mapping, semantic, container));
+ status.addInNew(new DLineCandidate(mapping, semantic, container, this.ids));
}
}
return status;
@@ -1122,6 +1125,7 @@ public class DTableSynchronizerImpl implements DTableSynchronizer {
*/
public void setTable(final DTable newTable) {
this.table = newTable;
+ this.ids = RefreshIdsHolder.getOrCreateHolder(table);
}
/**
diff --git a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTargetColumnCandidate.java b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTargetColumnCandidate.java
index 8c2db52571..ec9c943664 100644
--- a/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTargetColumnCandidate.java
+++ b/plugins/org.eclipse.sirius.table/src/org/eclipse/sirius/table/business/internal/refresh/DTargetColumnCandidate.java
@@ -11,7 +11,7 @@
package org.eclipse.sirius.table.business.internal.refresh;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.table.metamodel.table.DTargetColumn;
import org.eclipse.sirius.table.metamodel.table.description.ColumnMapping;
@@ -36,6 +36,8 @@ public class DTargetColumnCandidate {
private final int hashCode;
+ private RefreshIdsHolder ids;
+
/**
* Create a new candidate.
*
@@ -43,10 +45,13 @@ public class DTargetColumnCandidate {
* the column mapping.
* @param semanticElement
* the target semantic element.
+ * @param ids
+ * the holder of the refresh ids.
*/
- public DTargetColumnCandidate(final ColumnMapping mapping, final EObject semanticElement) {
+ public DTargetColumnCandidate(final ColumnMapping mapping, final EObject semanticElement, RefreshIdsHolder ids) {
this.mapping = mapping;
this.semantic = semanticElement;
+ this.ids = ids;
this.hashCode = computeHashCode();
}
@@ -55,11 +60,14 @@ public class DTargetColumnCandidate {
*
* @param tableElement
* an existing diagram element.
+ * @param ids
+ * the holder of the refresh ids.
*/
- public DTargetColumnCandidate(final DTargetColumn tableElement) {
+ public DTargetColumnCandidate(final DTargetColumn tableElement, RefreshIdsHolder ids) {
this.mapping = tableElement.getOriginMapping();
this.semantic = tableElement.getTarget();
this.element = tableElement;
+ this.ids = ids;
this.hashCode = computeHashCode();
}
@@ -134,14 +142,13 @@ public class DTargetColumnCandidate {
* @return the semantic ID
*/
private Integer getSemanticID() {
- return RefreshIDFactory.getOrCreateID(semantic);
+ return this.ids.getOrCreateID(semantic);
}
-
+
private Integer getMappingID() {
- return RefreshIDFactory.getOrCreateID(mapping);
+ return this.ids.getOrCreateID(mapping);
}
-
public ColumnMapping getMapping() {
return this.mapping;
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
index a40cdaa63b..4b2a06793c 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/suite/diagram/AllDiagramStandaloneTests.java
@@ -33,7 +33,7 @@ import org.eclipse.sirius.tests.unit.diagram.refresh.DDiagramElementSynchronizer
import org.eclipse.sirius.tests.unit.diagram.refresh.StyleHelperTest;
import org.eclipse.sirius.tests.unit.diagram.synchronization.AbstractDNodeCandidateTest;
import org.eclipse.sirius.tests.unit.diagram.synchronization.DEdgeCandidateTest;
-import org.eclipse.sirius.tests.unit.diagram.synchronization.RefreshIDFactoryTest;
+import org.eclipse.sirius.tests.unit.diagram.synchronization.RefreshIdsHolderTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.RepresentationDescriptionItemTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.ResourceFolderItemTest;
import org.eclipse.sirius.tests.unit.diagram.views.session.ResourceItemTest;
@@ -63,7 +63,7 @@ public class AllDiagramStandaloneTests {
suite.addTestSuite(EdgeMappingImportTests.class);
suite.addTestSuite(DEdgeCandidateTest.class);
suite.addTestSuite(AbstractDNodeCandidateTest.class);
- suite.addTestSuite(RefreshIDFactoryTest.class);
+ suite.addTestSuite(RefreshIdsHolderTest.class);
suite.addTestSuite(StyleHelperTest.class);
suite.addTestSuite(RepresentationDescriptionItemTest.class);
suite.addTestSuite(ResourceFolderItemTest.class);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/mappings/NodeMappingTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/mappings/NodeMappingTest.java
index 2ad24f73a8..dc14ad7be6 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/mappings/NodeMappingTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/api/mappings/NodeMappingTest.java
@@ -12,6 +12,8 @@ package org.eclipse.sirius.tests.unit.api.mappings;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.DiagramFactory;
import org.eclipse.sirius.diagram.description.DiagramDescription;
import org.eclipse.sirius.diagram.description.NodeMapping;
import org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase;
@@ -44,9 +46,10 @@ public class NodeMappingTest extends SiriusDiagramTestCase implements MappingsRe
RepresentationDescription representationDesc = viewpoints.iterator().next().getOwnedRepresentations().get(0);
assertTrue("Bad type for representation", representationDesc instanceof DiagramDescription);
DiagramDescription diagDesc = (DiagramDescription) representationDesc;
+ DDiagram diag = DiagramFactory.eINSTANCE.createDDiagram();
for (NodeMapping nodeMapping : diagDesc.getAllNodeMappings()) {
if (COMMON_NODE_MAPPING_ON_ECLASS.equals(nodeMapping.getName())) {
- EList<EObject> nodesCandidates = nodeMapping.getNodesCandidates(semanticModel, semanticModel);
+ EList<EObject> nodesCandidates = nodeMapping.getNodesCandidates(semanticModel, semanticModel, diag);
assertEquals("Bad number of nodes candidates for mapping \"" + COMMON_NODE_MAPPING_ON_ECLASS + "\"", 1, nodesCandidates.size());
}
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/CartesianProductTestCase.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/CartesianProductTestCase.java
index 06708e0ef7..69005694c3 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/CartesianProductTestCase.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/common/CartesianProductTestCase.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.sirius.common.tools.api.util.CartesianProduct;
import org.eclipse.sirius.common.tools.api.util.EObjectCouple;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
/**
* Cartesian product test case.
@@ -52,14 +53,16 @@ public class CartesianProductTestCase extends TestCase {
collection2.add(C);
collection2.add(D);
- CartesianProduct cartesianProduct = new CartesianProduct(collection1, collection2);
+ RefreshIdsHolder ids = new RefreshIdsHolder();
+
+ CartesianProduct cartesianProduct = new CartesianProduct(collection1, collection2, ids);
// the result should be the following
List<EObjectCouple> expectedResult = new ArrayList<EObjectCouple>();
- expectedResult.add(new EObjectCouple(A, C));
- expectedResult.add(new EObjectCouple(A, D));
- expectedResult.add(new EObjectCouple(B, C));
- expectedResult.add(new EObjectCouple(B, D));
+ expectedResult.add(new EObjectCouple(A, C, ids));
+ expectedResult.add(new EObjectCouple(A, D, ids));
+ expectedResult.add(new EObjectCouple(B, C, ids));
+ expectedResult.add(new EObjectCouple(B, D, ids));
List<EObjectCouple> result = new ArrayList<EObjectCouple>();
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/AbstractDNodeCandidateTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/AbstractDNodeCandidateTest.java
index d6f652f9a0..c76a4d875b 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/AbstractDNodeCandidateTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/AbstractDNodeCandidateTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.diagram.synchronization;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.DNodeContainer;
import org.eclipse.sirius.diagram.DiagramFactory;
@@ -33,6 +34,8 @@ public class AbstractDNodeCandidateTest extends EqualsHashCodeTestCase {
private NodeMapping nodeMapping = DDF.createNodeMapping();
+ private RefreshIdsHolder ids = new RefreshIdsHolder();
+
/**
* Constructor.
*/
@@ -51,7 +54,7 @@ public class AbstractDNodeCandidateTest extends EqualsHashCodeTestCase {
dNode.setActualMapping(nodeMapping);
dNodeContainer.getOwnedDiagramElements().add(dNode);
- return new AbstractDNodeCandidate(dNode);
+ return new AbstractDNodeCandidate(dNode, ids);
}
/**
@@ -59,7 +62,7 @@ public class AbstractDNodeCandidateTest extends EqualsHashCodeTestCase {
*/
@Override
protected Object createNotEqualInstance() throws Exception {
- return new AbstractDNodeCandidate(null, null, null);
+ return new AbstractDNodeCandidate(null, null, null, ids);
}
/**
@@ -75,11 +78,11 @@ public class AbstractDNodeCandidateTest extends EqualsHashCodeTestCase {
dNodeContainer.getOwnedDiagramElements().add(node);
node.setTarget(null);
- AbstractDNodeCandidate candidate1 = new AbstractDNodeCandidate(node);
+ AbstractDNodeCandidate candidate1 = new AbstractDNodeCandidate(node, ids);
node.setTarget(dNodeContainer);
- AbstractDNodeCandidate candidate2 = new AbstractDNodeCandidate(node);
+ AbstractDNodeCandidate candidate2 = new AbstractDNodeCandidate(node, ids);
assertFalse(candidate1.equals(candidate2));
}
@@ -96,11 +99,11 @@ public class AbstractDNodeCandidateTest extends EqualsHashCodeTestCase {
node.setActualMapping(nodeMapping);
node.setTarget(dNodeContainer);
- AbstractDNodeCandidate candidate1 = new AbstractDNodeCandidate(node);
+ AbstractDNodeCandidate candidate1 = new AbstractDNodeCandidate(node, ids);
dNodeContainer.getOwnedDiagramElements().add(node);
- AbstractDNodeCandidate candidate2 = new AbstractDNodeCandidate(node);
+ AbstractDNodeCandidate candidate2 = new AbstractDNodeCandidate(node, ids);
assertFalse(candidate1.equals(candidate2));
}
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/DEdgeCandidateTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/DEdgeCandidateTest.java
index abb158b495..8f3f7be935 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/DEdgeCandidateTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/DEdgeCandidateTest.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.sirius.tests.unit.diagram.synchronization;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.DNode;
@@ -39,6 +40,8 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
private DDiagram dDiagram = DF.createDDiagram();
+ private RefreshIdsHolder ids = new RefreshIdsHolder();
+
public DEdgeCandidateTest() {
super();
edgeMapping.setName("dfgsdf");
@@ -59,7 +62,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
dEdge.setSourceNode(sourceEdgeTarget);
dEdge.setTargetNode(targetEdgeTarget);
- return new DEdgeCandidate(dEdge);
+ return new DEdgeCandidate(dEdge, ids);
}
/**
@@ -67,7 +70,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
*/
@Override
protected Object createNotEqualInstance() throws Exception {
- return new DEdgeCandidate(null, null, null, null);
+ return new DEdgeCandidate(null, null, null, null, ids);
}
/**
@@ -83,7 +86,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
dEdge.setSourceNode(sourceEdgeTarget);
dEdge.setTargetNode(targetEdgeTarget);
- DEdgeCandidate instance = new DEdgeCandidate(dEdge);
+ DEdgeCandidate instance = new DEdgeCandidate(dEdge, ids);
assertTrue(instance.isInvalid());
}
@@ -100,7 +103,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
dEdge.setSourceNode(sourceEdgeTarget);
dEdge.setTargetNode(targetEdgeTarget);
- DEdgeCandidate instance = new DEdgeCandidate(dEdge);
+ DEdgeCandidate instance = new DEdgeCandidate(dEdge, ids);
dDiagram.getOwnedDiagramElements().add(sourceEdgeTarget);
assertTrue(instance.isInvalid());
@@ -119,7 +122,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
dEdge.setSourceNode(sourceEdgeTarget);
dEdge.setTargetNode(targetEdgeTarget);
- DEdgeCandidate instance = new DEdgeCandidate(dEdge);
+ DEdgeCandidate instance = new DEdgeCandidate(dEdge, ids);
dDiagram.getOwnedDiagramElements().add(targetEdgeTarget);
assertTrue(instance.isInvalid());
@@ -138,7 +141,7 @@ public class DEdgeCandidateTest extends EqualsHashCodeTestCase {
dEdge.setSourceNode(sourceEdgeTarget);
dEdge.setTargetNode(targetEdgeTarget);
- DEdgeCandidate instance = new DEdgeCandidate(dEdge);
+ DEdgeCandidate instance = new DEdgeCandidate(dEdge, ids);
dDiagram.getOwnedDiagramElements().add(sourceEdgeTarget);
dDiagram.getOwnedDiagramElements().add(targetEdgeTarget);
diff --git a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIDFactoryTest.java b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIdsHolderTest.java
index 122b7f55da..5b4b2c757f 100644
--- a/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIDFactoryTest.java
+++ b/plugins/org.eclipse.sirius.tests.junit/src/org/eclipse/sirius/tests/unit/diagram/synchronization/RefreshIdsHolderTest.java
@@ -12,26 +12,29 @@ package org.eclipse.sirius.tests.unit.diagram.synchronization;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.sirius.common.tools.api.util.RefreshIDFactory;
+import org.eclipse.sirius.common.tools.api.util.RefreshIdsHolder;
import org.eclipse.sirius.tests.support.api.EqualsHashCodeTestCase;
/**
- * Test class for {@link RefreshIDFactory}.
+ * Test class for {@link RefreshIdsHolder}.
*
* @author dlecan
*/
-public class RefreshIDFactoryTest extends EqualsHashCodeTestCase {
+public class RefreshIdsHolderTest extends EqualsHashCodeTestCase {
private static final EcoreFactory EF = EcoreFactory.eINSTANCE;
private final EObject eObject;
+ private RefreshIdsHolder ids;
+
/**
* Constructor.
*/
- public RefreshIDFactoryTest() {
+ public RefreshIdsHolderTest() {
super();
eObject = EF.createEObject();
+ ids = new RefreshIdsHolder();
}
/**
@@ -40,7 +43,7 @@ public class RefreshIDFactoryTest extends EqualsHashCodeTestCase {
@Override
protected Object createInstance() throws Exception {
// Instanciate a new Integer in order to have a different instance
- return new Integer(RefreshIDFactory.getOrCreateID(eObject));
+ return new Integer(ids.getOrCreateID(eObject));
}
/**
@@ -48,7 +51,7 @@ public class RefreshIDFactoryTest extends EqualsHashCodeTestCase {
*/
@Override
protected Object createNotEqualInstance() throws Exception {
- return RefreshIDFactory.getOrCreateID(EF.createEObject());
+ return ids.getOrCreateID(EF.createEObject());
}
/**
@@ -58,7 +61,7 @@ public class RefreshIDFactoryTest extends EqualsHashCodeTestCase {
* Test error.
*/
public void testCheckSameInstance() throws Exception {
- assertSame(RefreshIDFactory.getOrCreateID(eObject), RefreshIDFactory.getOrCreateID(eObject));
+ assertSame(ids.getOrCreateID(eObject), ids.getOrCreateID(eObject));
}
/**
@@ -68,7 +71,7 @@ public class RefreshIDFactoryTest extends EqualsHashCodeTestCase {
* Test error.
*/
public void testCheckNotSameInstance() throws Exception {
- assertNotSame(RefreshIDFactory.getOrCreateID(EF.createEObject()), RefreshIDFactory.getOrCreateID(eObject));
+ assertNotSame(ids.getOrCreateID(EF.createEObject()), ids.getOrCreateID(eObject));
}
}

Back to the top