Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org')
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java297
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java40
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java44
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java55
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java100
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java145
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java25
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java76
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java132
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java62
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java306
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java366
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java102
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java102
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java17
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties1
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java64
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java107
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java57
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java53
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java482
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java326
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java50
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java119
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java43
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java222
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java344
-rw-r--r--sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java197
-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
50 files changed, 0 insertions, 6392 deletions
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
deleted file mode 100644
index bb975328e95..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
+++ /dev/null
@@ -1,297 +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;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.facet.infra.browser.custom.MetamodelView;
-import org.eclipse.emf.facet.infra.browser.custom.TypeView;
-import org.eclipse.emf.facet.infra.browser.custom.core.CustomizationsCatalog;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
-import org.eclipse.emf.facet.infra.facet.Facet;
-import org.eclipse.emf.facet.infra.facet.FacetSet;
-import org.eclipse.emf.facet.infra.facet.core.FacetSetCatalog;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.papyrus.infra.core.log.LogHelper;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- /**
- * The plug-in ID
- */
- public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.emf"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The plug-in's logger
- */
- public static LogHelper log;
-
- private CustomizationManager fCustomizationManager;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- log = new LogHelper(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(final BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /**
- *
- * @return the customization manager in charge to adapt element in modisco
- */
- public CustomizationManager getCustomizationManager() {
- if(this.fCustomizationManager == null) {
- this.fCustomizationManager = new CustomizationManager();
- init(this.fCustomizationManager);
- }
- return this.fCustomizationManager;
- }
-
- /**
- * Saves the current Customization Manager settings to the preferences
- */
- public void saveCustomizationManagerState() {
- IDialogSettings dialogSettings = getBrowserCustomizationDialogSettings();
-
- List<MetamodelView> appliedCustomizations = getCustomizationManager().getRegisteredCustomizations();
-
- for(MetamodelView customization : CustomizationsCatalog.getInstance().getRegistryCustomizations()) {
-
- boolean isApplied = appliedCustomizations.contains(customization);
- String settingKey = getSettingKey(customization);
-
- dialogSettings.put(settingKey, isApplied);
- }
- }
-
- private String getSettingKey(MetamodelView customization) {
- return customization.getLocation();
- }
-
- protected IDialogSettings getBrowserCustomizationDialogSettings() {
- String sectionId = CUSTOMIZATION_MANAGER_SECTION;
-
- IDialogSettings settings = Activator.getDefault().getDialogSettings().getSection(sectionId);
- if(settings == null) {
- settings = Activator.getDefault().getDialogSettings().addNewSection(sectionId);
- }
- return settings;
- }
-
- private void init(final CustomizationManager customizationManager) {
- // the appearance can be customized here:
-
- customizationManager.setShowDerivedLinks(true);
- //to hide the blue arrow overlay
- customizationManager.setDecorateExternalResources(false);
-
- IDialogSettings settings = getBrowserCustomizationDialogSettings();
-
- try {
-
- // load customizations defined as default through the customization
- // extension
- List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
- List<MetamodelView> registryAllCustomizations = CustomizationsCatalog.getInstance().getRegistryCustomizations();
-
- List<MetamodelView> appliedCustomizations = new LinkedList<MetamodelView>();
-
- for(MetamodelView customization : registryAllCustomizations) {
- String settingKey = getSettingKey(customization);
-
- boolean isActive = false;
- if(settings.get(settingKey) == null) { //Never customized
- isActive = registryDefaultCustomizations.contains(customization); //Loaded by default
- } else {
- isActive = settings.getBoolean(settingKey);
- }
-
- if(isActive) {
- customizationManager.registerCustomization(customization);
- appliedCustomizations.add(customization);
- }
- }
-
- customizationManager.loadCustomizations();
- loadFacetsForCustomizations(appliedCustomizations, customizationManager);
-
- } catch (Throwable e) {
- Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error initializing customizations", e)); //$NON-NLS-1$
- }
- }
-
- /**
- * The section name of the Dialog Settings for storing Customization Manager settings
- */
- public static final String CUSTOMIZATION_MANAGER_SECTION = PLUGIN_ID + ".customizationManager";//$NON-NLS-1$
-
- /**
- * Restores the default Customization Manager configuration
- */
- public void restoreDefaultCustomizationManager() {
- CustomizationManager manager = getCustomizationManager();
-
- DialogSettings settings = (DialogSettings)getDialogSettings();
- settings.removeSection(CUSTOMIZATION_MANAGER_SECTION);
-
- List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
-
- manager.clearCustomizations();
- for(MetamodelView customization : registryDefaultCustomizations) {
- manager.registerCustomization(customization);
- }
- manager.loadCustomizations();
- }
-
- /**
- * load the facets
- *
- * @param customizations
- * list of customization
- * @param customizationManager
- * the Customization Manager
- */
- protected void loadFacetsForCustomizations(final List<MetamodelView> customizations, final CustomizationManager customizationManager) {
- final Set<Facet> referencedFacets = new HashSet<Facet>();
- final Collection<FacetSet> facetSets = FacetSetCatalog.getSingleton().getAllFacetSets();
-
- for(MetamodelView customization : customizations) {
- String metamodelURI = customization.getMetamodelURI();
- // find customized FacetSet
- FacetSet customizedFacetSet = null;
- if(metamodelURI != null) {
- for(FacetSet facetSet : facetSets) {
- if(metamodelURI.equals(facetSet.getNsURI())) {
- customizedFacetSet = facetSet;
- break;
- }
- }
- }
- if(customizedFacetSet == null) {
- continue;
- }
-
- // find customized Facets
- EList<TypeView> types = customization.getTypes();
- for(TypeView typeView : types) {
- String metaclassName = typeView.getMetaclassName();
- Facet facet = findFacetWithFullyQualifiedName(metaclassName, customizedFacetSet);
- if(facet != null) {
- referencedFacets.add(facet);
- } else {
- Activator.log.warn(String.format("Missing required facet \"%s\" in FacetSet \"%s\" for customization \"%s\"", metaclassName, customizedFacetSet.getName(), customization.getName()));
- }
- }
-
- for(Facet referencedFacet : referencedFacets) {
- customizationManager.loadFacet(referencedFacet);
- }
- }
-
- //
- // for modified facets
- // customizationManager.getInstancesForMetaclasses().buildDerivationTree();
- // customizationManager.getAppearanceConfiguration().touch();
- // customizationManager.refreshDelayed(true);
- }
-
- /**
- * fin a facet from
- *
- * @param metaclassName
- * @param customizedFacetSet
- * @return
- */
- private Facet findFacetWithFullyQualifiedName(final String metaclassName, final FacetSet customizedFacetSet) {
- EList<Facet> facets = customizedFacetSet.getFacets();
- for(Facet facet : facets) {
- String facetName = getMetaclassQualifiedName(facet);
- if(metaclassName.equals(facetName)) {
- return facet;
- }
- }
- return null;
- }
-
- /** @return the qualified name of the given metaclass */
- public static String getMetaclassQualifiedName(final EClassifier eClass) {
- final ArrayList<String> qualifiedNameParts = new ArrayList<String>();
- final StringBuilder builder = new StringBuilder();
-
- EPackage ePackage = eClass.getEPackage();
- while(ePackage != null) {
- qualifiedNameParts.add(ePackage.getName());
- ePackage = ePackage.getESuperPackage();
- }
-
- for(int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
- builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$
- }
-
- builder.append(eClass.getName());
-
- return builder.toString();
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
deleted file mode 100644
index 21894ef9909..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
+++ /dev/null
@@ -1,40 +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.advice;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-
-/**
- * An EditHelperAdvice which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
- * When a page identifier object is deleted, the associated page is removed
- *
- * This advice is used when an Object containing a page is deleted
- *
- * @author Camille Letavernier
- *
- */
-public class DeletePageAdvice extends AbstractEditHelperAdvice {
-
- @Override
- public ICommand getBeforeDestroyElementCommand(DestroyElementRequest request) {
- final EObject objectToDestroy = request.getElementToDestroy();
- if(objectToDestroy == null) {
- return null;
- }
-
- return RemovePageHelper.getRemovePageCommand(request.getEditingDomain(), objectToDestroy);
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
deleted file mode 100644
index 8819b05bcab..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
+++ /dev/null
@@ -1,44 +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.advice;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelper;
-import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest;
-
-/**
- * An EditHelper which applies to all Papyrus page identifiers (i.e. Tables, Diagrams, ...)
- * When a page identifier object is deleted, the associated page is removed
- *
- * This EditHelper will be called when a Page is deleted
- *
- * @author Camille Letavernier
- *
- */
-public class DeletePageEditHelper extends AbstractEditHelper {
-
- @Override
- protected ICommand getDestroyElementCommand(DestroyElementRequest req) {
- ICommand baseCommand = super.getDestroyElementCommand(req);
-
- final EObject elementToDestroy = req.getElementToDestroy();
-
- ICommand removePage = RemovePageHelper.getRemovePageCommand(req.getEditingDomain(), elementToDestroy);
-
- baseCommand = CompositeCommand.compose(removePage, baseCommand);
-
- return baseCommand;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
deleted file mode 100644
index 2f55fda2fea..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
+++ /dev/null
@@ -1,55 +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.advice;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.gmf.runtime.common.core.command.CommandResult;
-import org.eclipse.gmf.runtime.common.core.command.ICommand;
-import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
-
-/**
- * A Helper to build the command used to remove the page associated to the destroyed element
- *
- * @author Camille Letavernier
- *
- */
-public class RemovePageHelper {
-
- public static ICommand getRemovePageCommand(final TransactionalEditingDomain editingDomain, final EObject elementToDestroy) {
- try {
- final IPageManager pageManager = ServiceUtilsForEObject.getInstance().getIPageManager(elementToDestroy);
- if(pageManager.allPages().contains(elementToDestroy)) {
- return new AbstractTransactionalCommand(editingDomain, "Delete page", null) {
-
- @Override
- protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
- pageManager.removePage(elementToDestroy);
- return CommandResult.newOKCommandResult();
- }
- };
- }
- } catch (ServiceException ex) {
- //Ignore
- } catch (Exception ex) {
- //Ignore
- }
-
- return null;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java
deleted file mode 100644
index 52ee15b938a..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.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:
- * Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-
-/**
- *
- * This command allows to add an EObject to a resource
- *
- */
-public class AddToResourceCommand extends AbstractCommand {
-
- /**
- * the resource
- */
- private final Resource resource;
-
- /**
- * the object to add to the resource
- */
- private final EObject toAdd;
-
- /**
- *
- * Constructor.
- *
- * @param resource
- * the resource
- * @param toAdd
- * the objectto add to the resource
- */
- public AddToResourceCommand(final Resource resource, final EObject toAdd) {
- this.resource = resource;
- this.toAdd = toAdd;
- setLabel("Add an object to a resource");
- }
-
- /**
- *
- * @see org.eclipse.emf.common.command.Command#execute()
- *
- */
- public void execute() {
- this.resource.getContents().add(this.toAdd);
- }
-
- /**
- *
- * @see org.eclipse.emf.common.command.Command#redo()
- *
- */
- public void redo() {
- execute();
- }
-
- /**
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#prepare()
- *
- */
- @Override
- protected boolean prepare() {
- return true;
- }
-
-
- /**
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#undo()
- *
- */
- @Override
- public void undo() {
- this.resource.getContents().remove(this.toAdd);
- }
-
- /**
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
- *
- */
- @Override
- public boolean canExecute() {
- return super.canExecute() && this.resource != null;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
deleted file mode 100644
index c253c04e724..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
+++ /dev/null
@@ -1,145 +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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
-
- public EModelElement getObject() {
- return object;
- }
-
- // @unused
- public void setObject(EModelElement object) {
- this.object = object;
- }
-
- // @unused
- public String getEAnnotationName() {
- return eAnnotationName;
- }
-
- // @unused
- public void setEAnnotationName(String annotationName) {
- eAnnotationName = annotationName;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- /**
- * Instantiates a new creates the e annotation command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param eannotationName
- * the eannotation name
- */
- public CreateEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- attachEannotation(createEAnnotation(), object);
-
- }
-
- /**
- * Creates the e annotation.
- *
- * @return the e annotation
- */
- protected EAnnotation createEAnnotation() {
- EAnnotation eannotation = EcoreFactory.eINSTANCE.createEAnnotation();
- eannotation.setSource(eAnnotationName);
- return eannotation;
- }
-
- /**
- * Attach eannotation to an EmodelElement.
- *
- * @param annotation
- * the annotation
- * @param object
- * the object
- */
- protected void attachEannotation(EAnnotation annotation, EModelElement object) {
- object.getEAnnotations().add(annotation);
- }
-
- /**
- * Replace existing eannotation with a new eannotation. This repplaced eannotation has the same
- * source.
- *
- * @param annotation
- * the annotation
- * @param object
- * the object
- */
- protected void replaceEannotation(EAnnotation annotation, EModelElement object) {
- while(object.getEAnnotation(annotation.getSource()) != null) {
- object.getEAnnotations().remove(object.getEAnnotation(annotation.getSource()));
- }
-
- object.getEAnnotations().add(annotation);
- }
-
- /**
- * Adds the entry.
- *
- * @param annotation
- * the annotation
- * @param key
- * the key
- * @param value
- * the value
- */
- // @unused
- protected void addEntry(EAnnotation annotation, String key, String value) {
- annotation.getDetails().put(key, value);
- }
-
- /**
- * Replace entry.
- *
- * @param annotation
- * the annotation not null
- * @param key
- * the key
- * @param value
- * the value
- */
- protected void replaceEntry(EAnnotation annotation, String key, String value) {
- while(annotation.getDetails().get(key) != null) {
- annotation.getDetails().removeKey(key);
-
- }
- annotation.getDetails().put(key, value);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
deleted file mode 100644
index e2a59d4646b..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
+++ /dev/null
@@ -1,25 +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:
- *
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-
-/**
- * Constants for the duplication commands.
- */
-public interface IPapyrusDuplicateCommandConstants {
-
- /** Constant used as a key for the parameters map of the duplication request */
- public final String ADDITIONAL_DUPLICATED_ELEMENTS = "Additional_Duplicated_Elements"; //$NON-NLS-1$
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
deleted file mode 100644
index bca16f5e807..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
+++ /dev/null
@@ -1,76 +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:
- * Remi Schnekenburger (CEA LIST) - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.commands;
-
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- * This {@link RecordingCommand} removes an eannotation to a given element.
- */
-public class RemoveEAnnotationCommand extends org.eclipse.emf.transaction.RecordingCommand {
-
- // @unused
- public EModelElement getObject() {
- return object;
- }
-
- // @unused
- public void setObject(EModelElement object) {
- this.object = object;
- }
-
- // @unused
- public String getEAnnotationName() {
- return eAnnotationName;
- }
-
- // @unused
- public void setEAnnotationName(String annotationName) {
- eAnnotationName = annotationName;
- }
-
- /** The object. */
- private EModelElement object;
-
- /** The e annotation name. */
- private String eAnnotationName;
-
- /**
- * Instantiates a new creates the e annotation command.
- *
- * @param domain
- * the domain
- * @param object
- * the object
- * @param eannotationName
- * the eannotation name
- */
- public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
- super(domain);
- this.object = object;
- this.eAnnotationName = eannotationName;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doExecute() {
- EAnnotation annotation = object.getEAnnotation(eAnnotationName);
- object.getEAnnotations().remove(annotation);
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java
deleted file mode 100644
index 1d87e223a28..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java
+++ /dev/null
@@ -1,132 +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.commands;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-
-/**
- *
- * This command allows to remove elements from a resource
- *
- */
-public class RemoveFromResourcecommand extends RecordingCommand {
-
- /**
- * the managed resource
- */
- final private Resource resource;
-
- /**
- * the element to remove from the resource
- */
- final private EObject toRemove;
-
- /**
- * the list of the elements to remove from the resource
- */
- final private Collection<EObject> elementsToRemove;
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * the editing domain
- * @param resource
- * the resource
- * @param toRemove
- * the element to remove
- */
- public RemoveFromResourcecommand(final TransactionalEditingDomain domain, final Resource resource, final EObject toRemove) {
- this(domain, resource, toRemove, null);
- }
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * the editing domain
- * @param resource
- * the resource
- * @param elementsToRemove
- * the list of the elements to remove
- */
- public RemoveFromResourcecommand(final TransactionalEditingDomain domain, final Resource resource, final Collection<EObject> elementsToRemove) {
- this(domain, resource, null, elementsToRemove);
- }
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * the editing domain
- * @param resource
- * the resource
- * @param toRemove
- * the element to remove
- * @param elementsToRemove
- * the list of the elements to remove
- */
- protected RemoveFromResourcecommand(final TransactionalEditingDomain domain, final Resource resource, final EObject toRemove, final Collection<EObject> elementsToRemove) {
- super(domain, "Remove an EObject from a resource");
- this.resource = resource;
- this.toRemove = toRemove;
- this.elementsToRemove = elementsToRemove;
- }
-
- /**
- *
- * remove the element(s) of the resource
- *
- */
- @Override
- protected void doExecute() {
- try {
- if(this.toRemove != null) {
- this.resource.getContents().remove(toRemove);
- }
-
- if(this.elementsToRemove != null) {
- this.resource.getContents().removeAll(elementsToRemove);
- }
- } catch (Exception e) {
- int i = 0;
- i++;
- }
- }
-
-
- /**
- *
- * @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
- *
- * @return
- */
- @Override
- public boolean canExecute() {
- boolean result = super.canExecute();
- if(toRemove == null && elementsToRemove == null) {
- return false;
- }
- return result;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
deleted file mode 100644
index a5b70fd6c1e..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
+++ /dev/null
@@ -1,62 +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.commands;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
-import org.eclipse.papyrus.infra.emf.messages.Messages;
-
-
-public class UnsetCommand extends RecordingCommand {
-
- /**
- * the source eobject
- */
- private final EObject source;
-
- /**
- * the feature
- */
- private final EStructuralFeature feature;
-
- /**
- *
- * Constructor.
- *
- * @param domain
- * the editing domain
- * @param source
- * the eobject to modify
- * @param feature
- * the feature to unset
- */
- public UnsetCommand(final TransactionalEditingDomain domain, final EObject source, final EStructuralFeature feature) {
- super(domain, Messages.UnsetCommand_UnsetCommand);
- this.source = source;
- this.feature = feature;
- }
-
- /**
- *
- * @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
- */
- @Override
- protected void doExecute() {
- source.eUnset(feature);
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
deleted file mode 100644
index 1e690d4c09a..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
+++ /dev/null
@@ -1,306 +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.databinding;
-
-import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-
-/**
- * An IObservableValue for editing EMF EAnnotations
- *
- * @author Camille Letavernier
- */
-public class AnnotationObservableValue extends AbstractObservableValue {
-
- /**
- * The EModelElement to edit.
- */
- protected EModelElement source;
-
- /**
- * The editing domain on which the commands will be executed
- */
- protected EditingDomain domain;
-
- /**
- * The name of the annotation to use
- */
- protected String annotationName;
-
- /**
- * The annotation key to edit
- */
- protected String key;
-
- /**
- * Whether the EAnnotation should be removed from the source when its last
- * entry is removed (ie. value = null)
- */
- protected boolean deleteWithLastEntry;
-
- /**
- * Constructor.
- *
- * Creates an IObservableValue for the annotation. The annotation doesn't
- * need to be created beforehand
- *
- * @param source
- * The EObject owning the annotation
- * @param domain
- * The editing domain on which the commands will be executed
- * @param annotationName
- * The name of the annotation
- * @param key
- * The name of annotation's property to edit
- */
- public AnnotationObservableValue(EModelElement source, EditingDomain domain, String annotationName, String key) {
- this(source, domain, annotationName, key, false);
- }
-
- /**
- * Constructor.
- *
- * Creates an IObservableValue for the annotation. The annotation doesn't
- * need to be created beforehand
- *
- * @param source
- * The EObject owning the annotation
- * @param domain
- * The editing domain on which the commands will be executed
- * @param annotationName
- * The name of the annotation
- * @param key
- * The name of annotation's property to edit
- * @param deleteWithLastEntry
- * Whether the EAnnotation should be removed from the source when its
- * last entry is removed (ie. value = null)
- */
- public AnnotationObservableValue(EModelElement source, EditingDomain domain, String annotationName, String key, boolean deleteWithLastEntry) {
- this.source = source;
- this.domain = domain;
- this.annotationName = annotationName;
- this.key = key;
- this.deleteWithLastEntry = deleteWithLastEntry;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getValueType() {
- return String.class;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected Object doGetValue() {
- EAnnotation annotation = getEAnnotation();
- if(annotation == null) {
- return null;
- }
-
- return annotation.getDetails().get(key);
- }
-
- /**
- * @return the observed EAnnotation
- */
- protected EAnnotation getEAnnotation() {
- return source.getEAnnotation(annotationName);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void doSetValue(Object value) {
- Command emfCommand = getCommand(value);
- if(emfCommand != null) {
- domain.getCommandStack().execute(emfCommand);
- }
- }
-
- /**
- * Returns the command used to edit the observed annotation, which the
- * given value
- *
- * @param value
- * @return
- */
- protected Command getCommand(Object value) {
- EAnnotation annotation = getEAnnotation();
-
- if(value == null) {
- //No change : the key is not defined ; we cannot remove it
- if(annotation == null || !annotation.getDetails().containsKey(key)) {
- return null;
- }
- } else {
- if(!(value instanceof String)) {
- return null;
- }
- }
-
- CompoundCommand emfCommand = new CompoundCommand("Set " + key) {
-
- @Override
- public boolean prepare() {
- if(this.isEmpty()) {
- return false;
- }
-
- return commandList.get(0).canExecute();
- }
-
- };
-
- if(annotation == null) {
- annotation = EcoreFactory.eINSTANCE.createEAnnotation();
-
- SetCommand attachToSourceCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), source);
- attachToSourceCommand.setLabel("Attach to source");
- emfCommand.append(attachToSourceCommand);
-
- SetCommand nameCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_Source(), annotationName);
- nameCommand.setLabel("Set name");
- emfCommand.append(nameCommand);
- }
-
- if(value == null) {
- if(annotation.getDetails().size() == 1 && annotation.getDetails().containsKey(key) && deleteWithLastEntry) {
- //We removed the last key : delete the annotation
- SetCommand deleteAnnotationCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), null);
- deleteAnnotationCommand.setLabel("Delete EAnnotation");
- emfCommand.append(deleteAnnotationCommand);
- } else {
- Command removeEntryCommand = new RemoveEntryCommand(annotation, key);
- emfCommand.append(removeEntryCommand);
- }
- } else {
- Command addEntryCommand = new AddEntryCommand(annotation, key, (String)value);
- emfCommand.append(addEntryCommand);
- }
-
- return emfCommand;
- }
-
- /**
- * A Command to remove an entry from an EAnnotation
- *
- * @author Camille Letavernier
- *
- */
- protected class RemoveEntryCommand extends AbstractCommand {
-
- private EAnnotation annotation;
-
- private String key;
-
- private String previousValue;
-
- private boolean undo = false;
-
- /**
- * Constructor
- *
- * @param annotation
- * The EAnnotation to edit
- * @param key
- * The EAnnotation's key to edit
- */
- public RemoveEntryCommand(EAnnotation annotation, String key) {
- this.annotation = annotation;
- this.key = key;
- }
-
- public void execute() {
- undo = annotation.getDetails().containsKey(key);
- if(undo) {
- previousValue = annotation.getDetails().get(key);
- annotation.getDetails().remove(key);
- }
- }
-
- public void redo() {
- execute();
- }
-
- @Override
- public boolean prepare() {
- return true;
- }
-
- @Override
- public void undo() {
- if(undo) {
- annotation.getDetails().put(key, previousValue);
- }
- }
- }
-
- /**
- * A Command to set an EAnnotation's entry
- *
- * @author Camille Letavernier
- */
- protected class AddEntryCommand extends AbstractCommand {
-
- private EAnnotation annotation;
-
- private String key;
-
- private String value;
-
- /**
- *
- *
- * @param annotation
- * The EAnnotation to edit
- * @param key
- * The EAnnotation's key to edit
- * @param value
- * The value to set
- */
- public AddEntryCommand(EAnnotation annotation, String key, String value) {
- this.annotation = annotation;
- this.key = key;
- this.value = value;
- }
-
- public void execute() {
- annotation.getDetails().put(key, value);
- }
-
- public void redo() {
- execute();
- }
-
- @Override
- public void undo() {
- annotation.getDetails().remove(key);
- }
-
- @Override
- public boolean prepare() {
- return true;
- }
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
deleted file mode 100644
index 67b5f24364b..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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.databinding;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.databinding.observable.list.ObservableList;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
-import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
-
-/**
- * An ObservableList using EMF Commands to edit the underlying list.
- * The commands are executed when the {@link #commit(AbstractEditor)} method is called.
- * However, the read operations (such as get, size, ...) return up-to-date
- * results, even when {@link #commit(AbstractEditor)} hasn't been called.
- *
- * @author Camille Letavernier
- */
-@SuppressWarnings({ "unchecked", "rawtypes" })
-public class EMFObservableList extends ObservableList implements ICommitListener {
-
- /**
- * The list of commands that haven't been executed yet
- */
- protected List<Command> commands = new LinkedList<Command>();
-
- /**
- * The editing domain on which the commands will be executed
- */
- protected EditingDomain editingDomain;
-
- /**
- * The edited EObject
- */
- protected EObject source;
-
- /**
- * The feature being edited
- */
- protected EStructuralFeature feature;
-
- /**
- * The list to be updated only on #commit() calls
- */
- protected List<?> concreteList;
-
- /**
- *
- * Constructor.
- *
- * @param wrappedList
- * The list to be edited when #commit() is called
- * @param domain
- * The editing domain on which the commands will be executed
- * @param source
- * The EObject from which the list will be retrieved
- * @param feature
- * The feature from which the list will be retrieved
- */
- public EMFObservableList(List<?> wrappedList, EditingDomain domain, EObject source, EStructuralFeature feature) {
- super(new LinkedList<Object>(wrappedList), Object.class);
- this.concreteList = wrappedList;
- this.editingDomain = domain;
- this.source = source;
- this.feature = feature;
- }
-
- /**
- * Forces this list to commit all the pending commands. Only one composite command will
- * be executed, and can be undone in a single operation.
- *
- * @see org.eclipse.papyrus.infra.widgets.editors.ICommitListener#commit(AbstractEditor)
- *
- */
- public void commit(AbstractEditor editor) {
-
- if(commands.isEmpty()) {
- return;
- }
-
- CompoundCommand compoundCommand = new CompoundCommand() {
-
- @Override
- public void execute() {
- super.execute();
- refreshCacheList();
- }
-
- @Override
- public void undo() {
- super.undo();
- refreshCacheList();
- }
-
- @Override
- public void redo() {
- super.redo();
- refreshCacheList();
- }
-
- @Override
- protected boolean prepare() {
- if(commandList.isEmpty()) {
- return false;
- } else {
- //We only test the first command, as the following ones might depend
- //on the first command's execution. StrictCompoundCommands don't seem
- //to be compatible with emf transaction (execute() is called by
- //canExecute(), before the transaction is started)
- return commandList.get(0).canExecute();
- }
- }
- };
-
- for(Command cmd : commands) {
- compoundCommand.append(cmd);
- }
-
- editingDomain.getCommandStack().execute(compoundCommand);
- refreshCacheList();
- commands.clear();
- }
-
- /**
- * Refresh the cached list by copying the real list
- */
- protected void refreshCacheList() {
- if(isDisposed()) {
- //This observable can be disposed, but the commands might still be
- //in the command stack. Undo() or Redo() will call this method, which
- //should be ignored. The command should probably not call refresh directly ;
- //we should have listeners on the concrete list... but it is not necessarily
- //observable
- return;
- }
- wrappedList.clear();
- wrappedList.addAll(concreteList);
- fireListChange(null);
- }
-
- @Override
- public void add(int index, Object value) {
- Command command = getAddCommand(index, value);
- commands.add(command);
-
- wrappedList.add(index, value);
- fireListChange(null);
- }
-
- @Override
- public void clear() {
- Command command = getClearCommand();
- commands.add(command);
-
- wrappedList.clear();
- fireListChange(null);
- }
-
- @Override
- public boolean add(Object o) {
- Command command = getAddCommand(o);
- commands.add(command);
-
- boolean result = wrappedList.add(o);
- fireListChange(null);
- return result;
- }
-
- @Override
- public boolean remove(Object o) {
- Command command = getRemoveCommand(o);
-
- commands.add(command);
-
- boolean result = wrappedList.remove(o);
- fireListChange(null);
- return result;
- }
-
- @Override
- public boolean addAll(Collection c) {
- Command command = getAddAllCommand(c);
- commands.add(command);
-
- boolean result = wrappedList.addAll(c);
- fireListChange(null);
- return result;
- }
-
- @Override
- public boolean addAll(int index, Collection c) {
- Command command = getAddAllCommand(index, c);
- commands.add(command);
-
- boolean result = wrappedList.addAll(index, c);
- fireListChange(null);
- return result;
- }
-
- @Override
- public boolean removeAll(Collection c) {
- Command command = getRemoveCommand(c);
- commands.add(command);
-
- boolean result = wrappedList.removeAll(c);
- fireListChange(null);
- return result;
- }
-
- @Override
- public boolean retainAll(Collection c) {
- Command command = getRetainAllCommand(c);
- commands.add(command);
-
- boolean result = wrappedList.retainAll(c);
- fireListChange(null);
- return result;
- }
-
- @Override
- public Object set(int index, Object element) {
- Command command = getSetCommand(index, element);
- commands.add(command);
-
- Object result = wrappedList.set(index, element);
- fireListChange(null);
- return result;
- }
-
- @Override
- public Object move(int oldIndex, int newIndex) {
- commands.addAll(getMoveCommands(oldIndex, newIndex));
-
- Object value = get(oldIndex);
- wrappedList.remove(oldIndex);
- wrappedList.add(newIndex, value);
-
- fireListChange(null);
-
- return value;
- }
-
- @Override
- public Object remove(int index) {
- Object value = get(index);
- if(value != null) {
- Command command = getRemoveCommand(index);
- commands.add(command);
- }
-
- Object result = wrappedList.remove(index);
- fireListChange(null);
- return result;
- }
-
- public Command getAddCommand(int index, Object value) {
- return AddCommand.create(editingDomain, source, feature, value, index);
- }
-
- public Command getAddCommand(Object value) {
- return AddCommand.create(editingDomain, source, feature, value);
- }
-
- public Command getAddAllCommand(Collection<?> values) {
- return AddCommand.create(editingDomain, source, feature, values);
- }
-
- public Command getAddAllCommand(int index, Collection<?> values) {
- return AddCommand.create(editingDomain, source, feature, values, index);
- }
-
- public Command getClearCommand() {
- return getRemoveAllCommand(new LinkedList<Object>(wrappedList));
- }
-
- public Command getRemoveCommand(int index) {
- Object value = get(index);
- return getRemoveCommand(value);
- }
-
- public Command getRemoveCommand(Object value) {
- Command cmd = RemoveCommand.create(editingDomain, source, feature, value);
- if (value instanceof EObject && feature instanceof EReference && ((EReference)feature).isContainment()) {
- addDestroyCommand(cmd, (EObject)value);
- }
- return cmd;
- }
-
- public Command getRemoveAllCommand(Collection<?> values) {
- CompoundCommand cc = new CompoundCommand("Edit list");
-
- if (feature instanceof EReference && ((EReference)feature).isContainment() && values != null) {
- for (Object o : values) {
- if (o instanceof EObject) {
- addDestroyCommand(cc, (EObject)o);
- }
- }
- }
-
- cc.append(RemoveCommand.create(editingDomain, source, feature, values));
- return cc;
- }
-
- public List<Command> getMoveCommands(int oldIndex, int newIndex) {
- Object value = get(oldIndex);
- List<Command> commands = new LinkedList<Command>();
- commands.add(getRemoveCommand(value));
- commands.add(getAddCommand(newIndex, value));
- return commands;
- }
-
- public Command getRetainAllCommand(Collection<?> values) {
- List<Object> objectsToRemove = new LinkedList<Object>();
- for(Object object : values) {
- if(!contains(object)) {
- objectsToRemove.add(object);
- }
- }
- if(!objectsToRemove.isEmpty()) {
- return getRemoveAllCommand(objectsToRemove);
- } else {
- return null;
- }
- }
-
- public Command getSetCommand(int index, Object value) {
- Object oldValue = get(index);
- Command command = SetCommand.create(editingDomain, source, feature, value, index);
- if (oldValue instanceof EObject && feature instanceof EReference && ((EReference)feature).isContainment()) {
- addDestroyCommand(command, (EObject)oldValue);
- }
- return command;
- }
-
- protected void addDestroyCommand(Command cmd, EObject objToDestroy) {
- Command destroyCmd = DeleteCommand.create(editingDomain, objToDestroy);
-
- if (cmd instanceof CompoundCommand) {
- ((CompoundCommand)cmd).append(destroyCmd);
- } else {
- cmd.chain(destroyCmd);
- }
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
deleted file mode 100644
index 6ddd393f854..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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.databinding;
-
-import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.databinding.EObjectObservableValue;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.command.DeleteCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-
-/**
- * An Observable value to edit EMF values through EMF commands.
- *
- * @author Camille Letavernier
- */
-public class EMFObservableValue extends EObjectObservableValue {
-
- /**
- * The editing domain on which the commands will be executed
- */
- protected EditingDomain domain;
-
- /**
- *
- * Constructor.
- *
- * @param eObject
- * The eObject being edited
- * @param eStructuralFeature
- * The structuralFeature being edited
- * @param domain
- * The Editing domain on which the commands will be executed
- */
- public EMFObservableValue(EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) {
- this(Realm.getDefault(), eObject, eStructuralFeature, domain);
- }
-
- /**
- *
- * Constructor.
- *
- * @param realm
- * @param eObject
- * The eObject being edited
- * @param eStructuralFeature
- * The structuralFeature being edited
- * @param domain
- * The Editing domain on which the commands will be executed
- */
- public EMFObservableValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) {
- super(realm, eObject, eStructuralFeature);
- this.domain = domain;
- }
-
- @Override
- protected void doSetValue(Object value) {
- EObject eObject = EMFHelper.getEObject(value);
- if(eObject != null) {
- value = eObject;
- }
-
- Command command = getSetCommand(value);
- domain.getCommandStack().execute(command);
- }
-
- /**
- * Returns the command used to edit the value
- *
- * @param value
- * The new value
- * @return
- * The Set command used to edit the value
- */
- protected Command getSetCommand(Object value) {
- Object oldValue = getValue();
-
- CompoundCommand cc = new CompoundCommand("Edit value");
-
- if (oldValue instanceof EObject && eStructuralFeature instanceof EReference && ((EReference)eStructuralFeature).isContainment()) {
- cc.append(DeleteCommand.create(domain, (EObject)oldValue));
- }
-
- cc.append(new SetCommand(domain, eObject, eStructuralFeature, value));
-
- return cc;
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java
deleted file mode 100644
index be0fbe08ce4..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java
+++ /dev/null
@@ -1,102 +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.dialog;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- *
- * This dialog allows to create a command using a progress bar dialog
- * Typical usage is:
- *
- * <pre>
- * CreationCommandProgressMonitorDialog commandCreationDialog = new CreationCommandProgressMonitorDialog(Display.getShell());
- *
- * try {
- * commandCreationDialog.run(true, true, new IRunnableWithProgress() {
- *
- * public void run(final IProgressMonitor cancelProvider) throws InvocationTargetException, InterruptedException {
- * final Command cmd = commandProvider.getCommand();
- * commandCreationDialog.setCreatedCommand(cmd);
- * }
- * });
- * } catch (final InvocationTargetException e) {
- * Activator.log.error(e);
- * } catch (final InterruptedException e) {
- * Activator.log.error(e);
- * }
- * final int returnCode = commandCreationDialog.getReturnCode();
- * if(returnCode == Window.OK) {
- * final Command createdCommand = commandCreationDialog.getCreatedCommand();
- * ...
- * }
- * </pre>
- */
-public class CommandCreationProgressMonitorDialog extends ProgressMonitorDialog {
-
- /** the created command */
- private Command createdCommand = null;
-
- /** an exception threw by the command creation */
- private Exception exception;
-
- /**
- *
- * Constructor.
- *
- * @param parent
- */
- public CommandCreationProgressMonitorDialog(final Shell parent) {
- super(parent);
-
- }
-
- /**
- * Setter for {@link #createdCommand}
- *
- * @param cmd
- * the created command
- */
- public void setCreatedCommand(final Command cmd) {
- this.createdCommand = cmd;
- }
-
- /**
- * Getter for {@link #createdCommand}
- *
- * @return
- * the created command
- */
- public Command getCreatedCommand() {
- return this.createdCommand;
- }
-
- public void setCaughtException(final Exception e) {
- this.exception = e;
- }
-
- /**
- *
- * @return
- * the exception throwed by the command creation
- */
- public Exception getCaughtException() {
- return this.exception;
- }
-
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
deleted file mode 100644
index 04d8fa9b5a0..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.eclipse.papyrus.infra.emf.messages;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
-
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.emf.messages.messages"; //$NON-NLS-1$
-
- public static String UnsetCommand_UnsetCommand;
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties
deleted file mode 100644
index b5119e19f07..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-UnsetCommand_UnsetCommand=Unset Command
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java
deleted file mode 100644
index 4e1203a22e1..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java
+++ /dev/null
@@ -1,64 +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.providers;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xml.type.AnyType;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * A LabelProvider for unresolved "AnyType" elements
- *
- * @author Camille Letavernier
- *
- */
-public class AnyTypeLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
-
- @Override
- public String getText(Object element) {
- EObject eObject = EMFHelper.getEObject(element);
-
- if(!(eObject instanceof AnyType)) {
- return super.getText(element);
- }
-
- AnyType anyType = (AnyType)eObject;
- EClass eClass = anyType.eClass();
- if(eClass != null) {
- return "Missing " + eClass.getName();
- } else {
- return "Missing component";
- }
- }
-
- @Override
- public Image getImage(Object element) {
- EObject eObject = EMFHelper.getEObject(element);
- if(!(eObject instanceof AnyType)) {
- return super.getImage(element);
- }
-
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
- }
-
- public boolean accept(Object element) {
- return EMFHelper.getEObject(element) instanceof AnyType;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
deleted file mode 100644
index b03ffe1f2f2..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
+++ /dev/null
@@ -1,107 +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.providers;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-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.strategy.ContainmentBrowseStrategy;
-import org.eclipse.papyrus.infra.emf.providers.strategy.SemanticEMFContentProvider;
-import org.eclipse.papyrus.infra.emf.utils.HistoryUtil;
-import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
-import org.eclipse.papyrus.infra.widgets.strategy.IStrategyBasedContentProvider;
-import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
-import org.eclipse.papyrus.infra.widgets.strategy.StrategyBasedContentProvider;
-import org.eclipse.papyrus.infra.widgets.strategy.TreeBrowseStrategy;
-
-/**
- * A global Content provider for EMF
- *
- * @author Camille Letavernier
- */
-public class EMFContentProvider extends EncapsulatedContentProvider {
-
- /**
- *
- * Constructor.
- *
- * @param feature
- * The feature representing the reference for which we want to retrieve possible values
- * @param eObject
- */
- public EMFContentProvider(EObject editedEObject, EStructuralFeature feature) {
- IStructuredContentProvider provider = getSemanticProvider(editedEObject, feature);
-
- encapsulated = encapsulateProvider(provider, editedEObject, feature);
- }
-
- /**
- * Returns the content provider associated to feature being edited
- *
- * @param editedEObject
- * The object being edited
- * @param feature
- * The object's feature being edited
- * @return
- * A content provider returning all the values valid for the given feature
- */
- protected IStructuredContentProvider getSemanticProvider(EObject editedEObject, EStructuralFeature feature) {
- EClassifier type = feature.getEType();
- if(type instanceof EEnum) {
- return new EMFEnumeratorContentProvider(feature);
- } else if(type instanceof EClass) {
- return new SemanticEMFContentProvider(editedEObject, feature);
- }
-
- return EmptyContentProvider.instance;
- }
-
- /**
- * 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
- */
- protected EMFGraphicalContentProvider encapsulateProvider(IStructuredContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
- String historyId = HistoryUtil.getHistoryID(editedEObject, feature);
-
- IStructuredContentProvider contentProvider;
-
- if(provider instanceof ITreeContentProvider) {
- contentProvider = getStrategyProvider((ITreeContentProvider)provider);
- } else {
- contentProvider = provider;
- }
-
- ResourceSet rs = editedEObject == null ? null : editedEObject.eResource() == null ? null : editedEObject.eResource().getResourceSet();
- EMFGraphicalContentProvider graphicalProvider = new EMFGraphicalContentProvider(contentProvider, rs, historyId);
-
- return graphicalProvider;
- }
-
- protected IStrategyBasedContentProvider getStrategyProvider(ITreeContentProvider provider) {
- TreeBrowseStrategy browseStrategy = new ProviderBasedBrowseStrategy(provider);
- TreeBrowseStrategy revealStrategy = new ContainmentBrowseStrategy(provider);
-
- return new StrategyBasedContentProvider(browseStrategy, revealStrategy);
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
deleted file mode 100644
index a4d5f0c9d1d..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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.providers;
-
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
-
-/**
- * An IStaticContentProvider for EMF enumerators.
- *
- * @author Camille Letavernier
- */
-public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider {
-
- /**
- * The feature representing the Enumerator for this ContentProvider
- */
- protected EStructuralFeature feature;
-
- /**
- * Constructs an EcoreEnumerator for the given Structural Feature
- *
- * @param feature
- */
- public EMFEnumeratorContentProvider(EStructuralFeature feature) {
- this.feature = feature;
- }
-
- public Object[] getElements() {
- EClassifier type = feature.getEType();
- EEnum enumerated = (EEnum)type;
- EEnumLiteral[] literals = enumerated.getELiterals().toArray(new EEnumLiteral[0]);
- Enumerator[] values = new Enumerator[literals.length];
-
- int i = 0;
- for(EEnumLiteral literal : literals) {
- Enumerator value = literal.getInstance();
- values[i++] = value;
- }
-
- return values;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java
deleted file mode 100644
index 4b8190009c1..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java
+++ /dev/null
@@ -1,53 +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.providers;
-
-import java.util.Iterator;
-
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelProvider;
-
-/**
- * A LabelProvider which only accepts EMF Objects (EObject, or objects which can be adapted to EObjects)
- *
- * @author Camille Letavernier
- *
- */
-public class EMFFilteredLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
-
- public boolean accept(IStructuredSelection selection) {
- if(selection.isEmpty()) {
- return false;
- }
-
- Iterator<?> iterator = selection.iterator();
- while(iterator.hasNext()) {
- Object element = iterator.next();
- if(!accept(element)) {
- return false;
- }
- }
-
- return true;
- }
-
- public boolean accept(Object element) {
- if(element instanceof IStructuredSelection) {
- return accept((IStructuredSelection)element);
- }
-
- //The element is an EObject or can be adapted to an EObject
- return EMFHelper.getEObject(element) != null;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
deleted file mode 100644
index 16cc0586c3a..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Added graphic contributions for the filters
- * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial History implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - History integration
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IDetailLabelProvider;
-import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
-import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
-import org.eclipse.papyrus.infra.widgets.editors.StringEditor;
-import org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.EncapsulatedContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.PatternViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * This providers adds a text-filter and an History to EMF-based content providers
- */
-//TODO : Extend (Abstract)FilteredContentProvider
-public class EMFGraphicalContentProvider extends EncapsulatedContentProvider implements ISelectionChangedListener {
-
- private static final String DIALOG_SETTINGS = EMFGraphicalContentProvider.class.getName();
-
- protected String historyId;
-
- //Unused (yet)
- //TODO : Add a preference or a collapsible composite for this feature (Or both)
- //
- // /**
- // * The current metaclass viewer filter
- // */
- // protected ViewerFilter currentMetaclassViewerFilter;
-
- protected ViewerFilter patternFilter;
-
- private static final String HISTORY_SETTINGS = "History"; //$NON-NLS-1$
-
- private static final String PREVIOUS_SELECTION = "PreviousSelection";
-
- protected List<EObject> selectionHistory;
-
- protected CLabel detailLabel;
-
- protected Object selectedObject;
-
- protected StructuredViewer viewer;
-
- protected ResourceSet resourceSet;
-
- private static final int HISTORY_MAX_SIZE = 5;
-
- private String currentFilterPattern;
-
- private TableViewer historyViewer;
-
- /**
- * the wanted root of the contentprovider
- */
-
- /**
- * the constructor
- */
- public EMFGraphicalContentProvider(IStructuredContentProvider semanticProvider, ResourceSet resourceSet, String historyId) {
- super(semanticProvider);
- this.historyId = historyId;
- this.resourceSet = resourceSet;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void createBefore(Composite parent) {
- createPatternFilter(parent);
- }
-
- protected void createPatternFilter(Composite parent) {
- StringEditor editor = new StringEditor(parent, SWT.NONE);
- editor.setLabel("Filter:");
- editor.setToolTipText("Enter the name of the element you're looking for. You can use * as a wildcard");
- editor.setValidateOnDelay(true);
- patternFilter = new PatternViewerFilter();
- currentFilterPattern = ""; //$NON-NLS-1$
- ((PatternViewerFilter)patternFilter).setPattern(currentFilterPattern);
-
- editor.addCommitListener(new ICommitListener() {
-
- public void commit(AbstractEditor editor) {
- String filterPattern = (String)((StringEditor)editor).getValue();
- ((PatternViewerFilter)patternFilter).setPattern(filterPattern);
- viewer.refresh();
- if(!("".equals(filterPattern) || currentFilterPattern.equals(filterPattern))) {
-
- //FIXME: The reveal first match algorithm is not compatible with infinite trees and had bad performances
- //Object firstMatch = getFirstMatchingElement(null);
- //if(firstMatch != null) {
- // revealSemanticElement(Collections.singletonList(firstMatch));
- //}
-
- currentFilterPattern = filterPattern;
- }
- }
-
- });
-
- List<ViewerFilter> filters = new LinkedList<ViewerFilter>(Arrays.asList(viewer.getFilters()));
- filters.add(patternFilter);
- viewer.setFilters(filters.toArray(new ViewerFilter[filters.size()]));
- }
-
- /**
- * Returns the first (encapsulated) element matching the current filters
- *
- * @return
- */
- protected Object getFirstMatchingElement(Object parent) {
- //Browse from the root element
- if(parent == null) {
- for(Object parentElement : getElements(viewer.getInput())) {
- Object firstMatch = getFirstMatchingElement(parentElement);
- if(firstMatch != null) {
- return firstMatch;
- }
- }
- return null;
- }
-
- for(ViewerFilter filter : viewer.getFilters()) {
- if(!filter.select(viewer, getParent(parent), parent)) {
- return null;
- }
- }
-
- //Test the current element
- if(isValidValue(parent)) {
- return parent;
- }
-
- //Browse the child elements
- for(Object childElement : getChildren(parent)) {
- Object firstMatch = getFirstMatchingElement(childElement);
- if(firstMatch != null) {
- return firstMatch;
- }
- }
-
- //No match found
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void createAfter(Composite parent) {
- parent.setLayout(new GridLayout(1, false));
- // createMetaclassFilter(parent); //Disabled
- createHistory(parent);
- createDetailArea(parent);
- }
-
- /**
- * Creates a widget referencing the recently selected elements
- *
- * @param parent
- * The composite in which the widget will be created
- */
- protected void createHistory(Composite parent) {
- initSelectionHistory();
-
- Group historyGroup = new Group(parent, SWT.NONE);
- historyGroup.setText("Recent selections");
- historyGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
- historyGroup.setLayout(new GridLayout(1, true));
-
- // table
- Table historyTable = new Table(historyGroup, SWT.BORDER | SWT.SINGLE);
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
- data.heightHint = 70;
- historyTable.setLayoutData(data);
- historyViewer = new TableViewer(historyTable);
- historyViewer.setContentProvider(CollectionContentProvider.instance);
- historyViewer.setLabelProvider(viewer.getLabelProvider());
- historyViewer.setInput(selectionHistory);
- historyViewer.addSelectionChangedListener(new ISelectionChangedListener() {
-
- /**
- * {@inheritDoc}
- */
- public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection)historyViewer.getSelection();
- Object selectedObject = selection.getFirstElement();
- if(selectedObject instanceof EObject) {
- EObject eObject = ((EObject)selectedObject);
- revealSemanticElement(Collections.singletonList(eObject));
- }
- }
- });
- }
-
- /**
- * Inits the History
- */
- protected void initSelectionHistory() {
- selectionHistory = new ArrayList<EObject>(HISTORY_MAX_SIZE + 1);
-
- IDialogSettings historySettings = getDialogSettings().getSection(HISTORY_SETTINGS);
- if(historySettings != null && resourceSet != null) {
- String[] uriHistory = historySettings.getArray(PREVIOUS_SELECTION);
- // for each element in the list, try to get the EObject by its URI
- if(uriHistory != null) {
- for(String uri : uriHistory) {
- try {
- EObject object = resourceSet.getEObject(URI.createURI(uri), true);
- if(object != null && !selectionHistory.contains(object)) {
- selectionHistory.add(object);
- }
- } catch (Exception ex) {
- //Ignore : if the resource doesn't exist anymore, we just skip it
- }
- }
- }
- }
- }
-
- /**
- * Creates a widget to filter the tree according to the selected
- * metaclass.
- *
- * @param parent
- * The Composite in which the widgets will be created
- * @deprecated
- */
- @Deprecated
- protected void createMetaclassFilter(Composite parent) {
- // if(semanticRoot == null) {
- // return;
- // }
- //
- // Composite container = new Composite(parent, SWT.NONE);
- // container.setLayout(new GridLayout(2, false));
- // container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- //
- // ResourceSet resourceSet = semanticRoot.eResource().getResourceSet();
- // EcoreUtil.resolveAll(resourceSet);
- //
- // Label metamodelLabel = new Label(container, SWT.NONE);
- // metamodelLabel.setText("Metamodel:");
- //
- // ComboViewer metamodelViewer = new ComboViewer(container);
- // metamodelViewer.setContentProvider(getMetamodelContentProvider());
- // metamodelViewer.setLabelProvider(new EMFLabelProvider());
- // metamodelViewer.setInput(semanticRoot);
- // metamodelViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- //
- // Label metaclassLabel = new Label(container, SWT.NONE);
- // metaclassLabel.setText("Metaclass:");
- //
- // final ComboViewer metaclassViewer = new ComboViewer(container);
- // IStructuredContentProvider metaclassProvider = getMetaclassContentProvider();
- // metaclassViewer.setContentProvider(metaclassProvider);
- // metaclassViewer.setLabelProvider(new EMFLabelProvider());
- // metaclassViewer.getCombo().setEnabled(false);
- // metaclassViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- //
- // metamodelViewer.setFilters(new ViewerFilter[]{ new MetamodelContentFilter(metaclassProvider) });
- //
- // metamodelViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- //
- // public void selectionChanged(SelectionChangedEvent event) {
- // metaclassViewer.setInput(((IStructuredSelection)event.getSelection()).getFirstElement());
- // metaclassViewer.getCombo().setEnabled(true);
- // }
- // });
- //
- // metaclassViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- //
- // public void selectionChanged(SelectionChangedEvent event) {
- // if(!event.getSelection().isEmpty()) {
- // Object selectedObject = ((IStructuredSelection)event.getSelection()).getFirstElement();
- // List<ViewerFilter> filters = new LinkedList<ViewerFilter>(Arrays.asList(viewer.getFilters()));
- // filters.remove(currentMetaclassViewerFilter);
- // currentMetaclassViewerFilter = getMetaclassViewerFilter(selectedObject);
- // filters.add(currentMetaclassViewerFilter);
- // viewer.setFilters(filters.toArray(new ViewerFilter[filters.size()]));
- // viewer.refresh();
- // }
- // }
- // });
- }
-
- /**
- * Creates a label widget to display detailed information on the
- * current value (Such as fully qualified name, ...)
- *
- * @param parent
- * The composite in which the widget will be created
- */
- protected void createDetailArea(Composite parent) {
- detailLabel = new CLabel(parent, SWT.BORDER);
- detailLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- updateDetailLabel();
- }
-
- // @Deprecated
- // protected IStructuredContentProvider getMetamodelContentProvider() {
- // return new MetamodelContentProvider();
- // }
- //
- // @Deprecated
- // protected IStructuredContentProvider getMetaclassContentProvider() {
- // return new MetaclassContentProvider((EClass)this.metaClassWanted, this.metaClassNotWantedList);
- // }
- //
- // @Deprecated
- // protected ILabelProvider getLabelProvider() {
- // return new EMFObjectLabelProvider();
- // }
- //
- // @Deprecated
- // protected ViewerFilter getMetaclassViewerFilter(Object selectedMetaClass) {
- // return new MetaclassViewerFilter(selectedMetaClass);
- // }
-
- /**
- * Returns the dialog settings. Returned object can't be null.
- *
- * @return dialog settings for this dialog
- */
- protected IDialogSettings getDialogSettings() {
- IDialogSettings settings = Activator.getDefault().getDialogSettings().getSection(getDialogSettingsIdentifier());
- if(settings == null) {
- settings = Activator.getDefault().getDialogSettings().addNewSection(getDialogSettingsIdentifier());
- }
- return settings;
- }
-
- private String getDialogSettingsIdentifier() {
- return DIALOG_SETTINGS + "_" + historyId;
- }
-
- /**
- * Stores dialog settings.
- *
- * @param settings
- * settings used to store dialog
- */
- protected void storeDialog(IDialogSettings settings, Collection<EObject> newValues) {
- selectionHistory.removeAll(newValues);
-
- selectionHistory.addAll(0, newValues);
-
- //Truncate the history: only keep a sublist of size HISTORY_MAX_SIZE
- if(selectionHistory.size() > HISTORY_MAX_SIZE) {
- selectionHistory = selectionHistory.subList(0, HISTORY_MAX_SIZE);
- }
-
- List<String> uriList = new ArrayList<String>();
-
- // convert list of EObject into URI string list
- for(EObject object : selectionHistory) {
- URI uri = EcoreUtil.getURI(object);
- uriList.add(uri.toString());
- }
-
- IDialogSettings historySettings = settings.getSection(HISTORY_SETTINGS);
- if(historySettings == null) {
- historySettings = settings.addNewSection(HISTORY_SETTINGS);
- }
- historySettings.put(PREVIOUS_SELECTION, uriList.toArray(new String[uriList.size()]));
-
- historyViewer.setInput(selectionHistory);
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- encapsulated.inputChanged(viewer, oldInput, newInput);
-
- if(viewer instanceof StructuredViewer) {
- this.viewer = (StructuredViewer)viewer;
- if(newInput != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
- this.viewer.addSelectionChangedListener(this);
- }
- } else {
- this.viewer = null;
- }
- }
-
- public void selectionChanged(SelectionChangedEvent event) {
- selectedObject = ((IStructuredSelection)event.getSelection()).getFirstElement();
- updateDetailLabel();
- }
-
- private void updateDetailLabel() {
- if(detailLabel == null || detailLabel.isDisposed()) {
- return;
- }
- if(selectedObject == null) {
- detailLabel.setText("");
- detailLabel.setImage(null);
- } else {
- ILabelProvider labelProvider = (ILabelProvider)viewer.getLabelProvider();
- String description;
- if(labelProvider instanceof IDetailLabelProvider) {
- description = ((IDetailLabelProvider)labelProvider).getDetail(selectedObject);
- } else {
- description = labelProvider.getText(selectedObject);
- }
- detailLabel.setText(description);
- detailLabel.setImage(labelProvider.getImage(selectedObject));
- }
- detailLabel.getParent().getParent().layout();
- }
-
- @Override
- public void commit(AbstractEditor editor) {
- Iterator<?> selectionIterator = ((IStructuredSelection)viewer.getSelection()).iterator();
- Set<EObject> eObjectsToStore = new LinkedHashSet<EObject>();
- while(selectionIterator.hasNext()) {
- Object selectedElement = selectionIterator.next();
- if(isValidValue(selectedElement)) {
- Object semanticObject = getAdaptedValue(selectedElement);
- if(semanticObject instanceof EObject) {
- eObjectsToStore.add((EObject)semanticObject);
- }
- }
- }
-
- if(!eObjectsToStore.isEmpty()) {
- storeDialog(getDialogSettings(), eObjectsToStore);
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- viewer.removeSelectionChangedListener(this);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java
deleted file mode 100644
index e91126d9a5c..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java
+++ /dev/null
@@ -1,326 +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.providers;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelLabelProvider;
-import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ITreeElement;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IDetailLabelProvider;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IQualifierLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * This class handles labels for EMF Objects
- * The class can handle the following cases :
- * - An EObject (Which can be resolved with {@link EMFHelper#getEObject(Object)})
- * - A IStructuredSelection containing EObject(s)
- *
- * @author Camille Letavernier
- */
-public class EMFLabelProvider extends CustomizableModelLabelProvider implements IDetailLabelProvider, IQualifierLabelProvider {
-
- /** the max number of displayed element */
- public static final int MAX_ELEMENT = 2;
-
- protected ILabelProvider baseEMFLabelProvider;
-
- /**
- * Creates a new EMFObjectLabelProvider.
- */
- public EMFLabelProvider() {
- super(Activator.getDefault().getCustomizationManager()); //Note: CustomizableModelLabelProvider doesn't use the CustomizationManager. It relies on the content provider's CustomizationManager
- baseEMFLabelProvider = new StandardEMFLabelProvider();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getText(Object element) {
- if(element == null) {
- return ""; //$NON-NLS-1$
- }
-
- if(element instanceof ITreeElement) {
- return super.getText(element);
- }
-
- EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
- return getText(eObject);
- }
-
- if(element instanceof IStructuredSelection) {
- return getText((IStructuredSelection)element);
- }
-
- return element.toString();
- }
-
- protected String getText(EObject element) {
- return baseEMFLabelProvider.getText(element);
- }
-
- protected String getText(IStructuredSelection selection) {
- final int selectionSize = selection.size();
- int managedSize = selectionSize;
- if(selectionSize > MAX_ELEMENT) {
- managedSize = MAX_ELEMENT;
- }
- if(selection.isEmpty()) {
- return ""; //$NON-NLS-1$
- }
-
- if(managedSize == 1) {
- return getText(selection.getFirstElement());
- } else {
- final List<Object> selectionAsList = selection.toList();
- String str = "";
- for(int i = 0; i < managedSize; i++) {
- final String txt = getText(selectionAsList.get(i));
- if(txt != null) {
- str += txt;
- }
- if(i < managedSize - 1) {
- str += ", ";
- }
- }
- if(selectionSize > managedSize) {
- str += " + " + (selectionSize - managedSize) + " others elements.";
- }
- return str;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Image getImage(Object element) {
- if(element instanceof ITreeElement) {
- return super.getImage(element);
- }
-
- EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
- return getImage(eObject);
- }
-
- if(element instanceof IStructuredSelection) {
- return getImage((IStructuredSelection)element);
- }
-
- return null;
- }
-
- protected Image getImage(EObject eObject) {
- return baseEMFLabelProvider.getImage(eObject);
- }
-
- protected Image getImage(IStructuredSelection selection) {
- int selectionSize = selection.size();
- int managedSize = selectionSize;
- if(selectionSize > MAX_ELEMENT) {
- managedSize = MAX_ELEMENT;
- }
-
-
- if(selection.isEmpty()) {
- return null;
- } else if(selection.size() == 1) {
- return getImage(selection.getFirstElement());
- }
-
- final List<?> selectionAsList = selection.toList();
- final Set<EObject> selectedEObject = new HashSet<EObject>();
- boolean isEObjectSelection = true;
- for(int i = 0; i < managedSize; i++) {
- final EObject obj = EMFHelper.getEObject(selectionAsList.get(i));
- if(obj != null) {
- selectedEObject.add(obj);
- } else {
- isEObjectSelection = false;
- }
- }
- //selected object is a set, so the size can be lowest that the initial size
- selectionSize = selectedEObject.size();
- if(selectionSize > MAX_ELEMENT) {
- managedSize = MAX_ELEMENT;
- }
- if(isEObjectSelection) {//all selected elements are EObject
- if(managedSize == 1 || hasCommonImage(selectedEObject)) {
- return getImage(selectedEObject.toArray()[0]);
- } else {
- final EClass common = org.eclipse.emf.facet.util.emf.core.internal.EMFUtils.computeLeastCommonSupertype(getEClasses(selectedEObject));
- if(!common.isAbstract()) {
- //FIXME : the label provider service should manage this case
- final Object instance = common.getEPackage().getEFactoryInstance().create(common);
- return getNonCommonIcon(instance);
- }
- }
- } else if(selectedEObject.size() == 0) {
- //the multiple selection contains any EObject
- } else {
- //the selection contains EObject and others elements
- }
- return null;
- }
-
- /**
- *
- * @param objects
- * a collection of objects
- * @return
- * <code>true</code> if the image found for each object is the same <code>false</code> of if the collection is empty or the image returned
- * for each object is not the same
- */
- protected boolean hasCommonImage(final Collection<?> objects) {
- if(objects.size() > MAX_ELEMENT) {
- return false;
- }
- if(!objects.isEmpty()) {
- final Image lastImage = getImage(objects.toArray()[0]);
- for(final Object current : objects) {
- if(lastImage != getImage(current)) {
- return false;
- }
- }
- } else {
- return false;
- }
- return true;
- }
-
- /**
- *
- * @param commonEClass
- * the eClass
- * @return
- * the icon to use for this eclass
- */
- protected Image getNonCommonIcon(final Object commonObject) {
- return getImage(commonObject);
- }
-
- /**
- *
- * @param objects
- * a collection of eobject
- * @return
- * the set of eclasses for the parameter objects
- */
- private Set<EClass> getEClasses(final Collection<EObject> objects) {
- final Set<EClass> eclasses = new HashSet<EClass>();
- for(final EObject current : objects) {
- eclasses.add(current.eClass());
- }
- return eclasses;
- }
-
- public String getDetail(Object object) {
- object = EMFHelper.getEObject(object);
- return getText(object) + " - " + getQualifiedClassName(object); //$NON-NLS-1$
- }
-
- /**
- * Returns the qualified Class name of the given EObject, or an
- * empty String if the object is not an EObject
- *
- * @param object
- * @return The qualified name of this object's class, or an empty
- * String if the object is not an EObject
- */
- protected String getQualifiedClassName(Object object) {
- if(object instanceof EObject) {
- EObject eObject = (EObject)object;
- EClass eClass = eObject.eClass();
- return EMFHelper.getQualifiedName(eClass, "::"); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
-
-
-
- public String getQualifierText(Object element) {
- String result = null;
-
- EObject parent = getParentObject(element);
- if(parent != null) {
- result = getQualifiedText(parent);
- }
-
- return result;
- }
-
- private EObject getParentObject(Object element) {
- EObject result = null;
-
- if(element != null) {
- EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
- result = getParent(eObject);
- }
- }
-
- return result;
- }
-
- public Image getQualifierImage(Object element) {
- Image result = null;
-
- EObject parent = getParentObject(element);
- if(parent != null) {
- result = getImage(parent);
- }
-
- return result;
- }
-
- protected EObject getParent(EObject object) {
- return object.eContainer();
- }
-
- protected String getQualifiedText(EObject object) {
- StringBuilder result = new StringBuilder();
-
- appendQualifiedText(object, result);
-
- return result.toString();
- }
-
- protected void appendQualifiedText(EObject object, StringBuilder buf) {
- EObject parent = getParent(object);
- if(parent != null) {
- appendQualifiedText(parent, buf);
- }
-
- if(buf.length() > 0) {
- buf.append("::");
- }
-
- String name = getText(object);
- if(name == null) {
- name = String.format("<%s>", object.eClass().getName());
- }
- buf.append(name);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java
deleted file mode 100644
index 1dee49a7a56..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java
+++ /dev/null
@@ -1,50 +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.providers;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider for the history table
- *
- * @deprecated Use the generic {@link org.eclipse.papyrus.infra.widgets.providers.CollectionContentProvider#instance} instead
- */
-@Deprecated
-public class HistoryContentProvider implements IStructuredContentProvider {
-
- /**
- * {@inheritDoc}
- */
- public void dispose() {
- // nothing here
- }
-
- /**
- * {@inheritDoc}
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // nothing here
- }
-
- /**
- * {@inheritDoc}
- */
- public Object[] getElements(Object inputElement) {
- if(inputElement instanceof List<?>) {
- return ((List<?>)inputElement).toArray();
- }
- return new Object[0];
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
deleted file mode 100644
index de352fc6f25..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Mia-Software.
- * 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:
- * Nicolas Bros (Mia-Software) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
-import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
-import org.eclipse.papyrus.infra.core.resource.IModel;
-import org.eclipse.papyrus.infra.core.resource.ModelSet;
-import org.eclipse.papyrus.infra.core.resource.ModelUtils;
-import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageManager;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.eclipse.papyrus.infra.emf.Activator;
-
-/**
- * the content provider that inherits of modisco properties
- *
- * @deprecated Use SemanticUMLContentProvider instead
- */
-@Deprecated
-public class MoDiscoContentProvider extends CustomizableModelContentProvider {
-
- /** The ModelSet containing all the models. This is the initial input. */
- protected ModelSet modelSet;
-
- /** The list of open pages (diagrams) */
- protected IPageManager pageMngr;
-
- /**
- * Creates a new MoDiscoContentProvider.
- */
- public MoDiscoContentProvider() {
- super(Activator.getDefault().getCustomizationManager());
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return getChildren(element).length > 0;
- }
-
- @Override
- public Object[] getChildren(final Object parentElement) {
- Object[] children = super.getChildren(parentElement);
- if(children == null) {
- return new Object[0];
- }
- return children;
- }
-
- /**
- * Return the initial values from the input.
- * Input should be of type {@link UmlModel}.
- *
- * @see org.eclipse.gmt.modisco.infra.browser.uicore.CustomizableModelContentProvider#getRootElements(java.lang.Object)
- *
- * @param inputElement
- * @return
- */
- @Override
- public EObject[] getRootElements(Object inputElement) {
-
- try {
- if(!(inputElement instanceof ServicesRegistry)) {
- return null;
- }
-
- ServicesRegistry servicesRegistry = (ServicesRegistry)inputElement;
-
- modelSet = ModelUtils.getModelSetChecked(servicesRegistry);
- pageMngr = servicesRegistry.getService(IPageManager.class);
-
- return getRootElements(modelSet);
- } catch (Exception e) {
- Activator.log.error(e);
- }
-
- return new EObject[0];
- }
-
- /**
- * Get the roots elements from the {@link ModelSet} provided as input.
- *
- * @return
- */
- protected EObject[] getRootElements(ModelSet modelSet) {
- //FIXME: Refactoring. Workaround to remove the explicit dependency to UMLModel in uml.tools. We should not depend on UML at all.
- IModel umlIModel = modelSet.getModel("org.eclipse.papyrus.infra.core.resource.uml.UmlModel");
-
- AbstractBaseModel umlModel = null;
- if(umlIModel instanceof AbstractBaseModel) {
- umlModel = (AbstractBaseModel)umlIModel;
- }
-
- if(umlModel == null) {
- return null;
- }
-
- EList<EObject> contents = umlModel.getResource().getContents();
- ArrayList<EObject> result = new ArrayList<EObject>();
- Iterator<EObject> iterator = contents.iterator();
- while(iterator.hasNext()) {
- EObject eObject = iterator.next();
- result.add(eObject);
- }
- return result.toArray(new EObject[result.size()]);
- }
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
deleted file mode 100644
index 50698bb43ed..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 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:
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.papyrus.infra.core.IElementWithSemantic;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-
-/**
- * This class is used to obtain the semantic element for element of the model explorer
- */
-//FIXME: Remove the dependency to gmf
-public class SemanticFromModelExplorer implements IElementWithSemantic {
-
- /**
- * {@inheritDoc}
- */
- public Object getSemanticElement(Object wrapper) {
- EObject semantic = EMFHelper.getEObject(wrapper);
- if(semantic != null) {
- return semantic;
- }
-
- if(wrapper instanceof Diagram) {
- return wrapper;
- }
-
- return null;
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java
deleted file mode 100644
index 51d5774252f..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Obeo.
- * 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:
- * Obeo - initial API and implementation
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Added support for enum literals
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Implementation of IDetailLabelProvider
- *******************************************************************************/
-package org.eclipse.papyrus.infra.emf.providers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.provider.IItemLabelProvider;
-import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
-import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.services.labelprovider.service.IDetailLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * This class handles labels for EMF Objects
- * The class can handle the following cases :
- * - An EObject (Which can be resolved with {@link EMFHelper#getEObject(Object)})
- * - A IStructuredSelection containing EObject(s)
- *
- * @author Jerome Benois
- */
-public class StandardEMFLabelProvider extends AdapterFactoryLabelProvider implements IDetailLabelProvider {
-
- /** item provider class */
- private static final Class<?> IItemLabelProviderClass = IItemLabelProvider.class;
-
- /** list of adapter factories, identified by their Ids */
- private static Map<String, AdapterFactory> factories = new HashMap<String, AdapterFactory>();
-
- /** emf item provider factories */
- private static final String EXT_FACTORIES = "org.eclipse.emf.edit.itemProviderAdapterFactories"; //$NON-NLS-1$
-
- /**
- * Creates a new EMFObjectLabelProvider.
- */
- public StandardEMFLabelProvider() {
- super(new ReflectiveItemProviderAdapterFactory());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getText(Object element) {
- EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
- return getText(eObject);
- }
-
- if(element instanceof IStructuredSelection) {
- return getText((IStructuredSelection)element);
- }
-
- return super.getText(element);
- }
-
- protected String getText(EObject element) {
- String title = ""; //$NON-NLS-1$
- if(element instanceof Enumerator) {
- return ((Enumerator)element).getName();
- }
- EObject eObject = EMFHelper.getEObject(element);
- IItemLabelProvider itemLabelProvider = getItemLabelProvider(eObject);
- if(itemLabelProvider != null) {
- title = itemLabelProvider.getText(eObject);
- }
-
- if("".equals(title)) { //$NON-NLS-1$
- title = super.getText(eObject);
- }
-
- return title;
- }
-
- protected String getText(IStructuredSelection selection) {
- if(selection.isEmpty()) {
- return ""; //$NON-NLS-1$
- }
-
- //TODO : Implement a multi-selection label, instead of just the first element's label
- Object element = selection.getFirstElement();
- return getText(element);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Image getImage(Object element) {
- EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
- return getImage(eObject);
- }
-
- if(element instanceof IStructuredSelection) {
- return getImage((IStructuredSelection)element);
- }
-
- return super.getImage(element);
- }
-
- protected Image getImage(EObject eObject) {
- Image result = null;
- IItemLabelProvider itemLabelProvider = getItemLabelProvider(eObject);
- if(itemLabelProvider != null) {
- result = getImageFromObject(itemLabelProvider.getImage(eObject));
- }
-
- return result;
- }
-
- protected Image getImage(IStructuredSelection selection) {
- if(selection.isEmpty()) {
- return null;
- }
-
- //TODO : Implement a multi-selection label, instead of just the first element's label
- Object element = selection.getFirstElement();
- return getImage(element);
- }
-
- /**
- * Returns the item provider for the given object
- *
- * @param eObject
- * the object to display
- * @return the item label provider for the given eobject
- */
- private IItemLabelProvider getItemLabelProvider(EObject eObject) {
- IItemLabelProvider itemLabelProvider = null;
- if(eObject != null) {
- AdapterFactory adapterFactory = getEditFactory(eObject);
- if(adapterFactory != null) {
- return (IItemLabelProvider)adapterFactory.adapt(eObject, IItemLabelProviderClass);
- }
- }
- return itemLabelProvider;
- }
-
- /**
- * Gets the edit factory.
- *
- * @param eobject
- * the eobject
- *
- * @return the edits the factory
- */
- public static AdapterFactory getEditFactory(EObject eobject) {
- String uri = eobject.eClass().getEPackage().getNsURI();
- return getFactory(uri);
- }
-
- /**
- * Gets the factory from uri.
- *
- * @param uri
- * the uri
- *
- * @return the factory
- */
- public static AdapterFactory getFactory(String uri) {
- AdapterFactory factory = factories.get(uri);
- if(factory == null) {
- IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor(EXT_FACTORIES);
- for(IConfigurationElement e : extensions) {
- if(uri.equals(e.getAttribute("uri"))) { //$NON-NLS-1$
- try {
- factory = (AdapterFactory)e.createExecutableExtension("class"); //$NON-NLS-1$
- if(factory != null) {
- factories.put(uri, factory);
- }
- } catch (CoreException e1) {
- // do nothing
- }
- }
- }
- }
- return factory;
- }
-
- public String getDetail(Object object) {
- object = EMFHelper.getEObject(object);
- return getText(object) + " - " + getQualifiedClassName(object); //$NON-NLS-1$
- }
-
- /**
- * Returns the qualified Class name of the given EObject, or an
- * empty String if the object is not an EObject
- *
- * @param object
- * @return The qualified name of this object's class, or an empty
- * String if the object is not an EObject
- */
- protected String getQualifiedClassName(Object object) {
- if(object instanceof EObject) {
- EObject eObject = (EObject)object;
- EClass eClass = eObject.eClass();
- return EMFHelper.getQualifiedName(eClass, "::"); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
deleted file mode 100644
index 889ca013750..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
+++ /dev/null
@@ -1,344 +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.providers.strategy;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.facet.infra.facet.FacetReference;
-import org.eclipse.gmf.runtime.notation.Diagram;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider;
-import org.eclipse.papyrus.infra.widgets.strategy.ProviderBasedBrowseStrategy;
-import org.eclipse.swt.widgets.TreeItem;
-
-/**
- * A TreeBrowseStrategy based on the semantic model.
- * It can also retrieve a semantic element in a MoDisco tree, when the tree structure is close
- * to the semantic one (With optional EReferences).
- *
- * Container1::Container2::EObject1 can be retrieved in a Tree representing
- * Container1::(Reference1)::Container2::(Reference2)::EObject1
- *
- * @author Camille Letavernier
- */
-public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
-
- protected IAdaptableContentProvider adaptableProvider;
-
- protected TreeViewer viewer;
-
- public ContainmentBrowseStrategy(ITreeContentProvider provider) {
- if(!(provider instanceof IAdaptableContentProvider)) {
- throw new IllegalArgumentException("The provider must be an IAdaptableContentProvider");
- }
-
- setProvider(provider);
- this.adaptableProvider = (IAdaptableContentProvider)super.provider;
- }
-
- //
- // Elements filtering
- //
-
- @Override
- protected boolean browseElement(Object containerElement) {
- Object semanticElement = adaptableProvider.getAdaptedValue(containerElement);
-
- //Only browse Containment references and Facet references
- if(semanticElement instanceof EReference) {
- if(semanticElement instanceof FacetReference) {
- return true;
- }
-
- return ((EReference)semanticElement).isContainment() && !((EReference)semanticElement).isDerived();
- }
-
- return true;
- }
-
- //
- // Elements search
- //
-
- // /**
- // * {@inheritDoc}
- // */
- // @Override
- // public TreePath findPath(Object semanticElement, Object[] rootElements) {
- // List<Object> semanticPath = new LinkedList<Object>();
- // findSemanticPath(semanticElement, semanticPath);
- // return searchPath(semanticPath, rootElements);
- // }
-
- // /**
- // * Fills the semantic path to the given element
- // *
- // * @param element
- // * The element to retrieve
- // * @param currentPath
- // * The path to fill (in-out)
- // */
- // protected void findSemanticPath(Object element, List<Object> currentPath) {
- // if(element != null && element instanceof EObject) {
- // findSemanticPath(getSemanticParent(element), currentPath);
- // currentPath.add(element);
- // }
- // }
- //
- // protected Object getSemanticParent(Object element) {
- // if(element instanceof EObject) {
- // return ((EObject)element).eContainer();
- // }
- // return null;
- // }
- //
- // /**
- // * Retrieve the graphical TreePath from the given semantic path
- // *
- // * @param semanticPath
- // * @return
- // */
- // protected TreePath searchPath(List<Object> semanticPath, Object input) {
- // List<Object> graphicalPath = new LinkedList<Object>();
- // Object[] graphicalRootObjects = (Object[])input;
- // if(!searchPath(semanticPath, graphicalPath, graphicalRootObjects)) {
- // //Object not found
- // graphicalPath.clear();
- // }
- //
- // return new TreePath(graphicalPath.toArray());
- // }
- //
- // protected boolean searchPath(List<Object> semanticPath, List<Object> graphicalPath, Object[] graphicalRootObjects) {
- // if(semanticPath.isEmpty()) {
- // return true;
- // }
- //
- // if(graphicalRootObjects == null) {
- // return false;
- // }
- //
- // Object currentElement = semanticPath.get(0);
- // for(Object graphicalElement : graphicalRootObjects) {
- // Object semanticValue = adaptableProvider.getAdaptedValue(graphicalElement);
- //
- // //Specific case for containment EReference
- // if(semanticValue instanceof EReference) {
- // EReference referenceToBrowse = (EReference)semanticValue;
- // if(referenceToBrowse.isContainment()) {
- // graphicalPath.add(graphicalElement);
- //
- // if(searchPath(semanticPath, graphicalPath, provider.getChildren(graphicalElement))) {
- // //The element has been found
- // return true;
- // }
- //
- // //The element has not been found ; we revert the modifications
- // graphicalPath.remove(graphicalElement);
- // }
- // }
- //
- // if(semanticValue == currentElement) {
- // semanticPath.remove(0);
- // graphicalPath.add(graphicalElement);
- // if(searchPath(semanticPath, graphicalPath, provider.getChildren(graphicalElement))) {
- // return true;
- // }
- // }
- // }
- //
- // return false;
- // }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if(viewer instanceof TreeViewer) {
- this.viewer = (TreeViewer)viewer;
- }
- super.inputChanged(viewer, oldInput, newInput);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void revealSemanticElement(List<?> elementList) {
- //for each element we reveal it
- Iterator<?> elementListIterator = elementList.iterator();
- ArrayList<Object> treeElementToSelect = new ArrayList<Object>();
- while(elementListIterator.hasNext()) {
- Object currentElement = elementListIterator.next();
- //test if the type is an EObject
- if(currentElement instanceof EObject) {
- EObject currentEObject = (EObject)currentElement;
- //the content provider exist?
- if(provider != null) {
- //need the root in order to find all element in the tree
- Object root = provider.getElements(null)[0];
- //look for the path in order to access to this element
- List<Object> path = searchPath(currentEObject, Arrays.asList(provider.getElements(root)));
- if(path.size() > 0) {
- //expand in the common viewer the path
- expandItems(path, viewer.getTree().getItems());
- treeElementToSelect.add(path.get(path.size() - 1));
- }
- }
- }
- selectReveal(new StructuredSelection(treeElementToSelect));
- }
- }
-
- public void expandItems(List<Object> treeElementList, TreeItem[] list) {
- //the treeElement has more tan one element
- viewer.getTree().setRedraw(false);
- if(treeElementList.size() > 0) {
- for(int i = 0; i < list.length; i++) {
- if(list[i].getData() != null && list[i].getData().equals(treeElementList.get(0))) {
- if(treeElementList.size() > 1) {//Do no expand the last element
- Object[] toexpand = { treeElementList.get(0) };
- viewer.setExpandedElements(toexpand);
- }
- ArrayList<Object> tmpList = new ArrayList<Object>();
- tmpList.addAll(treeElementList);
- tmpList.remove(tmpList.get(0));
- expandItems(tmpList, list[i].getItems());
- }
- }
- }
- viewer.getTree().setRedraw(true);
- }
-
- public void selectReveal(ISelection selection) {
- if(viewer != null) {
- viewer.setSelection(selection, true);
- }
- }
-
- /**
- * Simple search, based on containment references
- *
- * @param eobject
- * @param objects
- * @return
- */
- protected List<Object> searchDirectContainmentPath(EObject eobject, List<Object> wrappedElements) {
- List<Object> path = new ArrayList<Object>();
-
- List<EObject> emfPath = EMFHelper.getContainmentPath(eobject);
-
- for(Object wrappedElement : wrappedElements) {
- EObject element = EMFHelper.getEObject(wrappedElement);
-
- if(eobject.equals(element)) {
- //We found the leaf element
- return Collections.singletonList(wrappedElement);
- }
-
- if(browseElementForDirectContainment(emfPath, element)) {
- List<Object> wrappedChildren = Arrays.asList(provider.getChildren(wrappedElement));
- List<Object> childPath = searchDirectContainmentPath(eobject, wrappedChildren);
- if(!childPath.isEmpty()) {
- //We (indirectly) found the leaf element
- path.add(wrappedElement);
- path.addAll(childPath);
- break;
- }
- } //Else: dead end
- }
-
- return path;
- }
-
- protected boolean browseElementForDirectContainment(List<EObject> emfPath, EObject element) {
- if(emfPath.contains(element)) {
- return true;
- }
-
- if(element instanceof EReference) {
- EReference reference = (EReference)element;
- if(reference.isContainment() && !reference.isDerived()) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * look for the path the list of element (from the content provider) to go the eObject
- *
- * @param eobject
- * that we look for.
- * @param objects
- * a list of elements where eobject can be wrapped.
- * @return the list of modelElementItem (from the root to the element that wrap the eobject)
- */
- protected List<Object> searchPath(EObject eobject, List<Object> objects) {
- //Simple/quick search (Based on containment)
- List<Object> path = searchDirectContainmentPath(eobject, objects);
- if(!path.isEmpty()) {
- return path;
- }
-
- //Advanced search
- path = new ArrayList<Object>();
-
- for(Object o : objects) {
- // Search matches in this level
- if(!(o instanceof Diagram)) {
- if(eobject.equals(EMFHelper.getEObject(o))) {
- path.add(o);
- return path;
- }
- }
-
- // Find childs only for feature container
- for(int i = 0; i < provider.getChildren(o).length; i++) {
- Object treeItem = provider.getChildren(o)[i];
-
- List<Object> tmppath = new ArrayList<Object>();
- Object element = EMFHelper.getEObject(treeItem);
-
- if(browseElement(element)) {
- List<Object> childs = new ArrayList<Object>();
- childs.add(treeItem);
- tmppath = searchPath(eobject, childs);
- }
-
- // if tmppath contains the wrapped eobject we have found the good path
- if(tmppath.size() > 0) {
- Object last = tmppath.get(tmppath.size() - 1);
- EObject lastEObject = EMFHelper.getEObject(last);
- if(eobject.equals(lastEObject)) {
- path.add(o);
- path.addAll(tmppath);
- return path;
- }
- }
- }
- }
-
- return new ArrayList<Object>();
- }
-
-}
diff --git a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java b/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
deleted file mode 100644
index 3dad19455c9..00000000000
--- a/sandbox/pasteInNewTable/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
+++ /dev/null
@@ -1,197 +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.providers.strategy;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizableModelContentProvider;
-import org.eclipse.emf.facet.infra.browser.uicore.CustomizationManager;
-import org.eclipse.papyrus.infra.emf.Activator;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
-import org.eclipse.papyrus.infra.widgets.providers.IAdaptableContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IHierarchicContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-
-
-public class SemanticEMFContentProvider extends CustomizableModelContentProvider implements IAdaptableContentProvider, IHierarchicContentProvider, IStaticContentProvider {
-
- protected EObject[] roots;
-
- protected List<?> metaclasses = new LinkedList<Object>();
-
- protected List<?> notWantedMetaclasses = new LinkedList<Object>();
-
- protected EObject eObject;
-
- protected EStructuralFeature feature;
-
- protected AdapterFactory factory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
-
- public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, EObject[] roots, CustomizationManager customizationManager) {
- super(customizationManager);
- this.roots = roots;
-
- configureMetaclasses(feature);
-
- this.eObject = editedEObject;
- this.feature = feature;
- }
-
- public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, EObject[] roots) {
- this(editedEObject, feature, roots, Activator.getDefault().getCustomizationManager());
- }
-
- protected void configureMetaclasses(EStructuralFeature feature) {
- if(feature != null) {
- setWantedMetaclasses(Collections.singletonList(feature.getEType()));
- }
- }
-
- public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature) {
- this(editedEObject, feature, findRoots(editedEObject));
- }
-
- public SemanticEMFContentProvider(EObject[] roots) {
- this(null, null, roots);
- }
-
- public SemanticEMFContentProvider(EObject[] roots, CustomizationManager customizationManager) {
- this(null, null, roots, customizationManager);
- }
-
- public SemanticEMFContentProvider(ResourceSet root) {
- this(null, null, root);
- }
-
- public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, ResourceSet root) {
- this(editedEObject, feature, getRoots(root));
- }
-
- protected static EObject[] getRoots(ResourceSet root) {
- List<EObject> roots = new LinkedList<EObject>();
- if(root != null) {
- for(Resource resource : root.getResources()) {
- roots.addAll(resource.getContents());
- }
- }
- return roots.toArray(new EObject[roots.size()]);
- }
-
- protected static EObject[] findRoots(EObject source) {
-
- //The EObject is not contained in a resource : we return the top-level EObject
- if(source.eResource() == null) {
- while(source.eContainer() != null) {
- source = source.eContainer();
- }
-
- return new EObject[]{ source };
- }
-
- //The resource is not contained in a resource set : we return the resource's contents
- if(source.eResource().getResourceSet() == null) {
- return source.eResource().getContents().toArray(new EObject[0]);
- }
-
- //We have a full resourceSet : we return its contents
- return getRoots(source.eResource().getResourceSet());
- }
-
- @Override
- public EObject[] getRootElements(final Object inputElement) {
- return roots;
- }
-
- public Object getAdaptedValue(Object containerElement) {
- return EMFHelper.getEObject(containerElement);
- }
-
- @Override
- public boolean hasChildren(Object parent) {
- //May be expensive
- Object[] children = getChildren(parent);
- return children != null && children.length > 0;
- }
-
- public boolean isValidValue(Object containerElement) {
- // get the semantic object form the element
- Object semanticObject = getAdaptedValue(containerElement);
-
- //return false for EReference and non-semantic objects
- if(semanticObject instanceof EReference || semanticObject == null) {
- return false;
- }
-
- //Tests whether the element is compatible with at least one metaclass
- if(metaclasses != null && !metaclasses.isEmpty()) {
- boolean compatible = false;
-
- for(Object metaclass : metaclasses) {
- if(isCompatibleMetaclass(containerElement, metaclass)) {
- compatible = true;
- break;
- }
- }
-
- if(!compatible) {
- return false;
- }
- }
-
- //If the element is compatible with at least one metaclass from notWanted, then it is not valid
- for(Object metaclass : notWantedMetaclasses) {
- if(isCompatibleMetaclass(containerElement, metaclass)) {
- return false;
- }
- }
-
- return true;
- }
-
- protected boolean isCompatibleMetaclass(Object containerElement, Object metaclass) {
- if(metaclass instanceof EClassifier) {
- Object semanticElement = getAdaptedValue(containerElement);
- return ((EClassifier)metaclass).isInstance(semanticElement);
- }
- return false;
- }
-
- public void setWantedMetaclasses(List<?> metaclasses) {
- this.metaclasses = metaclasses;
- }
-
- public void setNotWantedMetaclasses(List<?> notWantedMetaclasses) {
- this.notWantedMetaclasses = notWantedMetaclasses;
- }
-
- public Object[] getElements() {
- return super.getElements(null);
- }
-
- public List<?> getWantedMetaclasses() {
- return metaclasses;
- }
-
- public List<?> getNotWantedMetaclasses() {
- return notWantedMetaclasses;
- }
-}
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