Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-04-29 19:55:28 +0000
committerChristian W. Damus2014-04-30 12:35:29 +0000
commitdd542789773cee26e0e71d3a8a3c70ceb50d8fcf (patch)
treefa17b24eb2d1dd9c4e093b028651f15fd2ab0025 /extraplugins
parent956f6f6be4a6f76dd80dc39d7772e30d3316e6e6 (diff)
downloadorg.eclipse.papyrus-dd542789773cee26e0e71d3a8a3c70ceb50d8fcf.tar.gz
org.eclipse.papyrus-dd542789773cee26e0e71d3a8a3c70ceb50d8fcf.tar.xz
org.eclipse.papyrus-dd542789773cee26e0e71d3a8a3c70ceb50d8fcf.zip
422257: [Performances] Memory leaks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=422257 Updates to CDO Integration component and tests to fix memory leaks. This is a work-in-progress. Especially noteworthy is the new "unload" implementation for CDO views, which clears the adapters (especially UML CacheAdapter) from all CDOObjects in the view when closing it, in lieu of relying on Resource::unload() which CDOResource does not implement.
Diffstat (limited to 'extraplugins')
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF1
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java33
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java91
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java7
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/exporter/ModelExporter.java21
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java15
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelTransferConfiguration.java10
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextCopyAction.java11
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java73
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java25
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java20
-rw-r--r--extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java14
12 files changed, 266 insertions, 55 deletions
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
index 3aa652f5ae0..e97efda6226 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/META-INF/MANIFEST.MF
@@ -6,6 +6,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.papyrus.infra.core;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="1.0.0",
org.eclipse.papyrus.infra.services.resourceloading;bundle-version="1.0.0";visibility:=reexport,
+ org.eclipse.papyrus.infra.emf;bundle-version="1.0.0",
org.eclipse.papyrus.infra.emf.readonly;bundle-version="1.0.0";visibility:=reexport,
org.eclipse.emf.workspace;bundle-version="[1.5.1,2.0.0)",
org.eclipse.papyrus.infra.gmfdiag.commands;bundle-version="1.0.0",
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
index a0eb6f6f218..bee114137cd 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/core/resource/CDOAwareModelSet.java
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 429242
+ * Christian W. Damus (CEA) - bug 422257
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.core.resource;
@@ -203,23 +204,29 @@ public class CDOAwareModelSet extends OnDemandLoadingModelSet {
@Override
public void unload() {
try {
- super.unload();
+ // CDOResources don't implement unload(), but we can remove adapters from
+ // all of the objects that we have loaded in this view
+ CDOUtils.unload(getCDOView());
} finally {
- if((repository != null) && (getCDOView() != null)) {
- CDOView view = getCDOView();
- if(view != null) {
- view.removeListener(getInvalidationListener());
- }
- invalidationListener = null;
+ try {
+ super.unload();
+ } finally {
+ if((repository != null) && (getCDOView() != null)) {
+ CDOView view = getCDOView();
+ if(view != null) {
+ view.removeListener(getInvalidationListener());
+ }
+ invalidationListener = null;
- // dispose the transaction
- repository.close(this);
+ // dispose the transaction
+ repository.close(this);
- // now, we can remove the CDOViewSet adapter
- eAdapters().clear();
- }
+ // now, we can remove the CDOViewSet adapter
+ eAdapters().clear();
+ }
- repository = null;
+ repository = null;
+ }
}
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
index 3172f301cdf..f0d11c8a3c2 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/CDOUtils.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core;
@@ -25,12 +27,15 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.dawn.spi.DawnState;
+import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.CDOResourceNode;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.emf.cdo.view.CDOViewSet;
+import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
@@ -42,11 +47,17 @@ import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
import org.eclipse.emf.transaction.ResourceSetChangeEvent;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.lifecycle.LifecycleEvent;
import org.eclipse.papyrus.cdo.core.resource.CDOAwareTransactionalEditingDomain;
import org.eclipse.papyrus.cdo.core.util.CDOFunctions;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.UnmodifiableListIterator;
@@ -60,6 +71,9 @@ public class CDOUtils {
private static Executor broadcastExecutor = new DirectExecutor();
+ @SuppressWarnings("restriction")
+ private static final Predicate<Object> IS_LEGACY_WRAPPER = Predicates.instanceOf(org.eclipse.emf.internal.cdo.object.CDOObjectWrapperBase.class);
+
/**
* Not instantiable by clients.
*/
@@ -443,6 +457,81 @@ public class CDOUtils {
broadcastExecutor = (executor == null) ? new DirectExecutor() : executor;
}
+ /**
+ * Remove the given {@code listener} if the event it received is a lifecycle deactivation event.
+ *
+ * @param listener
+ * a listener that received a possible deactivation event
+ * @param possibleDeactivation
+ * the event that may be a lifecycle deactivation
+ *
+ * @return whether the listener was removed because the event was a deactivation
+ */
+ public static boolean removeListenerFromDeactivatedLifecycle(IListener listener, IEvent possibleDeactivation) {
+ boolean result = false;
+
+ if(possibleDeactivation instanceof LifecycleEvent) {
+ switch(((LifecycleEvent)possibleDeactivation).getKind()) {
+ case DEACTIVATED:
+ possibleDeactivation.getSource().removeListener(listener);
+ result = true;
+ break;
+ default:
+ // Pass
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Unloads a {@code cdoObject} (because {@link CDOResource}s don't implement unloading) by clearing its adapters.
+ *
+ * @param cdoObject
+ * a CDO object to unload
+ *
+ * @see #unload(CDOView)
+ */
+ public static void unload(CDOObject cdoObject) {
+ EObject eObject = CDOUtil.getEObject(cdoObject);
+ if(eObject != null) {
+ // Remove all adapters *except* the all-important legacy wrapper!
+ EList<Adapter> adapters = eObject.eAdapters();
+ if(!adapters.isEmpty()) {
+ Adapter legacyWrapper = Iterables.find(eObject.eAdapters(), IS_LEGACY_WRAPPER, null);
+
+ // Don't do anything if the only adapter is the legacy wrapper
+ if((legacyWrapper == null) || (adapters.size() > 1)) {
+ adapters.clear();
+ if(legacyWrapper != null) {
+ // Restore it, otherwise references to this CDOObject will break
+ adapters.add(0, legacyWrapper);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Unloads aall of the objects in a {@code cdoView} (because {@link CDOResource}s don't implement unloading) by clearing thriw adapters.
+ *
+ * @param cdoView
+ * a view to unload
+ *
+ * @see #unload(CDOObject)
+ */
+ public static void unload(CDOView cdoView) {
+ if(cdoView instanceof InternalCDOView) {
+ for(CDOObject next : ((InternalCDOView)cdoView).getObjectsList()) {
+ // Don't clear adapters of the resource because ECrossReferenceAdapters would try to crawl the contents
+ if(!(next instanceof CDOResourceNode)) {
+ CDOUtils.unload(next);
+ }
+ }
+ }
+ }
+
//
// Nested types
//
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
index 3396655f7e7..5cdfa656215 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/PapyrusRepository.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core;
@@ -461,6 +463,9 @@ public class PapyrusRepository extends Container<CDOResourceNode> implements IIn
} else {
fireEvent(); // just refresh my presentation
}
+
+ // We created this view, so we should do our best to clean it up
+ CDOUtils.unload(view);
}
} finally {
unadaptView(view);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/exporter/ModelExporter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/exporter/ModelExporter.java
index ecc06ee4911..1e4e951a001 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/exporter/ModelExporter.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/exporter/ModelExporter.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core.exporter;
@@ -33,8 +35,10 @@ import org.eclipse.papyrus.cdo.core.importer.IModelTransferNode;
import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation;
import org.eclipse.papyrus.cdo.internal.core.Activator;
import org.eclipse.papyrus.cdo.internal.core.CDOProxyResolvingResourceSet;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.cdo.internal.core.IInternalPapyrusRepository;
import org.eclipse.papyrus.cdo.internal.core.l10n.Messages;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
/**
* This is the ModelExporter type. Enjoy.
@@ -45,6 +49,7 @@ public class ModelExporter implements IModelExporter {
super();
}
+ @Override
public Diagnostic exportModels(final IModelExportMapping mapping) {
BasicDiagnostic result = new BasicDiagnostic();
@@ -54,6 +59,7 @@ public class ModelExporter implements IModelExporter {
if(result.getSeverity() < Diagnostic.ERROR) {
add(result, mapping.getConfiguration().getOperationContext().run(new IModelTransferOperation() {
+ @Override
public Diagnostic run(IProgressMonitor monitor) {
return doExport(mapping, monitor);
}
@@ -95,9 +101,10 @@ public class ModelExporter implements IModelExporter {
sub.worked(1);
} finally {
// don't clean up the configuration's resource set because it is not owned by the configuration
- cleanUp(destination);
+ EMFHelper.unload(destination);
+ CDOUtils.unload(repository.getCDOView(source));
repository.close(source);
- cleanUp(source);
+ EMFHelper.unload(source);
sub.worked(1);
}
@@ -166,14 +173,6 @@ public class ModelExporter implements IModelExporter {
return result;
}
- private void cleanUp(ResourceSet resourceSet) {
- for(Resource next : resourceSet.getResources()) {
- next.unload();
- next.eAdapters().clear();
- }
- resourceSet.getResources().clear();
- }
-
private static void add(DiagnosticChain diagnostics, Diagnostic diagnostic) {
if(diagnostic.getSeverity() > Diagnostic.OK) {
diagnostics.merge(diagnostic);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java
index 22102b48878..637a875787b 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelImporter.java
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 429242
+ * Christian W. Damus (CEA) - bug 422257
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core.importer;
@@ -48,6 +49,7 @@ import org.eclipse.papyrus.infra.core.sashwindows.di.PageList;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashModel;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashWindowsMngr;
import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import com.google.common.collect.Sets;
@@ -147,9 +149,10 @@ public class ModelImporter implements IModelImporter {
result.add(new BasicDiagnostic(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.ModelImporter_6, new Object[]{ e }));
}
} finally {
- cleanUp(configuration.getResourceSet());
- cleanUp(destination);
+ EMFHelper.unload(configuration.getResourceSet());
+ CDOUtils.unload(repository.getCDOView(destination));
repository.close(destination);
+ EMFHelper.unload(destination);
sub.worked(1);
}
@@ -338,14 +341,6 @@ public class ModelImporter implements IModelImporter {
return result;
}
- private void cleanUp(ResourceSet resourceSet) {
- for(Resource next : resourceSet.getResources()) {
- next.unload();
- next.eAdapters().clear();
- }
- resourceSet.getResources().clear();
- }
-
private static void add(DiagnosticChain diagnostics, Diagnostic diagnostic) {
if(diagnostic.getSeverity() > Diagnostic.OK) {
diagnostics.merge(diagnostic);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelTransferConfiguration.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelTransferConfiguration.java
index ea38d46ab41..abb3a6a2d4e 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelTransferConfiguration.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.core/src/org/eclipse/papyrus/cdo/internal/core/importer/ModelTransferConfiguration.java
@@ -9,6 +9,7 @@
* Contributors:
* CEA LIST - Initial API and implementation
* Christian W. Damus (CEA) - bug 429242
+ * Christian W. Damus (CEA) - bug 422257
*
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.core.importer;
@@ -38,6 +39,7 @@ import org.eclipse.papyrus.cdo.core.importer.IModelTransferOperation.Context;
import org.eclipse.papyrus.cdo.internal.core.Activator;
import org.eclipse.papyrus.cdo.internal.core.l10n.Messages;
import org.eclipse.papyrus.infra.core.sashwindows.di.util.DiUtils;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
@@ -97,13 +99,7 @@ public class ModelTransferConfiguration implements IModelTransferConfiguration {
public void dispose() {
if(resourceSet != null) {
if(ownResourceSet) {
- for(Resource next : resourceSet.getResources()) {
- next.unload();
- next.eAdapters().clear();
- }
-
- resourceSet.getResources().clear();
- resourceSet.eAdapters().clear();
+ EMFHelper.unload(resourceSet);
resourceSet = null;
} else {
// even if not owned, we should remove DependencyAdapters
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextCopyAction.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextCopyAction.java
index b0b26a5b52a..94017d3b78a 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextCopyAction.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui.customization.properties/src/org/eclipse/papyrus/cdo/internal/ui/customization/properties/storage/action/CDOContextCopyAction.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.customization.properties.storage.action;
@@ -70,14 +72,17 @@ import com.google.common.io.Closeables;
*/
public class CDOContextCopyAction extends AbstractCDOContextAction implements IContextCopyAction {
+ @Override
public String getLabel() {
return Messages.CDOContextCopyAction_0;
}
+ @Override
public String getToolTip() {
return Messages.CDOContextCopyAction_1;
}
+ @Override
public Context copy(Context source, String targetName, IProgressMonitor monitor) throws CoreException {
IInternalPapyrusRepository repository = selectRepository(source);
if(repository == null) {
@@ -135,7 +140,9 @@ public class CDOContextCopyAction extends AbstractCDOContextAction implements IC
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage(), e));
} finally {
+ CDOUtils.unload(transaction);
transaction.close();
+ EMFHelper.unload(transaction.getResourceSet());
sub.done();
}
@@ -170,10 +177,12 @@ public class CDOContextCopyAction extends AbstractCDOContextAction implements IC
final IPapyrusRepository[] innerResult = { initialSelection };
Display.getDefault().syncExec(new Runnable() {
+ @Override
public void run() {
Shell active = Display.getDefault().getActiveShell();
RepositorySelectionDialog dlg = new RepositorySelectionDialog(active, mgr, innerResult[0], new Supplier<IRunnableContext>() {
+ @Override
public IRunnableContext get() {
return new ProgressMonitorDialog(Display.getDefault().getActiveShell());
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java
index 4ec92a557cb..224b7ce8d5c 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusCDOEditorManager.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.editors;
@@ -35,7 +37,14 @@ import org.eclipse.papyrus.cdo.internal.ui.Activator;
import org.eclipse.papyrus.cdo.internal.ui.l10n.Messages;
import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IComponentPage;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IEditorPage;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IPage;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageLifeCycleEventsListener;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.IPageVisitor;
+import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.core.utils.AdapterUtils;
import org.eclipse.papyrus.infra.core.utils.EditorUtils;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
@@ -44,6 +53,7 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
+import com.google.common.base.Optional;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
@@ -174,12 +184,17 @@ public class PapyrusCDOEditorManager {
}
}
- private class EditorListener implements IPartListener {
+ private class EditorListener implements IPartListener, IPageLifeCycleEventsListener {
private final Set<IEditorPart> editors = Sets.newHashSet();
void addEditor(IEditorPart editor) {
editors.add(editor);
+
+ Optional<ISashWindowsContainer> sashContainer = AdapterUtils.adapt(editor, ISashWindowsContainer.class);
+ if(sashContainer.isPresent()) {
+ sashContainer.get().addPageLifeCycleListener(this);
+ }
}
@Override
@@ -188,6 +203,30 @@ public class PapyrusCDOEditorManager {
IEditorPart editor = (IEditorPart)part;
closed(editor);
}
+
+ Optional<ISashWindowsContainer> sashContainer = AdapterUtils.adapt(part, ISashWindowsContainer.class);
+ if(sashContainer.isPresent()) {
+ sashContainer.get().removePageLifeCycleListener(this);
+ sashContainer.get().visit(new IPageVisitor() {
+
+ @Override
+ public void accept(IEditorPage page) {
+ pageClosed(page);
+ }
+
+ @Override
+ public void accept(IComponentPage page) {
+ // pass
+ }
+ });
+ }
+ }
+
+ @Override
+ public void pageClosed(IPage page) {
+ if(page instanceof IEditorPage) {
+ closed(((IEditorPage)page).getIEditorPart());
+ }
}
@Override
@@ -209,6 +248,36 @@ public class PapyrusCDOEditorManager {
public void partOpened(IWorkbenchPart part) {
// pass
}
+
+ @Override
+ public void pageChanged(IPage newPage) {
+ // pass
+ }
+
+ @Override
+ public void pageOpened(IPage page) {
+ // pass
+ }
+
+ @Override
+ public void pageActivated(IPage page) {
+ // pass
+ }
+
+ @Override
+ public void pageDeactivated(IPage page) {
+ // pass
+ }
+
+ @Override
+ public void pageAboutToBeOpened(IPage page) {
+ // pass
+ }
+
+ @Override
+ public void pageAboutToBeClosed(IPage page) {
+ // pass
+ }
}
private class ResourceSetDisposalApprover implements IResourceSetDisposalApprover {
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java
index 58ae47eecab..2ffbebf2ad6 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,8 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.editors;
@@ -38,6 +40,8 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
import com.google.common.collect.Maps;
@@ -101,22 +105,27 @@ public class PapyrusGMFHandler extends DawnGMFHandler {
} else {
result = new CDOViewInvalidationEvent() {
+ @Override
public CDOView getSource() {
return event.getSource();
}
+ @Override
public long getTimeStamp() {
return event.getTimeStamp();
}
+ @Override
public Map<CDOObject, CDORevisionDelta> getRevisionDeltas() {
return deltas;
}
+ @Override
public Set<CDOObject> getDirtyObjects() {
return dirty;
}
+ @Override
public Set<CDOObject> getDetachedObjects() {
return detached;
}
@@ -156,6 +165,19 @@ public class PapyrusGMFHandler extends DawnGMFHandler {
RefreshAdapter.refreshLater(object, editor);
}
+ @Override
+ public void handleEvent(IEvent event) {
+ try {
+ super.handleEvent(event);
+ } finally {
+ if(CDOUtils.removeListenerFromDeactivatedLifecycle(this, event)) {
+ if(event.getSource() instanceof CDOTransaction) {
+ ((CDOTransaction)event.getSource()).removeTransactionHandler(this);
+ }
+ }
+ }
+ }
+
//
// Nested types
//
@@ -206,6 +228,7 @@ public class PapyrusGMFHandler extends DawnGMFHandler {
return type == TYPE;
}
+ @Override
public void run() {
pending.remove(editor, this);
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java
index 6c58788142e..ccf98ff5c58 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/editors/PapyrusGMFLockingHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
+ * Copyright (c) 2013, 2014 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,19 +8,22 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 422257
+ *
*****************************************************************************/
package org.eclipse.papyrus.cdo.internal.ui.editors;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFLockingHandler;
import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.papyrus.cdo.internal.core.CDOUtils;
import org.eclipse.papyrus.cdo.internal.ui.util.UIUtil;
/**
* This is the PapyrusGMFLockingHandler type. Enjoy.
*/
-public class PapyrusGMFLockingHandler
- extends DawnGMFLockingHandler {
+public class PapyrusGMFLockingHandler extends DawnGMFLockingHandler {
public PapyrusGMFLockingHandler(IDawnEditor editor) {
super(editor);
@@ -28,8 +31,17 @@ public class PapyrusGMFLockingHandler
@Override
public void handleLocksChangedEvent(CDOViewLocksChangedEvent event) {
- if (UIUtil.ensureUIThread(this, event)) {
+ if(UIUtil.ensureUIThread(this, event)) {
super.handleLocksChangedEvent(event);
}
}
+
+ @Override
+ public void handleEvent(IEvent event) {
+ try {
+ super.handleEvent(event);
+ } finally {
+ CDOUtils.removeListenerFromDeactivatedLifecycle(this, event);
+ }
+ }
}
diff --git a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java
index 0b1729a61a3..1564a708d52 100644
--- a/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java
+++ b/extraplugins/cdo/org.eclipse.papyrus.cdo.ui/src/org/eclipse/papyrus/cdo/internal/ui/views/DIResourceQuery.java
@@ -72,6 +72,8 @@ public class DIResourceQuery {
private AtomicReference<Set<CDOResource>> diResources = new AtomicReference<Set<CDOResource>>(Collections.<CDOResource> emptySet());
+ private Boolean hasLegacyModels;
+
private DIResourceQuery(StructuredViewer viewer, CDOView view) {
super();
@@ -195,6 +197,14 @@ public class DIResourceQuery {
return diResources.get();
}
+ boolean hasLegacyModels() {
+ if(hasLegacyModels == null) {
+ hasLegacyModels = query.getView().getSession().getPackageRegistry().getPackageInfo(DiPackage.eINSTANCE) != null;
+ }
+
+ return hasLegacyModels;
+ }
+
private void runQuery() {
// we cannot query for EClasses that the server doesn't know about. And,
// if it doesn't know about an EClass, then a priori, none of its
@@ -302,10 +312,6 @@ public class DIResourceQuery {
return Status.OK_STATUS;
}
- private boolean hasLegacyModels() {
- return query.getView().getSession().getPackageRegistry().getPackageInfo(DiPackage.eINSTANCE) != null;
- }
-
private boolean isContained(CDOResource resource) {
// determines whether a resource is properly contained in the view's
// node hierarchy

Back to the top