Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils')
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java56
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ConvertedValueContainer.java71
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java35
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java37
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java744
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java331
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java35
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java47
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/MultiConvertedValueContainer.java39
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java59
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java81
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java58
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java45
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java100
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java107
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java69
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java97
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java49
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java59
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/StringValueConverterStatus.java60
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java218
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java61
22 files changed, 0 insertions, 2458 deletions
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
deleted file mode 100644
index eb840db7f3b..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2008 CEA LIST.
- *
- *
- * 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.emf.utils;
-
-
-/**
- * This class allows to retrieve the business object from an object representing
- * a graphical artifact in a diagram. Each diagram can register its resolver
- * which will be added to the list of resolvers. Some common resolvers are
- * already registered : gef.EditPart TODO Use extensions to register additional
- * resolvers.
- */
-//Refactoring 0.10: This class has been moved from infra.core to infra.emf.
-//It should be re-implemented as a Service.
-public class BusinessModelResolver {
-
- /**
- * The unique instance
- */
- public static BusinessModelResolver instance = new BusinessModelResolver();
-
- public BusinessModelResolver() {
-
- }
-
- /**
- * Get the business object associated to this object, if any. This method
- * navigate throw the object if the object is an graphical artefact or a
- * diagram artifact.
- *
- * @param object
- * @return Object
- */
- public Object getBusinessModel(Object object) {
- return EMFHelper.getEObject(object);
- }
-
- /**
- * @return BusinessModelResolver
- */
- public static BusinessModelResolver getInstance() {
- return instance;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ConvertedValueContainer.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ConvertedValueContainer.java
deleted file mode 100644
index 4760ce6be06..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ConvertedValueContainer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-
-
-/**
- *
- * This class allows to store the value created for a pasted String AND a result status associated to this pasted String
- *
- * @param <T>
- */
-
-public class ConvertedValueContainer<T> {
-
- /**
- * this field is used when the pasted value is monovalued
- */
- private final T value;
-
- /**
- * the resulting status of the parsing
- */
- private final IStatus status;
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * a monovalued Value (can be <code>null</code>)
- * @param realListValue
- * a collection value (can be <code>null</code>)
- * @param status
- * a status (can be <code>null</code>)
- */
- public ConvertedValueContainer(final T realValue, final IStatus status) {
- this.value = realValue;
- this.status = status;
- Assert.isNotNull(status);
- }
-
-
-
- public final IStatus getStatus() {
- return this.status;
- }
-
- /**
- *
- * @return
- * the value
- */
- public final T getConvertedValue() {
- return this.value;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
deleted file mode 100644
index 0d559144ede..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * A class for comparing EClasses by name
- *
- * @author Camille Letavernier
- *
- */
-public class EClassNameComparator implements Comparator<EClass> {
-
- public int compare(EClass class1, EClass class2) {
- if(class1 == null) {
- return class2 == null ? 0 : -1;
- }
-
- return Collator.getInstance().compare(class1.getName(), class2.getName());
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
deleted file mode 100644
index 86c9f1d40d2..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-/**
- * Thyis class defines some useful constants for EMF
- *
- * @author vl222926
- *
- */
-public class EMFContants {
-
-
- private EMFContants() {
- //to prevent instanciation
- }
-
- public static final String ESTRING = "EString";
-
- public static final String EBOOLEAN = "EBoolean";
-
- public static final String EINT = "EInt";
-
- public static final String EDOUBLE = "EDouble";
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
deleted file mode 100644
index bdcc1864b2e..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010, 2013 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- * Christian W. Damus (CEA) - filter out EObjects that are Resources (CDO)
- * Christian W. Damus (CEA) - Support read-only state at object level (CDO)
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EStructuralFeature.Setting;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.facet.custom.ui.CustomizedContentProviderUtils;
-import org.eclipse.papyrus.infra.core.resource.IReadOnlyHandler;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtilsForActionHandlers;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.tools.util.PlatformHelper;
-
-/**
- * A Helper class for manipulating EMF Objects
- *
- * @author Camille Letavernier
- */
-//TODO : Check implementations. Most of them are old and don't always match the specification
-public class EMFHelper {
-
- /**
- * Returns the EClass corresponding to the given nsUri and className
- *
- * @param nsUri
- * The NSURI of the EClass' EPackage
- * @param className
- * The EClass' name
- * @return
- * The EClass instance, or null if the EClass couldn't be found
- */
- public static EClass getEClass(final String nsUri, final String className) {
- EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(nsUri);
- if(ePackage == null) {
- Activator.log.warn("Cannot find an EPackage matching the nsURI " + nsUri); //$NON-NLS-1$
- return null;
- }
- return getEClass(ePackage, className);
- }
-
- /**
- * Return the EClass corresponding to the given EPackage and className
- *
- * @param metamodel
- * The EClass' EPackage
- * @param className
- * The EClass' name
- * @return
- * The EClass instance, or null if the EClass couldn't be found
- */
- public static EClass getEClass(final EPackage metamodel, final String className) {
- EClassifier classifier = metamodel.getEClassifier(className);
- if(classifier == null) {
- Activator.log.warn("Classifier " + className + " not found in metamodel " + metamodel.getName() + " (" + metamodel.getNsURI() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- if(classifier instanceof EClass) {
- return (EClass)classifier;
- } else {
- Activator.log.warn("Classifier " + className + " in " + metamodel.getName() + " (" + metamodel.getNsURI() + ") is not an EClass"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- return null;
- }
-
- /**
- * Tests if an Object is an instance of the given EClass
- *
- * @param element
- * The EObject to test
- * @param className
- * The name of the EClass
- * @param metamodel
- * The EPackage owning the EClass
- * @return
- * True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
- */
- public static boolean isInstance(final EObject element, final String className, final EPackage metamodel) {
-
- EClassifier theClass = metamodel.getEClassifier(className);
-
- if(theClass == null) {
- Activator.log.warn("Class " + className + " not found in Metamodel : " + metamodel.getName() + " (" + metamodel.getNsURI() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return false;
- }
-
- return theClass.isInstance(element);
- }
-
- /**
- * Tests if the given eClass is a Subclass of fromClass
- * Also returns true when eClass == fromClass
- *
- * @param eClass
- * @param fromClass
- * @return
- * true if eClass is a subclass of fromClass
- */
- public static boolean isSubclass(final EClass eClass, final EClass fromClass) {
- //Everything is an EObject
- if(eClass != null && fromClass == EcorePackage.eINSTANCE.getEObject()) {
- return true;
- }
-
- if(eClass == fromClass) {
- return true;
- }
-
- List<EClass> superTypes = eClass.getEAllSuperTypes();
- if(superTypes.contains(fromClass)) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Returns the EObject corresponding to the input object
- * Tests if the input is an EObject, or if it is Adaptable
- * to an EObject
- *
- * @param source
- * @return An EObject corresponding to the input source, or null
- * if the EObject could not be resolved
- */
- public static EObject getEObject(final Object source) {
-
- //Support for EMF 0.2 CustomizedTree: The TreeElements are EObjects, and do not implement IAdatapble.
- //FIXME: Use an AdapterFactory instead, to remove the dependency to EMF Facet 0.2
- Object resolved = CustomizedContentProviderUtils.resolve(source);
- if(resolved != source && isEMFModelElement(resolved)) {
- return (EObject)resolved;
- }
-
- //General case
- if(isEMFModelElement(source)) {
- return (EObject)source;
- } else if(source instanceof IAdaptable) {
- EObject eObject = (EObject)((IAdaptable)source).getAdapter(EObject.class);
- if(eObject == null) { //EMF Facet 0.1
- eObject = (EObject)((IAdaptable)source).getAdapter(EReference.class);
- }
- return asEMFModelElement(eObject); // in case the adapter is a CDOResource
- }
-
- return null;
- }
-
- /**
- * Queries whether an {@code object} is an EMF model element, an instance of
- * some {@link EClass} from an EMF model. This isn't as simple as checking
- * whether the object is an {@link EObject} because there are edge cases
- * where objects are {@code EObject}s but shouldn't be treated as
- * "model content". But, a minimum requirement is that the {@code object} is
- * an {@link EObject}.
- *
- * @param object
- * an object
- * @return whether it is "model content"
- *
- * @see EMFHelper#asEMFModelElement(Object)
- */
- public static boolean isEMFModelElement(Object object) {
- return (object instanceof EObject) && !(object instanceof Resource);
- }
-
- /**
- * Casts an {@code object} as an EMF model element, if appropriate.
- *
- * @param object
- * an object
- * @return the object as an EMF model element, or {@code null} if it is not
- * an EMF model element
- *
- * @see #isEMFModelElement(Object)
- */
- public static EObject asEMFModelElement(Object object) {
- return isEMFModelElement(object) ? (EObject)object : null;
- }
-
- /**
- * Retrieve the EditingDomain for the given source object. The object is first
- * resolved to an EObject through #getEObject when possible.
- *
- * @param source
- * @return
- * The source object's editing domain, or null if it couldn't be found
- */
- public static EditingDomain resolveEditingDomain(final Object source) {
- return resolveEditingDomain(getEObject(source));
- }
-
- /**
- * Retrieve the EditingDomain for the given source EObject
- *
- * @param source
- * @return
- * The source eObject's editing domain, or null if it couldn't be found
- */
- public static EditingDomain resolveEditingDomain(final EObject source) {
- EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(source);
- if(domain == null) {
- try {
- domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
- } catch (ServiceException e) {
- //Ignore: We cannot find the domain
- }
- }
- return domain;
- }
-
- /**
- * Return the eClassifier' qualified name. The qualified name is obtained by the concatenation
- * of its package hierarchy with the class name, separated by the given separator
- *
- * @param eClassifier
- * @param separator
- * The separator used between each package name
- * @return
- * The EClassifier' qualified name
- */
- public static String getQualifiedName(final EClassifier eClassifier, final String separator) {
- return getQualifiedName(eClassifier.getEPackage(), separator) + separator + eClassifier.getName();
- }
-
- /**
- * Return the ePackage's qualified name. The qualified name is obtained by the concatenation
- * of its superPackage hierarchy with the ePackage name, separated by the given separator
- *
- * @param ePackage
- * @param separator
- * The separator used between each package name
- * @return
- * The EPackage's qualified name
- */
- public static String getQualifiedName(final EPackage ePackage, final String separator) {
- if(ePackage.getESuperPackage() == null) {
- return ePackage.getName();
- }
- return getQualifiedName(ePackage.getESuperPackage(), separator) + separator + ePackage.getName();
- }
-
-
- /**
- * Loads and returns the first EObject at the given URI.
- * The EObject is loaded in the given resourceSet.
- *
- * @param resourceSet
- * The ResourceSet in which the model will be loaded
- * @param uri
- * The URI describing the location of the model to load
- * @return
- * The first EObject located at the given URI
- * @throws IOException
- * When the URI cannot be loaded
- */
- public static EObject loadEMFModel(ResourceSet resourceSet, final URI uri) throws IOException {
- if(resourceSet == null) {
- resourceSet = new ResourceSetImpl();
- }
- try {
- Resource resource = resourceSet.getResource(uri, true);
- if(resource != null) {
- if(!resource.getContents().isEmpty()) {
- return resource.getContents().get(0);
- }
- }
- } catch (Exception ex) {
- IOException exception = new IOException(ex.toString());
- exception.initCause(ex);
- throw exception;
- }
-
- return null;
- }
-
- /**
- * Return the root package containing the given package, or the package
- * itself if it is already the root
- *
- * @param ePackage
- * @return
- * The Root package
- */
- public static EPackage getRootPackage(final EPackage ePackage) {
- if(ePackage == null) {
- return null;
- }
-
- if(ePackage.getESuperPackage() == null) {
- return ePackage;
- }
- return getRootPackage(ePackage.getESuperPackage());
- }
-
-
- /**
- * Return the list of EClasses that are subtypes
- * of the given EClass
- *
- * @param type
- * @param concreteClassesOnly
- * If true, only Concrete EClasses will be returned. Abstract and Interface EClasses will be filtered
- * @return
- * The list of EClasses implementing or extending the given EClass
- */
- public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly) {
- Set<EClass> result = new LinkedHashSet<EClass>();
- if(!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
- result.add(type);
- }
-
- EPackage ePackage = getRootPackage(type.getEPackage());
- getSubclassesOf(type, ePackage, result, concreteClassesOnly);
- return new LinkedList<EClass>(result);
- }
-
- /**
- * Return the list of EClasses that are sub types
- * of the given EClass
- *
- * @param type
- * @param concreteClassesOnly
- * If true, only Concrete EClasses will be returned. Abstract and Interface EClasses will be filtered
- * @param packagesToBrowse
- * The EPackages in which the EClasses should be retrieved
- * @return
- * The list of EClasses implementing or extending the given EClass
- */
- public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly, Collection<EPackage> packagesToBrowse) {
- Set<EClass> result = new LinkedHashSet<EClass>();
- if(!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
- result.add(type);
- }
-
- for(EPackage ePackage : packagesToBrowse) {
- getSubclassesOf(type, ePackage, result, concreteClassesOnly);
- }
-
- return new LinkedList<EClass>(result);
- }
-
- /**
- * Return the list of EClasses that are sub types of the given EClass
- *
- * @param type
- * @param concreteClassesOnly
- * If true, only Concrete EClasses will be returned. Abstract and Interface EClasses will be filtered
- * @param browseAllRegisteredPackages
- * If true, all registered EPackages will be navigated to retrieve the matching EClasses. Otherwise,
- * only the current EPackage will be used.
- * @return
- * The list of EClasses implementing or extending the given EClass
- */
- public static List<EClass> getSubclassesOf(final EClass type, final boolean concreteClassesOnly, final boolean browseAllRegisteredPackages) {
- //If the current package is a dynamic package, it may not be registered (?). Add it directly
- EPackage currentPackage = getRootPackage(type.getEPackage());
-
- Set<EPackage> allPackages = new LinkedHashSet<EPackage>();
- allPackages.add(currentPackage);
-
- if(browseAllRegisteredPackages) {
- //FIXME // WARNING: This loop will load all EPackages. The first call is expensive.
- Set<String> allUris = new HashSet<String>(EPackage.Registry.INSTANCE.keySet());
-
- for(String nsURI : allUris) {
- allPackages.add(EPackage.Registry.INSTANCE.getEPackage(nsURI));
- }
- }
-
- return getSubclassesOf(type, concreteClassesOnly, allPackages);
- }
-
- private static void getSubclassesOf(final EClass type, final EPackage fromPackage, final Set<EClass> result, final boolean concreteClassesOnly) {
- for(EClassifier classifier : fromPackage.getEClassifiers()) {
- if(classifier instanceof EClass) {
- EClass eClass = (EClass)classifier;
- if(eClass.getEAllSuperTypes().contains(type)) {
- if(!concreteClassesOnly || (!eClass.isAbstract() && !eClass.isInterface())) {
- result.add(eClass);
- }
- }
- }
- }
-
- for(EPackage subPackage : fromPackage.getESubpackages()) {
- getSubclassesOf(type, subPackage, result, concreteClassesOnly);
- }
- }
-
- /**
- * Tests if an EObject is read only
- * Delegates to the EObject's editing domain if it can be found
- *
- * @param eObject
- * @return
- * True if the EObject is read only
- */
- public static boolean isReadOnly(final EObject eObject) {
- EditingDomain domain = resolveEditingDomain(eObject);
- return isReadOnly(eObject, domain);
- }
-
- /**
- * Tests if an EObject is read only
- * Delegates to the given editing domain if it isn't null
- *
- * @param eObject
- *
- * @param domain
- * @return
- * True if the EObject is read only
- */
- public static boolean isReadOnly(final EObject eObject, final EditingDomain domain) {
- if(domain != null) {
- Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler) {
- return ((IReadOnlyHandler)handler).isReadOnly(eObject).get();
- }
-
- if(eObject.eResource() != null) {
- return domain.isReadOnly(eObject.eResource());
- }
- }
- return false;
- }
-
- /**
- * Tests if the Resource is read only
- * Delegates to the given editing domain if it isn't null
- *
- * @param resource
- * @param domain
- * @return
- * True if the Resource is read only
- */
- public static boolean isReadOnly(final Resource resource, final EditingDomain domain) {
- if(resource == null) {
- return false;
- }
-
- if(domain != null && resource.getURI() != null) {
- Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler) {
- return ((IReadOnlyHandler)handler).anyReadOnly(new URI[]{ resource.getURI() }).get();
- }
- return domain.isReadOnly(resource);
- }
-
- // no editing domain : use file system attribute
- ResourceSet resourceSet = resource.getResourceSet();
-
- if(resourceSet == null) {
- return false;
- }
-
- Map<String, ?> attributes = resourceSet.getURIConverter().getAttributes(resource.getURI(), null);
- Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
-
- return readOnly == null ? false : readOnly;
- }
-
- /**
- * Tests if the given EStructuralFeature is required (ie. should always
- * have a value)
- *
- * A feature is required if at least of one the following conditions if
- * true :
- *
- * - It has a defaultValue
- * - Its lowerBound is at least 1
- * - It is an enumeration (Enumerations always have a default value)
- * - It is a Java primitive type, and is not marked as Unsettable
- *
- * @param feature
- * the feature to test
- * @return
- * true if the feature is required, false otherwise
- */
- public static boolean isRequired(final EStructuralFeature feature) {
- //EEnums are always required, as an EEnum always has a default value
- if(feature.getEType() instanceof EEnum) {
- return true;
- }
-
- //At least one value means it is required
- if(feature.getLowerBound() >= 1) {
- return true;
- }
-
- //Java primitive types cannot have a null value
- //if the feature is not specifically marked as unsettable, then it is required
- if(feature.getEType().getInstanceClass().isPrimitive() && !feature.isUnsettable()) {
- return true;
- }
-
- //If there is a default value, there is always a value
- if(feature.getDefaultValueLiteral() != null) {
- return true;
- }
-
- return false; //The property if not required
- }
-
- /**
- * Returns all objects of type T contained in the resource
- *
- * @param resource
- * @param type
- * @return
- */
- public static <T> Set<T> allInstances(final Resource resource, Class<T> type) {
- TreeIterator<EObject> iterator = resource.getAllContents();
- Set<T> result = new LinkedHashSet<T>();
-
- while(iterator.hasNext()) {
- EObject element = iterator.next();
- if(type.isInstance(element)) {
- result.add(type.cast(element));
- }
- }
-
- return result;
- }
-
- /**
- * Returns all the EPackages and nested EPackages contained in this resource
- *
- * @param resource
- * @return
- */
- public static Set<EPackage> getAllEPackages(final Resource resource) {
- Set<EPackage> result = new LinkedHashSet<EPackage>();
-
- for(EObject rootElement : resource.getContents()) {
- if(rootElement instanceof EPackage) {
- result.add((EPackage)rootElement);
- result.addAll(getAllNestedPackages((EPackage)rootElement));
- }
- }
-
- return result;
- }
-
- /**
- * Returns all packages nested in the given EPackage (recursively). Does not
- * include the base EPackage.
- *
- * @param basePackage
- * @return
- */
- public static Set<EPackage> getAllNestedPackages(EPackage basePackage) {
- Set<EPackage> result = new LinkedHashSet<EPackage>();
-
- for(EPackage nestedPackage : basePackage.getESubpackages()) {
- result.add(nestedPackage);
- result.addAll(getAllNestedPackages(nestedPackage));
- }
-
- return result;
- }
-
- /**
- *
- * @param resource
- * a resource
- *
- * @return
- * the list of the metamodels known by the resource
- */
- public static Set<EPackage> getMetamodels(final Resource resource) {
- Set<EPackage> metamodels = new HashSet<EPackage>();
- if(resource != null) {
- final List<EObject> contents = new ArrayList<EObject>(resource.getContents());
- for(final EObject current : contents) {
- metamodels.add(current.eClass().getEPackage());
- }
- }
- return metamodels;
- }
-
- /**
- *
- * Returns the XMI ID of the given {@link EObject} or <code>null</code> if it cannot be resolved.
- *
- * @param object
- * Object which we seek the XMI ID of.
- * @return <code>object</code>'s XMI ID, <code>null</code> if not applicable.
- */
- public static final String getXMIID(final EObject object) {
- String objectID = null;
- if(object != null && object.eResource() instanceof XMIResource) {
- objectID = ((XMIResource)object.eResource()).getID(object);
- }
- return objectID;
- }
-
-
-
- /**
- * Gets the usages.
- *
- * @param source
- * the source
- *
- * @return the usages or null if there is no usages
- */
- public static Collection<Setting> getUsages(EObject source) {
- // the functional code is defined in core because we need it in infra.core
- // but infra.core can't depend on infra.emf (circular dependency)
- return org.eclipse.papyrus.infra.core.utils.EMFHelper.getUsages(source);
- }
-
-
- /**
- * <pre>
- * Test if the used element is referenced by other elements than the known
- * referencer (except its container). It ignores references from an other meta-model.
- * </pre>
- *
- * @param usedObject
- * the used object
- * @param knownReferencer
- * the known referencer
- * @return true if the known referencer is the only referencer.
- */
- public static boolean isOnlyUsage(EObject usedObject, EObject knownReferencer) {
- boolean isUsed = false;
- EPackage mmPackage = usedObject.eClass().getEPackage();
-
- // Retrieve the list of elements referencing the usedObject.
- Set<EObject> crossReferences = new HashSet<EObject>();
- for(Setting setting : getUsages(usedObject)) {
- EObject eObj = setting.getEObject();
- if(eObj.eClass().getEPackage().equals(mmPackage)) {
- crossReferences.add(eObj);
- }
- }
-
- // Remove the container of used object.
- crossReferences.remove(usedObject.eContainer());
- // Remove the knownReferencer from the list of references.
- crossReferences.remove(knownReferencer);
-
- // If no referencer remains in the list, the known element is the only
- // usage.
- if(crossReferences.isEmpty()) {
- isUsed = true;
- }
-
- return isUsed;
- }
-
- /**
- *
- * @param superType
- * an eclassifier
- * @param subType
- * another eClassifier
- * @return
- * <code>true</code> if the 2nd {@link EClassifier} is a subtype of the first one
- */
- public static boolean isSuperType(final EClassifier superType, final EClassifier subType) {
- if(superType == subType) {
- return true;
- }
-
- if(superType instanceof EClass && subType instanceof EClass) {
- // special case because isSuperTypeOf doesn't handle it
- if(superType == EcorePackage.eINSTANCE.getEObject()) {
- return true;
- }
-
- EClass superTypeEClass = (EClass)superType;
- EClass subTypeEClass = (EClass)subType;
- return superTypeEClass.isSuperTypeOf(subTypeEClass);
- }
-
- //manage EDtataType
- if(superType == EcorePackage.eINSTANCE.getEDataType() && subType instanceof EDataType) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Computes the path from the root EObject to the given element, as a List of EObjects
- *
- * @param element
- * @return
- */
- public static List<EObject> getContainmentPath(EObject element) {
- List<EObject> result;
- if(element.eContainer() == null) {
- result = new LinkedList<EObject>();
- result.add(element);
- return result;
- } else {
- result = getContainmentPath(element.eContainer());
- result.add(element);
- }
- return result;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
deleted file mode 100644
index 8f92a241737..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.tools.util.BooleanHelper;
-import org.eclipse.papyrus.infra.tools.util.TypesConstants;
-import org.eclipse.ui.services.IDisposable;
-
-/**
- * Value solver for EMF
- *
- * WARNING : incomplete implementations
- *
- * @author vl222926
- *
- */
-
-public class EMFStringValueConverter implements IDisposable {
-
- protected static final String THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y = "The String {0} is not valid to create {1}";
-
- protected static final String THE_FEATURE_X_CANT_BE_RESOLVED = "The feature {0} can't be resolved";
-
- protected static final String THE_STRING_VALUE_X_CANT_BE_RESOLVED = "The string value {0} can't be resolved";
-
- protected static final String SOME_STRING_ARE_NOT_VALID_TO_CREATE_X = "Some String are not valid to create {0}";
-
- /**
- * Context used for the resolution of the string
- */
- private EObject resolutionContext;
-
- /**
- * The separator used for multivalue
- */
- protected final String multiValueSeparator;
-
- /**
- *
- * Constructor.
- *
- * @param resolutionContext
- * the context used for the resolution of the string
- */
- public EMFStringValueConverter(final EObject resolutionContext, final String multiValueSeparator) {
- this.resolutionContext = resolutionContext;
- this.multiValueSeparator = multiValueSeparator;
- }
-
- /**
- *
- * @return
- * the context to use for the resolution
- */
- public EObject getResolutionContext() {
- return resolutionContext;
- }
-
- /**
- *
- * @see org.eclipse.ui.services.IDisposable#dispose()
- *
- */
- public void dispose() {
- this.resolutionContext = null;
- }
-
- /**
- *
- * @param resolutionContext
- * the table context
- * @param feature
- * the feature
- * @param valueAsString
- * the pasted string for this feature
- * @return
- * the value for the pasted string or <code>null</code> if not found
- */
- public ConvertedValueContainer<?> deduceValueFromString(final Object feature, final String valueAsString) {
- final EClassifier featureType = getFeatureType(feature);
- if(feature instanceof EStructuralFeature) {
- return deduceValueFromString(feature, featureType, valueAsString);
- }
- final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_FEATURE_X_CANT_BE_RESOLVED, feature));
- return new ConvertedValueContainer<Object>(null, status);
- }
-
- /**
- *
- * @param feature
- * @param featureType
- * @param valueAsString
- * @return
- */
- protected ConvertedValueContainer<?> deduceValueFromString(final Object feature, final EClassifier featureType, final String valueAsString) {
- ConvertedValueContainer<?> realValue = null;
-// if(feature instanceof EStructuralFeature) {
- final int upperbound = getFeatureUpperBound(feature);
- boolean isMany = (upperbound > 1 || upperbound == -1);
- if(featureType instanceof EDataType) {
- //move these strings
- final String typeName = featureType.getName();
- if(TypesConstants.STRING.equals(typeName) || EMFContants.ESTRING.equals(typeName)) {
- realValue = deduceStringValue(isMany, valueAsString);
- } else if(EMFContants.EBOOLEAN.equals(typeName) || TypesConstants.BOOLEAN.equals(typeName)) {
- realValue = deduceBooleanValue(isMany, valueAsString);
- } else if(EMFContants.EINT.equals(typeName) || TypesConstants.INTEGER.equals(typeName)) {
- realValue = deduceIntValue(isMany, valueAsString);
- } else if(EMFContants.EDOUBLE.equals(typeName)) {
- realValue = deduceDoubleValue(isMany, valueAsString);
- }
- } else if(featureType instanceof EClass) {
- realValue = deduceEObjectValue((EObject)getResolutionContext(), feature, (EClass)featureType, isMany, valueAsString);
- }
- // } else {
- // final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_VALUE_X_CANT_BE_RESOLVED, valueAsString));
- // return new SolvedValueContainer<Object>(null, status);
- // }
- return realValue;
- }
-
- protected int getFeatureUpperBound(final Object feature) {
- return ((EStructuralFeature)feature).getUpperBound();
- }
-
-
- /**
- *
- * @param resolutionContext
- * the context used for the resolution
- * @param feature
- * the feature
- * @param featureType
- * the type of the feature
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the string value to resolve
- * @return
- * a value container referencing the eobject represented by the string
- * @throws StringValueSolverException
- */
- protected ConvertedValueContainer<?> deduceEObjectValue(EObject resolutionContext, Object feature, EClass featureType, boolean isMany, String valueAsString) {
- if(valueAsString==null || valueAsString.equals("")){
- return new ConvertedValueContainer<EObject>(null, Status.OK_STATUS);
- }
- final IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_VALUE_X_CANT_BE_RESOLVED, valueAsString));
- return new ConvertedValueContainer<EObject>(null, status);
- }
-
- /**
- *
- * @param feature
- * an object representing a feature
- * @return
- * the type of the feature
- */
- protected EClassifier getFeatureType(final Object feature) {
- final EClassifier featureType;
- if(feature instanceof EStructuralFeature) {
- return ((EStructuralFeature)feature).getEType();
- } else {
- featureType = null;
- }
- return featureType;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceBooleanValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
- final Collection<Boolean> values = new ArrayList<Boolean>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
- if(BooleanHelper.isBoolean(str)) {
- values.add(Boolean.valueOf(valueAsString));
- } else {
- unresolvedValues.add(str);
- }
- }
- if(!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.BOOLEAN), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Boolean>(values, iStatus);
- } else {
- if(BooleanHelper.isBoolean(valueAsString)) {
- returnedValue = new ConvertedValueContainer<Boolean>(Boolean.valueOf(valueAsString), iStatus);
- } else {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.BOOLEAN), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceDoubleValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
- final Collection<Double> values = new ArrayList<Double>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
- final Double value = Double.valueOf(str);
- if(value != null) {
- values.add(value);
- } else {
- unresolvedValues.add(str);
- }
- }
- if(!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.DOUBLE), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Double>(values, iStatus);
- } else {
- try {
- returnedValue = new ConvertedValueContainer<Double>(Double.valueOf(valueAsString), iStatus);
- } catch (final NumberFormatException e) {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.DOUBLE), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature isMany
- * @param valueAsString
- * the value to parse
- * @return
- * the result of the parsing
- */
- protected ConvertedValueContainer<?> deduceIntValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- IStatus iStatus = Status.OK_STATUS;
- final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
- final Collection<Integer> values = new ArrayList<Integer>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
- try {
- values.add(Integer.valueOf(str));
- } catch (final NumberFormatException e) {
- unresolvedValues.add(str);
- }
- }
- if(!unresolvedValues.isEmpty()) {
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, TypesConstants.INTEGER), unresolvedValues);
- }
- returnedValue = new MultiConvertedValueContainer<Integer>(values, iStatus);
- } else {
- try {
- returnedValue = new ConvertedValueContainer<Integer>(Integer.valueOf(valueAsString), iStatus);
- } catch (final NumberFormatException e) {
- unresolvedValues.add(valueAsString);
- iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(THE_STRING_X_IS_NOT_VALID_TO_CREATE_Y, valueAsString, TypesConstants.INTEGER), unresolvedValues);
- returnedValue = new ConvertedValueContainer<Boolean>(null, iStatus);
- }
- }
- return returnedValue;
- }
-
-
- /**
- *
- * @param isMany
- * <code>true</code> if the feature is many
- * @param valueAsString
- * the value as string
- * @return
- * the value container with the real value(s)
- */
- protected ConvertedValueContainer<?> deduceStringValue(final boolean isMany, final String valueAsString) {
- ConvertedValueContainer<?> returnedValue = null;
- final IStatus iStatus = Status.OK_STATUS;
- if(isMany) {
- final Collection<String> values = new ArrayList<String>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
- values.add(str);
- }
- returnedValue = new MultiConvertedValueContainer<String>(values, iStatus);
- } else {
- returnedValue = new ConvertedValueContainer<String>(valueAsString, iStatus);
- }
- return returnedValue;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
deleted file mode 100644
index f2928885c13..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.text.Collator;
-import java.util.Comparator;
-
-import org.eclipse.emf.ecore.ENamedElement;
-
-/**
- *
- * A comparator for ENamedElement
- *
- */
-public class ENamedElementComparator implements Comparator<ENamedElement> {
-
- public int compare(final ENamedElement namedElement1, final ENamedElement namedElement2) {
- if(namedElement1 == null) {
- return namedElement2 == null ? 0 : -1;
- }
-
- return Collator.getInstance().compare(namedElement1.getName(), namedElement2.getName());
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
deleted file mode 100644
index 50d10a12b9f..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-
-public class HistoryUtil {
-
- /**
- * Returns a String identifying the History of selected values for the given object/feature
- *
- * @param editedObject
- * @param feature
- * @return
- */
- public static String getHistoryID(EObject editedObject, EStructuralFeature feature) {
- return getHistoryID(editedObject, feature, "");
- }
-
- /**
- * Returns a String identifying the History of selected values for the given object/feature,
- * and prepends the given prefix
- *
- * @param editedObject
- * @param feature
- * @return
- */
- public static String getHistoryID(EObject editedObject, EStructuralFeature feature, String prefix) {
- // return String.format("history_%s:%s:%s", feature.getEType().getEPackage().getName(), feature.getEType().getName(), feature.getName()); //$NON-NLS-1$
- if(editedObject.eResource() == null) {
- return String.format("history_%s_%s:%s", prefix, EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return String.format("history_%s_%s:%s:%s", prefix, editedObject.eResource().getURI(), EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/MultiConvertedValueContainer.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/MultiConvertedValueContainer.java
deleted file mode 100644
index 8cb52536ecd..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/MultiConvertedValueContainer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- *
- * This class allows to store the value created for a pasted String AND a result status associated to this pasted String
- *
- * @param <T>
- */
-public class MultiConvertedValueContainer<T> extends ConvertedValueContainer<Collection<T>> {
-
-
- /**
- *
- * Constructor.
- *
- * @param realValue
- * @param status
- */
- public MultiConvertedValueContainer(final Collection<T> realValue, final IStatus status) {
- super(realValue, status);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
deleted file mode 100644
index d3d919225bd..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.EMFGraphicalContentProvider;
-import org.eclipse.papyrus.infra.emf.providers.strategy.ContainmentBrowseStrategy;
-import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
-import org.eclipse.papyrus.infra.widgets.strategy.StrategyBasedContentProvider;
-import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
-
-
-public class ProviderHelper {
-
- /**
- * Encapsulates the given content provider in a higher-level content provider
- * The returned provider uses two different strategies to display and search
- * elements, and adds a pattern filter and an History
- *
- * @param provider
- * The ContentProvider to encapsulate
- * @return
- */
- public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, ResourceSet resourceSet, String historyId) {
- TreeBrowseStrategy browseStrategy = new ProviderBasedBrowseStrategy(provider);
- TreeBrowseStrategy revealStrategy = new ContainmentBrowseStrategy(provider);
- IStructuredContentProvider strategyProvider = new StrategyBasedContentProvider(browseStrategy, revealStrategy);
- EMFGraphicalContentProvider graphicalProvider = new EMFGraphicalContentProvider(strategyProvider, resourceSet, historyId);
-
- return graphicalProvider;
- }
-
- /**
- * Encapsulates the given content provider in a higher-level content provider
- * The returned provider uses two different strategies to display and search
- * elements, and adds a pattern filter and an History
- *
- * @param provider
- * The ContentProvider to encapsulate
- * @return
- */
- public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
- ResourceSet rs = editedEObject == null ? null : editedEObject.eResource() == null ? null : editedEObject.eResource().getResourceSet();
- return encapsulateProvider(provider, rs, HistoryUtil.getHistoryID(editedEObject, feature));
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java
deleted file mode 100644
index 225e5b57eae..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-
-/**
- *
- * This class provides methods for EMF Resource
- *
- */
-public class ResourceUtils {
-
- private ResourceUtils() {
- //to prevent instanciation
- }
-
- /**
- *
- * @param resource
- * an EMF resource
- * @return
- * the IFile corresponding to this resource, or <code>null</code> if not found
- */
- public static IFile getFile(final Resource resource) {
- if(resource != null) {
- URI uri = resource.getURI();
- uri = resource.getResourceSet().getURIConverter().normalize(uri);
- if(uri.isPlatformResource()) {
- String uriPlatformString = uri.toPlatformString(true) ;
- return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uriPlatformString));
- }
- }
- return null;
- }
-
- /**
- *
- *
- * @param resource
- * a resource
- * @return
- * a collection with all existing id in the resource
- *
- */
- public static Collection<String> getAllResourceIds(final XMIResource resource) {
- final Set<String> ids = new HashSet<String>();
- final Iterator<EObject> iterator = resource.getAllContents();
- while(iterator.hasNext()) {
- final EObject current = iterator.next();
- final String id = resource.getID(current);
- Assert.isNotNull(id);
- Assert.isTrue(!ids.contains(id));
- ids.add(id);
- }
- return ids;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
deleted file mode 100644
index 596451c8444..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Cedric Dumoulin.
- *
- *
- * 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * This AdapterFactory is used to attach a reference on the ServiceRegiqtry to an EMF ResourceSet.
- *
- * This adapterFactory is not a real factory: no adapter is created.
- *
- * @author cedric dumoulin
- *
- */
-public class ServiceRegistryAdapterFactory extends AdapterFactoryImpl {
-
- /**
- * ID used to register the factory in the ResourceSet.
- */
- static final public String TYPE_ID = ServiceRegistryAdapterFactory.class.getName() + "TypeId";
-
- /**
- * The reference to the ServiceRegistry.
- */
- protected ServicesRegistry servicesRegistry;
-
- /**
- * @param servicesRegistry
- */
- public ServiceRegistryAdapterFactory(ServicesRegistry servicesRegistry) {
- this.servicesRegistry = servicesRegistry;
- }
-
- /**
- *
- * @return the associated {@link ServicesRegistry}
- */
- public ServicesRegistry getServicesRegistry() {
- return servicesRegistry;
- }
-
- @Override
- public boolean isFactoryForType(Object type) {
- return type.equals(TYPE_ID);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java
deleted file mode 100644
index 32e3b45d222..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-
-/**
- * A ServiceUtils instance for manipulating Papyrus services on an EObject
- *
- * @author Camille Letavernier
- *
- */
-public class ServiceUtilsForEObject extends AbstractServiceUtils<EObject> {
-
- private static ServiceUtilsForEObject instance = new ServiceUtilsForEObject();
-
- public static ServiceUtilsForEObject getInstance() {
- return instance;
- }
-
- private ServiceUtilsForEObject() {
- //Singleton
- }
-
- @Override
- public ServicesRegistry getServiceRegistry(EObject from) throws ServiceException {
- if(from == null) {
- throw new ServiceException("The selected EObject must not be null");
- }
-
- return ServiceUtilsForResource.getInstance().getServiceRegistry(from.eResource());
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
deleted file mode 100644
index cdf46c2d5be..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-/**
- * ServicesUtils based on the Handler's ExecutionEvent
- *
- * It first tests the current selection, then the IWorkbenchPart on which the handler is executed.
- * The IWorkbenchPart is expected to be adaptable to a ServiceRegistry.
- *
- * @author Camille Letavernier
- *
- * @see ServiceUtilsForSelection
- */
-public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent> {
-
- private ServiceUtilsForHandlers() {
- //Singleton
- }
-
- @Override
- public ServicesRegistry getServiceRegistry(ExecutionEvent from) throws ServiceException {
-
- Object context = from.getApplicationContext();
-
- if(context instanceof IEvaluationContext) {
- IEvaluationContext evaluationContext = (IEvaluationContext)context;
-
- //Search for the IWorkbenchPartSite from which the ExecutionEvent is sent (May be different that the Active one)
- Object workbenchPartSite = evaluationContext.getVariable("org.eclipse.ui.IWorkbenchPartSite");
- if(workbenchPartSite instanceof IWorkbenchPartSite) {
- IWorkbenchPartSite site = (IWorkbenchPartSite)workbenchPartSite;
- Object registry = site.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
- }
-
- //Search for the IWorkbenchPart from which the ExecutionEvent is sent (May be different that the Active one)
- IWorkbenchPart workbenchPart = site.getPart();
- registry = workbenchPart.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
- }
- }
-
- Object selection = evaluationContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
-
- ServicesRegistry registry;
-
- //Try to resolve the ServicesRegistry from the current selection
- if(selection instanceof ISelection && !((ISelection)selection).isEmpty()) {
- try {
- registry = ServiceUtilsForSelection.getInstance().getServiceRegistry((ISelection)selection);
- if(registry != null) {
- return registry;
- }
- } catch (ServiceException ex) {
- //Ignore and try another ServiceUtils
- }
- }
-
- //We couldn't retrieve the ServiceRegistry from the current selection.
-
- //Try to adapt the active part to the ServicesRegistry
- IWorkbenchPart part = (IWorkbenchPart)evaluationContext.getVariable(ISources.ACTIVE_PART_NAME);
- registry = (ServicesRegistry)(part).getAdapter(ServicesRegistry.class);
- if(registry != null) {
- return registry;
- }
- }
-
- throw new ServiceNotFoundException("The ServiceRegistry cannot be resolved");
- }
-
- public static ServiceUtilsForHandlers getInstance() {
- return instance;
- }
-
- private static final ServiceUtilsForHandlers instance = new ServiceUtilsForHandlers();
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java
deleted file mode 100644
index 183fd824911..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Cedric Dumoulin.
- *
- * 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:
- * Cedric Dumoulin - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-/**
- * ServicesUtils based on the Handler's IEvaluationContext.
- * This class can be used for both the {@link AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)} and the {@link AbstractHandler#setEnabled(Object)} methods.
- *
- *
- * @author Cedric Dumoulin
- *
- */
-public class ServiceUtilsForIEvaluationContext extends AbstractServiceUtils<IEvaluationContext> {
-
- private ServiceUtilsForIEvaluationContext() {
- //Singleton
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils#getServiceRegistry(java.lang.Object)
- *
- * @param from
- * @return
- * @throws ServiceException
- */
- @Override
- public ServicesRegistry getServiceRegistry(IEvaluationContext from) throws ServiceException {
-
- IEvaluationContext evaluationContext = from;
-
- //Search for the IWorkbenchPartSite from which the ExecutionEvent is sent (May be different that the Active one)
- Object workbenchPartSite = evaluationContext.getVariable("org.eclipse.ui.IWorkbenchPartSite");
- if(workbenchPartSite instanceof IWorkbenchPartSite) {
- IWorkbenchPartSite site = (IWorkbenchPartSite)workbenchPartSite;
- Object registry = site.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
- }
-
- //Search for the IWorkbenchPart from which the ExecutionEvent is sent (May be different that the Active one)
- IWorkbenchPart workbenchPart = site.getPart();
- registry = workbenchPart.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
- }
- }
-
- Object selection = evaluationContext.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
-
- ServicesRegistry registry;
-
- //Try to resolve the ServicesRegistry from the current selection
- if(selection instanceof ISelection && !((ISelection)selection).isEmpty()) {
- try {
- registry = ServiceUtilsForSelection.getInstance().getServiceRegistry((ISelection)selection);
- if(registry != null) {
- return registry;
- }
- } catch (ServiceException ex) {
- //Ignore and try another ServiceUtils
- }
- }
-
- //We couldn't retrieve the ServiceRegistry from the current selection.
-
- //Try to adapt the active part to the ServicesRegistry
- Object _part = evaluationContext.getVariable(ISources.ACTIVE_PART_NAME);
- if (_part instanceof IWorkbenchPart) {
- IWorkbenchPart part = (IWorkbenchPart)_part;
- registry = (ServicesRegistry)(part).getAdapter(ServicesRegistry.class);
- if(registry != null) {
- return registry;
- }
- }
-
-
- // nothing found
- throw new ServiceNotFoundException("The ServiceRegistry cannot be resolved");
- }
-
- public static ServiceUtilsForIEvaluationContext getInstance() {
- return instance;
- }
-
- private static final ServiceUtilsForIEvaluationContext instance = new ServiceUtilsForIEvaluationContext();
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java
deleted file mode 100644
index 0dc6349fd76..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Cedric Dumoulin.
- *
- *
- * 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-
-/**
- * Get the {@link ServicesRegistry} from a {@link EObject} or a {@link Resource}.
- * This class allow to retrieve the {@link ServicesRegistry} associated to the {@link ResourceSet} owning the {@link Resource} owning the EObject.
- *
- * <br>
- * To work properly, the EObject should be associated to a {@link Resource}, itself
- * registered in a {@link ResourceSet}.
- * Also, the ServicesRegistry should be associated to the ResourceSet with the help of the {@link ServiceRegistryAdapterFactory}. <br>
- * Normally, this is automatically done thanks to the {@link ServiceUtilsForResourceInitializerService} service. <br>
- * If you access this class from a service, you can ensure that the previous service is started by letting your service
- * depends on the <b>org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForResourceInitializerService</b>.
- *
- *
- * @author cedric dumoulin
- *
- */
-public class ServiceUtilsForResource extends AbstractServiceUtils<Resource> {
-
- private final static ServiceUtilsForResource instance = new ServiceUtilsForResource();
-
- /**
- * Get the singleton instance of the class.
- *
- * @return
- */
- public static final ServiceUtilsForResource getInstance() {
- return instance;
- }
-
- /**
- * Get the {@link ServicesRegistry} from a {@link Resource}.
- *
- * @param from
- * The {@link Resource} from which we want the associated {@link ServicesRegistry}.
- * @return
- * @throws ServiceException
- * If there is no {@link ServicesRegistry} associated to the {@link ResourceSet} owning the {@link Resource}.
- */
- @Override
- public ServicesRegistry getServiceRegistry(Resource from) throws ServiceException {
- if(from == null) {
- throw new ServiceNotFoundException("Can't find the ResourceSet needed retrieve the ServiceRegistry.");
- }
- return ServiceUtilsForResourceSet.getInstance().getServiceRegistry(from.getResourceSet());
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
deleted file mode 100644
index 25eba9bb364..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 Cedric Dumoulin.
- *
- *
- * 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:
- * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.IService;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
-
-/**
- * This service register inside the ResourceSet an AdapterFactory referencing the ServiceRegistry.
- * This will allows to get the ServicesRegistry from any EMF object (see {@link ServiceUtilsForResource}.
- * The AdapterFactory can't provide Adapters. It is only used to hold a reference on the ServiceRegistry.
- *
- * This service depends on the ModelSet service.
- *
- *
- * @see ServiceRegistryAdapterFactory
- * @see ServiceUtilsForResource
- *
- * @author cedric dumoulin
- *
- */
-public class ServiceUtilsForResourceInitializerService implements IService {
-
- ServicesRegistry servicesRegistry;
-
- /**
- * Create a {@link ServiceRegistryAdapterFactory} and associate it to the ResourceSet.
- *
- */
- public void init(ServicesRegistry servicesRegistry) throws ServiceException {
-
- this.servicesRegistry = servicesRegistry;
- ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
-
- // Check if the Adapter Factory is already attached.
- if( lookupServiceRegistryAdapterFactory(modelSet) != null ) {
- return;
- }
-
- // Attach the adapter
- ServiceRegistryAdapterFactory factory = new ServiceRegistryAdapterFactory(servicesRegistry);
- modelSet.getAdapterFactories().add(factory);
-
- }
-
- /**
- * Return the AdapterFactory, or null if none is found.
- * @param resourceSet
- * @return
- */
- private ServiceRegistryAdapterFactory lookupServiceRegistryAdapterFactory(ResourceSet resourceSet) {
- ServiceRegistryAdapterFactory factory = (ServiceRegistryAdapterFactory)EcoreUtil.getAdapterFactory(resourceSet.getAdapterFactories(), ServiceRegistryAdapterFactory.TYPE_ID);
-
- return factory;
- }
-
- /**
- *
- */
- public void startService() throws ServiceException {
- // Do nothing
-
- }
-
- /**
- * Detach the Adapter from the resourceSet
- */
- public void disposeService() throws ServiceException {
-
- try {
- ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
- ServiceRegistryAdapterFactory factory = lookupServiceRegistryAdapterFactory(modelSet);
-
- modelSet.getAdapterFactories().remove(factory);
- } catch (BadStateException e) {
- // ModelSet is already disposed. Do nothing
- }
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java
deleted file mode 100644
index 7dd7c3d4d1d..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceNotFoundException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-
-
-public class ServiceUtilsForResourceSet extends AbstractServiceUtils<ResourceSet> {
-
- private ServiceUtilsForResourceSet() {
- //Singleton
- }
-
- private static ServiceUtilsForResourceSet instance = new ServiceUtilsForResourceSet();
-
- public static ServiceUtilsForResourceSet getInstance() {
- return instance;
- }
-
- @Override
- public ServicesRegistry getServiceRegistry(ResourceSet from) throws ServiceException {
- if(from == null) {
- throw new ServiceNotFoundException("Can't find the ResourceSet needed retrieve the ServiceRegistry.");
- }
-
- // An AdapterFactory referencing the ServiceRegistry is attache to the REsourceSet.
- // Try to get it.
- ServiceRegistryAdapterFactory factory = (ServiceRegistryAdapterFactory)EcoreUtil.getAdapterFactory(from.getAdapterFactories(), ServiceRegistryAdapterFactory.TYPE_ID);
- if(factory == null) {
- throw new ServiceNotFoundException("Can't find the ServiceRegistry. No Adapter is attached to the ResourceSet. Check if the proper service is ");
- }
- return factory.getServicesRegistry();
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java
deleted file mode 100644
index 729668d4160..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- * 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.Iterator;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
-
-/**
- * ServiceUtils based on an ISelection.
- *
- * Expects an IStructuredSelection containing at least one EObject (It then relies on ServiceUtilsForEObject to retrieve the ServicesRegistry)
- *
- * @author Camille Letavernier
- */
-public class ServiceUtilsForSelection extends AbstractServiceUtils<ISelection> {
-
- private ServiceUtilsForSelection() {
- //Singleton
- }
-
- private static ServiceUtilsForSelection instance = new ServiceUtilsForSelection();
-
- public static ServiceUtilsForSelection getInstance() {
- return instance;
- }
-
- @Override
- public ServicesRegistry getServiceRegistry(ISelection from) throws ServiceException {
- if(from instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection)from;
- Iterator<?> selectionIterator = selection.iterator();
- while(selectionIterator.hasNext()) {
- Object selectedElement = selectionIterator.next();
- EObject selectedEObject = EMFHelper.getEObject(selectedElement);
- if(selectedEObject != null) {
- return ServiceUtilsForEObject.getInstance().getServiceRegistry(selectedEObject);
- }
- }
- }
-
- throw new ServiceException("Cannot retrieve the ServiceRegistry");
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/StringValueConverterStatus.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/StringValueConverterStatus.java
deleted file mode 100644
index bcb738add8d..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/StringValueConverterStatus.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.Collection;
-
-import org.eclipse.core.runtime.Status;
-
-/**
- * This status is used y the String Value solvers
- *
- * @author vl222926
- *
- */
-public class StringValueConverterStatus extends Status {
-
- /**
- * the list of the uresolved strings
- */
- private Collection<String> unresolvedString;
-
- /**
- *
- * Constructor.
- *
- * @param severity
- * the severity of the status
- * @param pluginId
- * the plugin id providing this status
- * @param message
- * the message for this status
- * @param unresolvedString
- * the list of the unresolved string
- */
- public StringValueConverterStatus(int severity, String pluginId, String message, Collection<String> unresolvedString) {
- super(severity, pluginId, message);
- this.unresolvedString = unresolvedString;
- }
-
-
- /**
- *
- * @return
- * the list of the unresolved string
- */
- public final Collection<String> getUnresolvedString() {
- return unresolvedString;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java
deleted file mode 100644
index e3ac8d92d7e..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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:
- * Camille Letavernier (camille.letavernier@cea.fr) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.papyrus.infra.emf.Activator;
-
-/**
- * An abstract helper to replace references to EObjects (represented by their URI) with a label (related to this EObject).
- *
- * It is typically used to introduce dynamic references to object's labels in free text areas (e.g. in a description)
- *
- * The reference can be introduced with {@link #insertReference(EObject, String, int)}
- *
- * The parsed string can be retrieved with {@link #replaceReferences(String)}
- *
- * @author Camille Letavernier
- *
- */
-public abstract class TextReferencesHelper {
-
- public static final String URI_CHARS = "[^#]"; //Almost everything is allowed in a URI. It's simpler to exclude the fragment separator
-
- public static final String FRAGMENT_CHARS = "[-A-Za-z0-9_/]"; //In Papyrus this is sufficient. Do we need a more complex expression?
-
- public static final String URI_REGEX = String.format("%s*#%s+", URI_CHARS, FRAGMENT_CHARS); //The base uri is optional. The fragment is required.
-
- public static String UNKNOWN_ELEMENT = "UNKNOWN"; //Replacement text for unknown elements
-
- public static String PROXY_ELEMENT = "PROXY"; //Replacement text for proxy elements
-
- protected Resource baseResource;
-
- protected ResourceSet resourceSet;
-
- protected TextReferencesHelper() {
- //Empty
- }
-
- /**
- *
- * @param baseResource
- * The resource against which the link uris will be resolved
- */
- protected TextReferencesHelper(Resource baseResource) {
-
- if(baseResource != null) {
- this.baseResource = baseResource;
- this.resourceSet = baseResource.getResourceSet();
- }
- }
-
- /**
- * Parses the specified text, and replace all references with their replacement String
- *
- * @param text
- * @return
- *
- * @see {@link #getReplacement(EObject, String)}
- */
- public String replaceReferences(String text) {
- if(text == null) {
- return null;
- }
-
- if("".equals(text)) {
- return text;
- }
-
- //Javadoc-like @link tag
- String replaceRegex = String.format("\\{@link (%s)(\\|([^}]*))?\\}", URI_REGEX);
-
- Pattern pattern = Pattern.compile(replaceRegex);
- Matcher matcher = pattern.matcher(text);
-
- String newText = text;
-
- while(matcher.find()) {
- String uriToReplace = matcher.group(1); //0 is the full pattern (e.g. {link myUri#myFragment}, 1 is the first group (e.g. myUri#myFragment)
- String cachedValue = matcher.group(3); //group 2 is |CachedValue, group 3 is CachedValue
-
- String replacement = decorate(getReplacement(uriToReplace, cachedValue));
-
- newText = matcher.replaceFirst(replacement);
- matcher = pattern.matcher(newText);
- }
-
- return newText;
- }
-
- /**
- * Insert a reference to the given element in the specified text, at the specified position
- *
- * @param toElement
- * The element to reference
- * @param inText
- * The text in which the reference must be inserted
- * @param atPosition
- * The position at which the reference must be inserted. 0 is the beginning, while text.length() is the end. For all "invalid" indexes (<0
- * and > length()), the reference will be inserted at the end of the string
- * @return
- * The text containing the new reference
- */
- public String insertReference(EObject toElement, String inText, int atPosition) {
- String result = inText;
- if(inText == null) {
- return null; //No change
- }
-
- if(toElement == null) {
- return inText; //No change
- }
-
- //Use a Javadoc-like @link tag
- URI elementURI = EcoreUtil.getURI(toElement);
- if(baseResource != null) {
- URI baseURI = baseResource.getURI();
- if(baseURI != null) {
- elementURI = elementURI.deresolve(baseURI);
- }
- }
- String reference = "{@link " + elementURI + "}"; //The URI is already encoded
-
- if(atPosition == 0) {
- return reference + result; //At the beginning
- }
-
- if(atPosition < 0 || atPosition >= inText.length()) {
- result += reference; //Insert at the end
- } else {
- //Hello, world
- //The whitespace is the character at position 6. Insert the reference at position 7 to add it after the whitespace
- //It will result in Hello, <Replacement>world
- result = inText.substring(0, atPosition); //Include the "afterPosition" character
- result += reference; //Add the reference
- result += inText.substring(atPosition, inText.length()); //Complete the string (Exclude the afterPosition character, as it has already been copied in the first part of the result string)
- }
-
- return result;
- }
-
- /**
- * Adds a (text) decoration to the replacement string.
- * This can be used for e.g. html-based texts, to add tags around the replaced string
- *
- * The default implementation does nothing.
- */
- protected String decorate(String text) {
- return text;
- }
-
- protected String getReplacement(String uriToReplace, String cachedValue) {
- String uri, fragment;
-
- if(baseResource == null || resourceSet == null || baseResource.getURI() == null) {
- return UNKNOWN_ELEMENT;
- }
-
- if(uriToReplace.contains("#")) {
- uri = uriToReplace.substring(0, uriToReplace.indexOf('#'));
- fragment = uriToReplace.substring(uriToReplace.indexOf('#') + 1, uriToReplace.length());
- } else {
- return UNKNOWN_ELEMENT;
- }
-
- URI targetURI;
-
- URI resourceURI;
-
- resourceURI = baseResource.getURI();
-
- targetURI = URI.createURI(uri); //The URI must already be encoded
-
- targetURI = targetURI.resolve(resourceURI);
-
- if(targetURI == null) {
- return UNKNOWN_ELEMENT;
- }
-
- targetURI = targetURI.appendFragment(fragment);
-
- return getReplacement(targetURI, cachedValue);
- }
-
- protected String getReplacement(URI uriToReplace, String cachedValue) {
- try {
- EObject targetElement = resourceSet.getEObject(uriToReplace, true);
- return getReplacement(targetElement, cachedValue);
- } catch (Exception ex) {
- //Log the error? If it happens once, it will happen many times (after each refresh). The UNKNOWN keyword may be enough.
- //This error happens when the reference is broken (e.g. an element has been deleted). This is a "normal" behavior
- Activator.log.debug("An error occurred while loading the following URI: " + uriToReplace + ". The reference cannot be replaced");
- }
-
- return UNKNOWN_ELEMENT;
- }
-
- protected abstract String getReplacement(EObject elementToReplace, String cachedValue);
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
deleted file mode 100644
index 1d4ab1791a6..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2012 CEA LIST.
- *
- *
- * 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:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.utils;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.commands.UnsetCommand;
-
-/**
- *
- * This class allows to do unset on a feature using a command
- *
- */
-public class TransactionalUnsetter {
-
-
- /**
- * the source eobject
- */
- private final Command cmd;
-
- /**
- * the editing domain used for the command
- */
-
- private final TransactionalEditingDomain domain;
-
- /**
- *
- * Constructor.
- *
- * @param source
- * the eobject to modify
- * @param feature
- * the feature on which we want to do an unset
- */
- public TransactionalUnsetter(final EObject source, final EStructuralFeature feature) {
- domain = (TransactionalEditingDomain)EMFHelper.resolveEditingDomain(source);
- cmd = new UnsetCommand((TransactionalEditingDomain)domain, source, feature);
- }
-
- /**
- * this method do the unset
- */
- public void doUnset() {
- domain.getCommandStack().execute(cmd);
- }
-}

Back to the top