Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-03-27 14:48:54 -0400
committerChristian W. Damus2014-03-27 14:49:10 -0400
commitaca683fb78056238b7a5e533f55abf8b2e6ba0aa (patch)
tree7a73777adc34e9390ce1936e4bfc310c66b5d956 /plugins
parentee4591bbe74a80517780f021db9e550da17fbe79 (diff)
downloadorg.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.tar.gz
org.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.tar.xz
org.eclipse.papyrus-aca683fb78056238b7a5e533f55abf8b2e6ba0aa.zip
410346: Sudden performance degradation e.g. of the Outline View update.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=410346 Fix proliferation of item-provider adapters on model elements due to CompositeAdapterFactories being repeatedly created but never disposed.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java40
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java28
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java19
-rw-r--r--plugins/facet/org.eclipse.papyrus.emf.facet.widgets/src/org/eclipse/papyrus/emf/facet/widgets/internal/CustomizableLabelProvider.java16
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java21
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java18
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java16
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java17
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java9
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/util/LabelHelper.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java16
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ProviderUtil.java15
12 files changed, 176 insertions, 58 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
index 232c67c5999..5c9a88c06d8 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/ImageQuery.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2011, 2012 Mia-Software.
+ * Copyright (c) 2011, 2014 Mia-Software, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,6 +11,7 @@
* Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
* Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
* Gregoire Dupe (Mia-Software) - Bug 424122 - [Table] Images, fonts and colors are not shared between the instances of table
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
@@ -19,10 +20,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.ETypedElement;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.ComposedImage;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.Activator;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.ImageProvider;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.custompt.ImageWrapper;
import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
@@ -31,9 +30,6 @@ import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribu
import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
import org.eclipse.papyrus.emf.facet.query.java.core.IJavaQuery2;
import org.eclipse.papyrus.emf.facet.query.java.core.IParameterValueList2;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProvider;
-import org.eclipse.papyrus.emf.facet.util.swt.imageprovider.IImageProviderFactory;
-import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.emf.facet.custom.metamodel.custompt.IImage;
import org.eclipse.swt.graphics.Image;
@@ -61,21 +57,25 @@ public class ImageQuery implements IJavaQuery2<EObject, IImage> {
IImage result = null;
final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
- .adapt(source, IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- Object imageObject = itemLabelProvider.getImage(source);
- Image image = ExtendedImageRegistry.getInstance().getImage(imageObject);
- result = new ImageWrapper(image);
-//// final ImageDescriptor imgDescriptor = ExtendedImageRegistry
-//// .getInstance().getImageDescriptor(source);
-// final IImageProvider imgProvider = IImageProviderFactory.DEFAULT
-// .createIImageProvider(Activator.getDefault());
-// if (imgDescriptor != null) {
-// final Image image = imgProvider.getImage(imgDescriptor);
-// result = new ImageWrapper(image);
-// }
+
+ try {
+ final IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(source, IItemLabelProvider.class);
+ if(itemLabelProvider != null) {
+ Object imageObject = itemLabelProvider.getImage(source);
+ Image image = ExtendedImageRegistry.getInstance().getImage(imageObject);
+ result = new ImageWrapper(image);
+//// final ImageDescriptor imgDescriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(source);
+// final IImageProvider imgProvider = IImageProviderFactory.DEFAULT.createIImageProvider(Activator.getDefault());
+// if(imgDescriptor != null) {
+// final Image image = imgProvider.getImage(imgDescriptor);
+// result = new ImageWrapper(image);
+// }
+ }
+ } finally {
+ // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused
+ adapterFactory.dispose();
}
+
return result;
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
index 0d0d0130c20..8e5e5b7d05a 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.ui/src/org/eclipse/papyrus/emf/facet/custom/ui/internal/query/LabelQuery.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2011 Mia-Software.
+ * Copyright (c) 2011, 2014 Mia-Software, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -12,6 +12,7 @@
* Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
* Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
* Nicolas Bros (Mia-Software) - Bug 379683 - customizable Tree content provider
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.emf.facet.custom.ui.internal.query;
@@ -47,16 +48,21 @@ public class LabelQuery implements IJavaQuery2<EObject, String> {
if (sfParam == null) {
final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final IItemLabelProvider itemLabelProvider = (IItemLabelProvider) adapterFactory
- .adapt(source, IItemLabelProvider.class);
- // We don't want to use a ReflectiveItemProvider because it provides
- // a string prefixed with the eObject's meta-class name.
- if (itemLabelProvider instanceof ReflectiveItemProvider) {
- result = LabelQuery.getDefaultName(source);
- } else if (itemLabelProvider == null) {
- result = ModelUtils.getDefaultName(source);
- } else {
- result = itemLabelProvider.getText(source);
+
+ try {
+ final IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(source, IItemLabelProvider.class);
+ // We don't want to use a ReflectiveItemProvider because it provides
+ // a string prefixed with the eObject's meta-class name.
+ if(itemLabelProvider instanceof ReflectiveItemProvider) {
+ result = LabelQuery.getDefaultName(source);
+ } else if(itemLabelProvider == null) {
+ result = ModelUtils.getDefaultName(source);
+ } else {
+ result = itemLabelProvider.getText(source);
+ }
+ } finally {
+ // Dispose the adapter factory because it added an adapter that would leak, as nobody else will ever use it
+ adapterFactory.dispose();
}
} else {
try {
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java
index 51087d4e391..023da74e765 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.util.emf.core/src/org/eclipse/papyrus/emf/facet/util/emf/core/ModelUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010, 2012 Mia-Software.
+ * Copyright (c) 2009, 2014 Mia-Software, CEA, 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
@@ -12,6 +12,8 @@
* Gregoire Dupe (Mia-Software) - Bug 371367 - Hierarchical FacetSets
* Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
* Gregoire Dupe (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
+ * Christian W. Damus (CEA) - bug 410346
+ *
*******************************************************************************/
package org.eclipse.papyrus.emf.facet.util.emf.core;
@@ -162,11 +164,18 @@ public final class ModelUtils {
*/
//Copied from org.eclipse.papyrus.emf.facet.infra.common.core.internal.utils.ModelUtils.getName(EObject)
public static String getName(final EObject eObject) {
- IItemLabelProvider itemLabelProvider = (IItemLabelProvider) new ComposedAdapterFactory(
- ComposedAdapterFactory.Descriptor.Registry.INSTANCE).adapt(eObject, IItemLabelProvider.class);
- if (itemLabelProvider != null) {
- return itemLabelProvider.getText(eObject);
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ try {
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProvider.class);
+ if(itemLabelProvider != null) {
+ return itemLabelProvider.getText(eObject);
+ }
+ } finally {
+ // Dispose the adapter factory because it added an adapter that would leak, as it will never be reused
+ adapterFactory.dispose();
}
+
return ModelUtils.getDefaultName(eObject);
}
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.widgets/src/org/eclipse/papyrus/emf/facet/widgets/internal/CustomizableLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.widgets/src/org/eclipse/papyrus/emf/facet/widgets/internal/CustomizableLabelProvider.java
index 77b942396af..edd2ff8f2cf 100644
--- a/plugins/facet/org.eclipse.papyrus.emf.facet.widgets/src/org/eclipse/papyrus/emf/facet/widgets/internal/CustomizableLabelProvider.java
+++ b/plugins/facet/org.eclipse.papyrus.emf.facet.widgets/src/org/eclipse/papyrus/emf/facet/widgets/internal/CustomizableLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 Mia-Software.
+ * Copyright (c) 2010, 2014 Mia-Software, CEA, 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
@@ -9,6 +9,8 @@
* Nicolas Bros (Mia-Software) - initial API and implementation
* Nicolas Bros (Mia-Software) - Bug 339653 - org.eclipse.papyrus.emf.facet.widgets API Cleaning
* Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
+ * Christian W. Damus (CEA) - bug 410346
+ *
*******************************************************************************/
package org.eclipse.papyrus.emf.facet.widgets.internal;
@@ -49,6 +51,18 @@ public class CustomizableLabelProvider extends LabelProvider {
}
@Override
+ public void dispose() {
+ try {
+ // Because we created this adapter factory, ourselves, we must dispose it, as it may have created
+ // adapters that are redundant with other adapters still attached to the model and nobody else will
+ // be using our adapters (they are only recognized by the factory that created them)
+ adapterFactoryWithRegistry.dispose();
+ } finally {
+ super.dispose();
+ }
+ }
+
+ @Override
public String getText(final Object element) {
if (element instanceof EReference) {
EReference eReference = (EReference) element;
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
index e1d193baa2a..6f07621e710 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/editor/CoreMultiDiagramEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2008, 2013 CEA LIST.
+ * Copyright (c) 2008, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
* Christian W. Damus (CEA) - manage models by URI, not IFile (CDO)
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
@@ -28,6 +29,7 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
@@ -65,6 +67,7 @@ import org.eclipse.papyrus.infra.core.services.ServiceStartKind;
import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
import org.eclipse.papyrus.infra.core.services.internal.EditorLifecycleManagerImpl;
import org.eclipse.papyrus.infra.core.services.internal.InternalEditorLifecycleManager;
+import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorActionBarContributor;
@@ -529,8 +532,22 @@ public class CoreMultiDiagramEditor extends AbstractMultiPageSashEditor implemen
// register a basic label provider
// adapter factory used by EMF objects
- AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ AdapterFactory factory = null;
+ try {
+ EditingDomain domain = ServiceUtils.getInstance().getTransactionalEditingDomain(servicesRegistry);
+ if(domain instanceof AdapterFactoryEditingDomain) {
+ // Use the adapter factory already provided by this editing domain
+ factory = ((AdapterFactoryEditingDomain)domain).getAdapterFactory();
+ }
+ } catch (ServiceException e) {
+ // OK, there's no editing domain. That's fine
+ }
+ if(factory == null) {
+ // Must create a new adapter factory
+ factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ }
+
/** label provider for EMF objects */
ILabelProvider labelProvider = new AdapterFactoryLabelProvider(factory) {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
index c875500d8fd..ced8e99148f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
+ * Copyright (c) 2012, 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.providers.strategy;
@@ -23,8 +25,8 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationManager;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedTreeContentProvider;
import org.eclipse.papyrus.infra.emf.Activator;
import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
@@ -90,6 +92,18 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, ResourceSet root) {
this(editedEObject, feature, getRoots(root));
}
+
+ @Override
+ public void dispose() {
+ try {
+ // Because we created this adapter factory, we must dispose it
+ if(factory instanceof IDisposable) {
+ ((IDisposable)factory).dispose();
+ }
+ } finally {
+ super.dispose();
+ }
+ }
protected static EObject[] getRoots(ResourceSet root) {
List<EObject> roots = new LinkedList<EObject>();
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
index 437e8de24d1..ffdb29e723f 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.outline/src/org/eclipse/papyrus/infra/gmfdiag/outline/DiagramNavigator.java
@@ -1,5 +1,5 @@
/***********************************************************************
- * Copyright (c) 2007, 2008, 2009 Anyware Technologies, Obeo.
+ * Copyright (c) 2007, 2014 Anyware Technologies, Obeo, CEA, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* Anyware Technologies - initial API and implementation
* Obeo
+ * Christian W. Damus (CEA) - bug 410346
*
**********************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.outline;
@@ -20,6 +21,7 @@ import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IViewerNotification;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
@@ -155,7 +157,17 @@ public class DiagramNavigator extends Composite {
* Set the tree providers for the outline
*/
protected void initProviders() {
- AdapterFactoryContentProvider adapterContentProvider = new NavigatorAdapterFactoryContentProvider(getAdapterFactory());
+ final AdapterFactory adapterFactory = getAdapterFactory();
+ AdapterFactoryContentProvider adapterContentProvider = new NavigatorAdapterFactoryContentProvider(adapterFactory) {
+ @Override
+ public void dispose() {
+ // Dispose the adapter factory because we created it
+ if(adapterFactory instanceof IDisposable) {
+ ((IDisposable)adapterFactory).dispose();
+ }
+ super.dispose();
+ }
+ };
adapterContentProvider.inputChanged(viewer, null, null);
viewer.setContentProvider(new DiagramOrientedContentProvider(adapterContentProvider));
try {
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
index 79aa3d7ed94..45fb62f2e4f 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
+ * Copyright (c) 2011, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -22,6 +23,7 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -45,6 +47,8 @@ import org.eclipse.papyrus.infra.hyperlink.Activator;
import org.eclipse.papyrus.infra.hyperlink.util.EditorListContentProvider;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -384,6 +388,17 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
}
});
+ // dispose the adapter factory when the shell is closed
+ getLookforShell().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ // we created the adapter factory, so we should dispose it
+ if(adapterFactory instanceof IDisposable) {
+ ((IDisposable)adapterFactory).dispose();
+ }
+ }
+ });
+
}
/**
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java
index 877ba90940e..59e96bb777c 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/handlers/ControlCommandHandler.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2013 Atos, CEA LIST, and others.
+ * Copyright (c) 2013, 2014 Atos, CEA LIST, and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -10,6 +10,7 @@
* Contributors:
* Arthur Daussy (Atos) arthur.daussy@atos.net - Initial API and implementation
* Christian W. Damus (CEA LIST) - pluggable providers of fragment-resource selection dialogs
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.infra.services.controlmode.handlers;
@@ -92,9 +93,9 @@ public class ControlCommandHandler extends AbstractModelExplorerHandler {
}
}
if(defaultName == null) {
- LabelHelper.getPrettyLabel(eObject);
- Pattern p = Pattern.compile("<<.*>>");
- defaultName = p.matcher(defaultName).replaceAll("");
+ defaultName = LabelHelper.getPrettyLabel(eObject);
+ Pattern p = Pattern.compile("<<.*?>>|<.*?>");
+ defaultName = p.matcher(defaultName).replaceAll("").trim();
}
StringBuilder b = new StringBuilder();
for(Character c : defaultName.toCharArray()) {
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/util/LabelHelper.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/util/LabelHelper.java
index 3af4a8c6c90..3e6a7948d71 100644
--- a/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/util/LabelHelper.java
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.controlmode/src/org/eclipse/papyrus/infra/services/controlmode/util/LabelHelper.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Atos.
+ * Copyright (c) 2013, 2014 Atos, CEA, 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
@@ -7,6 +7,8 @@
*
* Contributors:
* Arthur Daussy <a href="mailto:arthur.daussy@atos.net"> - initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ *
******************************************************************************/
package org.eclipse.papyrus.infra.services.controlmode.util;
@@ -21,8 +23,6 @@ import org.eclipse.emf.edit.provider.IItemLabelProvider;
*/
public class LabelHelper {
- protected static ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
-
/**
* Return an user understandable label for an {@link EObject}
*
@@ -30,10 +30,17 @@ public class LabelHelper {
* @return
*/
public static String getPrettyLabel(EObject eObject) {
- IItemLabelProvider itemLavelProvider = (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProvider.class);
- if(itemLavelProvider != null) {
- return itemLavelProvider.getText(eObject);
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ try {
+ IItemLabelProvider itemLabelProvider = (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProvider.class);
+ if(itemLabelProvider != null) {
+ return itemLabelProvider.getText(eObject);
+ }
+ } finally {
+ adapterFactory.dispose();
}
+
return "Error in getting correct label";
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java
index fc06e09acf2..cf41e0e929e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ConditionalElementListDialog.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 AtoS.
+ * Copyright (c) 2011, 2014 AtoS, CEA, 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:
* Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.palette.customaction.utils;
@@ -17,6 +19,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.papyrus.infra.core.modelsetquery.ModelSetQuery;
import org.eclipse.swt.widgets.Shell;
@@ -40,7 +43,16 @@ public class ConditionalElementListDialog<T extends EObject> extends ElementList
}
public ConditionalElementListDialog(Shell parent, Predicate<T> condition, Collection<T> elements) {
- super(parent, new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)));
+ super(parent, new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)) {
+ @Override
+ public void dispose() {
+ if(adapterFactory instanceof IDisposable) {
+ // We created this adapter factory, so we must dispose it
+ ((IDisposable)adapterFactory).dispose();
+ }
+ super.dispose();
+ }
+ });
setMultipleSelection(false);
List<T> result = Lists.newArrayList(Iterables.filter(elements, condition));
setTitle("Choose Elements");
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ProviderUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ProviderUtil.java
index 5f7f5b56950..da9c4b02bde 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ProviderUtil.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.palette.customaction/src/org/eclipse/papyrus/uml/diagram/common/palette/customaction/utils/ProviderUtil.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2011 AtoS.
+ * Copyright (c) 2011, 2014 AtoS, CEA, 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:
* Tristan FAURE (AtoS) tristan.faure@atos.net - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ *
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.common.palette.customaction.utils;
@@ -29,6 +31,15 @@ public class ProviderUtil {
*/
public static String getLabel (EObject eobject)
{
- return new ReflectiveItemProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE)).getText(eobject);
+ // FIXME: The reflective provider doesn't use the factory to get item labels. If that was intended, it will not work. This will only provide generic labels
+ ComposedAdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ ReflectiveItemProvider provider = new ReflectiveItemProvider(factory);
+ try {
+ return provider.getText(eobject);
+ } finally {
+ // We created these, so we must dispose them
+ provider.dispose();
+ factory.dispose();
+ }
}
}

Back to the top