Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java159
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java56
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorLookForEditorShell.java30
-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.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/ui/GroupNotifierLabelProvider.java18
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/utils/Utils.java25
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/ui/AbstractTemplateParameterConfigurationDialog.java7
-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
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ElementChooseDialog.java39
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/CollaborationRoleCreateCommand.java33
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/InformationFlowCreateCommand.java92
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/RoleBindingCreateCommand.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRootElementPage.java19
22 files changed, 443 insertions, 282 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.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java
index 32fe14d66de..7bd85f8a708 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.export/src/org/eclipse/papyrus/infra/export/ExportAllDiagrams.java
@@ -1,14 +1,15 @@
/*******************************************************************************
- * Copyright (c) 2007 Anyware Technologies. 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
+ * Copyright (c) 2007, 2014 Anyware Technologies, 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 http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors: Jacques Lescot (Anyware Technologies) - initial API and
- * implementation
+ * Contributors: Jacques Lescot (Anyware Technologies) - initial API and implementation
* Thibault Landre (Atos Origin) - refactor to extract the exportAllDiagram from ExportAllDiagramsAction
* Alexia Allanic (Atos Origin) - Add margin to not truncate images
* Anass Radouani (AtoS) - add use GMF exporting tool and remove manual extraction
+ * Christian W. Damus (CEA) - bug 431411
+ * Christian W. Damus (CEA) - bug 410346
*
******************************************************************************/
package org.eclipse.papyrus.infra.export;
@@ -24,6 +25,7 @@ import java.util.Map;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -51,8 +53,6 @@ import org.eclipse.emf.transaction.RollbackException;
import org.eclipse.emf.transaction.Transaction;
import org.eclipse.emf.transaction.TransactionalCommandStack;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.emf.transaction.TransactionalEditingDomain.Factory;
-import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.gmf.runtime.diagram.ui.image.ImageFileFormat;
@@ -63,6 +63,8 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.export.internal.Activator;
+import org.eclipse.papyrus.infra.onefile.model.IPapyrusFile;
+import org.eclipse.papyrus.infra.onefile.model.PapyrusModelHelper;
import org.eclipse.swt.SWTError;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbenchWindow;
@@ -162,70 +164,93 @@ public class ExportAllDiagrams {
newMonitor.subTask(Messages.ExportAllDiagrams_2);
if(file != null) {
final ResourceSetImpl resourceSet = new ResourceSetImpl();
- resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
- resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true);
- resourceSet.getResource(URI.createPlatformResourceURI(file.getFullPath().toString(), true), true);
-
- // create transactional editing domain
-
- TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resourceSet);
- if(editingDomain == null) {
- Factory factory = TransactionalEditingDomain.Factory.INSTANCE;
- editingDomain = factory.createEditingDomain(resourceSet);
- }
-
- AbstractTransactionalCommand com = new AbstractTransactionalCommand(editingDomain, "Resolve", Collections.emptyList()) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- EcoreUtil.resolveAll(resourceSet);
- return null;
+ TransactionalEditingDomain editingDomain = null;
+ try {
+ resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
+ resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true);
+
+ // Since the *.di file is empty as of Luna, we cannot rely on it to find all diagrams by resolving cross-references
+ IPapyrusFile logical = PapyrusModelHelper.getPapyrusModelFactory().createIPapyrusFile(file);
+ if(logical != null) {
+ for(IResource component : logical.getAssociatedResources()) {
+ if(component.getType() == IResource.FILE) {
+ resourceSet.getResource(URI.createPlatformResourceURI(component.getFullPath().toString(), true), true);
+ }
+ }
}
- };
-
- // bypass all the transaction/validate/notification mechanisms, it is a lot faster and it has no impact
- // since we do not modify the model
- CommandStack commandStack = editingDomain.getCommandStack();
- if(commandStack instanceof TransactionalCommandStack) {
- TransactionalCommandStack stack = (TransactionalCommandStack)commandStack;
- Map<Object, Object> options = new HashMap<Object, Object>();
- options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
- options.put(Transaction.OPTION_NO_UNDO, Boolean.TRUE);
- options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
- options.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, Boolean.FALSE);
- options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
- options.put(Transaction.OPTION_VALIDATE_EDIT, Boolean.FALSE);
- options.put(Transaction.OPTION_VALIDATE_EDIT_CONTEXT, Boolean.FALSE);
- try {
- stack.execute(new GMFtoEMFCommandWrapper(com), options);
- } catch (InterruptedException e) {
- } catch (RollbackException e) {
+
+ // create transactional editing domain
+ editingDomain = TransactionalEditingDomain.Factory.INSTANCE.createEditingDomain(resourceSet);
+
+ AbstractTransactionalCommand com = new AbstractTransactionalCommand(editingDomain, "Resolve", Collections.emptyList()) {
+
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ EcoreUtil.resolveAll(resourceSet);
+ return null;
+ }
+ };
+
+ // bypass all the transaction/validate/notification mechanisms, it is a lot faster and it has no impact
+ // since we do not modify the model
+ CommandStack commandStack = editingDomain.getCommandStack();
+ if(commandStack instanceof TransactionalCommandStack) {
+ TransactionalCommandStack stack = (TransactionalCommandStack)commandStack;
+ Map<Object, Object> options = new HashMap<Object, Object>();
+ options.put(Transaction.OPTION_NO_NOTIFICATIONS, Boolean.TRUE);
+ options.put(Transaction.OPTION_NO_UNDO, Boolean.TRUE);
+ options.put(Transaction.OPTION_UNPROTECTED, Boolean.TRUE);
+ options.put(Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, Boolean.FALSE);
+ options.put(Transaction.OPTION_NO_TRIGGERS, Boolean.TRUE);
+ options.put(Transaction.OPTION_VALIDATE_EDIT, Boolean.FALSE);
+ options.put(Transaction.OPTION_VALIDATE_EDIT_CONTEXT, Boolean.FALSE);
+ try {
+ stack.execute(new GMFtoEMFCommandWrapper(com), options);
+ } catch (InterruptedException e) {
+ } catch (RollbackException e) {
+ }
+ } else {
+ Activator.log.warn("no transactional editing domain found");
}
- } else {
- Activator.log.warn("no transactional editing domain found");
- }
-
- List<Diagram> diagrams = new ArrayList<Diagram>();
- if(newMonitor.isCanceled()) {
- return;
- }
- for(Iterator<Notifier> i = resourceSet.getAllContents(); i.hasNext();) {
- Notifier n = i.next();
- if(n instanceof Diagram) {
- diagrams.add((Diagram)n);
+
+ List<Diagram> diagrams = new ArrayList<Diagram>();
+ if(newMonitor.isCanceled()) {
+ return;
+ }
+ for(Iterator<Notifier> i = resourceSet.getAllContents(); i.hasNext();) {
+ Notifier n = i.next();
+ if(n instanceof Diagram) {
+ diagrams.add((Diagram)n);
+ }
+ }
+ if(newMonitor.isCanceled()) {
+ return;
+ }
+ newMonitor.worked(1);
+ export(new SubProgressMonitor(newMonitor, 9), diagrams);
+ } finally {
+ // Unload the resource set so that we don't leak loads of UML content in the CacheAdapter
+ unload(resourceSet);
+ if(editingDomain != null) {
+ editingDomain.dispose();
}
}
- if(newMonitor.isCanceled()) {
- return;
- }
- newMonitor.worked(1);
- export(new SubProgressMonitor(newMonitor, 9), diagrams);
} else {
Activator.log.warn(Messages.ExportAllDiagrams_3);
}
}
+ private void unload(ResourceSet resourceSet) {
+ for (Resource next : resourceSet.getResources()) {
+ next.unload();
+ next.eAdapters().clear();
+ }
+
+ resourceSet.getResources().clear();
+ resourceSet.eAdapters().clear();
+ }
+
/**
* export all the diagrams in image
*
@@ -305,8 +330,14 @@ public class ExportAllDiagrams {
if(qualifiedName) {
ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
composedAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
- IItemLabelProvider itemLabelFactory = (IItemLabelProvider)composedAdapterFactory.adapt(diagram.getElement(), IItemLabelProvider.class);
- label = itemLabelFactory.getText(diagram.getElement()).replace(Messages.ExportAllDiagrams_16, "") + "_"; //$NON-NLS-1$//$NON-NLS-2$
+
+ try {
+ IItemLabelProvider itemLabelFactory = (IItemLabelProvider)composedAdapterFactory.adapt(diagram.getElement(), IItemLabelProvider.class);
+ label = itemLabelFactory.getText(diagram.getElement()).replace(Messages.ExportAllDiagrams_16, "") + "_"; //$NON-NLS-1$//$NON-NLS-2$
+ } finally {
+ // Don't leak the adapters created by this factory
+ composedAdapterFactory.dispose();
+ }
}
String uniqueFileName = encodeFileName(label + diagram.getName());
if(uniqueFileName.length() > 150) {
diff --git a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java
index a5dd2ebf566..184e6a23a7c 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.hyperlink/src/org/eclipse/papyrus/infra/hyperlink/ui/EditorHyperLinkEditorShell.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 431397
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
@@ -26,8 +27,8 @@ import org.eclipse.papyrus.infra.hyperlink.helper.EditorHyperLinkHelper;
import org.eclipse.papyrus.infra.hyperlink.messages.Messages;
import org.eclipse.papyrus.infra.hyperlink.object.HyperLinkEditor;
import org.eclipse.papyrus.infra.services.labelprovider.service.LabelProviderService;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Display;
/**
@@ -89,9 +90,9 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
getTooltipInputText().setText(getObjectLabeltext().getText());
}
// add listener "use default button"
- getUseDefaultCheckBox().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
+ getUseDefaultCheckBox().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
usedefaultTooltip = getUseDefaultCheckBox().getSelection();
if(usedefaultTooltip) {
getTooltipInputText().setEditable(false);
@@ -100,21 +101,12 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
getTooltipInputText().setEditable(true);
}
}
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
// launch a new editor to choose or create diagrams
- getChooseDiagramButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
+ getChooseDiagramButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
EditorLookForEditorShell editorLookForDiagram = new EditorLookForEditorShell(editorRegistry, amodel);
editorLookForDiagram.open();
Object selection = editorLookForDiagram.getSelectedEditor();
@@ -141,33 +133,20 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
}
}
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
// listener to cancel
- this.getCancelButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
+ this.getCancelButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
hyperLinkEditor = null;
getEditHyperlinkShell().close();
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
// listener to click on OK
- this.getOkButton().addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
-
+ this.getOkButton().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
if(hyperLinkEditor != null) {
hyperLinkEditor.setTooltipText(getTooltipInputText().getText().trim());
// if diagram is null, maybe bad selection or other it
@@ -178,9 +157,6 @@ public class EditorHyperLinkEditorShell extends AbstractEditHyperlinkDocumentShe
}
getEditHyperlinkShell().close();
}
-
- public void mouseDoubleClick(MouseEvent e) {
- }
});
}
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..69616e81bbe 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,19 +9,24 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ * Christian W. Damus (CEA) - bug 431397
*
*****************************************************************************/
package org.eclipse.papyrus.infra.hyperlink.ui;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
+import java.util.Set;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
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 +50,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;
@@ -234,7 +241,7 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
// SemanticEMFContentProvider(amodel)); //This content provider will
// only display the selected element, instead of the root element
// FIXME: Use a standard, non-deprecated content
- treeViewer.setContentProvider(new SemanticEMFContentProvider() {
+ treeViewer.setContentProvider(new SemanticEMFContentProvider(null, null, new EObject[] {EcoreUtil.getRootContainer(amodel)}) {
@Override
public boolean hasChildren(Object element) {
@@ -252,12 +259,12 @@ public class EditorLookForEditorShell extends AbstractLookForEditorShell {
//TODO the best correction we be able to manage applied facet, because if we get diagram twice it is probably because there are 2 facets with the same behavior applied
@Override
public Object[] getChildren(Object parentElement) {
- List<Object> alreadyVisited = new ArrayList<Object>();
+ Set<Object> alreadyVisited = new HashSet<Object>();
List<Object> returnedChildren = new ArrayList<Object>();
Object[] children = super.getChildren(parentElement);
for(Object current : children) {
- if(current instanceof IAdaptable) {
- EObject el = EMFHelper.getEObject(current);
+ EObject el = EMFHelper.getEObject(current);
+ if(el != null) {
if(!alreadyVisited.contains(el)) {
returnedChildren.add(current);
alreadyVisited.add(el);
@@ -384,6 +391,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.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/ui/GroupNotifierLabelProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/ui/GroupNotifierLabelProvider.java
index 9f11cf849f6..04eacfd72b9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/ui/GroupNotifierLabelProvider.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/ui/GroupNotifierLabelProvider.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
@@ -10,6 +10,7 @@
* Contributors:
* Arthur Daussy (Atos) - Initial API and implementation
* Arthur Daussy - 371712 : 372745: [ActivityDiagram] Major refactoring group framework
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.activitygroup.ui;
@@ -25,13 +26,14 @@ import org.eclipse.swt.graphics.Image;
*/
public class GroupNotifierLabelProvider extends LabelProvider {
- static AdapterFactoryLabelProvider factory = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
+ private ComposedAdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ private AdapterFactoryLabelProvider delegate = new AdapterFactoryLabelProvider(factory);
@Override
public String getText(Object element) {
if(element instanceof IGroupNotifier) {
IGroupNotifier notifier = (IGroupNotifier)element;
- return factory.getText(notifier.getEObject());
+ return delegate.getText(notifier.getEObject());
}
return super.getText(element);
}
@@ -40,8 +42,16 @@ public class GroupNotifierLabelProvider extends LabelProvider {
public Image getImage(Object element) {
if(element instanceof IGroupNotifier) {
IGroupNotifier notifier = (IGroupNotifier)element;
- return factory.getImage(notifier.getEObject());
+ return delegate.getImage(notifier.getEObject());
}
return super.getImage(element);
}
+
+ @Override
+ public void dispose() {
+ delegate.dispose();
+ factory.dispose();
+
+ super.dispose();
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/utils/Utils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/utils/Utils.java
index b38517b9826..31c72b85ba8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/utils/Utils.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/activitygroup/utils/Utils.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
@@ -10,6 +10,7 @@
* Contributors:
* Arthur Daussy (Atos) - Initial API and implementation
* Arthur Daussy - 371712 : 372745: [ActivityDiagram] Major refactoring group framework
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.activity.activitygroup.utils;
@@ -25,8 +26,6 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.ChangeBoundsRequest;
@@ -37,8 +36,7 @@ import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.papyrus.uml.diagram.activity.activitygroup.predicates.DescendantsFilter;
import org.eclipse.papyrus.uml.diagram.activity.activitygroup.request.IGroupRequest;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.edit.providers.UMLItemProviderAdapterFactory;
+import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
@@ -176,27 +174,16 @@ public class Utils {
return Sets.filter(all, new DescendantsFilter(all));
}
- private static UMLItemProviderAdapterFactory adapter = new UMLItemProviderAdapterFactory();
-
- static AdapterFactoryLabelProvider factory = new AdapterFactoryLabelProvider(new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE));
+ static AdapterFactoryLabelProvider factory = new AdapterFactoryLabelProvider(UMLDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
public static String getCorrectLabel(Object object) {
if(object instanceof EObject) {
- if(object instanceof Element) {
- Object provider = adapter.adapt(object, IItemLabelProvider.class);
- if(provider instanceof IItemLabelProvider) {
- IItemLabelProvider labelProvider = (IItemLabelProvider)provider;
- return labelProvider.getText(object);
- }
- } else {
- return factory.getText(object);
- }
+ return factory.getText(object);
} else if(object instanceof EReference) {
return ((EReference)object).getName();
} else {
- return object.toString();
+ return String.valueOf(object); // null safe
}
- return "Error in getting name";////$NON-NLS-1$
}
public static String getCorrectLabel(IAdaptable object) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/ui/AbstractTemplateParameterConfigurationDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/ui/AbstractTemplateParameterConfigurationDialog.java
index 617b1c188b4..6262acadf59 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/ui/AbstractTemplateParameterConfigurationDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.clazz/custom-src/org/eclipse/papyrus/uml/diagram/clazz/custom/ui/AbstractTemplateParameterConfigurationDialog.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.uml.diagram.clazz.custom.ui;
@@ -126,7 +127,7 @@ public class AbstractTemplateParameterConfigurationDialog extends Dialog {
public void widgetSelected(SelectionEvent e) {
}
});
- choosePararameteredElementButton.setImage(Activator.getPluginIconImage("org.eclipse.papyrus.icons.uml", "resource/gif/Package.gif"));
+ choosePararameteredElementButton.setImage(Activator.getPluginIconImage("org.eclipse.papyrus.uml.icons", "resource/gif/Package.gif"));
choosePararameteredElementButton.setBounds(322, 10, 68, 23);
choosePararameteredElementButton.setText("...");
parameteredElementLabel = new CLabel(composite_1, SWT.NONE);
@@ -150,7 +151,7 @@ public class AbstractTemplateParameterConfigurationDialog extends Dialog {
composite.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
xpndtmSetTheDefault.setControl(composite);
chooseDefaultParameterButton = new Button(composite, SWT.NONE);
- chooseDefaultParameterButton.setImage(Activator.getPluginIconImage("org.eclipse.papyrus.icons.uml", "resource/gif/Package.gif"));
+ chooseDefaultParameterButton.setImage(Activator.getPluginIconImage("org.eclipse.papyrus.uml.icons", "resource/gif/Package.gif"));
chooseDefaultParameterButton.setBounds(322, 10, 68, 23);
chooseDefaultParameterButton.setText("...");
defaultElementLabel = new CLabel(composite, SWT.NONE);
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();
+ }
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ElementChooseDialog.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ElementChooseDialog.java
index cb4f17e5a61..83b2810f4af 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ElementChooseDialog.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/ui/dialogs/ElementChooseDialog.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
+ * Copyright (c) 2010, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*/
package org.eclipse.papyrus.uml.diagram.common.ui.dialogs;
@@ -20,6 +21,7 @@ import org.eclipse.emf.common.notify.AdapterFactory;
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.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -28,8 +30,10 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
+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.widgets.Shell;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.ParameterableElement;
@@ -161,26 +165,31 @@ public class ElementChooseDialog extends AbstractChooseElement {
}
});
- btnSelect.addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
+ btnSelect.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
getParent().close();
}
-
- public void mouseDown(MouseEvent e) {}
- public void mouseDoubleClick(MouseEvent e) {}
});
- btnCancel.addMouseListener(new MouseListener() {
-
- public void mouseUp(MouseEvent e) {
+ btnCancel.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
result=null;
selectedElement=null;
getParent().close();
}
-
- public void mouseDown(MouseEvent e) {}
- public void mouseDoubleClick(MouseEvent e) {}
+ });
+
+ getParent().addDisposeListener(new DisposeListener() {
+
+ @Override
+ public void widgetDisposed(DisposeEvent e) {
+ // Remove the adapters created by this factory
+ if(adapterFactory instanceof IDisposable) {
+ ((IDisposable)adapterFactory).dispose();
+ }
+ }
});
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/CollaborationRoleCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/CollaborationRoleCreateCommand.java
index 65abb920576..b89c3de008c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/CollaborationRoleCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/CollaborationRoleCreateCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
+ * Copyright (c) 2009, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.composite.custom.edit.command;
@@ -16,7 +17,6 @@ package org.eclipse.papyrus.uml.diagram.composite.custom.edit.command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-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.ui.provider.AdapterFactoryContentProvider;
@@ -24,7 +24,6 @@ import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
import org.eclipse.gmf.runtime.common.core.command.CommandResult;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.composite.custom.messages.Messages;
import org.eclipse.papyrus.uml.diagram.composite.custom.ui.CollaborationRoleValidator;
import org.eclipse.papyrus.uml.diagram.composite.edit.commands.CollaborationRoleCreateCommandCN;
@@ -95,22 +94,26 @@ public class CollaborationRoleCreateCommand extends CollaborationRoleCreateComma
Collaboration owner = (Collaboration)getElementToEdit();
// Create and open the selection dialog
- AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
Shell currentShell = new Shell(Display.getCurrent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(currentShell, new AdapterFactoryLabelProvider(adapterFactory), new AdapterFactoryContentProvider(adapterFactory));
- // Set dialog parameters
- dialog.setTitle(Messages.CollaborationRoleSelectionDialog_Title);
- dialog.setMessage(Messages.CollaborationRoleSelectionDialog_Message);
- dialog.setAllowMultiple(false);
- dialog.setHelpAvailable(false);
- // ConnectableElement from the whole model can be selected as role.
- dialog.setInput(owner.getModel());
- // CollaborationRoleValidator ensures that an the selected element is a ConnectableElement.
- dialog.setValidator(new CollaborationRoleValidator());
-
- dialog.open();
+ try {
+ // Set dialog parameters
+ dialog.setTitle(Messages.CollaborationRoleSelectionDialog_Title);
+ dialog.setMessage(Messages.CollaborationRoleSelectionDialog_Message);
+ dialog.setAllowMultiple(false);
+ dialog.setHelpAvailable(false);
+ // ConnectableElement from the whole model can be selected as role.
+ dialog.setInput(owner.getModel());
+ // CollaborationRoleValidator ensures that an the selected element is a ConnectableElement.
+ dialog.setValidator(new CollaborationRoleValidator());
+ dialog.open();
+ } finally {
+ adapterFactory.dispose();
+ }
+
// If a ConnectableElement has been selected, complete command execution
// using selection as the "newly created" element and make the edited
// Collaboration reference it in the CollaborationRoles eReference.
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/InformationFlowCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/InformationFlowCreateCommand.java
index cd94d49e2d1..768cc8b4267 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/InformationFlowCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/InformationFlowCreateCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
+ * Copyright (c) 2009, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.composite.custom.edit.command;
@@ -18,7 +19,6 @@ import java.util.ArrayList;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-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.ui.provider.AdapterFactoryContentProvider;
@@ -74,52 +74,56 @@ public class InformationFlowCreateCommand extends org.eclipse.papyrus.uml.diagra
protected CommandResult doExecuteWithResult(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
// Create and open the selection dialog
- AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
Shell currentShell = new Shell(Display.getCurrent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
InformationItemElementTreeSelectionDialog dialog = new InformationItemElementTreeSelectionDialog(currentShell, new AdapterFactoryLabelProvider(adapterFactory), new AdapterFactoryContentProvider(adapterFactory));
- // Set dialog parameters
- dialog.setTitle(Messages.InformationFlowSelectionDialog_Title);
- dialog.setMessage(Messages.InformationFlowSelectionDialog_Message);
- dialog.setAllowMultiple(true);
- dialog.setHelpAvailable(false);
- dialog.setInput(getSource().getModel());
- dialog.setValidator(new InformationItemValidator());
-
- ArrayList<Classifier> initialSelection = new ArrayList<Classifier>();
-
- // here the dialog.getReturnCode is IDialogConstants.OK_ID
- while(dialog.open() != IDialogConstants.CANCEL_ID) {
-
- /*
- * If classifiers have been selected, complete command execution and write the selection
- * in the conveyed:Classifief Association
- */
- if(dialog.getReturnCode() == ElementTreeSelectionDialog.OK) {
- Object[] conveyedClassified = dialog.getResult();
-
- InformationFlow newInformationFlow = UMLFactory.eINSTANCE.createInformationFlow();
- getContainer().getPackagedElements().add(newInformationFlow);
- newInformationFlow.getInformationSources().add(getSource());
- newInformationFlow.getInformationTargets().add(getTarget());
-
- // add the classifier in the list of conveyed Classifier
- for(int i = 0; i < conveyedClassified.length; i++) {
- newInformationFlow.getConveyeds().add((Classifier)conveyedClassified[i]);
+ try {
+ // Set dialog parameters
+ dialog.setTitle(Messages.InformationFlowSelectionDialog_Title);
+ dialog.setMessage(Messages.InformationFlowSelectionDialog_Message);
+ dialog.setAllowMultiple(true);
+ dialog.setHelpAvailable(false);
+ dialog.setInput(getSource().getModel());
+ dialog.setValidator(new InformationItemValidator());
+
+ ArrayList<Classifier> initialSelection = new ArrayList<Classifier>();
+
+ // here the dialog.getReturnCode is IDialogConstants.OK_ID
+ while(dialog.open() != IDialogConstants.CANCEL_ID) {
+
+ /*
+ * If classifiers have been selected, complete command execution and write the selection
+ * in the conveyed:Classifief Association
+ */
+ if(dialog.getReturnCode() == ElementTreeSelectionDialog.OK) {
+ Object[] conveyedClassified = dialog.getResult();
+
+ InformationFlow newInformationFlow = UMLFactory.eINSTANCE.createInformationFlow();
+ getContainer().getPackagedElements().add(newInformationFlow);
+ newInformationFlow.getInformationSources().add(getSource());
+ newInformationFlow.getInformationTargets().add(getTarget());
+
+ // add the classifier in the list of conveyed Classifier
+ for(int i = 0; i < conveyedClassified.length; i++) {
+ newInformationFlow.getConveyeds().add((Classifier)conveyedClassified[i]);
+ }
+
+ ElementInitializers.getInstance().init_InformationFlow_4021(newInformationFlow);
+
+ ((CreateElementRequest)getRequest()).setNewElement(newInformationFlow);
+ return CommandResult.newOKCommandResult(newInformationFlow);
+
+ } else if(dialog.getReturnCode() == InformationItemElementTreeSelectionDialog.newInformationItemButton_ID) {
+ // create a new InformationItem
+ initialSelection.add((Classifier)createNewInformationItem());
+ dialog.setInitialElementSelections(initialSelection);
}
-
- ElementInitializers.getInstance().init_InformationFlow_4021(newInformationFlow);
-
- ((CreateElementRequest)getRequest()).setNewElement(newInformationFlow);
- return CommandResult.newOKCommandResult(newInformationFlow);
-
- } else if(dialog.getReturnCode() == InformationItemElementTreeSelectionDialog.newInformationItemButton_ID) {
- // create a new InformationItem
- initialSelection.add((Classifier)createNewInformationItem());
- dialog.setInitialElementSelections(initialSelection);
- }
- }// end of while()
-
+ }// end of while()
+ } finally {
+ adapterFactory.dispose();
+ }
+
// No Classifier selected: abort element creation
return CommandResult.newCancelledCommandResult();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/RoleBindingCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/RoleBindingCreateCommand.java
index 82ed31b27d5..5ae344cf87f 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/RoleBindingCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/command/RoleBindingCreateCommand.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
+ * Copyright (c) 2009, 2014 CEA LIST and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -9,6 +9,7 @@
*
* Contributors:
* Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
*
*****************************************************************************/
package org.eclipse.papyrus.uml.diagram.composite.custom.edit.command;
@@ -16,7 +17,6 @@ package org.eclipse.papyrus.uml.diagram.composite.custom.edit.command;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
-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.ui.provider.AdapterFactoryLabelProvider;
@@ -78,21 +78,25 @@ public class RoleBindingCreateCommand extends org.eclipse.papyrus.uml.diagram.co
CollaborationUse graphicalSource = (CollaborationUse)getSource();
// Create and open the selection dialog
- AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
Shell currentShell = new Shell(Display.getCurrent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(currentShell, new AdapterFactoryLabelProvider(adapterFactory), new CollaborationRoleTreeContentProvider());
- // Set dialog parameters
- dialog.setTitle(Messages.RoleBindingRoleSelectionDialog_Title);
- dialog.setMessage(Messages.RoleBindingRoleSelectionDialog_Message);
- dialog.setAllowMultiple(false);
- dialog.setHelpAvailable(false);
- // The source CollaborationUse is set as input for the selection dialog,
- // the CollaborationRoleTreeContentProvider provides the roles that can possibly be
- // selected.
- dialog.setInput(graphicalSource);
+ try {
+ // Set dialog parameters
+ dialog.setTitle(Messages.RoleBindingRoleSelectionDialog_Title);
+ dialog.setMessage(Messages.RoleBindingRoleSelectionDialog_Message);
+ dialog.setAllowMultiple(false);
+ dialog.setHelpAvailable(false);
+ // The source CollaborationUse is set as input for the selection dialog,
+ // the CollaborationRoleTreeContentProvider provides the roles that can possibly be
+ // selected.
+ dialog.setInput(graphicalSource);
- dialog.open();
+ dialog.open();
+ } finally {
+ adapterFactory.dispose();
+ }
// If a ConnectableElement has been selected, complete command execution
// using selection as the "newly created" element and make the edited
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRootElementPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRootElementPage.java
index 540df8ed6cb..a8796595be8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRootElementPage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectRootElementPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Obeo.
+ * Copyright (c) 2008, 2014 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
* which accompanies this distribution, and is available at
@@ -7,6 +7,8 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Christian W. Damus (CEA) - bug 410346
+ *
*******************************************************************************/
package org.eclipse.papyrus.uml.diagram.wizards.pages;
@@ -25,6 +27,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IWrapperItemProvider;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
@@ -42,6 +45,8 @@ import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
import org.eclipse.papyrus.uml.diagram.wizards.Messages;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -127,7 +132,7 @@ public class SelectRootElementPage extends WizardPage {
layoutData.heightHint = 300;
layoutData.widthHint = 300;
modelViewer.getTree().setLayoutData(layoutData);
- AdapterFactory adapterFactory = createAdapterFactory();
+ final AdapterFactory adapterFactory = createAdapterFactory();
modelViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
modelViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
@@ -143,6 +148,16 @@ public class SelectRootElementPage extends WizardPage {
}
});
+ modelViewer.getControl().addDisposeListener(new DisposeListener() {
+
+ public void widgetDisposed(DisposeEvent e) {
+ // Dispose the adapter factory that we created to avoid leaking its adapters
+ if(adapterFactory instanceof IDisposable) {
+ ((IDisposable)adapterFactory).dispose();
+ }
+ }
+ });
+
setPageComplete(validatePage());
}

Back to the top