Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-08-21 11:43:07 +0000
committerCamille Letavernier2014-08-21 13:50:25 +0000
commitdbc038b44bcbb890ae256d15eb09eb285512f020 (patch)
tree757e736583eea3ae352ad9ac91a81df7e59b79ff /plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf
parentea48a20561464c3cbb7895d430583669a9f82fcc (diff)
downloadorg.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.gz
org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.tar.xz
org.eclipse.papyrus-dbc038b44bcbb890ae256d15eb09eb285512f020.zip
[Code style] Apply clean-up and formatter on Main plug-ins
Diffstat (limited to 'plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java183
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java15
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/EObjectAdapterFactory.java14
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java26
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java100
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java18
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java36
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java44
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java54
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java16
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetValueCommand.java12
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java84
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java94
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java34
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java20
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/NestedEditingDialogContext.java40
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java87
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AdapterFactoryHierarchicContentProvider.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java14
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java28
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java18
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java254
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java99
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java24
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java30
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java16
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java270
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java58
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/requests/UnsetRequest.java9
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManagementHelper.java164
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManager.java20
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IDependencyReplacementParticipant.java18
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IURIReplacementStrategy.java2
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/MoveFileURIReplacementStrategy.java38
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/ReplacementImpl.java4
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/RestoreDependencyHelper.java51
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java23
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java433
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java146
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java6
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java8
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java52
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java50
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java48
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java26
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java20
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java10
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java16
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java106
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java18
64 files changed, 1533 insertions, 1537 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
index 9c720dfab9f..b436cf928fd 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/Activator.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -14,17 +14,10 @@
package org.eclipse.papyrus.infra.emf;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
-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.ecore.resource.ResourceSet;
@@ -59,8 +52,8 @@ public class Activator extends AbstractUIPlugin {
public static LogHelper log;
private ICustomizationManager fCustomizationManager;
- //temp resourceSet
- private ResourceSet facetRecsourceSet= new ResourceSetImpl();
+ // temp resourceSet
+ private ResourceSet facetRecsourceSet = new ResourceSetImpl();
/**
* The constructor
@@ -93,7 +86,7 @@ public class Activator extends AbstractUIPlugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static Activator getDefault() {
@@ -101,11 +94,11 @@ public class Activator extends AbstractUIPlugin {
}
/**
- *
+ *
* @return the customization manager in charge to adapt element in modisco
*/
public ICustomizationManager getCustomizationManager() {
- if(this.fCustomizationManager == null) {
+ if (this.fCustomizationManager == null) {
this.fCustomizationManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(facetRecsourceSet);
init(this.fCustomizationManager);
}
@@ -121,7 +114,7 @@ public class Activator extends AbstractUIPlugin {
final List<Customization> registeredCustomizations = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(getCustomizationManager().getResourceSet()).getRegisteredCustomizations();
- for(Customization customization : registeredCustomizations) {
+ for (Customization customization : registeredCustomizations) {
boolean isApplied = appliedCustomizations.contains(customization);
String settingKey = getSettingKey(customization);
@@ -133,14 +126,14 @@ public class Activator extends AbstractUIPlugin {
private String getSettingKey(Customization customization) {
// do not exist anymore
return customization.eResource().getURI().toString();
- //return "";
+ // return "";
}
protected IDialogSettings getBrowserCustomizationDialogSettings() {
String sectionId = CUSTOMIZATION_MANAGER_SECTION;
IDialogSettings settings = Activator.getDefault().getDialogSettings().getSection(sectionId);
- if(settings == null) {
+ if (settings == null) {
settings = Activator.getDefault().getDialogSettings().addNewSection(sectionId);
}
return settings;
@@ -156,27 +149,27 @@ public class Activator extends AbstractUIPlugin {
// load customizations defined as default through the customization
// extension
ICustomizationCatalogManager customCatalog = ICustomizationCatalogManagerFactory.DEFAULT.getOrCreateCustomizationCatalogManager(customizationManager.getResourceSet());
- //no possibility to get default customization
+ // no possibility to get default customization
List<Customization> registryAllCustomizations = customCatalog.getRegisteredCustomizations();
- ArrayList<Customization> orderedCustomizationList= new ArrayList<Customization>();
- for(Customization customization : registryAllCustomizations) {
+ ArrayList<Customization> orderedCustomizationList = new ArrayList<Customization>();
+ for (Customization customization : registryAllCustomizations) {
String settingKey = getSettingKey(customization);
boolean isActive = false;
- if(settings.get(settingKey) == null) { //Never customized
- isActive = customization.isMustBeLoadedByDefault(); //Loaded by default
-
+ if (settings.get(settingKey) == null) { // Never customized
+ isActive = customization.isMustBeLoadedByDefault(); // Loaded by default
+
} else {
isActive = settings.getBoolean(settingKey);
}
- if(isActive) {
- orderedCustomizationList.add(customization);
-
+ if (isActive) {
+ orderedCustomizationList.add(customization);
+
}
}
-
+
Collections.sort(orderedCustomizationList, new CustomizationComparator());
customizationManager.getManagedCustomizations().addAll(orderedCustomizationList);
@@ -198,87 +191,87 @@ public class Activator extends AbstractUIPlugin {
public void restoreDefaultCustomizationManager() {
ICustomizationManager manager = getCustomizationManager();
- DialogSettings settings = (DialogSettings)getDialogSettings();
+ DialogSettings settings = (DialogSettings) getDialogSettings();
settings.removeSection(CUSTOMIZATION_MANAGER_SECTION);
- // List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
+ // List<MetamodelView> registryDefaultCustomizations = CustomizationsCatalog.getInstance().getRegistryDefaultCustomizations();
//
- // manager.clearCustomizations();
- // for(MetamodelView customization : registryDefaultCustomizations) {
- // manager.registerCustomization(customization);
- // }
- // manager.loadCustomizations();
+ // manager.clearCustomizations();
+ // for(MetamodelView customization : registryDefaultCustomizations) {
+ // manager.registerCustomization(customization);
+ // }
+ // manager.loadCustomizations();
}
/**
* load the facets
- *
+ *
* @param customizations
- * list of customization
+ * list of customization
* @param customizationManager
- * the Customization Manager
+ * 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();
+ // 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;
- // }
+ // 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()));
- // }
- // }
+ // // 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(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;
- // }
+ // //
+ // // 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) {
@@ -286,12 +279,12 @@ public class Activator extends AbstractUIPlugin {
final StringBuilder builder = new StringBuilder();
EPackage ePackage = eClass.getEPackage();
- while(ePackage != null) {
+ while (ePackage != null) {
qualifiedNameParts.add(ePackage.getName());
ePackage = ePackage.getESuperPackage();
}
- for(int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
+ for (int i = qualifiedNameParts.size() - 1; i >= 0; i--) {
builder.append(qualifiedNameParts.get(i) + "."); //$NON-NLS-1$
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
index 885c3c8023c..2f6fbe39135 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/CustomizationComparator.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2014 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
@@ -16,13 +16,14 @@ package org.eclipse.papyrus.infra.emf;
import java.util.Comparator;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
+
/**
* this class is used to compare customization by taking in account the rank of the customization
*
*/
-public class CustomizationComparator implements Comparator<Customization>{
-
- public int compare(Customization o1, Customization o2) {
- return (o1.getRank()<o2.getRank() ? -1 : (o1.getRank()==o2.getRank() ? 0 : 1));
- }
-}
+public class CustomizationComparator implements Comparator<Customization> {
+
+ public int compare(Customization o1, Customization o2) {
+ return (o1.getRank() < o2.getRank() ? -1 : (o1.getRank() == o2.getRank() ? 0 : 1));
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/EObjectAdapterFactory.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/EObjectAdapterFactory.java
index e16b485fc3b..6db9f56e76c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/EObjectAdapterFactory.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/EObjectAdapterFactory.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -36,16 +36,16 @@ public class EObjectAdapterFactory implements IAdapterFactory {
public Object getAdapter(Object adaptable, @SuppressWarnings("rawtypes") Class adapterType) {
Object result = null;
- if(adaptable instanceof EObject) {
- if(adapterType == IAtomicOperationExecutor.class) {
- TransactionalEditingDomain domain = TransactionUtil.getEditingDomain((EObject)adaptable);
- if(domain == null) {
+ if (adaptable instanceof EObject) {
+ if (adapterType == IAtomicOperationExecutor.class) {
+ TransactionalEditingDomain domain = TransactionUtil.getEditingDomain((EObject) adaptable);
+ if (domain == null) {
ResourceSet rset = NestedEditingDialogContext.getInstance().getResourceSet();
- if(rset != null) {
+ if (rset != null) {
domain = TransactionUtil.getEditingDomain(rset);
}
}
- if(domain != null) {
+ if (domain != null) {
result = new EMFAtomicOperationExecutor(domain);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
index 99ebd3839aa..4f8a718fe48 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/adapters/ResourceSetRootsAdapter.java
@@ -20,15 +20,15 @@ import org.eclipse.emf.ecore.util.EContentAdapter;
/**
* An EMF Adapter which listens on Resource Set root elements
- *
+ *
* @author Camille Letavernier
- *
+ *
*/
public abstract class ResourceSetRootsAdapter extends EContentAdapter {
@Override
public void notifyChanged(Notification msg) {
- switch(msg.getEventType()) {
+ switch (msg.getEventType()) {
case Notification.ADD:
case Notification.ADD_MANY:
case Notification.REMOVE:
@@ -43,9 +43,9 @@ public abstract class ResourceSetRootsAdapter extends EContentAdapter {
@Override
protected void setTarget(ResourceSet target) {
- if(target instanceof ResourceSet) {
+ if (target instanceof ResourceSet) {
ResourceSet resourceSet = target;
- if(!resourceSet.eAdapters().contains(this)) {
+ if (!resourceSet.eAdapters().contains(this)) {
addAdapter(resourceSet);
}
}
@@ -54,22 +54,22 @@ public abstract class ResourceSetRootsAdapter extends EContentAdapter {
@Override
protected void setTarget(Resource target) {
- //Ignore
+ // Ignore
}
@Override
protected void setTarget(EObject target) {
- //Ignore
+ // Ignore
}
@Override
protected void unsetTarget(EObject target) {
- //Ignore
+ // Ignore
}
@Override
protected void unsetTarget(Resource target) {
- //Ignore
+ // Ignore
}
@Override
@@ -84,7 +84,7 @@ public abstract class ResourceSetRootsAdapter extends EContentAdapter {
@Override
protected void unsetTarget(ResourceSet target) {
- if(target != null) {
+ if (target != null) {
removeAdapter(target);
}
super.unsetTarget(target);
@@ -92,9 +92,9 @@ public abstract class ResourceSetRootsAdapter extends EContentAdapter {
@Override
protected void handleContainment(Notification notification) {
- if(notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY) {
- //Do not propagate listeners to EObjects. We're only interested on events on the ResourceSet (Add/remove resources) and Resources (Add/remove EObjects)
- if(notification.getNotifier() == getTarget()) {
+ if (notification.getEventType() == Notification.ADD || notification.getEventType() == Notification.ADD_MANY) {
+ // Do not propagate listeners to EObjects. We're only interested on events on the ResourceSet (Add/remove resources) and Resources (Add/remove EObjects)
+ if (notification.getNotifier() == getTarget()) {
super.handleContainment(notification);
}
} else {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
index aca59b0a751..8d5e552b410 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageAdvice.java
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 433371
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.advice;
@@ -32,7 +32,7 @@ public class DeletePageAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) {
final EObject objectToDestroy = request.getElementToDestroy();
- if(objectToDestroy == null) {
+ if (objectToDestroy == null) {
return null;
}
return RemovePageHelper.getRemovePageCommand(request.getEditingDomain(), objectToDestroy);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
index 8819b05bcab..8741660c19a 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/DeletePageEditHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -20,11 +20,11 @@ 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 {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java
index 5c7c1b62fb4..631e95632c0 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/ReadOnlyObjectEditAdvice.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -56,7 +56,7 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
boolean result = false;
EObject container = object.eContainer();
- if(container == null) {
+ if (container == null) {
// Resource root. Is the resource editable?
Resource resource = object.eResource();
result = (resource != null) && isUneditable(request, resource);
@@ -71,7 +71,7 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
boolean result = false;
EditingDomain domain = request.getEditingDomain();
- if(EMFHelper.isReadOnly(object, domain)) {
+ if (EMFHelper.isReadOnly(object, domain)) {
// Check whether we have some means of making it writable
result = !EMFHelper.canMakeWritable(object, domain);
}
@@ -83,7 +83,7 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
boolean result = false;
EditingDomain domain = request.getEditingDomain();
- if(EMFHelper.isReadOnly(resource, domain)) {
+ if (EMFHelper.isReadOnly(resource, domain)) {
// Check whether we have some means of making it writable
result = !EMFHelper.canMakeWritable(resource, domain);
}
@@ -99,7 +99,7 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
protected ICommand getBeforeCreateCommand(CreateElementRequest request) {
EObject container = request.getContainer();
- if((container != null) && isUneditable(request, container)) {
+ if ((container != null) && isUneditable(request, container)) {
return getRefusal();
}
@@ -110,11 +110,11 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
protected ICommand getBeforeCreateRelationshipCommand(CreateRelationshipRequest request) {
EObject container = request.getContainer();
- if((container != null) && isUneditable(request, container)) {
+ if ((container != null) && isUneditable(request, container)) {
return getRefusal();
}
- if(isUneditable(request, request.getSource())) {
+ if (isUneditable(request, request.getSource())) {
return getRefusal();
}
// Assume that the target (as in most cases) will not have an inverse reference to the new relationship
@@ -126,7 +126,7 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
protected ICommand getBeforeDestroyElementCommand(DestroyElementRequest request) {
EObject container = request.getContainer();
- if((container != null) && isUneditable(request, container)) {
+ if ((container != null) && isUneditable(request, container)) {
return getRefusal();
}
// Cross-resource containment to a read-only resource? Unlikely. Don't need to look at the object-to-be-destroyed
@@ -139,16 +139,16 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
EObject container = request.getContainer();
// Simple case is when the owner object is read-only
- if((container != null) && isUneditable(request, container)) {
+ if ((container != null) && isUneditable(request, container)) {
return getRefusal();
}
// Handle the case where the reference has an opposite
EReference ref = request.getContainingFeature();
- if(ref.getEOpposite() != null) {
+ if (ref.getEOpposite() != null) {
// The object being removed will have its inverse reference removed, also
EObject referenced = request.getReferencedObject();
- if((referenced != null) && isUneditable(request, referenced)) {
+ if ((referenced != null) && isUneditable(request, referenced)) {
return getRefusal();
}
}
@@ -161,9 +161,9 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
List<?> elements = request.getElementsToBeDuplicated();
// Elements are duplicated in their containers, so the container must not be read-only
- for(EObject next : Iterables.filter(elements, EObject.class)) {
+ for (EObject next : Iterables.filter(elements, EObject.class)) {
EObject container = next.eContainer();
- if((container != null) && isUneditable(request, container)) {
+ if ((container != null) && isUneditable(request, container)) {
return getRefusal();
}
}
@@ -174,13 +174,13 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getBeforeMoveCommand(MoveRequest request) {
// Is any of the former containers read-only?
- for(EObject next : Iterables.filter(request.getElementsToMove().keySet(), EObject.class)) {
- if(isContainerUneditable(request, next)) {
+ for (EObject next : Iterables.filter(request.getElementsToMove().keySet(), EObject.class)) {
+ if (isContainerUneditable(request, next)) {
return getRefusal();
}
}
- if(isUneditable(request, request.getTargetContainer())) {
+ if (isUneditable(request, request.getTargetContainer())) {
return getRefusal();
}
@@ -192,16 +192,16 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
EObject relationship = request.getRelationship();
// Simple case is when the owner object is read-only
- if((relationship != null) && isUneditable(request, relationship)) {
+ if ((relationship != null) && isUneditable(request, relationship)) {
return getRefusal();
}
// Assume that changing the target would not affect the target object because it would not have an inverse reference
- if(request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
- if(isUneditable(request, request.getOldRelationshipEnd())) {
+ if (request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
+ if (isUneditable(request, request.getOldRelationshipEnd())) {
return getRefusal();
}
- if(isUneditable(request, request.getNewRelationshipEnd())) {
+ if (isUneditable(request, request.getNewRelationshipEnd())) {
return getRefusal();
}
}
@@ -214,16 +214,16 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
EObject owner = request.getReferenceOwner();
// Simple case is when the owner object is read-only
- if((owner != null) && isUneditable(request, owner)) {
+ if ((owner != null) && isUneditable(request, owner)) {
return getRefusal();
}
// Assume that changing the target would not affect the target object because it would not have an inverse reference
- if(request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
- if(isUneditable(request, request.getOldRelationshipEnd())) {
+ if (request.getDirection() == ReorientRequest.REORIENT_SOURCE) {
+ if (isUneditable(request, request.getOldRelationshipEnd())) {
return getRefusal();
}
- if(isUneditable(request, request.getNewRelationshipEnd())) {
+ if (isUneditable(request, request.getNewRelationshipEnd())) {
return getRefusal();
}
}
@@ -234,34 +234,34 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
@Override
protected ICommand getBeforeSetCommand(SetRequest request) {
// Simple case of read-only element
- if(isUneditable(request, request.getElementToEdit())) {
+ if (isUneditable(request, request.getElementToEdit())) {
return getRefusal();
}
- if(request.getFeature() instanceof EReference) {
- EReference ref = (EReference)request.getFeature();
- if(ref.getEOpposite() != null) {
+ if (request.getFeature() instanceof EReference) {
+ EReference ref = (EReference) request.getFeature();
+ if (ref.getEOpposite() != null) {
// Objects on the opposite end must not be read-only
Collection<EObject> affectedOpposites = getAffectedOpposites(request.getElementToEdit(), ref, request.getValue());
- if(!affectedOpposites.isEmpty()) {
- for(EObject next : affectedOpposites) {
- if(isUneditable(request, next)) {
+ if (!affectedOpposites.isEmpty()) {
+ for (EObject next : affectedOpposites) {
+ if (isUneditable(request, next)) {
return getRefusal();
}
}
}
- } else if(ref.isContainment()) {
+ } else if (ref.isContainment()) {
// Current container of any object must not change if it is read-only (and different from new container)
EObject owner = request.getElementToEdit();
Object value = request.getValue();
- if(value instanceof Collection<?>) {
- for(EObject next : Iterables.filter((Collection<?>)value, EObject.class)) {
- if((next.eContainer() != owner) && isContainerUneditable(request, next)) {
+ if (value instanceof Collection<?>) {
+ for (EObject next : Iterables.filter((Collection<?>) value, EObject.class)) {
+ if ((next.eContainer() != owner) && isContainerUneditable(request, next)) {
return getRefusal();
}
}
- } else if(request.getValue() instanceof EObject) {
- if(isContainerUneditable(request, (EObject)value)) {
+ } else if (request.getValue() instanceof EObject) {
+ if (isContainerUneditable(request, (EObject) value)) {
return getRefusal();
}
}
@@ -278,26 +278,26 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
protected Collection<EObject> getAffectedOpposites(EObject source, EReference refWithOpposite, Object newValue) {
Collection<EObject> result;
- if(refWithOpposite.isMany()) {
- if((newValue == null) || ((newValue instanceof Collection<?>) && ((Collection<?>)newValue).isEmpty())) {
+ if (refWithOpposite.isMany()) {
+ if ((newValue == null) || ((newValue instanceof Collection<?>) && ((Collection<?>) newValue).isEmpty())) {
// Removing all current references (and, hence, their inverses)
result = getReferencedObjects(source, refWithOpposite);
} else {
// The symmetric difference of currently- and to-be-referenced objects will change
Set<EObject> current = Sets.newHashSet(getReferencedObjects(source, refWithOpposite));
- Set<EObject> future = (newValue instanceof Collection<?>) ? ImmutableSet.copyOf(Iterables.filter((Collection<?>)newValue, EObject.class)) : Collections.singleton((EObject)newValue);
+ Set<EObject> future = (newValue instanceof Collection<?>) ? ImmutableSet.copyOf(Iterables.filter((Collection<?>) newValue, EObject.class)) : Collections.singleton((EObject) newValue);
result = ImmutableList.copyOf(Sets.symmetricDifference(current, future));
}
} else {
Object current = source.eGet(refWithOpposite);
- if(current != newValue) {
+ if (current != newValue) {
// The current value will lose its inverse reference and the new value will gain one
- if(current == null) {
- result = Collections.singletonList((EObject)newValue);
- } else if(newValue == null) {
- result = Collections.singleton((EObject)current);
+ if (current == null) {
+ result = Collections.singletonList((EObject) newValue);
+ } else if (newValue == null) {
+ result = Collections.singleton((EObject) current);
} else {
- result = ImmutableList.of((EObject)current, (EObject)newValue);
+ result = ImmutableList.of((EObject) current, (EObject) newValue);
}
} else {
// No objects will change
@@ -315,10 +315,10 @@ public class ReadOnlyObjectEditAdvice extends AbstractEditHelperAdvice {
Collection<EObject> result;
Object current = source.eGet(reference);
- if(current instanceof Collection<?>) {
- result = ImmutableList.copyOf(Iterables.filter((Collection<?>)current, EObject.class));
- } else if(current != null) {
- result = Collections.singletonList((EObject)current);
+ if (current instanceof Collection<?>) {
+ result = ImmutableList.copyOf(Iterables.filter((Collection<?>) current, EObject.class));
+ } else if (current != null) {
+ result = Collections.singletonList((EObject) current);
} else {
result = Collections.emptyList();
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
index f633c8ea851..dd3dc672392 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/advice/RemovePageHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2013, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 433371
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.advice;
@@ -29,25 +29,25 @@ 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)) {
+ if (pageManager.allPages().contains(elementToDestroy)) {
final Command command = IPageUtils.getMemoizedCloseAllPagesCommand(editingDomain, pageManager, elementToDestroy);
if (command != null) {
return new AbstractTransactionalCommand(editingDomain, "Delete page", null) { //$NON-NLS-1$
-
+
@Override
public boolean canExecute() {
return command.canExecute();
}
-
+
@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
command.execute();
@@ -57,9 +57,9 @@ public class RemovePageHelper {
}
}
} catch (ServiceException ex) {
- //Ignore
+ // Ignore
} catch (Exception ex) {
- //Ignore
+ // Ignore
}
return null;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java
index 39d6397e3d4..76f2b533692 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/AddToResourceCommand.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -18,9 +18,9 @@ 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 {
@@ -35,42 +35,42 @@ public class AddToResourceCommand extends AbstractCommand {
private final EObject toAdd;
/**
- *
+ *
* Constructor.
- *
+ *
* @param resource
- * the resource
+ * the resource
* @param toAdd
- * the object to add to the resource
+ * the object to 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");
+ 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() {
@@ -79,9 +79,9 @@ public class AddToResourceCommand extends AbstractCommand {
/**
- *
+ *
* @see org.eclipse.emf.common.command.AbstractCommand#undo()
- *
+ *
*/
@Override
public void undo() {
@@ -89,9 +89,9 @@ public class AddToResourceCommand extends AbstractCommand {
}
/**
- *
+ *
* @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
- *
+ *
*/
@Override
public boolean canExecute() {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
index c253c04e724..76b633d5fa7 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/CreateEAnnotationCommand.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -47,13 +47,13 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Instantiates a new creates the e annotation command.
- *
+ *
* @param domain
- * the domain
+ * the domain
* @param object
- * the object
+ * the object
* @param eannotationName
- * the eannotation name
+ * the eannotation name
*/
public CreateEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
super(domain);
@@ -72,7 +72,7 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Creates the e annotation.
- *
+ *
* @return the e annotation
*/
protected EAnnotation createEAnnotation() {
@@ -83,11 +83,11 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Attach eannotation to an EmodelElement.
- *
+ *
* @param annotation
- * the annotation
+ * the annotation
* @param object
- * the object
+ * the object
*/
protected void attachEannotation(EAnnotation annotation, EModelElement object) {
object.getEAnnotations().add(annotation);
@@ -96,14 +96,14 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Replace existing eannotation with a new eannotation. This repplaced eannotation has the same
* source.
- *
+ *
* @param annotation
- * the annotation
+ * the annotation
* @param object
- * the object
+ * the object
*/
protected void replaceEannotation(EAnnotation annotation, EModelElement object) {
- while(object.getEAnnotation(annotation.getSource()) != null) {
+ while (object.getEAnnotation(annotation.getSource()) != null) {
object.getEAnnotations().remove(object.getEAnnotation(annotation.getSource()));
}
@@ -112,13 +112,13 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Adds the entry.
- *
+ *
* @param annotation
- * the annotation
+ * the annotation
* @param key
- * the key
+ * the key
* @param value
- * the value
+ * the value
*/
// @unused
protected void addEntry(EAnnotation annotation, String key, String value) {
@@ -127,16 +127,16 @@ public class CreateEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Replace entry.
- *
+ *
* @param annotation
- * the annotation not null
+ * the annotation not null
* @param key
- * the key
+ * the key
* @param value
- * the value
+ * the value
*/
protected void replaceEntry(EAnnotation annotation, String key, String value) {
- while(annotation.getDetails().get(key) != null) {
+ while (annotation.getDetails().get(key) != null) {
annotation.getDetails().removeKey(key);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
index e2a59d4646b..53234310bde 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/IPapyrusDuplicateCommandConstants.java
@@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
* CEA LIST - Initial API and implementation
*
*****************************************************************************/
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
index bca16f5e807..8988dd44ec2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveEAnnotationCommand.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -50,13 +50,13 @@ public class RemoveEAnnotationCommand extends org.eclipse.emf.transaction.Record
/**
* Instantiates a new creates the e annotation command.
- *
+ *
* @param domain
- * the domain
+ * the domain
* @param object
- * the object
+ * the object
* @param eannotationName
- * the eannotation name
+ * the eannotation name
*/
public RemoveEAnnotationCommand(TransactionalEditingDomain domain, EModelElement object, String eannotationName) {
super(domain);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java
index 9079b898838..543b48c1176 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/RemoveFromResourcecommand.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -22,9 +22,9 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.papyrus.infra.emf.Activator;
/**
- *
+ *
* This command allows to remove elements from a resource
- *
+ *
*/
public class RemoveFromResourcecommand extends RecordingCommand {
@@ -44,68 +44,68 @@ public class RemoveFromResourcecommand extends RecordingCommand {
final private Collection<EObject> elementsToRemove;
/**
- *
+ *
* Constructor.
- *
+ *
* @param domain
- * the editing domain
+ * the editing domain
* @param resource
- * the resource
+ * the resource
* @param toRemove
- * the element to remove
+ * 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
+ * the editing domain
* @param resource
- * the resource
+ * the resource
* @param elementsToRemove
- * the list of the elements to remove
+ * 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
+ * the editing domain
* @param resource
- * the resource
+ * the resource
* @param toRemove
- * the element to remove
+ * the element to remove
* @param elementsToRemove
- * the list of the elements to remove
+ * 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");
+ 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) {
+ if (this.toRemove != null) {
this.resource.getContents().remove(toRemove);
}
- if(this.elementsToRemove != null) {
+ if (this.elementsToRemove != null) {
this.resource.getContents().removeAll(elementsToRemove);
}
} catch (Exception e) {
@@ -115,15 +115,15 @@ public class RemoveFromResourcecommand extends RecordingCommand {
/**
- *
+ *
* @see org.eclipse.emf.common.command.AbstractCommand#canExecute()
- *
+ *
* @return
*/
@Override
public boolean canExecute() {
boolean result = super.canExecute();
- if(toRemove == null && elementsToRemove == null) {
+ if (toRemove == null && elementsToRemove == null) {
return false;
}
return result;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
index a5b70fd6c1e..90723871d7a 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetCommand.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -33,15 +33,15 @@ public class UnsetCommand extends RecordingCommand {
private final EStructuralFeature feature;
/**
- *
+ *
* Constructor.
- *
+ *
* @param domain
- * the editing domain
+ * the editing domain
* @param source
- * the eobject to modify
+ * the eobject to modify
* @param feature
- * the feature to unset
+ * the feature to unset
*/
public UnsetCommand(final TransactionalEditingDomain domain, final EObject source, final EStructuralFeature feature) {
super(domain, Messages.UnsetCommand_UnsetCommand);
@@ -50,9 +50,9 @@ public class UnsetCommand extends RecordingCommand {
}
/**
- *
+ *
* @see org.eclipse.emf.transaction.RecordingCommand#doExecute()
- *
+ *
*/
@Override
protected void doExecute() {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetValueCommand.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetValueCommand.java
index 34f85125915..6c81afe9cfa 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetValueCommand.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/commands/UnsetValueCommand.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.commands;
@@ -33,9 +33,9 @@ public class UnsetValueCommand extends EditElementCommand {
/**
* Constructs a new command to set the value of a feature of a model
* element.
- *
+ *
* @param request
- * the set value request
+ * the set value request
*/
public UnsetValueCommand(UnsetRequest request) {
super(request.getLabel(), request.getElementToEdit(), request);
@@ -43,9 +43,10 @@ public class UnsetValueCommand extends EditElementCommand {
this.feature = request.getFeature();
}
+ @Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
EObject elementToEdit = getElementToEdit();
- if(elementToEdit == null) {
+ if (elementToEdit == null) {
throw new ExecutionException("No element to edit"); //$NON-NLS-1$
}
@@ -54,6 +55,7 @@ public class UnsetValueCommand extends EditElementCommand {
return CommandResult.newOKCommandResult();
}
+ @Override
public boolean canExecute() {
EObject elementToEdit = getElementToEdit();
return (elementToEdit != null) && super.canExecute();
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
index d1cc29e49a5..dda2b90e684 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/AnnotationObservableValue.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -24,7 +24,7 @@ import org.eclipse.emf.edit.domain.EditingDomain;
/**
* An IObservableValue for editing EMF EAnnotations
- *
+ *
* @author Camille Letavernier
*/
public class AnnotationObservableValue extends AbstractObservableValue {
@@ -57,18 +57,18 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* Constructor.
- *
+ *
* Creates an IObservableValue for the annotation. The annotation doesn't
* need to be created beforehand
- *
+ *
* @param source
- * The EObject owning the annotation
+ * The EObject owning the annotation
* @param domain
- * The editing domain on which the commands will be executed
+ * The editing domain on which the commands will be executed
* @param annotationName
- * The name of the annotation
+ * The name of the annotation
* @param key
- * The name of annotation's property to edit
+ * The name of annotation's property to edit
*/
public AnnotationObservableValue(EModelElement source, EditingDomain domain, String annotationName, String key) {
this(source, domain, annotationName, key, false);
@@ -76,21 +76,21 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* Constructor.
- *
+ *
* Creates an IObservableValue for the annotation. The annotation doesn't
* need to be created beforehand
- *
+ *
* @param source
- * The EObject owning the annotation
+ * The EObject owning the annotation
* @param domain
- * The editing domain on which the commands will be executed
+ * The editing domain on which the commands will be executed
* @param annotationName
- * The name of the annotation
+ * The name of the annotation
* @param key
- * The name of annotation's property to edit
+ * 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)
+ * 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;
@@ -113,7 +113,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
@Override
protected Object doGetValue() {
EAnnotation annotation = getEAnnotation();
- if(annotation == null) {
+ if (annotation == null) {
return null;
}
@@ -133,7 +133,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
@Override
protected void doSetValue(Object value) {
Command emfCommand = getCommand(value);
- if(emfCommand != null) {
+ if (emfCommand != null) {
domain.getCommandStack().execute(emfCommand);
}
}
@@ -141,20 +141,20 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* 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)) {
+ 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)) {
+ if (!(value instanceof String)) {
return null;
}
}
@@ -163,7 +163,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
@Override
public boolean prepare() {
- if(this.isEmpty()) {
+ if (this.isEmpty()) {
return false;
}
@@ -172,7 +172,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
};
- if(annotation == null) {
+ if (annotation == null) {
annotation = EcoreFactory.eINSTANCE.createEAnnotation();
SetCommand attachToSourceCommand = new SetCommand(domain, annotation, EcorePackage.eINSTANCE.getEAnnotation_EModelElement(), source);
@@ -184,9 +184,9 @@ public class AnnotationObservableValue extends AbstractObservableValue {
emfCommand.append(nameCommand);
}
- if(value == null) {
- if(annotation.getDetails().size() == 1 && annotation.getDetails().containsKey(key) && deleteWithLastEntry) {
- //We removed the last key : delete the annotation
+ 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);
@@ -195,7 +195,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
emfCommand.append(removeEntryCommand);
}
} else {
- Command addEntryCommand = new AddEntryCommand(annotation, key, (String)value);
+ Command addEntryCommand = new AddEntryCommand(annotation, key, (String) value);
emfCommand.append(addEntryCommand);
}
@@ -204,9 +204,9 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* A Command to remove an entry from an EAnnotation
- *
+ *
* @author Camille Letavernier
- *
+ *
*/
protected class RemoveEntryCommand extends AbstractCommand {
@@ -220,11 +220,11 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* Constructor
- *
+ *
* @param annotation
- * The EAnnotation to edit
+ * The EAnnotation to edit
* @param key
- * The EAnnotation's key to edit
+ * The EAnnotation's key to edit
*/
public RemoveEntryCommand(EAnnotation annotation, String key) {
this.annotation = annotation;
@@ -233,7 +233,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
public void execute() {
undo = annotation.getDetails().containsKey(key);
- if(undo) {
+ if (undo) {
previousValue = annotation.getDetails().get(key);
annotation.getDetails().remove(key);
}
@@ -250,7 +250,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
@Override
public void undo() {
- if(undo) {
+ if (undo) {
annotation.getDetails().put(key, previousValue);
}
}
@@ -258,7 +258,7 @@ public class AnnotationObservableValue extends AbstractObservableValue {
/**
* A Command to set an EAnnotation's entry
- *
+ *
* @author Camille Letavernier
*/
protected class AddEntryCommand extends AbstractCommand {
@@ -270,14 +270,14 @@ public class AnnotationObservableValue extends AbstractObservableValue {
private String value;
/**
- *
- *
+ *
+ *
* @param annotation
- * The EAnnotation to edit
+ * The EAnnotation to edit
* @param key
- * The EAnnotation's key to edit
+ * The EAnnotation's key to edit
* @param value
- * The value to set
+ * The value to set
*/
public AddEntryCommand(EAnnotation annotation, String key, String value) {
this.annotation = annotation;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
index beb832a0015..7e524ae2ded 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 402525
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.databinding;
@@ -40,7 +40,7 @@ import org.eclipse.papyrus.infra.widgets.editors.ICommitListener;
* 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" })
@@ -72,17 +72,17 @@ public class EMFObservableList extends ObservableList implements ICommitListener
protected List<?> concreteList;
/**
- *
+ *
* Constructor.
- *
+ *
* @param wrappedList
- * The list to be edited when #commit() is called
+ * The list to be edited when #commit() is called
* @param domain
- * The editing domain on which the commands will be executed
+ * The editing domain on which the commands will be executed
* @param source
- * The EObject from which the list will be retrieved
+ * The EObject from which the list will be retrieved
* @param feature
- * The feature from which the list will be retrieved
+ * 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);
@@ -91,20 +91,20 @@ public class EMFObservableList extends ObservableList implements ICommitListener
this.source = source;
this.feature = feature;
- if(concreteList instanceof IObservableList) {
- ((IObservableList)concreteList).addChangeListener(this);
+ if (concreteList instanceof IObservableList) {
+ ((IObservableList) concreteList).addChangeListener(this);
}
}
protected boolean isCommitting;
public void handleChange(ChangeEvent event) {
- if(isCommitting) {
- return; //We're modifying the wrapped Observable list, which sends us change events. Ignore them.
+ if (isCommitting) {
+ return; // We're modifying the wrapped Observable list, which sends us change events. Ignore them.
}
- //Refresh if we don't have pending changes
- if(commands.isEmpty()) {
+ // Refresh if we don't have pending changes
+ if (commands.isEmpty()) {
refreshCacheList();
}
}
@@ -112,11 +112,11 @@ public class EMFObservableList extends ObservableList implements ICommitListener
public Object getObserved() {
return source;
}
-
+
@Override
public synchronized void dispose() {
- if(concreteList instanceof IObservableList) {
- ((IObservableList)concreteList).removeChangeListener(this);
+ if (concreteList instanceof IObservableList) {
+ ((IObservableList) concreteList).removeChangeListener(this);
}
super.dispose();
}
@@ -124,15 +124,15 @@ public class EMFObservableList extends ObservableList implements ICommitListener
/**
* 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 synchronized void commit(AbstractEditor editor) {
isCommitting = true;
- if(commands.isEmpty()) {
+ if (commands.isEmpty()) {
return;
}
@@ -158,19 +158,19 @@ public class EMFObservableList extends ObservableList implements ICommitListener
@Override
protected boolean prepare() {
- if(commandList.isEmpty()) {
+ 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)
+ // 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) {
+ for (Command cmd : commands) {
compoundCommand.append(cmd);
}
@@ -185,12 +185,12 @@ public class EMFObservableList extends ObservableList implements ICommitListener
* 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
+ 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();
@@ -303,7 +303,7 @@ public class EMFObservableList extends ObservableList implements ICommitListener
@Override
public Object remove(int index) {
Object value = get(index);
- if(value != null) {
+ if (value != null) {
Command command = getRemoveCommand(index);
commands.add(command);
}
@@ -340,8 +340,8 @@ public class EMFObservableList extends ObservableList implements ICommitListener
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);
+ if (value instanceof EObject && feature instanceof EReference && ((EReference) feature).isContainment()) {
+ addDestroyCommand(cmd, (EObject) value);
}
return cmd;
}
@@ -349,10 +349,10 @@ public class EMFObservableList extends ObservableList implements ICommitListener
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);
+ if (feature instanceof EReference && ((EReference) feature).isContainment() && values != null) {
+ for (Object o : values) {
+ if (o instanceof EObject) {
+ addDestroyCommand(cc, (EObject) o);
}
}
}
@@ -371,12 +371,12 @@ public class EMFObservableList extends ObservableList implements ICommitListener
public Command getRetainAllCommand(Collection<?> values) {
List<Object> objectsToRemove = new LinkedList<Object>();
- for(Object object : values) {
- if(!contains(object)) {
+ for (Object object : values) {
+ if (!contains(object)) {
objectsToRemove.add(object);
}
}
- if(!objectsToRemove.isEmpty()) {
+ if (!objectsToRemove.isEmpty()) {
return getRemoveAllCommand(objectsToRemove);
} else {
return null;
@@ -386,8 +386,8 @@ public class EMFObservableList extends ObservableList implements ICommitListener
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);
+ if (oldValue instanceof EObject && feature instanceof EReference && ((EReference) feature).isContainment()) {
+ addDestroyCommand(command, (EObject) oldValue);
}
return command;
}
@@ -395,8 +395,8 @@ public class EMFObservableList extends ObservableList implements ICommitListener
protected void addDestroyCommand(Command cmd, EObject objToDestroy) {
Command destroyCmd = DeleteCommand.create(editingDomain, objToDestroy);
- if(cmd instanceof CompoundCommand) {
- ((CompoundCommand)cmd).append(destroyCmd);
+ if (cmd instanceof CompoundCommand) {
+ ((CompoundCommand) cmd).append(destroyCmd);
} else {
cmd.chain(destroyCmd);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
index 547bb6e4165..402ce4f1927 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -25,7 +25,7 @@ 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 {
@@ -36,31 +36,31 @@ public class EMFObservableValue extends EObjectObservableValue {
protected EditingDomain domain;
/**
- *
+ *
* Constructor.
- *
+ *
* @param eObject
- * The eObject being edited
+ * The eObject being edited
* @param eStructuralFeature
- * The structuralFeature being edited
+ * The structuralFeature being edited
* @param domain
- * The Editing domain on which the commands will be executed
+ * 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
+ * The eObject being edited
* @param eStructuralFeature
- * The structuralFeature being edited
+ * The structuralFeature being edited
* @param domain
- * The Editing domain on which the commands will be executed
+ * The Editing domain on which the commands will be executed
*/
public EMFObservableValue(Realm realm, EObject eObject, EStructuralFeature eStructuralFeature, EditingDomain domain) {
super(realm, eObject, eStructuralFeature);
@@ -70,7 +70,7 @@ public class EMFObservableValue extends EObjectObservableValue {
@Override
protected void doSetValue(Object value) {
EObject eObject = EMFHelper.getEObject(value);
- if(eObject != null) {
+ if (eObject != null) {
value = eObject;
}
@@ -80,9 +80,9 @@ public class EMFObservableValue extends EObjectObservableValue {
/**
* Returns the command used to edit the value
- *
+ *
* @param value
- * The new value
+ * The new value
* @return
* The Set command used to edit the value
*/
@@ -91,8 +91,8 @@ public class EMFObservableValue extends EObjectObservableValue {
CompoundCommand cc = new CompoundCommand("Edit value"); //$NON-NLS-1$
- if (oldValue instanceof EObject && eStructuralFeature instanceof EReference && ((EReference)eStructuralFeature).isContainment()) {
- cc.append(DeleteCommand.create(domain, (EObject)oldValue));
+ if (oldValue instanceof EObject && eStructuralFeature instanceof EReference && ((EReference) eStructuralFeature).isContainment()) {
+ cc.append(DeleteCommand.create(domain, oldValue));
}
cc.append(new SetCommand(domain, eObject, eStructuralFeature, value));
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java
index be0fbe08ce4..c9a14228dec 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/CommandCreationProgressMonitorDialog.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -9,7 +9,7 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) Vincent.Lorenzo@cea.fr - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.dialog;
@@ -19,10 +19,10 @@ 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());
*
@@ -55,9 +55,9 @@ public class CommandCreationProgressMonitorDialog extends ProgressMonitorDialog
private Exception exception;
/**
- *
+ *
* Constructor.
- *
+ *
* @param parent
*/
public CommandCreationProgressMonitorDialog(final Shell parent) {
@@ -67,9 +67,9 @@ public class CommandCreationProgressMonitorDialog extends ProgressMonitorDialog
/**
* Setter for {@link #createdCommand}
- *
+ *
* @param cmd
- * the created command
+ * the created command
*/
public void setCreatedCommand(final Command cmd) {
this.createdCommand = cmd;
@@ -77,7 +77,7 @@ public class CommandCreationProgressMonitorDialog extends ProgressMonitorDialog
/**
* Getter for {@link #createdCommand}
- *
+ *
* @return
* the created command
*/
@@ -90,7 +90,7 @@ public class CommandCreationProgressMonitorDialog extends ProgressMonitorDialog
}
/**
- *
+ *
* @return
* the exception throwed by the command creation
*/
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/NestedEditingDialogContext.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/NestedEditingDialogContext.java
index 813e5524574..2ba17a5167d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/NestedEditingDialogContext.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/dialog/NestedEditingDialogContext.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -33,7 +33,7 @@ public class NestedEditingDialogContext {
/**
* Queries whether the current editing dialog is nested in (created by) a higher-level dialog editing some other object.
- *
+ *
* @return whether the current thread is presenting a nested editing dialog
*/
public boolean isNested() {
@@ -44,12 +44,12 @@ public class NestedEditingDialogContext {
/**
* Signals entry of an editing dialog context (the current thread is now presenting a dialog). Must be matched by a subsequent
* call to {@linkplain #exit() exit} the context.
- *
+ *
* @see #exit()
*/
public void enter() {
Integer depth = nesting.get();
- if((depth == null) || (depth.intValue() < 1)) {
+ if ((depth == null) || (depth.intValue() < 1)) {
depth = 1;
} else {
depth = depth.intValue() + 1;
@@ -60,13 +60,13 @@ public class NestedEditingDialogContext {
/**
* Signals the end of an editing dialog context (the current thread is no longer presenting a dialog). Must match an earlier
* call to {@linkplain #enter() enter} the context.
- *
+ *
* @see #enter()
*/
public void exit() {
Integer depth = nesting.get();
- if(depth != null) {
- if(depth.intValue() <= 1) {
+ if (depth != null) {
+ if (depth.intValue() <= 1) {
depth = null;
} else {
depth = depth.intValue() - 1;
@@ -77,7 +77,7 @@ public class NestedEditingDialogContext {
/**
* Obtains the resource set in the editing-dialog context of the current thread.
- *
+ *
* @return the current contextual resource set
*/
public ResourceSet getResourceSet() {
@@ -87,23 +87,23 @@ public class NestedEditingDialogContext {
/**
* Determines, if possible, the resource set containing the given {@code context} object being edited and pushes it onto the
* current thread's context stack.
- *
+ *
* @param context
- * the object currently being edited in a dialog
- *
+ * the object currently being edited in a dialog
+ *
* @return the resource set that was previously the context (which may be the same as the new one being pushed). This
* must be {@linkplain #pop(ResourceSet) popped} from the context subsequently
- *
+ *
* @see #pop(ResourceSet)
*/
public ResourceSet push(Object context) {
final ResourceSet previous = resourceSet.get();
- if(context instanceof EObject) {
- Resource res = ((EObject)context).eResource();
- if(res != null) {
+ if (context instanceof EObject) {
+ Resource res = ((EObject) context).eResource();
+ if (res != null) {
ResourceSet current = res.getResourceSet();
- if(current != null) {
+ if (current != null) {
// put it in context
resourceSet.set(current);
}
@@ -116,14 +116,14 @@ public class NestedEditingDialogContext {
/**
* Pops the current resource set from the context, restoring the given resource set that was returned by a previous {@linkplain #push(Object)
* push}, even if it was {@code null}.
- *
+ *
* @param previous
- * a resource set returned by an earlier push (may be {@code null})
- *
+ * a resource set returned by an earlier push (may be {@code null})
+ *
* @see #push(Object)
*/
public void pop(ResourceSet previous) {
- if(previous == null) {
+ if (previous == null) {
resourceSet.remove();
} else {
resourceSet.set(previous);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
index 6e02b835316..3b3f75dcb1b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/messages/Messages.java
@@ -1,45 +1,44 @@
+/*************************************************************
+ * Copyright (c) 2012, 2014 CEA and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent Lorenzo (CEA LIST) - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 323802
+ *
+ */
-/*************************************************************
- * Copyright (c) 2012, 2014 CEA and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Vincent Lorenzo (CEA LIST) - Initial API and implementation
- * Christian W. Damus (CEA) - bug 323802
- *
- */
-
-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 ResourceFilteredLabelProvider_local;
-
- public static String ResourceFilteredLabelProvider_localExt;
-
- public static String ResourceFilteredLabelProvider_system;
-
- public static String ResourceFilteredLabelProvider_systemExt;
-
- public static String ResourceFilteredLabelProvider_workspace;
-
- public static String ResourceFilteredLabelProvider_workspaceExt;
-
- public static String UnsetCommand_UnsetCommand;
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+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 ResourceFilteredLabelProvider_local;
+
+ public static String ResourceFilteredLabelProvider_localExt;
+
+ public static String ResourceFilteredLabelProvider_system;
+
+ public static String ResourceFilteredLabelProvider_systemExt;
+
+ public static String ResourceFilteredLabelProvider_workspace;
+
+ public static String ResourceFilteredLabelProvider_workspaceExt;
+
+ public static String UnsetCommand_UnsetCommand;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AdapterFactoryHierarchicContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AdapterFactoryHierarchicContentProvider.java
index ba1c5fc4f26..5a1653e88c2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AdapterFactoryHierarchicContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AdapterFactoryHierarchicContentProvider.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java
index 4e1203a22e1..d6b55f7c363 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/AnyTypeLabelProvider.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -24,9 +24,9 @@ import org.eclipse.ui.PlatformUI;
/**
* A LabelProvider for unresolved "AnyType" elements
- *
+ *
* @author Camille Letavernier
- *
+ *
*/
public class AnyTypeLabelProvider extends EMFLabelProvider implements IFilteredLabelProvider {
@@ -34,13 +34,13 @@ public class AnyTypeLabelProvider extends EMFLabelProvider implements IFilteredL
public String getText(Object element) {
EObject eObject = EMFHelper.getEObject(element);
- if(!(eObject instanceof AnyType)) {
+ if (!(eObject instanceof AnyType)) {
return super.getText(element);
}
- AnyType anyType = (AnyType)eObject;
+ AnyType anyType = (AnyType) eObject;
EClass eClass = anyType.eClass();
- if(eClass != null) {
+ if (eClass != null) {
return "Missing " + eClass.getName();
} else {
return "Missing component";
@@ -50,7 +50,7 @@ public class AnyTypeLabelProvider extends EMFLabelProvider implements IFilteredL
@Override
public Image getImage(Object element) {
EObject eObject = EMFHelper.getEObject(element);
- if(!(eObject instanceof AnyType)) {
+ if (!(eObject instanceof AnyType)) {
return super.getImage(element);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
index b03ffe1f2f2..f2f3e4361a2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -31,17 +31,17 @@ 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
+ * The feature representing the reference for which we want to retrieve possible values
* @param eObject
*/
public EMFContentProvider(EObject editedEObject, EStructuralFeature feature) {
@@ -52,19 +52,19 @@ public class EMFContentProvider extends EncapsulatedContentProvider {
/**
* Returns the content provider associated to feature being edited
- *
+ *
* @param editedEObject
- * The object being edited
+ * The object being edited
* @param feature
- * The object's feature being edited
+ * 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) {
+ if (type instanceof EEnum) {
return new EMFEnumeratorContentProvider(feature);
- } else if(type instanceof EClass) {
+ } else if (type instanceof EClass) {
return new SemanticEMFContentProvider(editedEObject, feature);
}
@@ -75,9 +75,9 @@ public class EMFContentProvider extends EncapsulatedContentProvider {
* 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
+ * The ContentProvider to encapsulate
* @return
*/
protected EMFGraphicalContentProvider encapsulateProvider(IStructuredContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
@@ -85,8 +85,8 @@ public class EMFContentProvider extends EncapsulatedContentProvider {
IStructuredContentProvider contentProvider;
- if(provider instanceof ITreeContentProvider) {
- contentProvider = getStrategyProvider((ITreeContentProvider)provider);
+ if (provider instanceof ITreeContentProvider) {
+ contentProvider = getStrategyProvider((ITreeContentProvider) provider);
} else {
contentProvider = provider;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
index a4d5f0c9d1d..aed1a94544f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFEnumeratorContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -20,7 +20,7 @@ import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider
/**
* An IStaticContentProvider for EMF enumerators.
- *
+ *
* @author Camille Letavernier
*/
public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider {
@@ -32,7 +32,7 @@ public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider
/**
* Constructs an EcoreEnumerator for the given Structural Feature
- *
+ *
* @param feature
*/
public EMFEnumeratorContentProvider(EStructuralFeature feature) {
@@ -41,12 +41,12 @@ public class EMFEnumeratorContentProvider extends AbstractStaticContentProvider
public Object[] getElements() {
EClassifier type = feature.getEType();
- EEnum enumerated = (EEnum)type;
+ 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) {
+ for (EEnumLiteral literal : literals) {
Enumerator value = literal.getInstance();
values[i++] = value;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java
index 4b8190009c1..c36d6592798 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFFilteredLabelProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -19,21 +19,21 @@ import org.eclipse.papyrus.infra.services.labelprovider.service.IFilteredLabelPr
/**
* 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()) {
+ if (selection.isEmpty()) {
return false;
}
Iterator<?> iterator = selection.iterator();
- while(iterator.hasNext()) {
+ while (iterator.hasNext()) {
Object element = iterator.next();
- if(!accept(element)) {
+ if (!accept(element)) {
return false;
}
}
@@ -42,11 +42,11 @@ public class EMFFilteredLabelProvider extends EMFLabelProvider implements IFilte
}
public boolean accept(Object element) {
- if(element instanceof IStructuredSelection) {
- return accept((IStructuredSelection)element);
+ if (element instanceof IStructuredSelection) {
+ return accept((IStructuredSelection) element);
}
- //The element is an EObject or can be adapted to an EObject
+ // The element is an EObject or can be adapted to an EObject
return EMFHelper.getEObject(element) != null;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
index bea0471d57d..a4f735ac29d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFGraphicalContentProvider.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -59,20 +59,20 @@ import org.eclipse.swt.widgets.Table;
/**
* This providers adds a text-filter and an History to EMF-based content providers
*/
-//TODO : Extend (Abstract)FilteredContentProvider
+// 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)
+ // Unused (yet)
+ // TODO : Add a preference or a collapsible composite for this feature (Or both)
//
- // /**
- // * The current metaclass viewer filter
- // */
- // protected ViewerFilter currentMetaclassViewerFilter;
+ // /**
+ // * The current metaclass viewer filter
+ // */
+ // protected ViewerFilter currentMetaclassViewerFilter;
protected ViewerFilter patternFilter;
@@ -124,21 +124,21 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
editor.setValidateOnDelay(true);
patternFilter = new PatternViewerFilter();
currentFilterPattern = ""; //$NON-NLS-1$
- ((PatternViewerFilter)patternFilter).setPattern(currentFilterPattern);
+ ((PatternViewerFilter) patternFilter).setPattern(currentFilterPattern);
editor.addCommitListener(new ICommitListener() {
public void commit(AbstractEditor editor) {
- String filterPattern = (String)((StringEditor)editor).getValue();
- ((PatternViewerFilter)patternFilter).setPattern(filterPattern);
+ String filterPattern = (String) ((StringEditor) editor).getValue();
+ ((PatternViewerFilter) patternFilter).setPattern(filterPattern);
viewer.refresh();
- if(!("".equals(filterPattern) || currentFilterPattern.equals(filterPattern))) {
+ 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));
- //}
+ // 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;
}
@@ -153,41 +153,41 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
/**
* 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())) {
+ // Browse from the root element
+ if (parent == null) {
+ for (Object parentElement : getElements(viewer.getInput())) {
Object firstMatch = getFirstMatchingElement(parentElement);
- if(firstMatch != null) {
+ if (firstMatch != null) {
return firstMatch;
}
}
return null;
}
- for(ViewerFilter filter : viewer.getFilters()) {
- if(!filter.select(viewer, getParent(parent), parent)) {
+ for (ViewerFilter filter : viewer.getFilters()) {
+ if (!filter.select(viewer, getParent(parent), parent)) {
return null;
}
}
- //Test the current element
- if(isValidValue(parent)) {
+ // Test the current element
+ if (isValidValue(parent)) {
return parent;
}
- //Browse the child elements
- for(Object childElement : getChildren(parent)) {
+ // Browse the child elements
+ for (Object childElement : getChildren(parent)) {
Object firstMatch = getFirstMatchingElement(childElement);
- if(firstMatch != null) {
+ if (firstMatch != null) {
return firstMatch;
}
}
- //No match found
+ // No match found
return null;
}
@@ -197,16 +197,16 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
@Override
public void createAfter(Composite parent) {
parent.setLayout(new GridLayout(1, false));
- // createMetaclassFilter(parent); //Disabled
+ // 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
+ * The composite in which the widget will be created
*/
protected void createHistory(Composite parent) {
initSelectionHistory();
@@ -231,10 +231,10 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
* {@inheritDoc}
*/
public void selectionChanged(SelectionChangedEvent event) {
- IStructuredSelection selection = (IStructuredSelection)historyViewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection) historyViewer.getSelection();
Object selectedObject = selection.getFirstElement();
- if(selectedObject instanceof EObject) {
- EObject eObject = ((EObject)selectedObject);
+ if (selectedObject instanceof EObject) {
+ EObject eObject = ((EObject) selectedObject);
revealSemanticElement(Collections.singletonList(eObject));
}
}
@@ -248,18 +248,18 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
selectionHistory = new ArrayList<EObject>(HISTORY_MAX_SIZE + 1);
IDialogSettings historySettings = getDialogSettings().getSection(HISTORY_SETTINGS);
- if(historySettings != null && resourceSet != null) {
+ 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) {
+ if (uriHistory != null) {
+ for (String uri : uriHistory) {
try {
EObject object = resourceSet.getEObject(URI.createURI(uri), true);
- if(object != null && !selectionHistory.contains(object)) {
+ if (object != null && !selectionHistory.contains(object)) {
selectionHistory.add(object);
}
} catch (Exception ex) {
- //Ignore : if the resource doesn't exist anymore, we just skip it
+ // Ignore : if the resource doesn't exist anymore, we just skip it
}
}
}
@@ -269,75 +269,75 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
/**
* Creates a widget to filter the tree according to the selected
* metaclass.
- *
+ *
* @param parent
- * The Composite in which the widgets will be created
+ * The Composite in which the widgets will be created
* @deprecated
*/
@Deprecated
protected void createMetaclassFilter(Composite parent) {
- // if(semanticRoot == null) {
- // return;
- // }
+ // 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));
+ // 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);
+ // ResourceSet resourceSet = semanticRoot.eResource().getResourceSet();
+ // EcoreUtil.resolveAll(resourceSet);
//
- // Label metamodelLabel = new Label(container, SWT.NONE);
- // metamodelLabel.setText("Metamodel:");
+ // 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));
+ // 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:");
+ // 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));
+ // 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.setFilters(new ViewerFilter[]{ new MetamodelContentFilter(metaclassProvider) });
//
- // metamodelViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ // metamodelViewer.addSelectionChangedListener(new ISelectionChangedListener() {
//
- // public void selectionChanged(SelectionChangedEvent event) {
- // metaclassViewer.setInput(((IStructuredSelection)event.getSelection()).getFirstElement());
- // metaclassViewer.getCombo().setEnabled(true);
- // }
- // });
+ // public void selectionChanged(SelectionChangedEvent event) {
+ // metaclassViewer.setInput(((IStructuredSelection)event.getSelection()).getFirstElement());
+ // metaclassViewer.getCombo().setEnabled(true);
+ // }
+ // });
//
- // metaclassViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ // 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();
- // }
- // }
- // });
+ // 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
+ * The composite in which the widget will be created
*/
protected void createDetailArea(Composite parent) {
detailLabel = new CLabel(parent, SWT.BORDER);
@@ -345,34 +345,34 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
updateDetailLabel();
}
- // @Deprecated
- // protected IStructuredContentProvider getMetamodelContentProvider() {
- // return new MetamodelContentProvider();
- // }
+ // @Deprecated
+ // protected IStructuredContentProvider getMetamodelContentProvider() {
+ // return new MetamodelContentProvider();
+ // }
//
- // @Deprecated
- // protected IStructuredContentProvider getMetaclassContentProvider() {
- // return new MetaclassContentProvider((EClass)this.metaClassWanted, this.metaClassNotWantedList);
- // }
+ // @Deprecated
+ // protected IStructuredContentProvider getMetaclassContentProvider() {
+ // return new MetaclassContentProvider((EClass)this.metaClassWanted, this.metaClassNotWantedList);
+ // }
//
- // @Deprecated
- // protected ILabelProvider getLabelProvider() {
- // return new EMFObjectLabelProvider();
- // }
+ // @Deprecated
+ // protected ILabelProvider getLabelProvider() {
+ // return new EMFObjectLabelProvider();
+ // }
//
- // @Deprecated
- // protected ViewerFilter getMetaclassViewerFilter(Object selectedMetaClass) {
- // return new MetaclassViewerFilter(selectedMetaClass);
- // }
+ // @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) {
+ if (settings == null) {
settings = Activator.getDefault().getDialogSettings().addNewSection(getDialogSettingsIdentifier());
}
return settings;
@@ -384,30 +384,30 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
/**
* Stores dialog settings.
- *
+ *
* @param settings
- * settings used to store dialog
+ * 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) {
+ // 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) {
+ for (EObject object : selectionHistory) {
URI uri = EcoreUtil.getURI(object);
uriList.add(uri.toString());
}
IDialogSettings historySettings = settings.getSection(HISTORY_SETTINGS);
- if(historySettings == null) {
+ if (historySettings == null) {
historySettings = settings.addNewSection(HISTORY_SETTINGS);
}
historySettings.put(PREVIOUS_SELECTION, uriList.toArray(new String[uriList.size()]));
@@ -419,9 +419,9 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
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()) {
+ if (viewer instanceof StructuredViewer) {
+ this.viewer = (StructuredViewer) viewer;
+ if (newInput != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
this.viewer.addSelectionChangedListener(this);
}
} else {
@@ -430,22 +430,22 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
}
public void selectionChanged(SelectionChangedEvent event) {
- selectedObject = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ selectedObject = ((IStructuredSelection) event.getSelection()).getFirstElement();
updateDetailLabel();
}
private void updateDetailLabel() {
- if(detailLabel == null || detailLabel.isDisposed()) {
+ if (detailLabel == null || detailLabel.isDisposed()) {
return;
}
- if(selectedObject == null) {
+ if (selectedObject == null) {
detailLabel.setText("");
detailLabel.setImage(null);
} else {
- ILabelProvider labelProvider = (ILabelProvider)viewer.getLabelProvider();
+ ILabelProvider labelProvider = (ILabelProvider) viewer.getLabelProvider();
String description;
- if(labelProvider instanceof IDetailLabelProvider) {
- description = ((IDetailLabelProvider)labelProvider).getDetail(selectedObject);
+ if (labelProvider instanceof IDetailLabelProvider) {
+ description = ((IDetailLabelProvider) labelProvider).getDetail(selectedObject);
} else {
description = labelProvider.getText(selectedObject);
}
@@ -457,19 +457,19 @@ public class EMFGraphicalContentProvider extends EncapsulatedContentProvider imp
@Override
public void commit(AbstractEditor editor) {
- Iterator<?> selectionIterator = ((IStructuredSelection)viewer.getSelection()).iterator();
+ Iterator<?> selectionIterator = ((IStructuredSelection) viewer.getSelection()).iterator();
Set<EObject> eObjectsToStore = new LinkedHashSet<EObject>();
- while(selectionIterator.hasNext()) {
+ while (selectionIterator.hasNext()) {
Object selectedElement = selectionIterator.next();
- if(isValidValue(selectedElement)) {
+ if (isValidValue(selectedElement)) {
Object semanticObject = getAdaptedValue(selectedElement);
- if(semanticObject instanceof EObject) {
- eObjectsToStore.add((EObject)semanticObject);
+ if (semanticObject instanceof EObject) {
+ eObjectsToStore.add((EObject) semanticObject);
}
}
}
- if(!eObjectsToStore.isEmpty()) {
+ if (!eObjectsToStore.isEmpty()) {
storeDialog(getDialogSettings(), eObjectsToStore);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java
index c6e0ac7cb6f..d1c69487e6b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/EMFLabelProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -21,7 +21,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.internal.treeproxy.TreeElement;
-import org.eclipse.papyrus.emf.facet.custom.ui.internal.CustomizedLabelProvider;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.DecoratingCustomizedLabelProvider;
import org.eclipse.papyrus.emf.facet.custom.ui.internal.ResolvingCustomizedLabelProvider;
import org.eclipse.papyrus.infra.emf.Activator;
@@ -35,7 +34,7 @@ import org.eclipse.swt.graphics.Image;
* 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 ResolvingCustomizedLabelProvider implements IDetailLabelProvider, IQualifierLabelProvider {
@@ -46,7 +45,7 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
* Creates a new EMFObjectLabelProvider.
*/
public EMFLabelProvider() {
- super(new DecoratingCustomizedLabelProvider(Activator.getDefault().getCustomizationManager())); //Note: CustomizableModelLabelProvider doesn't use the CustomizationManager. It relies on the content provider's CustomizationManager
+ super(new DecoratingCustomizedLabelProvider(Activator.getDefault().getCustomizationManager())); // Note: CustomizableModelLabelProvider doesn't use the CustomizationManager. It relies on the content provider's CustomizationManager
baseEMFLabelProvider = new StandardEMFLabelProvider();
}
@@ -55,21 +54,21 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
*/
@Override
public String getText(Object element) {
- if(element == null) {
+ if (element == null) {
return ""; //$NON-NLS-1$
}
- if(element instanceof TreeElement) {
+ if (element instanceof TreeElement) {
return super.getText(element);
}
EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
+ if (eObject != null) {
return getText(eObject);
}
- if(element instanceof IStructuredSelection) {
- return getText((IStructuredSelection)element);
+ if (element instanceof IStructuredSelection) {
+ return getText((IStructuredSelection) element);
}
return element.toString();
@@ -80,21 +79,21 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
}
protected String getText(IStructuredSelection selection) {
- if(selection.isEmpty()) {
+ if (selection.isEmpty()) {
return ""; //$NON-NLS-1$
}
- if(selection.size() == 1) {
+ if (selection.size() == 1) {
return getText(selection.getFirstElement());
} else {
final List<Object> selectionAsList = selection.toList();
String str = "";
- for(int i = 0; i < selectionAsList.size(); i++) {
+ for (int i = 0; i < selectionAsList.size(); i++) {
final String txt = getText(selectionAsList.get(i));
- if(txt != null) {
+ if (txt != null) {
str += txt;
}
- if(i < selectionAsList.size() - 1) {
+ if (i < selectionAsList.size() - 1) {
str += ", ";
}
}
@@ -107,17 +106,17 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
*/
@Override
public Image getImage(Object element) {
- if(element instanceof TreeElement) {
+ if (element instanceof TreeElement) {
return super.getImage(element);
}
EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
+ if (eObject != null) {
return getImage(eObject);
}
- if(element instanceof IStructuredSelection) {
- return getImage((IStructuredSelection)element);
+ if (element instanceof IStructuredSelection) {
+ return getImage((IStructuredSelection) element);
}
return null;
@@ -128,56 +127,56 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
}
protected Image getImage(IStructuredSelection selection) {
- if(selection.isEmpty()) {
+ if (selection.isEmpty()) {
return null;
- } else if(selection.size() == 1) {
+ } 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(final Object current : selectionAsList) {
+ for (final Object current : selectionAsList) {
final EObject obj = EMFHelper.getEObject(current);
- if(obj != null) {
+ if (obj != null) {
selectedEObject.add(obj);
} else {
isEObjectSelection = false;
}
}
- if(isEObjectSelection) {//all selected elements are EObject
- if(selectedEObject.size() == 1 || hasCommonImage(selectedEObject)) {
+ if (isEObjectSelection) {// all selected elements are EObject
+ if (selectedEObject.size() == 1 || hasCommonImage(selectedEObject)) {
return getImage(selectedEObject.toArray()[0]);
} else {
final EClass common = org.eclipse.papyrus.emf.facet.util.emf.core.internal.EMFUtils.computeLeastCommonSupertype(getEClasses(selectedEObject));
- if(!common.isAbstract()) {
- //FIXME : the label provider service should manage this case
+ 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 if (selectedEObject.size() == 0) {
+ // the multiple selection contains any EObject
} else {
- //the selection contains EObject and others elements
+ // the selection contains EObject and others elements
}
return null;
}
/**
- *
+ *
* @param objects
- * a collection of 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.isEmpty()) {
+ if (!objects.isEmpty()) {
final Image lastImage = getImage(objects.toArray()[0]);
- for(final Object current : objects) {
- if(lastImage != getImage(current)) {
+ for (final Object current : objects) {
+ if (lastImage != getImage(current)) {
return false;
}
}
@@ -188,9 +187,9 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
}
/**
- *
+ *
* @param commonEClass
- * the eClass
+ * the eClass
* @return
* the icon to use for this eclass
*/
@@ -199,15 +198,15 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
}
/**
- *
+ *
* @param objects
- * a collection of eobject
+ * 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) {
+ for (final EObject current : objects) {
eclasses.add(current.eClass());
}
return eclasses;
@@ -221,27 +220,27 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
/**
* 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;
+ 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) {
+ if (parent != null) {
result = getQualifiedText(parent);
}
@@ -251,9 +250,9 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
private EObject getParentObject(Object element) {
EObject result = null;
- if(element != null) {
+ if (element != null) {
EObject eObject = EMFHelper.getEObject(element);
- if(eObject != null) {
+ if (eObject != null) {
result = getParent(eObject);
}
}
@@ -265,7 +264,7 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
Image result = null;
EObject parent = getParentObject(element);
- if(parent != null) {
+ if (parent != null) {
result = getImage(parent);
}
@@ -286,16 +285,16 @@ public class EMFLabelProvider extends ResolvingCustomizedLabelProvider implement
protected void appendQualifiedText(EObject object, StringBuilder buf) {
EObject parent = getParent(object);
- if(parent != null) {
+ if (parent != null) {
appendQualifiedText(parent, buf);
}
- if(buf.length() > 0) {
+ if (buf.length() > 0) {
buf.append("::");
}
String name = getText(object);
- if(name == null) {
+ if (name == null) {
name = String.format("<%s>", object.eClass().getName());
}
buf.append(name);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java
index 1dee49a7a56..e6691a33267 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/HistoryContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -18,7 +18,7 @@ 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
@@ -42,8 +42,8 @@ public class HistoryContentProvider implements IStructuredContentProvider {
* {@inheritDoc}
*/
public Object[] getElements(Object inputElement) {
- if(inputElement instanceof List<?>) {
- return ((List<?>)inputElement).toArray();
+ if (inputElement instanceof List<?>) {
+ return ((List<?>) inputElement).toArray();
}
return new Object[0];
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
index 508d197435a..8fd37159f40 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/MoDiscoContentProvider.java
@@ -26,7 +26,7 @@ import org.eclipse.papyrus.infra.emf.Activator;
/**
* the content provider that inherits of modisco properties
- *
+ *
* @deprecated Use SemanticUMLContentProvider instead
*/
@Deprecated
@@ -53,7 +53,7 @@ public class MoDiscoContentProvider extends CustomizedTreeContentProvider {
@Override
public Object[] getChildren(final Object parentElement) {
Object[] children = super.getChildren(parentElement);
- if(children == null) {
+ if (children == null) {
return new Object[0];
}
return children;
@@ -62,9 +62,9 @@ public class MoDiscoContentProvider extends CustomizedTreeContentProvider {
/**
* 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
*/
@@ -72,11 +72,11 @@ public class MoDiscoContentProvider extends CustomizedTreeContentProvider {
protected EObject[] getRootElements(Object inputElement) {
try {
- if(!(inputElement instanceof ServicesRegistry)) {
+ if (!(inputElement instanceof ServicesRegistry)) {
return null;
}
- ServicesRegistry servicesRegistry = (ServicesRegistry)inputElement;
+ ServicesRegistry servicesRegistry = (ServicesRegistry) inputElement;
modelSet = ModelUtils.getModelSetChecked(servicesRegistry);
pageMngr = servicesRegistry.getService(IPageManager.class);
@@ -91,26 +91,26 @@ public class MoDiscoContentProvider extends CustomizedTreeContentProvider {
/**
* 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.
+ // 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 (umlIModel instanceof AbstractBaseModel) {
+ umlModel = (AbstractBaseModel) umlIModel;
}
- if(umlModel == null) {
+ 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()) {
+ while (iterator.hasNext()) {
EObject eObject = iterator.next();
result.add(eObject);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java
index b776f51de5a..6440770e64f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/ResourceFilteredLabelProvider.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -46,7 +46,7 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
@Override
public void dispose() {
- if(images != null) {
+ if (images != null) {
images.dispose();
images = null;
}
@@ -56,7 +56,7 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
@Override
public String getText(Object element) {
- return (element instanceof Resource) ? getText((Resource)element) : super.getText(element);
+ return (element instanceof Resource) ? getText((Resource) element) : super.getText(element);
}
protected String getText(Resource resource) {
@@ -64,21 +64,21 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
URI uri = resource.getURI();
- if(uri.isPlatformResource()) {
+ if (uri.isPlatformResource()) {
String ext = uri.fileExtension();
- if(ext == null) {
+ if (ext == null) {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_workspace, uri.toPlatformString(true));
} else {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_workspaceExt, uri.toPlatformString(true), uri.fileExtension());
}
- } else if(uri.isFile()) {
+ } else if (uri.isFile()) {
String ext = uri.fileExtension();
- if(ext == null) {
+ if (ext == null) {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_local, uri.toFileString());
} else {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_localExt, uri.toFileString(), uri.fileExtension());
}
- } else if(uri.isHierarchical()) {
+ } else if (uri.isHierarchical()) {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_system, uri.lastSegment());
} else {
result = NLS.bind(Messages.ResourceFilteredLabelProvider_systemExt, uri.toString());
@@ -89,7 +89,7 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
@Override
public Image getImage(Object element) {
- return (element instanceof Resource) ? getImage((Resource)element) : super.getImage(element);
+ return (element instanceof Resource) ? getImage((Resource) element) : super.getImage(element);
}
protected Image getImage(Resource resource) {
@@ -99,20 +99,20 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
IContentType contentType = null;
try {
Map<String, ?> description = converter.contentDescription(uri, null);
- contentType = (description.get(ContentHandler.CONTENT_TYPE_PROPERTY) == null) ? null : Platform.getContentTypeManager().getContentType((String)description.get(ContentHandler.CONTENT_TYPE_PROPERTY));
+ contentType = (description.get(ContentHandler.CONTENT_TYPE_PROPERTY) == null) ? null : Platform.getContentTypeManager().getContentType((String) description.get(ContentHandler.CONTENT_TYPE_PROPERTY));
} catch (IOException e) {
Activator.log.error(e);
}
IEditorDescriptor[] editors;
- if(contentType != null) {
+ if (contentType != null) {
editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(uri.lastSegment(), contentType);
} else {
editors = PlatformUI.getWorkbench().getEditorRegistry().getEditors(uri.lastSegment());
}
ImageDescriptor result = null;
- for(int i = 0; (result == null) && (i < editors.length); i++) {
+ for (int i = 0; (result == null) && (i < editors.length); i++) {
result = editors[0].getImageDescriptor();
}
@@ -122,12 +122,12 @@ public class ResourceFilteredLabelProvider extends EMFLabelProvider implements I
protected Image convert(ImageDescriptor descriptor) {
Image result = null;
- if(descriptor != null) {
- if(images == null) {
+ if (descriptor != null) {
+ if (images == null) {
images = new LocalResourceManager(JFaceResources.getResources());
}
- result = (Image)images.get(descriptor);
+ result = (Image) images.get(descriptor);
}
return result;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
index 50698bb43ed..3c69f464f68 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/SemanticFromModelExplorer.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -21,7 +21,7 @@ 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
+// FIXME: Remove the dependency to gmf
public class SemanticFromModelExplorer implements IElementWithSemantic {
/**
@@ -29,11 +29,11 @@ public class SemanticFromModelExplorer implements IElementWithSemantic {
*/
public Object getSemanticElement(Object wrapper) {
EObject semantic = EMFHelper.getEObject(wrapper);
- if(semantic != null) {
+ if (semantic != null) {
return semantic;
}
- if(wrapper instanceof Diagram) {
+ if (wrapper instanceof Diagram) {
return wrapper;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java
index b565e10d9b2..96e25e91955 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/StandardEMFLabelProvider.java
@@ -4,7 +4,7 @@
* 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
@@ -37,7 +37,7 @@ import org.eclipse.swt.graphics.Image;
* 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 {
@@ -144,7 +144,7 @@ public class StandardEMFLabelProvider extends AdapterFactoryLabelProvider implem
/**
* Returns the item provider for the given object
- *
+ *
* @param eObject
* the object to display
* @return the item label provider for the given eobject
@@ -162,10 +162,10 @@ public class StandardEMFLabelProvider extends AdapterFactoryLabelProvider implem
/**
* Gets the edit factory.
- *
+ *
* @param eobject
* the eobject
- *
+ *
* @return the edits the factory
*/
public static AdapterFactory getEditFactory(EObject eobject) {
@@ -175,10 +175,10 @@ public class StandardEMFLabelProvider extends AdapterFactoryLabelProvider implem
/**
* Gets the factory from uri.
- *
+ *
* @param uri
* the uri
- *
+ *
* @return the factory
*/
public static AdapterFactory getFactory(String uri) {
@@ -213,7 +213,7 @@ public class StandardEMFLabelProvider extends AdapterFactoryLabelProvider implem
/**
* 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
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
index d64446720d5..9a330a9fa08 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/ContainmentBrowseStrategy.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -34,10 +34,10 @@ 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 {
@@ -47,132 +47,132 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
protected TreeViewer viewer;
public ContainmentBrowseStrategy(ITreeContentProvider provider) {
- if(!(provider instanceof IAdaptableContentProvider)) {
+ if (!(provider instanceof IAdaptableContentProvider)) {
throw new IllegalArgumentException("The provider must be an IAdaptableContentProvider");
}
setProvider(provider);
- this.adaptableProvider = (IAdaptableContentProvider)super.provider;
+ this.adaptableProvider = (IAdaptableContentProvider) super.provider;
}
//
- // Elements filtering
+ // 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;
- //}
+ // 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 ((EReference) semanticElement).isContainment() && !((EReference) semanticElement).isDerived();
}
return true;
}
//
- // Elements search
+ // 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);
- // }
- // }
+ // /**
+ // * {@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;
- // }
+ // 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();
- // }
+ // /**
+ // * 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());
- // }
+ // return new TreePath(graphicalPath.toArray());
+ // }
//
- // protected boolean searchPath(List<Object> semanticPath, List<Object> graphicalPath, Object[] graphicalRootObjects) {
- // if(semanticPath.isEmpty()) {
- // return true;
- // }
+ // protected boolean searchPath(List<Object> semanticPath, List<Object> graphicalPath, Object[] graphicalRootObjects) {
+ // if(semanticPath.isEmpty()) {
+ // return true;
+ // }
//
- // if(graphicalRootObjects == null) {
- // return false;
- // }
+ // if(graphicalRootObjects == null) {
+ // return false;
+ // }
//
- // Object currentElement = semanticPath.get(0);
- // for(Object graphicalElement : graphicalRootObjects) {
- // Object semanticValue = adaptableProvider.getAdaptedValue(graphicalElement);
+ // 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);
+ // //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;
- // }
+ // 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);
- // }
- // }
+ // //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;
- // }
- // }
- // }
+ // if(semanticValue == currentElement) {
+ // semanticPath.remove(0);
+ // graphicalPath.add(graphicalElement);
+ // if(searchPath(semanticPath, graphicalPath, provider.getChildren(graphicalElement))) {
+ // return true;
+ // }
+ // }
+ // }
//
- // return false;
- // }
+ // return false;
+ // }
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if(viewer instanceof TreeViewer) {
- this.viewer = (TreeViewer)viewer;
+ if (viewer instanceof TreeViewer) {
+ this.viewer = (TreeViewer) viewer;
}
super.inputChanged(viewer, oldInput, newInput);
}
@@ -182,22 +182,22 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
*/
@Override
public void revealSemanticElement(List<?> elementList) {
- //for each element we reveal it
+ // for each element we reveal it
Iterator<?> elementListIterator = elementList.iterator();
ArrayList<Object> treeElementToSelect = new ArrayList<Object>();
- while(elementListIterator.hasNext()) {
+ 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
+ // 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
+ // 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
+ if (path.size() > 0) {
+ // expand in the common viewer the path
expandItems(path, viewer.getTree().getItems());
treeElementToSelect.add(path.get(path.size() - 1));
}
@@ -208,12 +208,12 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
}
public void expandItems(List<Object> treeElementList, TreeItem[] list) {
- //the treeElement has more tan one element
+ // 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
+ 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);
}
@@ -228,14 +228,14 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
}
public void selectReveal(ISelection selection) {
- if(viewer != null) {
+ if (viewer != null) {
viewer.setSelection(selection, true);
}
}
/**
* Simple search, based on containment references
- *
+ *
* @param eobject
* @param objects
* @return
@@ -245,37 +245,37 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
List<EObject> emfPath = EMFHelper.getContainmentPath(eobject);
- for(Object wrappedElement : wrappedElements) {
+ for (Object wrappedElement : wrappedElements) {
EObject element = EMFHelper.getEObject(wrappedElement);
- if(eobject.equals(element)) {
- //We found the leaf element
+ if (eobject.equals(element)) {
+ // We found the leaf element
return Collections.singletonList(wrappedElement);
}
- if(browseElementForDirectContainment(emfPath, element)) {
+ 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
+ if (!childPath.isEmpty()) {
+ // We (indirectly) found the leaf element
path.add(wrappedElement);
path.addAll(childPath);
break;
}
- } //Else: dead end
+ } // Else: dead end
}
return path;
}
protected boolean browseElementForDirectContainment(List<EObject> emfPath, EObject element) {
- if(emfPath.contains(element)) {
+ if (emfPath.contains(element)) {
return true;
}
- if(element instanceof EReference) {
- EReference reference = (EReference)element;
- if(reference.isContainment() && !reference.isDerived()) {
+ if (element instanceof EReference) {
+ EReference reference = (EReference) element;
+ if (reference.isContainment() && !reference.isDerived()) {
return true;
}
}
@@ -285,50 +285,50 @@ public class ContainmentBrowseStrategy extends ProviderBasedBrowseStrategy {
/**
* look for the path the list of element (from the content provider) to go the eObject
- *
+ *
* @param eobject
- * that we look for.
+ * that we look for.
* @param objects
- * a list of elements where eobject can be wrapped.
+ * 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)
+ // Simple/quick search (Based on containment)
List<Object> path = searchDirectContainmentPath(eobject, objects);
- if(!path.isEmpty()) {
+ if (!path.isEmpty()) {
return path;
}
- //Advanced search
+ // Advanced search
path = new ArrayList<Object>();
- for(Object o : objects) {
+ for (Object o : objects) {
// Search matches in this level
- if(!(o instanceof Diagram)) {
- if(eobject.equals(EMFHelper.getEObject(o))) {
+ 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++) {
+ 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)) {
+ 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) {
+ if (tmppath.size() > 0) {
Object last = tmppath.get(tmppath.size() - 1);
EObject lastEObject = EMFHelper.getEObject(last);
- if(eobject.equals(lastEObject)) {
+ if (eobject.equals(lastEObject)) {
path.add(o);
path.addAll(tmppath);
return path;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
index c9e4d63fbfc..ffecbefc9fe 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/providers/strategy/SemanticEMFContentProvider.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2012, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 410346
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.providers.strategy;
@@ -68,7 +68,7 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
}
protected void configureMetaclasses(EStructuralFeature feature) {
- if(feature != null) {
+ if (feature != null) {
setWantedMetaclasses(Collections.singletonList(feature.getEType()));
}
}
@@ -92,13 +92,13 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
public SemanticEMFContentProvider(EObject editedEObject, EStructuralFeature feature, ResourceSet root) {
this(editedEObject, feature, getRoots(root));
}
-
+
@Override
public void dispose() {
try {
// Because we created this adapter factory, we must dispose it
- if(factory instanceof IDisposable) {
- ((IDisposable)factory).dispose();
+ if (factory instanceof IDisposable) {
+ ((IDisposable) factory).dispose();
}
} finally {
super.dispose();
@@ -107,8 +107,8 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
protected static EObject[] getRoots(ResourceSet root) {
List<EObject> roots = new LinkedList<EObject>();
- if(root != null) {
- for(Resource resource : root.getResources()) {
+ if (root != null) {
+ for (Resource resource : root.getResources()) {
roots.addAll(resource.getContents());
}
}
@@ -117,21 +117,21 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
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) {
+ // 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 };
+ return new EObject[] { source };
}
- //The resource is not contained in a resource set : we return the resource's contents
- if(source.eResource().getResourceSet() == null) {
+ // 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
+ // We have a full resourceSet : we return its contents
return getRoots(source.eResource().getResourceSet());
}
@@ -146,7 +146,7 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
@Override
public boolean hasChildren(Object parent) {
- //May be expensive
+ // May be expensive
Object[] children = getChildren(parent);
return children != null && children.length > 0;
}
@@ -155,41 +155,41 @@ public class SemanticEMFContentProvider extends CustomizedTreeContentProvider im
// 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 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()) {
+ // 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)) {
+ for (Object metaclass : metaclasses) {
+ if (isCompatibleMetaclass(containerElement, metaclass)) {
compatible = true;
break;
}
}
- if(!compatible) {
+ 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)) {
+ // 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) {
+ if (metaclass instanceof EClassifier) {
Object semanticElement = getAdaptedValue(containerElement);
- return ((EClassifier)metaclass).isInstance(semanticElement);
+ return ((EClassifier) metaclass).isInstance(semanticElement);
}
return false;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/requests/UnsetRequest.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/requests/UnsetRequest.java
index 0e74f95e99e..a6fab0af303 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/requests/UnsetRequest.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/requests/UnsetRequest.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
*
* Contributors:
* CEA LIST - Initial API and implementation
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.requests;
@@ -48,7 +48,7 @@ public class UnsetRequest extends AbstractEditCommandRequest {
public Object getEditHelperContext() {
IClientContext context = getClientContext();
- if(context == null) {
+ if (context == null) {
return elementToEdit;
} else {
return new EditHelperContext(elementToEdit, context);
@@ -63,8 +63,9 @@ public class UnsetRequest extends AbstractEditCommandRequest {
return elementToEdit;
}
+ @Override
public List<? extends EObject> getElementsToEdit() {
- if(elementToEdit != null) {
+ if (elementToEdit != null) {
return Collections.singletonList(elementToEdit);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManagementHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManagementHelper.java
index 65d9a2fe23f..9804a314025 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManagementHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManagementHelper.java
@@ -51,34 +51,34 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: fromResources.replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
- * Must not be null
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * Must not be null
* @param fromResources
- * The list of resources to edit. Only the objects of these resources will be modified.
- * Must not be empty
+ * The list of resources to edit. Only the objects of these resources will be modified.
+ * Must not be empty
* @param editingDomain
- * The editing domain. May be null.
+ * The editing domain. May be null.
*
* @return
* The collection of replacements
*/
public static Collection<Replacement> updateDependencies(URI uriToReplace, URI targetURI, Collection<Resource> fromResources, EditingDomain editingDomain) {
- if(fromResources == null || fromResources.isEmpty()) {
+ if (fromResources == null || fromResources.isEmpty()) {
throw new IllegalArgumentException("There is no resource to modify"); //$NON-NLS-1$
}
Collection<Replacement> replacements = new LinkedList<Replacement>();
- for(Resource currentResource : fromResources) {
- if(currentResource == null) {
+ for (Resource currentResource : fromResources) {
+ if (currentResource == null) {
continue;
}
- if(EMFHelper.isReadOnly(currentResource, editingDomain)) {
+ if (EMFHelper.isReadOnly(currentResource, editingDomain)) {
continue;
}
@@ -94,34 +94,34 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: fromResources.replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
- * Must not be null
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * Must not be null
* @param fromResource
- * The resource to edit. Only the objects of this resource will be modified.
- * Must not be null
+ * The resource to edit. Only the objects of this resource will be modified.
+ * Must not be null
* @param editingDomain
- * The editing domain. May be null.
+ * The editing domain. May be null.
* @return
* The collection of replacements
*/
public static Collection<Replacement> updateDependencies(URI uriToReplace, URI targetURI, Resource fromResource, EditingDomain editingDomain) {
- if(uriToReplace == null) {
+ if (uriToReplace == null) {
throw new IllegalArgumentException("There is no URI to replace"); //$NON-NLS-1$
}
- if(targetURI == null) {
+ if (targetURI == null) {
throw new IllegalArgumentException("There is no target URI"); //$NON-NLS-1$
}
- if(uriToReplace.equals(targetURI)) {
+ if (uriToReplace.equals(targetURI)) {
throw new IllegalArgumentException("The source and target URIs are identical"); //$NON-NLS-1$
}
- if(fromResource == null) {
+ if (fromResource == null) {
throw new IllegalArgumentException("The edited resource must not be null"); //$NON-NLS-1$
}
@@ -129,60 +129,60 @@ public class DependencyManagementHelper {
Collection<Replacement> replacements = new LinkedList<Replacement>();
- while(allContentsIterator.hasNext()) {
+ while (allContentsIterator.hasNext()) {
EObject eObject = allContentsIterator.next();
- for(EReference reference : eObject.eClass().getEAllReferences()) {
- if(reference.isContainment()) {
+ for (EReference reference : eObject.eClass().getEAllReferences()) {
+ if (reference.isContainment()) {
continue;
}
- if(!reference.isChangeable()) {
+ if (!reference.isChangeable()) {
continue;
}
Object value = eObject.eGet(reference);
- if(value instanceof EObject) {
- EObject eObjectToReplace = (EObject)value;
+ if (value instanceof EObject) {
+ EObject eObjectToReplace = (EObject) value;
EObject newEObject = checkAndReplace(eObjectToReplace, uriToReplace, targetURI);
- if(newEObject == null) {
+ if (newEObject == null) {
continue;
}
try {
- //System.out.println("Replace " + EcoreUtil.getURI(eObjectToReplace) + " with " + EcoreUtil.getURI(newEObject));
+ // System.out.println("Replace " + EcoreUtil.getURI(eObjectToReplace) + " with " + EcoreUtil.getURI(newEObject));
eObject.eSet(reference, newEObject);
replacements.add(new ReplacementImpl(eObject, reference, eObjectToReplace, newEObject));
} catch (Exception ex) {
Activator.log.error(ex);
}
- } else if(value instanceof Collection<?>) {
+ } else if (value instanceof Collection<?>) {
Map<EObject, EObject> previousToNewValue = new HashMap<EObject, EObject>();
- Collection<?> collection = (Collection<?>)value;
+ Collection<?> collection = (Collection<?>) value;
- for(Object collectionElement : (Collection<?>)value) {
- if(collectionElement instanceof EObject) {
- EObject eObjectToReplace = (EObject)collectionElement;
+ for (Object collectionElement : (Collection<?>) value) {
+ if (collectionElement instanceof EObject) {
+ EObject eObjectToReplace = (EObject) collectionElement;
EObject newEObject = checkAndReplace(eObjectToReplace, uriToReplace, targetURI);
- if(newEObject == null) {
+ if (newEObject == null) {
continue;
}
- //System.out.println("Replace " + EcoreUtil.getURI(eObjectToReplace) + " with " + EcoreUtil.getURI(newEObject));
+ // System.out.println("Replace " + EcoreUtil.getURI(eObjectToReplace) + " with " + EcoreUtil.getURI(newEObject));
previousToNewValue.put(eObjectToReplace, newEObject);
}
}
- if(previousToNewValue.isEmpty()) {
+ if (previousToNewValue.isEmpty()) {
continue;
}
- if(collection instanceof EStructuralFeature.Setting) {
- EStructuralFeature.Setting setting = (EStructuralFeature.Setting)collection;
- for(Map.Entry<EObject, EObject> entry : previousToNewValue.entrySet()) {
+ if (collection instanceof EStructuralFeature.Setting) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) collection;
+ for (Map.Entry<EObject, EObject> entry : previousToNewValue.entrySet()) {
EcoreUtil.replace(setting, entry.getKey(), entry.getValue());
replacements.add(new ReplacementImpl(eObject, reference, entry.getKey(), entry.getValue()));
}
@@ -199,12 +199,12 @@ public class DependencyManagementHelper {
* Returns null if the "currentValueToReplace" doesn't belong to the resource represented by "uriToReplace".
*
* @param currentValueToReplace
- * The current value, to be replaced. May be a proxy
+ * The current value, to be replaced. May be a proxy
* @param uriToReplace
- * The URI of the resource to be replaced.
+ * The URI of the resource to be replaced.
* @param targetURI
- * The URI of the target resource (Which will contain the resulting EObject).
- * The resource doesn't need to exist (and won't be created). If it doesn't exist, this method will return a Proxy
+ * The URI of the target resource (Which will contain the resulting EObject).
+ * The resource doesn't need to exist (and won't be created). If it doesn't exist, this method will return a Proxy
* @return
* The EObject equivalent to the replaced EObject, in the target resource.
*/
@@ -212,7 +212,7 @@ public class DependencyManagementHelper {
URI eObjectURIToReplace = EcoreUtil.getURI(currentValueToReplace);
URI resourceURI = eObjectURIToReplace.trimFragment();
- if(!uriToReplace.equals(resourceURI)) {
+ if (!uriToReplace.equals(resourceURI)) {
return null;
}
@@ -223,10 +223,10 @@ public class DependencyManagementHelper {
* Replaces the EObject (Which may be a proxy) by its equivalent in the given Resource's URI.
*
* @param currentValueToReplace
- * The current value, to be replaced. May be a proxy
+ * The current value, to be replaced. May be a proxy
* @param targetURI
- * The URI of the target resource (Which will contain the resulting EObject).
- * The resource doesn't need to exist (and won't be created). If it doesn't exist, this method will return a Proxy
+ * The URI of the target resource (Which will contain the resulting EObject).
+ * The resource doesn't need to exist (and won't be created). If it doesn't exist, this method will return a Proxy
* @return
* The EObject equivalent to the replaced EObject, in the target resource.
*/
@@ -237,12 +237,12 @@ public class DependencyManagementHelper {
InternalEObject proxyEObject;
- //Try to instantiate the Proxy from the same EClass.
+ // Try to instantiate the Proxy from the same EClass.
EObject newEObject = targetEClass.getEPackage().getEFactoryInstance().create(targetEClass);
- if(newEObject instanceof InternalEObject) {
- proxyEObject = (InternalEObject)newEObject;
+ if (newEObject instanceof InternalEObject) {
+ proxyEObject = (InternalEObject) newEObject;
} else {
- //If the result is not an InternalEObject, create a basic EObject instead
+ // If the result is not an InternalEObject, create a basic EObject instead
proxyEObject = new DynamicEObjectImpl(targetEClass);
}
@@ -259,23 +259,23 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: resourceSet.getResources().replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
- * Must not be null
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * Must not be null
* @param resourceSet
- * The resourceSet to edit. Its resources will be modified.
+ * The resourceSet to edit. Its resources will be modified.
* @param editingDomain
- * The editing domain. May be null.
+ * The editing domain. May be null.
* @return
* The collection of replacements
*/
public static Collection<Replacement> updateDependencies(URI uriToReplace, URI targetURI, ResourceSet resourceSet, EditingDomain editingDomain) {
Set<Resource> resourcesToEdit = new HashSet<Resource>(resourceSet.getResources());
Resource resourceToReplace = resourceSet.getResource(uriToReplace, false);
- if(resourceToReplace != null) {
+ if (resourceToReplace != null) {
resourcesToEdit.remove(resourceToReplace);
}
return updateDependencies(uriToReplace, targetURI, resourcesToEdit, editingDomain);
@@ -287,15 +287,15 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: fromResources.replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
- * Must not be null
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * Must not be null
* @param fromResource
- * The resource to edit. Only the objects of this resource will be modified.
- * Must not be null
+ * The resource to edit. Only the objects of this resource will be modified.
+ * Must not be null
* @return
* The collection of replacements
*/
@@ -309,15 +309,15 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: fromResource.replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
- * Must not be null
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * Must not be null
* @param fromResource
- * The resource to edit. Only the objects of this resource will be modified.
- * Must not be null
+ * The resource to edit. Only the objects of this resource will be modified.
+ * Must not be null
* @return
* The collection of replacements
*/
@@ -331,13 +331,13 @@ public class DependencyManagementHelper {
* Simplified pseudo code algorithm: resourceSet.getResources().replaceAll(uriToReplace, targetURI)
*
* @param uriToReplace
- * The URI of the resource which initially contains the referenced elements. May or may not exist.
- * Must not be null
+ * The URI of the resource which initially contains the referenced elements. May or may not exist.
+ * Must not be null
* @param targetURI
- * The URI of the resource which contains the newly referenced elements.
- * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
+ * The URI of the resource which contains the newly referenced elements.
+ * May or may not exist. In the later case, the values will be proxies to the un-existing target URI
* @param resourceSet
- * The resourceSet to edit. Its resources will be modified.
+ * The resourceSet to edit. Its resources will be modified.
* @return
* The collection of replacements
*/
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManager.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManager.java
index 1579191bb7e..27c864d8d48 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManager.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/DependencyManager.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -71,7 +71,7 @@ public class DependencyManager {
public Collection<Replacement> updateDependencies(final URI oldURI, URI newURI, DiagnosticChain diagnostics, IProgressMonitor monitor) {
final List<? extends IDependencyReplacementParticipant> participants = loadParticipants(oldURI, newURI);
final SubMonitor subMonitor = SubMonitor.convert(monitor, (participants.size() * 2) + 1);
-
+
// Don't attempt to update references within the resource whose URI we are replacing!
Collection<Resource> resourcesToUpdate = ImmutableList.copyOf(Iterables.filter(resources, new Predicate<Resource>() {
@@ -84,10 +84,10 @@ public class DependencyManager {
child.beginTask("Updating references ...", IProgressMonitor.UNKNOWN);
Collection<Replacement> result = DependencyManagementHelper.updateDependencies(oldURI, newURI, resourcesToUpdate, editingDomain);
child.done();
-
+
// Don't need participants if no replacements were made
- if(!result.isEmpty()) {
- for(IDependencyReplacementParticipant participant : participants) {
+ if (!result.isEmpty()) {
+ for (IDependencyReplacementParticipant participant : participants) {
try {
participant.postProcessReplacements(result, resourcesToUpdate, subMonitor.newChild(1), diagnostics);
} catch (Exception e) {
@@ -95,7 +95,7 @@ public class DependencyManager {
}
}
}
-
+
subMonitor.done();
return result;
@@ -108,12 +108,12 @@ public class DependencyManager {
context.addVariable("oldURI", oldURI); //$NON-NLS-1$
context.addVariable("newURI", newURI);//$NON-NLS-1$
- for(IConfigurationElement next : Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, "dependencyUpdateParticipant")) { //$NON-NLS-1$
- if("replaceParticipant".equals(next.getName())) { //$NON-NLS-1$
+ for (IConfigurationElement next : Platform.getExtensionRegistry().getConfigurationElementsFor(Activator.PLUGIN_ID, "dependencyUpdateParticipant")) { //$NON-NLS-1$
+ if ("replaceParticipant".equals(next.getName())) { //$NON-NLS-1$
IConfigurationElement[] enablement = next.getChildren("enablement"); //$NON-NLS-1$
- if((enablement == null) || (enablement.length == 0) || matches(enablement[0], context)) {
+ if ((enablement == null) || (enablement.length == 0) || matches(enablement[0], context)) {
try {
- result.add((IDependencyReplacementParticipant)next.createExecutableExtension("class")); //$NON-NLS-1$
+ result.add((IDependencyReplacementParticipant) next.createExecutableExtension("class")); //$NON-NLS-1$
} catch (Exception e) {
Activator.log.error("Invalid replaceParticipant extension in " + next.getContributor().getName(), e); //$NON-NLS-1$
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IDependencyReplacementParticipant.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IDependencyReplacementParticipant.java
index 7df5186bc78..9c9cddb7738 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IDependencyReplacementParticipant.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IDependencyReplacementParticipant.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2014 CEA and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,24 +20,22 @@ import org.eclipse.emf.ecore.resource.Resource;
/**
- * A participant in the
- * {@link DependencyManager#updateDependencies(org.eclipse.emf.common.util.URI, org.eclipse.emf.common.util.URI, org.eclipse.emf.common.util.DiagnosticChain)}
- * operation.
+ * A participant in the {@link DependencyManager#updateDependencies(org.eclipse.emf.common.util.URI, org.eclipse.emf.common.util.URI, org.eclipse.emf.common.util.DiagnosticChain)} operation.
*/
public interface IDependencyReplacementParticipant {
/**
* Post-processes a set of replacements that resulted from a dependency update on the specified {@code resources}.
- *
+ *
* @param replacements
- * the replacements resulting from the dependency update operation
+ * the replacements resulting from the dependency update operation
* @param resources
- * the resources on which the replacements were computed
+ * the resources on which the replacements were computed
* @param monitor
- * an optional progress monitor. If {@code null}, then the client does not want progress reporting
+ * an optional progress monitor. If {@code null}, then the client does not want progress reporting
* @param diagnostics
- * an optional diagnostic chain to collect problems. If {@code null}, then the client does not want problem reporting
- *
+ * an optional diagnostic chain to collect problems. If {@code null}, then the client does not want problem reporting
+ *
* @return a diagnostic indicating any problems in post-processing, or {@code null} if no problems
*/
void postProcessReplacements(Collection<? extends Replacement> replacements, Collection<? extends Resource> resources, IProgressMonitor monitor, DiagnosticChain diagnostics);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IURIReplacementStrategy.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IURIReplacementStrategy.java
index 65e3d46d423..b5ca2ddab48 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IURIReplacementStrategy.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/IURIReplacementStrategy.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2014 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
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/MoveFileURIReplacementStrategy.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/MoveFileURIReplacementStrategy.java
index 81f59eb4a81..a9f9b5fcf9f 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/MoveFileURIReplacementStrategy.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/MoveFileURIReplacementStrategy.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2014 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
@@ -48,11 +48,11 @@ public class MoveFileURIReplacementStrategy implements IURIReplacementStrategy {
* Instantiates a new move file uri replacement strategy.
*
* @param replacementURIMapping
- * the replacement uri mapping
+ * the replacement uri mapping
* @param sourcePath
- * the source path
+ * the source path
* @param targetPath
- * the target path
+ * the target path
*/
public MoveFileURIReplacementStrategy(Map<URI, URI> replacementURIMapping, IPath sourcePath, IPath targetPath) {
this.replacementURIMapping = replacementURIMapping;
@@ -64,9 +64,9 @@ public class MoveFileURIReplacementStrategy implements IURIReplacementStrategy {
* Instantiates a new move file uri replacement strategy.
*
* @param sourcePath
- * the source path
+ * the source path
* @param targetPath
- * the target path
+ * the target path
*/
public MoveFileURIReplacementStrategy(IPath sourcePath, IPath targetPath) {
this(new HashMap<URI, URI>(), sourcePath, targetPath);
@@ -80,7 +80,7 @@ public class MoveFileURIReplacementStrategy implements IURIReplacementStrategy {
* @see org.eclipse.papyrus.infra.emf.resource.IURIReplacementStrategy#getReplacementCandidate(org.eclipse.emf.common.util.URI)
*/
public URI getReplacementCandidate(URI resourceURI) {
- if(replacementURIMapping.containsKey(resourceURI)) {
+ if (replacementURIMapping.containsKey(resourceURI)) {
return replacementURIMapping.get(resourceURI);
}
URI calculateUri = calculateNewUri(resourceURI);
@@ -93,16 +93,16 @@ public class MoveFileURIReplacementStrategy implements IURIReplacementStrategy {
* Calculate uri.
*
* @param resourceURI
- * the resource uri
+ * the resource uri
* @return the uri
*/
protected URI calculateNewUri(URI resourceURI) {
ModelSet modelSet = new ModelSet();
URIConverter uriConverter = modelSet.getURIConverter();
boolean exists = uriConverter.exists(resourceURI, Collections.EMPTY_MAP);
- if(!exists) {
+ if (!exists) {
URI choseCorrectPath = trySourcePath(sourcePath, targetPath, resourceURI);
- if(choseCorrectPath != null) {
+ if (choseCorrectPath != null) {
return choseCorrectPath;
}
}
@@ -116,29 +116,29 @@ public class MoveFileURIReplacementStrategy implements IURIReplacementStrategy {
* If the resource is not found in the target location then look in the source location
*
* @param sourcePath
- * the source path
+ * the source path
* @param targetPath
- * the target path
+ * the target path
* @param resourceURI
- * the resource uri
+ * the resource uri
* @return the uri
*/
protected URI trySourcePath(IPath sourcePath, IPath targetPath, URI resourceURI) {
String uriPlatformString = resourceURI.toPlatformString(true);
- if(uriPlatformString != null) {
+ if (uriPlatformString != null) {
Path path = new Path(uriPlatformString);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = root.getFile(path);
- if(!file.exists()) {// test file non existence from the target
+ if (!file.exists()) {// test file non existence from the target
// calculate a new path from source path
- URI sourceURI = URI.createPlatformResourceURI(sourcePath.toString()+Path.SEPARATOR, true);
- URI targetURI = URI.createPlatformResourceURI(targetPath.toString()+Path.SEPARATOR, true);
- URI resourceDeresolved = resourceURI.deresolve(targetURI);
+ URI sourceURI = URI.createPlatformResourceURI(sourcePath.toString() + IPath.SEPARATOR, true);
+ URI targetURI = URI.createPlatformResourceURI(targetPath.toString() + IPath.SEPARATOR, true);
+ URI resourceDeresolved = resourceURI.deresolve(targetURI);
URI resourceResolved = resourceDeresolved.resolve(sourceURI);
return resourceResolved;
}
}
return null;
}
-
+
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
index 855068a4d62..daa0dbe8cf3 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/Replacement.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -16,15 +16,15 @@ import org.eclipse.emf.ecore.EStructuralFeature;
/**
* Represents a value replacement.
- *
+ *
* @author Camille Letavernier
- *
+ *
*/
public interface Replacement extends EStructuralFeature.Setting {
/**
* Returns the old value
- *
+ *
* @return
* The value which has been replaced
*/
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/ReplacementImpl.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/ReplacementImpl.java
index 6eafbfba7cc..51eaed2f6c9 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/ReplacementImpl.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/ReplacementImpl.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -42,7 +42,7 @@ public class ReplacementImpl implements Replacement {
}
public EObject get(boolean resolve) {
- if(resolve && newValue != null && newValue.eIsProxy()) {
+ if (resolve && newValue != null && newValue.eIsProxy()) {
newValue = EcoreUtil.resolve(newValue, parent);
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/RestoreDependencyHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/RestoreDependencyHelper.java
index f018ddb9c5e..a5704b0eb2d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/RestoreDependencyHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/resource/RestoreDependencyHelper.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2014 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
@@ -34,13 +34,14 @@ import org.eclipse.papyrus.infra.emf.Activator;
public class RestoreDependencyHelper {
- /** The uri replacement strategy. */
+ /** The uri replacement strategy. */
protected IURIReplacementStrategy iURIReplacementStrategy;
/**
* Instantiates a new restore dependency helper.
*
- * @param iURIReplacementStrategy the chosen uriReplacementStrategy
+ * @param iURIReplacementStrategy
+ * the chosen uriReplacementStrategy
*/
public RestoreDependencyHelper(IURIReplacementStrategy iURIReplacementStrategy) {
this.iURIReplacementStrategy = iURIReplacementStrategy;
@@ -49,29 +50,30 @@ public class RestoreDependencyHelper {
/**
* Restore dependencies, iterate on all contents to check and replace URIs.
*
- * @param resource the resource
+ * @param resource
+ * the resource
* @return the collection
*/
public Collection<Replacement> restoreDependencies(Resource resource) {
Iterator<EObject> allContentsIterator = resource.getAllContents();
Collection<Replacement> replacements = new LinkedList<Replacement>();
- while(allContentsIterator.hasNext()) {
+ while (allContentsIterator.hasNext()) {
EObject eObject = allContentsIterator.next();
- for(EReference reference : eObject.eClass().getEAllReferences()) {
- if(reference.isContainment()) {
+ for (EReference reference : eObject.eClass().getEAllReferences()) {
+ if (reference.isContainment()) {
continue;
}
- if(!reference.isChangeable()) {
+ if (!reference.isChangeable()) {
continue;
}
Object value = eObject.eGet(reference);
- if(value instanceof EObject) {
- EObject eObjectToReplace = (EObject)value;
+ if (value instanceof EObject) {
+ EObject eObjectToReplace = (EObject) value;
EObject newEObject = checkAndReplace(eObjectToReplace);
- if(newEObject == null) {
+ if (newEObject == null) {
continue;
}
@@ -82,25 +84,25 @@ public class RestoreDependencyHelper {
Activator.log.error(ex);
}
- } else if(value instanceof Collection<?>) {
+ } else if (value instanceof Collection<?>) {
Map<EObject, EObject> previousToNewValue = new HashMap<EObject, EObject>();
- Collection<?> collection = (Collection<?>)value;
- for(Object collectionElement : (Collection<?>)value) {
- if(collectionElement instanceof EObject) {
- EObject eObjectToReplace = (EObject)collectionElement;
+ Collection<?> collection = (Collection<?>) value;
+ for (Object collectionElement : (Collection<?>) value) {
+ if (collectionElement instanceof EObject) {
+ EObject eObjectToReplace = (EObject) collectionElement;
EObject newEObject = checkAndReplace(eObjectToReplace);
- if(newEObject == null) {
+ if (newEObject == null) {
continue;
}
previousToNewValue.put(eObjectToReplace, newEObject);
}
}
- if(previousToNewValue.isEmpty()) {
+ if (previousToNewValue.isEmpty()) {
continue;
}
- if(collection instanceof EStructuralFeature.Setting) {
- EStructuralFeature.Setting setting = (EStructuralFeature.Setting)collection;
- for(Map.Entry<EObject, EObject> entry : previousToNewValue.entrySet()) {
+ if (collection instanceof EStructuralFeature.Setting) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) collection;
+ for (Map.Entry<EObject, EObject> entry : previousToNewValue.entrySet()) {
EcoreUtil.replace(setting, entry.getKey(), entry.getValue());
replacements.add(new ReplacementImpl(eObject, reference, entry.getKey(), entry.getValue()));
}
@@ -114,15 +116,16 @@ public class RestoreDependencyHelper {
/**
* Check and replace.
*
- * @param eObject the e object to replace
+ * @param eObject
+ * the e object to replace
* @return the e object
*/
protected EObject checkAndReplace(EObject eObject) {
URI eObjectURIToReplace = EcoreUtil.getURI(eObject);
URI resourceURI = eObjectURIToReplace.trimFragment();
- if(!resourceURI.isEmpty()) {
+ if (!resourceURI.isEmpty()) {
URI targetURI = iURIReplacementStrategy.getReplacementCandidate(resourceURI);
- if(targetURI != null && !targetURI.equals(resourceURI)) {
+ if (targetURI != null && !targetURI.equals(resourceURI)) {
return DependencyManagementHelper.replace(eObject, targetURI);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
index eb840db7f3b..1aa4fce087c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/BusinessModelResolver.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -22,8 +22,8 @@ package org.eclipse.papyrus.infra.emf.utils;
* 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.
+// 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 {
/**
@@ -39,7 +39,7 @@ public class 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
*/
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
index 0d559144ede..d8d4217066d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EClassNameComparator.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -18,14 +18,14 @@ 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) {
+ if (class1 == null) {
return class2 == null ? 0 : -1;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
index 68545151410..18c0a6310d7 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFContants.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -15,15 +15,15 @@ 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
+ // to prevent instanciation
}
public static final String ESTRING = "EString";
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
index b66b1cadeb2..cc95ad412b7 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFFileUtil.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2014 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
@@ -15,7 +15,6 @@ package org.eclipse.papyrus.infra.emf.utils;
import java.io.File;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
@@ -30,12 +29,13 @@ public class EMFFileUtil {
* Returns the path to the IFile (Encoded)
*
* @param file
+ *
* @return
*/
- public static String getPath(IFile file) {
+ public static String getPath(IFile file) {
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
-
- //ToString, toPlatformString
+
+ // ToString, toPlatformString
return uri.toString();
}
@@ -45,17 +45,18 @@ public class EMFFileUtil {
* relative to the workspace root.
*
* @param location
+ *
* @return
*/
public static IFile getIFile(String location) {
URI uri = URI.createURI(location);
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
-
- //Search the file in the workspace
- if (uri.isPlatform()){
+
+ // Search the file in the workspace
+ if (uri.isPlatform()) {
Path workspacePath = new Path(uri.toPlatformString(true));
return workspace.getFile(workspacePath);
- } else { //Then search it on the disk
+ } else { // Then search it on the disk
Path absolutePath = new Path(URI.decode(location));
return workspace.getFileForLocation(absolutePath);
}
@@ -67,11 +68,12 @@ public class EMFFileUtil {
* relative to the workspace root.
*
* @param location
+ *
* @return
*/
public static File getFile(String location) {
IFile iFile = getIFile(location);
- if(iFile == null || !iFile.exists()) {
+ if (iFile == null || !iFile.exists()) {
return new File(location);
}
@@ -83,6 +85,7 @@ public class EMFFileUtil {
* The location is relative to the workspace root.
*
* @param location
+ *
* @return
*/
public static File getWorkspaceFile(String location) {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
index 4e579760b83..214bda7c03b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2010, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@
* Christian W. Damus (CEA) - bug 408491
* Christian W. Damus (CEA) - bug 432813
* Christian W. Damus (CEA) - bug 422257
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -65,25 +65,25 @@ import com.google.common.collect.Iterables;
/**
* 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
+// 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
+ * The NSURI of the EClass' EPackage
* @param className
- * The EClass' name
+ * 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) {
+ if (ePackage == null) {
Activator.log.warn("Cannot find an EPackage matching the nsURI " + nsUri); //$NON-NLS-1$
return null;
}
@@ -92,21 +92,21 @@ public class EMFHelper {
/**
* Return the EClass corresponding to the given EPackage and className
- *
+ *
* @param metamodel
- * The EClass' EPackage
+ * The EClass' EPackage
* @param className
- * The EClass' name
+ * 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) {
+ 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;
+ 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$
}
@@ -116,13 +116,13 @@ public class EMFHelper {
/**
* Tests if an Object is an instance of the given EClass
- *
+ *
* @param element
- * The EObject to test
+ * The EObject to test
* @param className
- * The name of the EClass
+ * The name of the EClass
* @param metamodel
- * The EPackage owning the EClass
+ * The EPackage owning the EClass
* @return
* True if the EObject is an instance of the EClass, or of one of the EClass' subtypes
*/
@@ -130,7 +130,7 @@ public class EMFHelper {
EClassifier theClass = metamodel.getEClassifier(className);
- if(theClass == null) {
+ if (theClass == null) {
String message = String.format("Class %s not found in metamodel: %s (%s)", className, metamodel.getName(), metamodel.getNsURI());//$NON-NLS-1$
Activator.log.warn(message);
return false;
@@ -144,25 +144,25 @@ public class EMFHelper {
* Tests if an Object is an instance of the given EClass
*
* @param element
- * The EObject to test
+ * The EObject to test
* @param className
- * The name of the EClass
+ * The name of the EClass
* @param metamodel
- * The URI of the EPackage owning the EClass
+ * The URI of 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(EObject selectedItem, String className, String nsUri) {
EClass actualEClass = selectedItem.eClass();
- //Exact match
- if(isExactMatch(actualEClass, className, nsUri)) {
+ // Exact match
+ if (isExactMatch(actualEClass, className, nsUri)) {
return true;
}
List<EClass> allSuperTypes = actualEClass.getEAllSuperTypes();
- for(EClass eClass : allSuperTypes) {
- if(isExactMatch(eClass, className, nsUri)) {
+ for (EClass eClass : allSuperTypes) {
+ if (isExactMatch(eClass, className, nsUri)) {
return true;
}
}
@@ -174,7 +174,7 @@ public class EMFHelper {
* Tests whether the given EClass has the given className and belongs to the EPackage represented by nsUri
*
* @param eClass
- * The EClass to test
+ * The EClass to test
* @param className
*
* @param nsUri
@@ -188,24 +188,24 @@ public class EMFHelper {
/**
* 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()) {
+ // Everything is an EObject
+ if (eClass != null && fromClass == EcorePackage.eINSTANCE.getEObject()) {
return true;
}
- if(eClass == fromClass) {
+ if (eClass == fromClass) {
return true;
}
List<EClass> superTypes = eClass.getEAllSuperTypes();
- if(superTypes.contains(fromClass)) {
+ if (superTypes.contains(fromClass)) {
return true;
}
@@ -216,27 +216,27 @@ public class EMFHelper {
* 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
+ // 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;
+ 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);
+ // 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
}
@@ -251,11 +251,11 @@ public class EMFHelper {
* 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
+ * an object
* @return whether it is "model content"
- *
+ *
* @see EMFHelper#asEMFModelElement(Object)
*/
public static boolean isEMFModelElement(Object object) {
@@ -264,22 +264,22 @@ public class EMFHelper {
/**
* Casts an {@code object} as an EMF model element, if appropriate.
- *
+ *
* @param object
- * an 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;
+ 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
@@ -290,18 +290,18 @@ public class EMFHelper {
/**
* 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) {
+ if (domain == null) {
try {
domain = ServiceUtilsForActionHandlers.getInstance().getTransactionalEditingDomain();
} catch (ServiceException e) {
- //Ignore: We cannot find the domain
+ // Ignore: We cannot find the domain
}
}
return domain;
@@ -310,10 +310,10 @@ public class EMFHelper {
/**
* 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
+ * The separator used between each package name
* @return
* The EClassifier' qualified name
*/
@@ -324,15 +324,15 @@ public class EMFHelper {
/**
* 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
+ * 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) {
+ if (ePackage.getESuperPackage() == null) {
return ePackage.getName();
}
return getQualifiedName(ePackage.getESuperPackage(), separator) + separator + ePackage.getName();
@@ -342,27 +342,27 @@ public class EMFHelper {
/**
* 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
+ * The ResourceSet in which the model will be loaded
* @param uri
- * The URI describing the location of the model to load
+ * 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
+ * When the URI cannot be loaded
*/
public static EObject loadEMFModel(ResourceSet resourceSet, final URI uri) throws IOException {
assert resourceSet != null : "null resourceSet"; //$NON-NLS-1$
- if(resourceSet == null) {
+ if (resourceSet == null) {
Activator.log.warn("Created a new resourceSet to load an EMF model in " + Activator.log.getCallerMethod()); //$NON-NLS-1$
resourceSet = new ResourceSetImpl();
}
try {
Resource resource = resourceSet.getResource(uri, true);
- if(resource != null) {
- if(!resource.getContents().isEmpty()) {
+ if (resource != null) {
+ if (!resource.getContents().isEmpty()) {
return resource.getContents().get(0);
}
}
@@ -384,14 +384,14 @@ public class EMFHelper {
* <li>removing all adapters from all resources</li>
* <li>removing all adapters from the resource set</li>
* </ul>
- *
+ *
* @param resourceSet
- * the resource set to purge
+ * the resource set to purge
*/
public static void unload(ResourceSet resourceSet) {
List<Resource> resources = ImmutableList.copyOf(resourceSet.getResources());
resourceSet.getResources().clear();
- for(Resource next : resources) {
+ for (Resource next : resources) {
next.unload();
next.eAdapters().clear();
}
@@ -401,7 +401,7 @@ public class EMFHelper {
// want to leak in BasicExtendedMetaData instances attached to static EPackages)
// Works around EMF bug 433108
EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
- if(packageRegistry != null) {
+ if (packageRegistry != null) {
packageRegistry.clear();
}
}
@@ -409,17 +409,17 @@ public class EMFHelper {
/**
* 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) {
+ if (ePackage == null) {
return null;
}
- if(ePackage.getESuperPackage() == null) {
+ if (ePackage.getESuperPackage() == null) {
return ePackage;
}
return getRootPackage(ePackage.getESuperPackage());
@@ -429,16 +429,16 @@ public class EMFHelper {
/**
* 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
+ * 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())) {
+ if (!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
result.add(type);
}
@@ -450,22 +450,22 @@ public class EMFHelper {
/**
* 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
+ * 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
+ * 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())) {
+ if (!concreteClassesOnly || (!type.isAbstract() && !type.isInterface())) {
result.add(type);
}
- for(EPackage ePackage : packagesToBrowse) {
+ for (EPackage ePackage : packagesToBrowse) {
getSubclassesOf(type, ePackage, result, concreteClassesOnly);
}
@@ -474,28 +474,28 @@ public class EMFHelper {
/**
* 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
+ * 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.
+ * 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
+ // 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.
+ 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) {
+ for (String nsURI : allUris) {
allPackages.add(EPackage.Registry.INSTANCE.getEPackage(nsURI));
}
}
@@ -504,18 +504,18 @@ public class EMFHelper {
}
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())) {
+ 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()) {
+ for (EPackage subPackage : fromPackage.getESubpackages()) {
getSubclassesOf(type, subPackage, result, concreteClassesOnly);
}
}
@@ -523,7 +523,7 @@ public class EMFHelper {
/**
* Tests if an EObject is read only on any {@linkplain ReadOnlyAxis axis}.
* Delegates to the EObject's editing domain if it can be found
- *
+ *
* @param eObject
* @return
* True if the EObject is read only on any axis
@@ -536,9 +536,9 @@ public class EMFHelper {
/**
* Tests if an EObject is read only on any of the specified {@code axes}.
* Delegates to the EObject's editing domain if it can be found
- *
+ *
* @param axes
- * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
+ * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param eObject
* @return
* True if the EObject is read only on any of the given {@code axes}
@@ -551,7 +551,7 @@ public class EMFHelper {
/**
* Tests if an EObject is read only on any {@linkplain ReadOnlyAxis axis}.
* Delegates to the given editing domain if it isn't null
- *
+ *
* @param eObject
* @param domain
* @return
@@ -564,26 +564,26 @@ public class EMFHelper {
/**
* Tests if an EObject is read only on any of the specified {@code axes}.
* Delegates to the given editing domain if it isn't null
- *
+ *
* @param axes
- * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
+ * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param eObject
- *
+ *
* @param domain
* @return
* True if the EObject is read only
*/
public static boolean isReadOnly(Set<ReadOnlyAxis> axes, final EObject eObject, final EditingDomain domain) {
- if(domain != null) {
+ if (domain != null) {
Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler2) {
- return ((IReadOnlyHandler2)handler).isReadOnly(axes, eObject).get();
- } else if(handler instanceof IReadOnlyHandler) {
+ if (handler instanceof IReadOnlyHandler2) {
+ return ((IReadOnlyHandler2) handler).isReadOnly(axes, eObject).get();
+ } else if (handler instanceof IReadOnlyHandler) {
// these handlers only deal with permission-based read-only-ness
- return axes.contains(ReadOnlyAxis.PERMISSION) && ((IReadOnlyHandler)handler).isReadOnly(eObject).get();
+ return axes.contains(ReadOnlyAxis.PERMISSION) && ((IReadOnlyHandler) handler).isReadOnly(eObject).get();
}
- if(eObject.eResource() != null) {
+ if (eObject.eResource() != null) {
return domain.isReadOnly(eObject.eResource());
}
}
@@ -593,7 +593,7 @@ public class EMFHelper {
/**
* Tests if the Resource is read only on any {@linkplain ReadOnlyAxis axis}.
* Delegates to the given editing domain if it isn't null
- *
+ *
* @param resource
* @param domain
* @return
@@ -606,26 +606,26 @@ public class EMFHelper {
/**
* Tests if the Resource is read only on any of the given {@code axes}.
* Delegates to the given editing domain if it isn't null
- *
+ *
* @param axes
- * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
+ * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param resource
* @param domain
* @return
* True if the Resource is read only on any of the given {@code axes}
*/
public static boolean isReadOnly(Set<ReadOnlyAxis> axes, final Resource resource, final EditingDomain domain) {
- if(resource == null) {
+ if (resource == null) {
return false;
}
- if(domain != null && resource.getURI() != null) {
+ if (domain != null && resource.getURI() != null) {
Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler2) {
- return ((IReadOnlyHandler2)handler).anyReadOnly(axes, new URI[]{ resource.getURI() }).get();
- } else if(handler instanceof IReadOnlyHandler) {
+ if (handler instanceof IReadOnlyHandler2) {
+ return ((IReadOnlyHandler2) handler).anyReadOnly(axes, new URI[] { resource.getURI() }).get();
+ } else if (handler instanceof IReadOnlyHandler) {
// these handlers only deal with permission-based read-only-ness
- return axes.contains(ReadOnlyAxis.PERMISSION) && ((IReadOnlyHandler)handler).anyReadOnly(new URI[]{ resource.getURI() }).get();
+ return axes.contains(ReadOnlyAxis.PERMISSION) && ((IReadOnlyHandler) handler).anyReadOnly(new URI[] { resource.getURI() }).get();
}
return domain.isReadOnly(resource);
}
@@ -633,12 +633,12 @@ public class EMFHelper {
// no editing domain : use file system attribute
ResourceSet resourceSet = resource.getResourceSet();
- if(resourceSet == null) {
+ if (resourceSet == null) {
return false;
}
Map<String, ?> attributes = resourceSet.getURIConverter().getAttributes(resource.getURI(), null);
- Boolean readOnly = (Boolean)attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
+ Boolean readOnly = (Boolean) attributes.get(URIConverter.ATTRIBUTE_READ_ONLY);
return readOnly == null ? false : readOnly;
}
@@ -646,11 +646,11 @@ public class EMFHelper {
/**
* Tests if an object that is read only could possibly be made writable by some means (file system attributes, team provider hook, database
* permissions, etc.)
- *
+ *
* @param eObject
- * an object that is assumed to be read-only
+ * an object that is assumed to be read-only
* @param domain
- * the editing domain context of the {@link eObject}
+ * the editing domain context of the {@link eObject}
* @return
* whether the {@code eObject} could be made writable
*/
@@ -661,21 +661,21 @@ public class EMFHelper {
/**
* Tests if an object that is read only could possibly be made writable according to any of
* the specified {@code axes} of read-only-ness.
- *
+ *
* @param axes
- * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
+ * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param eObject
- * an object that is assumed to be read-only
+ * an object that is assumed to be read-only
* @param domain
- * the editing domain context of the {@link eObject}
+ * the editing domain context of the {@link eObject}
* @return
* whether the {@code eObject} could be made writable
*/
public static boolean canMakeWritable(Set<ReadOnlyAxis> axes, final EObject eObject, final EditingDomain domain) {
- if(domain != null) {
+ if (domain != null) {
Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler2) {
- return ((IReadOnlyHandler2)handler).canMakeWritable(axes, eObject).or(false);
+ if (handler instanceof IReadOnlyHandler2) {
+ return ((IReadOnlyHandler2) handler).canMakeWritable(axes, eObject).or(false);
}
}
return false;
@@ -684,11 +684,11 @@ public class EMFHelper {
/**
* Tests if a resource that is read only could possibly be made writable by some means (file system attributes, team provider hook, database
* permissions, etc.)
- *
+ *
* @param resource
- * a resource that is assumed to be read-only
+ * a resource that is assumed to be read-only
* @param domain
- * the editing domain context of the {@link resource}
+ * the editing domain context of the {@link resource}
* @return
* whether the {@code resource} could be made writable
*/
@@ -699,21 +699,21 @@ public class EMFHelper {
/**
* Tests if a resource that is read only could possibly be made writable according to any of
* the specified {@code axes} of read-only-ness.
- *
+ *
* @param axes
- * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
+ * a set if orthogonal axes of read-only-ness to consider. May be empty, but that would not be especially useful
* @param resource
- * a resource that is assumed to be read-only
+ * a resource that is assumed to be read-only
* @param domain
- * the editing domain context of the {@link resource}
+ * the editing domain context of the {@link resource}
* @return
* whether the {@code resource} could be made writable
*/
public static boolean canMakeWritable(Set<ReadOnlyAxis> axes, final Resource resource, final EditingDomain domain) {
- if(domain != null) {
+ if (domain != null) {
Object handler = PlatformHelper.getAdapter(domain, IReadOnlyHandler.class);
- if(handler instanceof IReadOnlyHandler2) {
- return ((IReadOnlyHandler2)handler).canMakeWritable(axes, new URI[]{ resource.getURI() }).or(false);
+ if (handler instanceof IReadOnlyHandler2) {
+ return ((IReadOnlyHandler2) handler).canMakeWritable(axes, new URI[] { resource.getURI() }).or(false);
}
}
return false;
@@ -722,48 +722,48 @@ public class EMFHelper {
/**
* 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
+ * 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) {
+ // 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) {
+ // 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()) {
+ // 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) {
+ // If there is a default value, there is always a value
+ if (feature.getDefaultValueLiteral() != null) {
return true;
}
- return false; //The property if not required
+ return false; // The property if not required
}
/**
* Returns all objects of type T contained in the resource
- *
+ *
* @param resource
* @param type
* @return
@@ -772,9 +772,9 @@ public class EMFHelper {
TreeIterator<EObject> iterator = resource.getAllContents();
Set<T> result = new LinkedHashSet<T>();
- while(iterator.hasNext()) {
+ while (iterator.hasNext()) {
EObject element = iterator.next();
- if(type.isInstance(element)) {
+ if (type.isInstance(element)) {
result.add(type.cast(element));
}
}
@@ -784,17 +784,17 @@ public class EMFHelper {
/**
* 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));
+ for (EObject rootElement : resource.getContents()) {
+ if (rootElement instanceof EPackage) {
+ result.add((EPackage) rootElement);
+ result.addAll(getAllNestedPackages((EPackage) rootElement));
}
}
@@ -804,14 +804,14 @@ public class EMFHelper {
/**
* 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()) {
+ for (EPackage nestedPackage : basePackage.getESubpackages()) {
result.add(nestedPackage);
result.addAll(getAllNestedPackages(nestedPackage));
}
@@ -820,18 +820,18 @@ public class EMFHelper {
}
/**
- *
+ *
* @param resource
- * a 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) {
+ if (resource != null) {
final List<EObject> contents = new ArrayList<EObject>(resource.getContents());
- for(final EObject current : contents) {
+ for (final EObject current : contents) {
metamodels.add(current.eClass().getEPackage());
}
}
@@ -839,17 +839,17 @@ public class EMFHelper {
}
/**
- *
+ *
* 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.
+ * 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);
+ if (object != null && object.eResource() instanceof XMIResource) {
+ objectID = ((XMIResource) object.eResource()).getID(object);
}
return objectID;
}
@@ -858,10 +858,10 @@ public class EMFHelper {
/**
* Gets the usages.
- *
+ *
* @param source
- * the source
- *
+ * the source
+ *
* @return the usages or null if there is no usages
*/
public static Collection<Setting> getUsages(EObject source) {
@@ -876,11 +876,11 @@ public class EMFHelper {
* 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
+ * the used object
* @param knownReferencer
- * the known referencer
+ * the known referencer
* @return true if the known referencer is the only referencer.
*/
public static boolean isOnlyUsage(EObject usedObject, EObject knownReferencer) {
@@ -889,9 +889,9 @@ public class EMFHelper {
// Retrieve the list of elements referencing the usedObject.
Set<EObject> crossReferences = new HashSet<EObject>();
- for(Setting setting : getUsages(usedObject)) {
+ for (Setting setting : getUsages(usedObject)) {
EObject eObj = setting.getEObject();
- if(eObj.eClass().getEPackage().equals(mmPackage)) {
+ if (eObj.eClass().getEPackage().equals(mmPackage)) {
crossReferences.add(eObj);
}
}
@@ -903,7 +903,7 @@ public class EMFHelper {
// If no referencer remains in the list, the known element is the only
// usage.
- if(crossReferences.isEmpty()) {
+ if (crossReferences.isEmpty()) {
isUsed = true;
}
@@ -911,32 +911,32 @@ public class EMFHelper {
}
/**
- *
+ *
* @param superType
- * an eclassifier
+ * an eclassifier
* @param subType
- * another eClassifier
+ * 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) {
+ if (superType == subType) {
return true;
}
- if(superType instanceof EClass && subType instanceof EClass) {
+ if (superType instanceof EClass && subType instanceof EClass) {
// special case because isSuperTypeOf doesn't handle it
- if(superType == EcorePackage.eINSTANCE.getEObject()) {
+ if (superType == EcorePackage.eINSTANCE.getEObject()) {
return true;
}
- EClass superTypeEClass = (EClass)superType;
- EClass subTypeEClass = (EClass)subType;
+ EClass superTypeEClass = (EClass) superType;
+ EClass subTypeEClass = (EClass) subType;
return superTypeEClass.isSuperTypeOf(subTypeEClass);
}
- //manage EDtataType
- if(superType == EcorePackage.eINSTANCE.getEDataType() && subType instanceof EDataType) {
+ // manage EDtataType
+ if (superType == EcorePackage.eINSTANCE.getEDataType() && subType instanceof EDataType) {
return true;
}
@@ -945,13 +945,13 @@ public class EMFHelper {
/**
* 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) {
+ if (element.eContainer() == null) {
result = new LinkedList<EObject>();
result.add(element);
return result;
@@ -977,14 +977,14 @@ public class EMFHelper {
ResourceSet sourceResourceSet = getResourceSet(element);
ResourceSet loadingContext = getResourceSet(contextElement);
- if(sourceResourceSet == loadingContext || loadingContext == null) {
+ if (sourceResourceSet == loadingContext || loadingContext == null) {
return element;
}
URI sourceURI = EcoreUtil.getURI(element);
EObject result = loadingContext.getEObject(sourceURI, true);
- return (T)result;
+ return (T) result;
}
/**
@@ -998,18 +998,17 @@ public class EMFHelper {
}
/**
- * Best-effort loads a resource, returning the first root element of the requested {@code type}. Unlike the
- * {@link #loadChecked(ResourceSet, URI, Class) loadChecked} method, this will never throw an exception.
- *
+ * Best-effort loads a resource, returning the first root element of the requested {@code type}. Unlike the {@link #loadChecked(ResourceSet, URI, Class) loadChecked} method, this will never throw an exception.
+ *
* @param rset
- * a resource set in which to load the resource
+ * a resource set in which to load the resource
* @param uri
- * the URI of the resource to load
+ * the URI of the resource to load
* @param type
- * the type of root element to retrieve
- *
+ * the type of root element to retrieve
+ *
* @return the requested root element, or {@code null} if the resource does not contain such an element or could not be loaded
- *
+ *
* @see #loadChecked(ResourceSet, URI, Class)
*/
public static <T extends EObject> T load(ResourceSet rset, URI uri, Class<T> type) {
@@ -1022,7 +1021,7 @@ public class EMFHelper {
// Maybe it was partially loaded? If so, try again
Resource res = rset.getResource(uri, false);
- if((res != null) && res.isLoaded()) {
+ if ((res != null) && res.isLoaded()) {
result = Iterables.getFirst(Iterables.filter(res.getContents(), type), null);
}
}
@@ -1032,29 +1031,29 @@ public class EMFHelper {
/**
* Best-effort loads a resource, returning the first root element of the requested {@code type}.
- *
+ *
* @param rset
- * a resource set in which to load the resource
+ * a resource set in which to load the resource
* @param uri
- * the URI of the resource to load
+ * the URI of the resource to load
* @param type
- * the type of root element to retrieve
- *
+ * the type of root element to retrieve
+ *
* @return the requested root element, or {@code null} if the resource does not contain such an element or could not be loaded
* @throws IOException
- * on an I/O problem in loading the resource
+ * on an I/O problem in loading the resource
* @throw RuntimeException on any other unforeseen (usually programming error) problem
- *
+ *
* @see #load(ResourceSet, URI, Class)
*/
public static <T extends EObject> T loadChecked(ResourceSet rset, URI uri, Class<T> type) throws IOException {
try {
return Iterables.getFirst(Iterables.filter(rset.getResource(uri, true).getContents(), type), null);
} catch (WrappedException e) {
- if(e.exception() instanceof IOException) {
- throw (IOException)e.exception();
- } else if(e.exception() instanceof RuntimeException) {
- throw (RuntimeException)e.exception();
+ if (e.exception() instanceof IOException) {
+ throw (IOException) e.exception();
+ } else if (e.exception() instanceof RuntimeException) {
+ throw (RuntimeException) e.exception();
} else {
throw e;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
index 5f659d15f18..29e082e9e46 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/EMFStringValueConverter.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -36,11 +36,11 @@ import org.eclipse.papyrus.infra.tools.util.TypesConstants;
/**
* Value solver for EMF
- *
+ *
* WARNING : incomplete implementations
- *
+ *
* @author vl222926
- *
+ *
*/
public class EMFStringValueConverter extends AbstractStringValueConverter {
@@ -58,11 +58,11 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
protected final String multiValueSeparator;
/**
- *
+ *
* Constructor.
- *
+ *
* @param resolutionContext
- * the context used for the resolution of the string
+ * the context used for the resolution of the string
*/
public EMFStringValueConverter(final EObject resolutionContext, final String multiValueSeparator) {
this.resolutionContext = resolutionContext;
@@ -71,7 +71,7 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
/**
- *
+ *
* @return
* the context to use for the resolution
*/
@@ -80,36 +80,36 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @see org.eclipse.ui.services.IDisposable#dispose()
- *
+ *
*/
public void dispose() {
this.resolutionContext = null;
}
/**
- *
+ *
* @param resolutionContext
- * the table context
+ * the table context
* @param feature
- * the feature
+ * the feature
* @param valueAsString
- * the pasted string for this feature
+ * the pasted string for this feature
* @return
* the value for the pasted string or <code>null</code> if not found
*/
@Override
protected ConvertedValueContainer<?> doDeduceValueFromString(final Object feature, final String valueAsString) {
final EClassifier featureType = getFeatureType(feature);
- if(feature instanceof EStructuralFeature) {
+ if (feature instanceof EStructuralFeature) {
return deduceValueFromString(feature, featureType, valueAsString);
}
return null;
}
/**
- *
+ *
* @param feature
* @param featureType
* @param valueAsString
@@ -117,53 +117,53 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
*/
protected ConvertedValueContainer<?> deduceValueFromString(final Object feature, final EClassifier featureType, final String valueAsString) {
ConvertedValueContainer<?> realValue = null;
- // if(feature instanceof EStructuralFeature) {
+ // if(feature instanceof EStructuralFeature) {
final int upperbound = getFeatureUpperBound(feature);
boolean isMany = (upperbound > 1 || upperbound == -1);
- if(featureType instanceof EDataType) {
- if(featureType instanceof EEnum) {
- realValue = deduceEEnumLiteralValue((EEnum)featureType, isMany, valueAsString);
+ if (featureType instanceof EDataType) {
+ if (featureType instanceof EEnum) {
+ realValue = deduceEEnumLiteralValue((EEnum) featureType, isMany, valueAsString);
}
final String typeName = featureType.getName();
- if(TypesConstants.STRING.equals(typeName) || EMFContants.ESTRING.equals(typeName)) {
+ if (TypesConstants.STRING.equals(typeName) || EMFContants.ESTRING.equals(typeName)) {
realValue = deduceStringValue(isMany, valueAsString);
- } else if(EMFContants.EBOOLEAN.equals(typeName) || TypesConstants.BOOLEAN.equals(typeName)) {
+ } else if (EMFContants.EBOOLEAN.equals(typeName) || TypesConstants.BOOLEAN.equals(typeName)) {
realValue = deduceBooleanValue(isMany, valueAsString);
- } else if(EMFContants.EINT.equals(typeName) || TypesConstants.INTEGER.equals(typeName)) {
+ } else if (EMFContants.EINT.equals(typeName) || TypesConstants.INTEGER.equals(typeName)) {
realValue = deduceIntValue(isMany, valueAsString);
- } else if(EMFContants.EDOUBLE.equals(typeName)) {
+ } 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 if (featureType instanceof EClass) {
+ realValue = deduceEObjectValue(getResolutionContext(), feature, (EClass) featureType, isMany, valueAsString);
}
return realValue;
}
protected int getFeatureUpperBound(final Object feature) {
- return ((EStructuralFeature)feature).getUpperBound();
+ return ((EStructuralFeature) feature).getUpperBound();
}
/**
- *
+ *
* @param resolutionContext
- * the context used for the resolution
+ * the context used for the resolution
* @param feature
- * the feature
+ * the feature
* @param featureType
- * the type of the feature
+ * the type of the feature
* @param isMany
- * <code>true</code> if the feature isMany
+ * <code>true</code> if the feature isMany
* @param valueAsString
- * the string value to resolve
+ * 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("")) {
+ 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));
@@ -171,16 +171,16 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @param feature
- * an object representing a 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();
+ if (feature instanceof EStructuralFeature) {
+ return ((EStructuralFeature) feature).getEType();
} else {
featureType = null;
}
@@ -188,13 +188,13 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @param eenum
- * the enumeration
+ * the enumeration
* @param isMany
- * <code>true</code> if the feature is many
+ * <code>true</code> if the feature is many
* @param valueAsString
- * the value to convert
+ * the value to convert
* @return
* the converted value
*/
@@ -202,23 +202,23 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
ConvertedValueContainer<?> returnedValue = null;
IStatus iStatus = Status.OK_STATUS;
final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
+ if (isMany) {
final Collection<EEnumLiteral> values = new ArrayList<EEnumLiteral>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
+ for (final String str : valueAsString.split(this.multiValueSeparator)) {
final EEnumLiteral literal = eenum.getEEnumLiteral(str);
- if(literal != null) {
+ if (literal != null) {
values.add(literal);
} else {
unresolvedValues.add(str);
}
}
- if(!unresolvedValues.isEmpty()) {
+ if (!unresolvedValues.isEmpty()) {
iStatus = new StringValueConverterStatus(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(SOME_STRING_ARE_NOT_VALID_TO_CREATE_X, EMFContants.EENUM_LITERAL), unresolvedValues);
}
returnedValue = new MultiConvertedValueContainer<EEnumLiteral>(values, iStatus);
} else {
final EEnumLiteral literal = eenum.getEEnumLiteral(valueAsString);
- if(literal != null) {
+ if (literal != null) {
returnedValue = new ConvertedValueContainer<EEnumLiteral>(literal, iStatus);
} else {
unresolvedValues.add(valueAsString);
@@ -230,11 +230,11 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @param isMany
- * <code>true</code> if the feature isMany
+ * <code>true</code> if the feature isMany
* @param valueAsString
- * the value to parse
+ * the value to parse
* @return
* the result of the parsing
*/
@@ -242,21 +242,21 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
ConvertedValueContainer<?> returnedValue = null;
IStatus iStatus = Status.OK_STATUS;
final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
+ if (isMany) {
final Collection<Boolean> values = new ArrayList<Boolean>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
- if(BooleanHelper.isBoolean(str)) {
+ for (final String str : valueAsString.split(this.multiValueSeparator)) {
+ if (BooleanHelper.isBoolean(str)) {
values.add(Boolean.valueOf(valueAsString));
} else {
unresolvedValues.add(str);
}
}
- if(!unresolvedValues.isEmpty()) {
+ 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)) {
+ if (BooleanHelper.isBoolean(valueAsString)) {
returnedValue = new ConvertedValueContainer<Boolean>(Boolean.valueOf(valueAsString), iStatus);
} else {
unresolvedValues.add(valueAsString);
@@ -268,11 +268,11 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @param isMany
- * <code>true</code> if the feature isMany
+ * <code>true</code> if the feature isMany
* @param valueAsString
- * the value to parse
+ * the value to parse
* @return
* the result of the parsing
*/
@@ -280,17 +280,17 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
ConvertedValueContainer<?> returnedValue = null;
IStatus iStatus = Status.OK_STATUS;
final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
+ if (isMany) {
final Collection<Double> values = new ArrayList<Double>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
+ for (final String str : valueAsString.split(this.multiValueSeparator)) {
final Double value = Double.valueOf(str);
- if(value != null) {
+ if (value != null) {
values.add(value);
} else {
unresolvedValues.add(str);
}
}
- if(!unresolvedValues.isEmpty()) {
+ 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);
@@ -307,11 +307,11 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
}
/**
- *
+ *
* @param isMany
- * <code>true</code> if the feature isMany
+ * <code>true</code> if the feature isMany
* @param valueAsString
- * the value to parse
+ * the value to parse
* @return
* the result of the parsing
*/
@@ -319,16 +319,16 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
ConvertedValueContainer<?> returnedValue = null;
IStatus iStatus = Status.OK_STATUS;
final Collection<String> unresolvedValues = new ArrayList<String>();
- if(isMany) {
+ if (isMany) {
final Collection<Integer> values = new ArrayList<Integer>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
+ for (final String str : valueAsString.split(this.multiValueSeparator)) {
try {
values.add(Integer.valueOf(str));
} catch (final NumberFormatException e) {
unresolvedValues.add(str);
}
}
- if(!unresolvedValues.isEmpty()) {
+ 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);
@@ -346,20 +346,20 @@ public class EMFStringValueConverter extends AbstractStringValueConverter {
/**
- *
+ *
* @param isMany
- * <code>true</code> if the feature is many
+ * <code>true</code> if the feature is many
* @param valueAsString
- * the value as string
+ * 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) {
+ if (isMany) {
final Collection<String> values = new ArrayList<String>();
- for(final String str : valueAsString.split(this.multiValueSeparator)) {
+ for (final String str : valueAsString.split(this.multiValueSeparator)) {
values.add(str);
}
returnedValue = new MultiConvertedValueContainer<String>(values, iStatus);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
index f2928885c13..36bb8a4ea08 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ENamedElementComparator.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -19,14 +19,14 @@ 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) {
+ if (namedElement1 == null) {
return namedElement2 == null ? 0 : -1;
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
index 50d10a12b9f..eedc0a505b2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/HistoryUtil.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -19,7 +19,7 @@ public class HistoryUtil {
/**
* Returns a String identifying the History of selected values for the given object/feature
- *
+ *
* @param editedObject
* @param feature
* @return
@@ -31,14 +31,14 @@ public class HistoryUtil {
/**
* 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) {
+ if (editedObject.eResource() == null) {
return String.format("history_%s_%s:%s", prefix, EMFHelper.getQualifiedName(feature.getEType(), ":"), feature.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
index d3d919225bd..52df1d82b23 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ProviderHelper.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -29,9 +29,9 @@ 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
+ * The ContentProvider to encapsulate
* @return
*/
public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, ResourceSet resourceSet, String historyId) {
@@ -47,9 +47,9 @@ 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
+ * The ContentProvider to encapsulate
* @return
*/
public static EMFGraphicalContentProvider encapsulateProvider(ITreeContentProvider provider, EObject editedEObject, EStructuralFeature feature) {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java
index 26e1818e66b..94bfe86cc3e 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ResourceUtils.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -28,31 +28,32 @@ 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;
+import org.eclipse.emf.ecore.xmi.XMLResource;
/**
- *
+ *
* This class provides methods for EMF Resource
- *
+ *
*/
public class ResourceUtils {
private ResourceUtils() {
- //to prevent instanciation
+ // to prevent instanciation
}
/**
- *
+ *
* @param resource
- * an EMF 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) {
+ if (resource != null) {
URI uri = resource.getURI();
uri = resource.getResourceSet().getURIConverter().normalize(uri);
- if(uri.isPlatformResource()) {
- String uriPlatformString = uri.toPlatformString(true) ;
+ if (uri.isPlatformResource()) {
+ String uriPlatformString = uri.toPlatformString(true);
return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uriPlatformString));
}
}
@@ -60,18 +61,18 @@ public class ResourceUtils {
}
/**
- *
- *
+ *
+ *
* @param resource
- * a 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()) {
+ while (iterator.hasNext()) {
final EObject current = iterator.next();
final String id = resource.getID(current);
Assert.isNotNull(id);
@@ -80,28 +81,29 @@ public class ResourceUtils {
}
return ids;
}
-
-
+
+
/**
* Default options to save emf files used in Papyrus
+ *
* @return
*/
public static Map<String, Object> getSaveOptions() {
Map<String, Object> saveOptions = new HashMap<String, Object>();
// default save options.
- saveOptions.put(XMIResource.OPTION_DECLARE_XML, Boolean.TRUE);
- saveOptions.put(XMIResource.OPTION_PROCESS_DANGLING_HREF, XMIResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
- saveOptions.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
+ saveOptions.put(XMLResource.OPTION_DECLARE_XML, Boolean.TRUE);
+ saveOptions.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
+ saveOptions.put(XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
saveOptions.put(XMIResource.OPTION_USE_XMI_TYPE, Boolean.TRUE);
- saveOptions.put(XMIResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE);
- saveOptions.put(XMIResource.OPTION_SKIP_ESCAPE_URI, Boolean.FALSE);
- saveOptions.put(XMIResource.OPTION_ENCODING, "UTF-8");
+ saveOptions.put(XMLResource.OPTION_SAVE_TYPE_INFORMATION, Boolean.TRUE);
+ saveOptions.put(XMLResource.OPTION_SKIP_ESCAPE_URI, Boolean.FALSE);
+ saveOptions.put(XMLResource.OPTION_ENCODING, "UTF-8");
- //see bug 397987: [Core][Save] The referenced plugin models are saved using relative path
- saveOptions.put(XMIResource.OPTION_URI_HANDLER, new org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl.PlatformSchemeAware());
+ // see bug 397987: [Core][Save] The referenced plugin models are saved using relative path
+ saveOptions.put(XMLResource.OPTION_URI_HANDLER, new org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl.PlatformSchemeAware());
return saveOptions;
}
-
+
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
index 1f610c57d5a..e9d8e12815d 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceRegistryAdapterFactory.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012, 2014 Cedric Dumoulin, CEA, and others.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,11 +20,11 @@ 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
- *
+ *
* @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry.
*/
@Deprecated
@@ -48,7 +48,7 @@ public class ServiceRegistryAdapterFactory extends AdapterFactoryImpl {
}
/**
- *
+ *
* @return the associated {@link ServicesRegistry}
*/
public ServicesRegistry getServicesRegistry() {
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java
index 3a6dba8b718..385496d15ac 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForEObject.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -18,9 +18,9 @@ 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> {
@@ -31,12 +31,12 @@ public class ServiceUtilsForEObject extends AbstractServiceUtils<EObject> {
}
private ServiceUtilsForEObject() {
- //Singleton
+ // Singleton
}
@Override
public ServicesRegistry getServiceRegistry(EObject from) throws ServiceException {
- if(from == null) {
+ if (from == null) {
throw new ServiceException("The selected EObject must not be null"); //$NON-NLS-1$
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
index 158a3ca08b4..b3068b03106 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForHandlers.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -24,18 +24,18 @@ 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
+ // Singleton
}
@Override
@@ -43,23 +43,23 @@ public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent
Object context = from.getApplicationContext();
- if(context instanceof IEvaluationContext) {
- IEvaluationContext evaluationContext = (IEvaluationContext)context;
+ 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)
+ // 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;
+ if (workbenchPartSite instanceof IWorkbenchPartSite) {
+ IWorkbenchPartSite site = (IWorkbenchPartSite) workbenchPartSite;
Object registry = site.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
+ 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)
+ // 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;
+ if (registry != null && registry instanceof ServicesRegistry) {
+ return (ServicesRegistry) registry;
}
}
@@ -67,24 +67,24 @@ public class ServiceUtilsForHandlers extends AbstractServiceUtils<ExecutionEvent
ServicesRegistry registry;
- //Try to resolve the ServicesRegistry from the current selection
- if(selection instanceof ISelection && !((ISelection)selection).isEmpty()) {
+ // 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) {
+ registry = ServiceUtilsForSelection.getInstance().getServiceRegistry((ISelection) selection);
+ if (registry != null) {
return registry;
}
} catch (ServiceException ex) {
- //Ignore and try another ServiceUtils
+ // Ignore and try another ServiceUtils
}
}
- //We couldn't retrieve the ServiceRegistry from the current selection.
+ // 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) {
+ // 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;
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java
index 769bed77a13..469d835f6fc 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForIEvaluationContext.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -25,19 +25,19 @@ 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
+ // Singleton
}
/**
- *
+ *
* @see org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils#getServiceRegistry(java.lang.Object)
*
* @param from
@@ -49,20 +49,20 @@ public class ServiceUtilsForIEvaluationContext extends AbstractServiceUtils<IEva
IEvaluationContext evaluationContext = from;
- //Search for the IWorkbenchPartSite from which the ExecutionEvent is sent (May be different that the Active one)
+ // 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;
+ if (workbenchPartSite instanceof IWorkbenchPartSite) {
+ IWorkbenchPartSite site = (IWorkbenchPartSite) workbenchPartSite;
Object registry = site.getAdapter(ServicesRegistry.class);
- if(registry != null && registry instanceof ServicesRegistry) {
- return (ServicesRegistry)registry;
+ 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)
+ // 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;
+ if (registry != null && registry instanceof ServicesRegistry) {
+ return (ServicesRegistry) registry;
}
}
@@ -70,26 +70,26 @@ public class ServiceUtilsForIEvaluationContext extends AbstractServiceUtils<IEva
ServicesRegistry registry;
- //Try to resolve the ServicesRegistry from the current selection
- if(selection instanceof ISelection && !((ISelection)selection).isEmpty()) {
+ // 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) {
+ registry = ServiceUtilsForSelection.getInstance().getServiceRegistry((ISelection) selection);
+ if (registry != null) {
return registry;
}
} catch (ServiceException ex) {
- //Ignore and try another ServiceUtils
+ // Ignore and try another ServiceUtils
}
}
- //We couldn't retrieve the ServiceRegistry from the current selection.
+ // We couldn't retrieve the ServiceRegistry from the current selection.
- //Try to adapt the active part to the ServicesRegistry
+ // 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) {
+ IWorkbenchPart part = (IWorkbenchPart) _part;
+ registry = (ServicesRegistry) (part).getAdapter(ServicesRegistry.class);
+ if (registry != null) {
return registry;
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java
index b064299981c..809ca9a0d04 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResource.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012, 2014 Cedric Dumoulin, CEA, and others.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,18 +24,14 @@ 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 {@code ServicesRegistry} associated to the {@link ResourceSet} owning the {@code Resource}
- * containing the {@code EObject}.
+ * This class allow to retrieve the {@code ServicesRegistry} associated to the {@link ResourceSet} owning the {@code Resource} containing the {@code EObject}.
* <p>
- * To work properly, the EObject should be associated to a {@link Resource}, itself registered in a {@link ResourceSet}.
- * Also, the {@code ServicesRegistry} should be associated to the {@code ResourceSet}.
- * Normally, this is automatically done thanks to the {@link ModelSetServiceFactory} service.
- * If you access this class from a service, you can ensure that the latter service is started by letting your service
- * depend on the <tt>org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory</tt>.
+ * To work properly, the EObject should be associated to a {@link Resource}, itself registered in a {@link ResourceSet}. Also, the {@code ServicesRegistry} should be associated to the {@code ResourceSet}. Normally, this is automatically done thanks to the
+ * {@link ModelSetServiceFactory} service. If you access this class from a service, you can ensure that the latter service is started by letting your service depend on the <tt>org.eclipse.papyrus.infra.core.editor.ModelSetServiceFactory</tt>.
* </p>
- *
+ *
* @author cedric dumoulin
- *
+ *
*/
public class ServiceUtilsForResource extends AbstractServiceUtils<Resource> {
@@ -43,7 +39,7 @@ public class ServiceUtilsForResource extends AbstractServiceUtils<Resource> {
/**
* Get the singleton instance of the class.
- *
+ *
* @return
*/
public static final ServiceUtilsForResource getInstance() {
@@ -52,16 +48,16 @@ public class ServiceUtilsForResource extends AbstractServiceUtils<Resource> {
/**
* Get the {@link ServicesRegistry} from a {@link Resource}.
- *
+ *
* @param from
- * The {@link Resource} from which we want the associated {@link ServicesRegistry}.
+ * 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}.
+ * 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) {
+ if (from == null) {
throw new ServiceNotFoundException("Can't find the ResourceSet needed retrieve the ServiceRegistry."); //$NON-NLS-1$
}
return ServiceUtilsForResourceSet.getInstance().getServiceRegistry(from.getResourceSet());
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
index 8ac0f6edafa..a3a98b5a0fe 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceInitializerService.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2012, 2014 Cedric Dumoulin, CEA, and others.
*
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -26,13 +26,13 @@ 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
*
* @deprecated Since 1.0, the {@link ModelSetServiceFactory} class associates the model-set with its service registry
@@ -42,15 +42,15 @@ import org.eclipse.papyrus.infra.core.utils.ServiceUtils;
public class ServiceUtilsForResourceInitializerService implements IService {
ServicesRegistry servicesRegistry;
-
+
/**
* Associate the service registry with the resource set if the resource set wasn't created by the registry.
*/
public void init(ServicesRegistry servicesRegistry) throws ServiceException {
-
+
this.servicesRegistry = servicesRegistry;
ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
-
+
ModelSetServiceFactory.setServiceRegistry(modelSet, servicesRegistry);
}
@@ -64,11 +64,11 @@ public class ServiceUtilsForResourceInitializerService implements IService {
public void disposeService() throws ServiceException {
try {
ModelSet modelSet = ServiceUtils.getInstance().getModelSet(servicesRegistry);
-
+
ModelSetServiceFactory.setServiceRegistry(modelSet, null);
} catch (BadStateException e) {
// ModelSet is already disposed. Do nothing
}
}
-
+
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java
index ba444e61ddc..fe12044b226 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForResourceSet.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* Copyright (c) 2013, 2014 CEA LIST and others.
- *
+ *
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,7 +9,7 @@
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 431953 (pre-requisite refactoring of ModelSet service start-up)
- *
+ *
*****************************************************************************/
package org.eclipse.papyrus.infra.emf.utils;
@@ -24,7 +24,7 @@ import org.eclipse.papyrus.infra.core.utils.AbstractServiceUtils;
public class ServiceUtilsForResourceSet extends AbstractServiceUtils<ResourceSet> {
private ServiceUtilsForResourceSet() {
- //Singleton
+ // Singleton
}
private static ServiceUtilsForResourceSet instance = new ServiceUtilsForResourceSet();
@@ -35,12 +35,12 @@ public class ServiceUtilsForResourceSet extends AbstractServiceUtils<ResourceSet
@Override
public ServicesRegistry getServiceRegistry(ResourceSet from) throws ServiceException {
- if(from == null) {
+ if (from == null) {
throw new ServiceNotFoundException("Can't find the ResourceSet needed retrieve the ServiceRegistry."); //$NON-NLS-1$
}
ServicesRegistry result = ModelSetServiceFactory.getServiceRegistry(from);
- if(result == null) {
+ if (result == null) {
throw new ServiceNotFoundException("The resource set was not initialized as a service."); //$NON-NLS-1$
}
return result;
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java
index 04de7290287..c79aba34c57 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/ServiceUtilsForSelection.java
@@ -1,6 +1,6 @@
/*****************************************************************************
* 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
@@ -22,15 +22,15 @@ 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
+ // Singleton
}
private static ServiceUtilsForSelection instance = new ServiceUtilsForSelection();
@@ -41,13 +41,13 @@ public class ServiceUtilsForSelection extends AbstractServiceUtils<ISelection> {
@Override
public ServicesRegistry getServiceRegistry(ISelection from) throws ServiceException {
- if(from instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection)from;
+ if (from instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) from;
Iterator<?> selectionIterator = selection.iterator();
- while(selectionIterator.hasNext()) {
+ while (selectionIterator.hasNext()) {
Object selectedElement = selectionIterator.next();
EObject selectedEObject = EMFHelper.getEObject(selectedElement);
- if(selectedEObject != null) {
+ if (selectedEObject != null) {
return ServiceUtilsForEObject.getInstance().getServiceRegistry(selectedEObject);
}
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java
index ece95494ed2..c7c783ea587 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TextReferencesHelper.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -25,44 +25,44 @@ 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 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 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 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 UNKNOWN_ELEMENT = "UNKNOWN"; // Replacement text for unknown elements
- public static String PROXY_ELEMENT = "PROXY"; //Replacement text for proxy elements
+ public static String PROXY_ELEMENT = "PROXY"; // Replacement text for proxy elements
protected Resource baseResource;
protected ResourceSet resourceSet;
protected TextReferencesHelper() {
- //Empty
+ // Empty
}
/**
- *
+ *
* @param baseResource
- * The resource against which the link uris will be resolved
+ * The resource against which the link uris will be resolved
*/
protected TextReferencesHelper(Resource baseResource) {
- if(baseResource != null) {
+ if (baseResource != null) {
this.baseResource = baseResource;
this.resourceSet = baseResource.getResourceSet();
}
@@ -70,22 +70,22 @@ public abstract class TextReferencesHelper {
/**
* 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) {
+ if (text == null) {
return null;
}
- if("".equals(text)) {
+ if ("".equals(text)) {
return text;
}
- //Javadoc-like @link tag
+ // Javadoc-like @link tag
String replaceRegex = String.format("\\{@link (%s)(\\|([^}]*))?\\}", URI_REGEX);
Pattern pattern = Pattern.compile(replaceRegex);
@@ -93,9 +93,9 @@ public abstract class TextReferencesHelper {
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
+ 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));
@@ -108,50 +108,50 @@ public abstract class TextReferencesHelper {
/**
* Insert a reference to the given element in the specified text, at the specified position
- *
+ *
* @param toElement
- * The element to reference
+ * The element to reference
* @param inText
- * The text in which the reference must be inserted
+ * 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
+ * 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 (inText == null) {
+ return null; // No change
}
- if(toElement == null) {
- return inText; //No change
+ if (toElement == null) {
+ return inText; // No change
}
- //Use a Javadoc-like @link tag
+ // Use a Javadoc-like @link tag
URI elementURI = EcoreUtil.getURI(toElement);
- if(baseResource != null) {
+ if (baseResource != null) {
URI baseURI = baseResource.getURI();
- if(baseURI != null) {
+ if (baseURI != null) {
elementURI = elementURI.deresolve(baseURI);
}
}
- String reference = "{@link " + elementURI + "}"; //The URI is already encoded
+ String reference = "{@link " + elementURI + "}"; // The URI is already encoded
- if(atPosition == 0) {
- return reference + result; //At the beginning
+ if (atPosition == 0) {
+ return reference + result; // At the beginning
}
- if(atPosition < 0 || atPosition >= inText.length()) {
- result += reference; //Insert at the end
+ 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)
+ // 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;
@@ -160,7 +160,7 @@ public abstract class TextReferencesHelper {
/**
* 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) {
@@ -170,11 +170,11 @@ public abstract class TextReferencesHelper {
protected String getReplacement(String uriToReplace, String cachedValue) {
String uri, fragment;
- if(baseResource == null || resourceSet == null || baseResource.getURI() == null) {
+ if (baseResource == null || resourceSet == null || baseResource.getURI() == null) {
return UNKNOWN_ELEMENT;
}
- if(uriToReplace.contains("#")) {
+ if (uriToReplace.contains("#")) {
uri = uriToReplace.substring(0, uriToReplace.indexOf('#'));
fragment = uriToReplace.substring(uriToReplace.indexOf('#') + 1, uriToReplace.length());
} else {
@@ -187,11 +187,11 @@ public abstract class TextReferencesHelper {
resourceURI = baseResource.getURI();
- targetURI = URI.createURI(uri); //The URI must already be encoded
+ targetURI = URI.createURI(uri); // The URI must already be encoded
targetURI = targetURI.resolve(resourceURI);
- if(targetURI == null) {
+ if (targetURI == null) {
return UNKNOWN_ELEMENT;
}
@@ -205,8 +205,8 @@ public abstract class TextReferencesHelper {
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
+ // 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"); //$NON-NLS-1$ //$NON-NLS-2$
}
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
index 1d4ab1791a6..6fcca922d2c 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/utils/TransactionalUnsetter.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* 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
@@ -20,9 +20,9 @@ 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 {
@@ -39,17 +39,17 @@ public class TransactionalUnsetter {
private final TransactionalEditingDomain domain;
/**
- *
+ *
* Constructor.
- *
+ *
* @param source
- * the eobject to modify
+ * the eobject to modify
* @param feature
- * the feature on which we want to do an unset
+ * 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);
+ domain = (TransactionalEditingDomain) EMFHelper.resolveEditingDomain(source);
+ cmd = new UnsetCommand(domain, source, feature);
}
/**

Back to the top