Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2015-02-24 17:02:57 +0000
committerAxel Richard2015-03-02 17:43:34 +0000
commit0b01ab1cf07dae2b4c3685555abdf7797e8caed8 (patch)
tree7a67ca0de4ae2443aeb9ef98979313133e47290a
parentf35d8bd5606eca519f57b7a65f9289ccb3584fed (diff)
downloadorg.eclipse.emf.compare-0b01ab1cf07dae2b4c3685555abdf7797e8caed8.tar.gz
org.eclipse.emf.compare-0b01ab1cf07dae2b4c3685555abdf7797e8caed8.tar.xz
org.eclipse.emf.compare-0b01ab1cf07dae2b4c3685555abdf7797e8caed8.zip
[458968] Fix Rejecting DiagramChange causes NPE
Bug: 458968 Change-Id: Ib7c4541f04101fd21603e5a870fc581d1a51f3ca Signed-off-by: Axel Richard <axel.richard@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java30
1 files changed, 22 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
index c153bf59b..ffbf11773 100644
--- a/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.diagram.ide.ui/src/org/eclipse/emf/compare/diagram/ide/ui/internal/contentmergeviewer/diagram/DiagramMergeViewer.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.compare.diagram.ide.ui.internal.accessor.IDiagramDiffAcce
import org.eclipse.emf.compare.diagram.ide.ui.internal.accessor.IDiagramNodeAccessor;
import org.eclipse.emf.compare.rcp.ui.internal.configuration.IEMFCompareConfiguration;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.gef.EditDomain;
@@ -190,8 +191,8 @@ class DiagramMergeViewer extends AbstractGraphicalMergeViewer {
if (input instanceof IDiagramNodeAccessor) {
Diagram diagram = ((IDiagramNodeAccessor)input).getOwnedDiagram();
if (diagram != null) {
- initEditingDomain(diagram);
- if (currentDiag != diagram) {
+ TransactionalEditingDomain domain = getEditingDomain(diagram);
+ if (domain != null && currentDiag != diagram) {
DiagramRootEditPart rootEditPart = new DiagramRootEditPart(diagram.getMeasurementUnit());
// rootEditPart.getZoomManager().setZoomAnimationStyle(ZoomManager.ANIMATE_NEVER);
// rootEditPart.getZoomManager().setZoom(ZOOM_FACTOR);
@@ -231,20 +232,33 @@ class DiagramMergeViewer extends AbstractGraphicalMergeViewer {
}
/**
- * It creates an editing domain for this diagram.
+ * It creates/retrieves an editing domain for this diagram.
*
* @param diagram
* The diagram.
+ * @return The editing domain for this diagram.
*/
- private void initEditingDomain(Diagram diagram) {
+ private TransactionalEditingDomain getEditingDomain(Diagram diagram) {
+ final TransactionalEditingDomain domain;
ResourceSet resourceSet = null;
if (diagram != null) {
- resourceSet = diagram.eResource().getResourceSet();
+ Resource resource = diagram.eResource();
+ if (resource != null) {
+ resourceSet = resource.getResourceSet();
+ }
}
- if (resourceSet != null
- && TransactionalEditingDomain.Factory.INSTANCE.getEditingDomain(resourceSet) == null) {
- TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
+ if (resourceSet != null) {
+ TransactionalEditingDomain existingDomain = TransactionalEditingDomain.Factory.INSTANCE
+ .getEditingDomain(resourceSet);
+ if (existingDomain == null) {
+ domain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
+ } else {
+ domain = existingDomain;
+ }
+ } else {
+ domain = null;
}
+ return domain;
}
/**

Back to the top