diff options
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom')
22 files changed, 1501 insertions, 1501 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManager.java index e7774b31aab..711f59ebfa3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManager.java @@ -1,66 +1,66 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-
-/**
- * This interface allows to access the customization catalog.
- *
- * @author Gregoire Dupe
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationCatalogManager {
-
- /**
- * This method is used to get all the registered customizations.
- *
- * @return all the registered customizations (may contain aggregates)
- */
- List<Customization> getRegisteredCustomizations();
-
- /**
- * This method is used to get all the customization which can be applied on a list of
- * eObjects and on the sub elements of those eObjects.
- *
- * Inheritance is handled. For example, assuming meta-model A extends
- * meta-model B, the customizations declared on meta-model B have to
- * be available on the instances of meta-model A. Furthermore all
- * customizations containing a customization of EObject have to be applicable
- * on all the models.
- *
- * @param eObjects
- * the {@link EObject}s for which to get the applicable customizations
- * @return a list of customizations
- */
- List<Customization> getCustomizationsApplicableOn(
- Collection<EObject> eObjects);
-
- /**
- * This method is used to register a customization which has not been declared through the
- * regular way (extension point).
- *
- * @param customization
- * the customization to register
- */
- void registerCustomization(Customization customization);
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; + +/** + * This interface allows to access the customization catalog. + * + * @author Gregoire Dupe + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationCatalogManager { + + /** + * This method is used to get all the registered customizations. + * + * @return all the registered customizations (may contain aggregates) + */ + List<Customization> getRegisteredCustomizations(); + + /** + * This method is used to get all the customization which can be applied on a list of + * eObjects and on the sub elements of those eObjects. + * + * Inheritance is handled. For example, assuming meta-model A extends + * meta-model B, the customizations declared on meta-model B have to + * be available on the instances of meta-model A. Furthermore all + * customizations containing a customization of EObject have to be applicable + * on all the models. + * + * @param eObjects + * the {@link EObject}s for which to get the applicable customizations + * @return a list of customizations + */ + List<Customization> getCustomizationsApplicableOn( + Collection<EObject> eObjects); + + /** + * This method is used to register a customization which has not been declared through the + * regular way (extension point). + * + * @param customization + * the customization to register + */ + void registerCustomization(Customization customization); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManagerFactory.java index 470cc74f1e7..b87d0c3491b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationCatalogManagerFactory.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationCatalogManagerFactory;
-
-/**
- * A factory for {@link ICustomizationCatalogManager}
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationCatalogManagerFactory {
-
- ICustomizationCatalogManagerFactory DEFAULT = new CustomizationCatalogManagerFactory();
-
- ICustomizationCatalogManager getOrCreateCustomizationCatalogManager(
- ResourceSet resourceSet);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationCatalogManagerFactory; + +/** + * A factory for {@link ICustomizationCatalogManager} + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationCatalogManagerFactory { + + ICustomizationCatalogManagerFactory DEFAULT = new CustomizationCatalogManagerFactory(); + + ICustomizationCatalogManager getOrCreateCustomizationCatalogManager( + ResourceSet resourceSet); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java index 332ae9dc16e..1fff8e2dd31 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManager.java @@ -1,101 +1,101 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-
-/**
- * This interface allows to access the customization manager. A customization
- * manager will compute the customization property depending on the loaded
- * customizations. Be careful, the load order has an impact on the customization
- * property value. Customizations are loaded in a stack. If there is a conflict
- * between two customizations, the higher customization (the nearest from the
- * top of the stack) gets the priority.
- *
- * @author Gregoire Dupe
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationManager {
-
- /**
- * This method is used to get the customization stack. The top
- * customization in the stack will be the first in the list.
- *
- * @return a mutable list of customizations
- */
- List<Customization> getManagedCustomizations();
-
- /**
- * This method is used to get the value of a customization property for a
- * chosen eObject.
- *
- * @param eObject
- * @param customProperty
- * @param classs
- * the expected result type
- * @return a value having a type depending a the customizationProperty type.
- * (Can be null.)
- */
- <T> T getCustomValueOf(EObject eObject,
- FacetOperation customProperty, Class<T> classs)
- throws CustomizationException;
-
- /**
- * This method is used to get the value of a customization property for a
- * chosen eObject and a chosen eStructuralFeature.
- *
- * @param eObject
- * @param structuralFeature
- * must not be null
- * @param customProperty
- * must not be null
- * @param classs
- * the expected result type
- * @return a value having a type depending a the customizationProperty type.
- * (Can be null.)
- */
- <T> T getCustomValueOf(EObject eObject,
- ETypedElement structuralFeature,
- FacetOperation customProperty, Class<T> classs)
- throws CustomizationException;
-
- /**
- * This method returns the resourceSet used to manage the customization
- * models.
- */
- ResourceSet getResourceSet();
-
- IFacetManager getFacetManager();
-
- /**
- * Multi-valued version of {@link #getCustomValueOf(EObject, FacetOperation, Class)}
- *
- * @param eObject
- * @param visibleReferences
- * @param class1
- * @return
- */
- <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customProperty, Class<T> class1) throws CustomizationException;;
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; + +/** + * This interface allows to access the customization manager. A customization + * manager will compute the customization property depending on the loaded + * customizations. Be careful, the load order has an impact on the customization + * property value. Customizations are loaded in a stack. If there is a conflict + * between two customizations, the higher customization (the nearest from the + * top of the stack) gets the priority. + * + * @author Gregoire Dupe + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationManager { + + /** + * This method is used to get the customization stack. The top + * customization in the stack will be the first in the list. + * + * @return a mutable list of customizations + */ + List<Customization> getManagedCustomizations(); + + /** + * This method is used to get the value of a customization property for a + * chosen eObject. + * + * @param eObject + * @param customProperty + * @param classs + * the expected result type + * @return a value having a type depending a the customizationProperty type. + * (Can be null.) + */ + <T> T getCustomValueOf(EObject eObject, + FacetOperation customProperty, Class<T> classs) + throws CustomizationException; + + /** + * This method is used to get the value of a customization property for a + * chosen eObject and a chosen eStructuralFeature. + * + * @param eObject + * @param structuralFeature + * must not be null + * @param customProperty + * must not be null + * @param classs + * the expected result type + * @return a value having a type depending a the customizationProperty type. + * (Can be null.) + */ + <T> T getCustomValueOf(EObject eObject, + ETypedElement structuralFeature, + FacetOperation customProperty, Class<T> classs) + throws CustomizationException; + + /** + * This method returns the resourceSet used to manage the customization + * models. + */ + ResourceSet getResourceSet(); + + IFacetManager getFacetManager(); + + /** + * Multi-valued version of {@link #getCustomValueOf(EObject, FacetOperation, Class)} + * + * @param eObject + * @param visibleReferences + * @param class1 + * @return + */ + <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customProperty, Class<T> class1) throws CustomizationException;; + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManagerFactory.java index f52cb9afc51..29fe853503b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationManagerFactory.java @@ -1,52 +1,52 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationManagerFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-
-/**
- * Used to instantiate a customization manager
- *
- * @author Gregoire Dupe
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationManagerFactory {
-
- /**
- * Default factory instance.
- */
- ICustomizationManagerFactory DEFAULT = new CustomizationManagerFactory();
-
- /**
- * This method is used to instantiate a customization manager
- *
- * @param resourceSet
- * the resource set to use to manage the customization models.
- * @return
- */
- ICustomizationManager getOrCreateICustomizationManager(ResourceSet resourceSet);
-
- /**
- *
- * @param facetManager
- * @return
- * @since 0.2
- */
- ICustomizationManager createICustomizationManager(IFacetManager facetManager);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationManagerFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; + +/** + * Used to instantiate a customization manager + * + * @author Gregoire Dupe + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationManagerFactory { + + /** + * Default factory instance. + */ + ICustomizationManagerFactory DEFAULT = new CustomizationManagerFactory(); + + /** + * This method is used to instantiate a customization manager + * + * @param resourceSet + * the resource set to use to manage the customization models. + * @return + */ + ICustomizationManager getOrCreateICustomizationManager(ResourceSet resourceSet); + + /** + * + * @param facetManager + * @return + * @since 0.2 + */ + ICustomizationManager createICustomizationManager(IFacetManager facetManager); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManager.java index 0e63b8c4d3b..289e43e9cb7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManager.java @@ -1,42 +1,42 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/**
- * This interface allows to access the customization catalog.
- *
- * @author Gregoire Dupe
- * @since 0.3
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationPropertiesCatalogManager {
-
- /**
- * This method is used to get all the registered customization properties (facetSet).
- *
- * @return all the registered customizations
- */
- List<FacetSet> getAllRegisteredCustomizationPropertySet();
-
- List<FacetOperation> getCustomizationPropertiesByName(
- String propertyName);
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** + * This interface allows to access the customization catalog. + * + * @author Gregoire Dupe + * @since 0.3 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationPropertiesCatalogManager { + + /** + * This method is used to get all the registered customization properties (facetSet). + * + * @return all the registered customizations + */ + List<FacetSet> getAllRegisteredCustomizationPropertySet(); + + List<FacetOperation> getCustomizationPropertiesByName( + String propertyName); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManagerFactory.java index 0efcaf42f0b..e5f5c2f6704 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/ICustomizationPropertiesCatalogManagerFactory.java @@ -1,31 +1,31 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.custom.core;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationPropertiesCatalogManagerFactory;
-
-/**
- * This interface provides the customization catalog manager.
- *
- * @since 0.3
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface ICustomizationPropertiesCatalogManagerFactory {
-
- ICustomizationPropertiesCatalogManagerFactory INSTANCE = new CustomizationPropertiesCatalogManagerFactory();
-
- ICustomizationPropertiesCatalogManager getOrCreateCustomizationPropertiesCatalogManager(
- final ResourceSet resourceSet);
-
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.custom.core; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.internal.CustomizationPropertiesCatalogManagerFactory; + +/** + * This interface provides the customization catalog manager. + * + * @since 0.3 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface ICustomizationPropertiesCatalogManagerFactory { + + ICustomizationPropertiesCatalogManagerFactory INSTANCE = new CustomizationPropertiesCatalogManagerFactory(); + + ICustomizationPropertiesCatalogManager getOrCreateCustomizationPropertiesCatalogManager( + final ResourceSet resourceSet); + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/exception/CustomizationException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/exception/CustomizationException.java index b2d3790a1b5..fe5741b1d36 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/exception/CustomizationException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/exception/CustomizationException.java @@ -1,41 +1,41 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core.exception;
-
-/**
- * This exception is thrown when the computation of a customization property value failed.
- *
- * @author Gregoire Dupe
- * @noinstantiate This class is not intended to be instantiated by clients.
- */
-public final class CustomizationException extends Exception {
-
- private static final long serialVersionUID = -4070159863668577038L;
-
- public CustomizationException() {
- super();
- }
-
- public CustomizationException(final String message) {
- super(message);
- }
-
- public CustomizationException(final Throwable cause) {
- super(cause);
- }
-
- public CustomizationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core.exception; + +/** + * This exception is thrown when the computation of a customization property value failed. + * + * @author Gregoire Dupe + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class CustomizationException extends Exception { + + private static final long serialVersionUID = -4070159863668577038L; + + public CustomizationException() { + super(); + } + + public CustomizationException(final String message) { + super(message); + } + + public CustomizationException(final Throwable cause) { + super(cause); + } + + public CustomizationException(final String message, final Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/Activator.java index d51c1ece2c7..11d791d2a95 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/Activator.java @@ -1,64 +1,64 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- Activator.plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(final BundleContext context) throws Exception {
- Activator.plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return Activator.plugin;
- }
-
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Nicolas Bros (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends Plugin { + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + Activator.plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(final BundleContext context) throws Exception { + Activator.plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return Activator.plugin; + } + + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManager.java index 118f3d50a2e..0f81585f8e2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManager.java @@ -1,99 +1,99 @@ -/**
- * Copyright (c) 2011-2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.exception.CustomizationCatalogRuntimeException;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationCatalog;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationcatalogFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager;
-
-/**
- * Customization catalog implementation using the catalog manager features provided by the plug-in
- * org.eclipse.papyrus.emf.facet.util.emf.core
- *
- * @author Gregoire Dupe
- *
- */
-public class CustomizationCatalogManager implements
- ICustomizationCatalogManager, ICatalogManager {
-
- private final CustomizationCatalog catalog = CustomizationcatalogFactory.eINSTANCE
- .createCustomizationCatalog();
-
- public boolean canBeManaged(final EObject root) {
- return root instanceof Customization;
- }
-
- public void manage(final EObject root) {
- if (root instanceof Customization) {
- Customization customization = (Customization) root;
- this.catalog.getInstalledEntries().add(customization);
- } else {
- throw new CustomizationCatalogRuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$
- }
- }
-
- public void setCatalogSet(final CatalogSet catalogSet) {
- catalogSet.getCatalogs().add(this.catalog);
- }
-
- public List<Customization> getCustomizationsByName(final String name) {
- List<Customization> result = new ArrayList<Customization>();
- for (EObject eObject : this.catalog.getInstalledEntries()) {
- if (eObject instanceof Customization) {
- Customization customization = (Customization) eObject;
- if (name.equals(customization.getName())) {
- result.add(customization);
- }
- } else {
- throw new RuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- public void registerCustomization(final Customization customization) {
- this.catalog.getInstalledEntries().add(customization);
- }
-
- public List<Customization> getCustomizationsApplicableOn(
- final Collection<EObject> eObjects) {
-
- return null;
- }
-
- public List<Customization> getRegisteredCustomizations() {
- List<Customization> result = new ArrayList<Customization>();
- for (EObject eObject : this.catalog.getInstalledEntries()) {
- if (eObject instanceof Customization) {
- Customization customization = (Customization) eObject;
- result.add(customization);
- } else {
- throw new RuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$
- }
- }
- return Collections.unmodifiableList(result);
- }
-
-}
+/** + * Copyright (c) 2011-2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager; +import org.eclipse.papyrus.emf.facet.custom.core.internal.exception.CustomizationCatalogRuntimeException; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationCatalog; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationcatalogFactory; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager; + +/** + * Customization catalog implementation using the catalog manager features provided by the plug-in + * org.eclipse.papyrus.emf.facet.util.emf.core + * + * @author Gregoire Dupe + * + */ +public class CustomizationCatalogManager implements + ICustomizationCatalogManager, ICatalogManager { + + private final CustomizationCatalog catalog = CustomizationcatalogFactory.eINSTANCE + .createCustomizationCatalog(); + + public boolean canBeManaged(final EObject root) { + return root instanceof Customization; + } + + public void manage(final EObject root) { + if (root instanceof Customization) { + Customization customization = (Customization) root; + this.catalog.getInstalledEntries().add(customization); + } else { + throw new CustomizationCatalogRuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$ + } + } + + public void setCatalogSet(final CatalogSet catalogSet) { + catalogSet.getCatalogs().add(this.catalog); + } + + public List<Customization> getCustomizationsByName(final String name) { + List<Customization> result = new ArrayList<Customization>(); + for (EObject eObject : this.catalog.getInstalledEntries()) { + if (eObject instanceof Customization) { + Customization customization = (Customization) eObject; + if (name.equals(customization.getName())) { + result.add(customization); + } + } else { + throw new RuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$ + } + } + return result; + } + + public void registerCustomization(final Customization customization) { + this.catalog.getInstalledEntries().add(customization); + } + + public List<Customization> getCustomizationsApplicableOn( + final Collection<EObject> eObjects) { + + return null; + } + + public List<Customization> getRegisteredCustomizations() { + List<Customization> result = new ArrayList<Customization>(); + for (EObject eObject : this.catalog.getInstalledEntries()) { + if (eObject instanceof Customization) { + Customization customization = (Customization) eObject; + result.add(customization); + } else { + throw new RuntimeException("Only customizations (and aggregates) must be stored in the customization catalog"); //$NON-NLS-1$ + } + } + return Collections.unmodifiableList(result); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManagerFactory.java index 6dd400b8e90..9d4f41c9633 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationCatalogManagerFactory.java @@ -1,29 +1,29 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-
-public class CustomizationCatalogManagerFactory implements
- org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory {
-
- public ICustomizationCatalogManager getOrCreateCustomizationCatalogManager(
- final ResourceSet resourceSet) {
- return ICatalogSetManagerFactory.DEFAULT
- .createICatalogSetManager(resourceSet)
- .getCatalogManagerByType(ICustomizationCatalogManager.class)
- .get(0);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManager; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; + +public class CustomizationCatalogManagerFactory implements + org.eclipse.papyrus.emf.facet.custom.core.ICustomizationCatalogManagerFactory { + + public ICustomizationCatalogManager getOrCreateCustomizationCatalogManager( + final ResourceSet resourceSet) { + return ICatalogSetManagerFactory.DEFAULT + .createICatalogSetManager(resourceSet) + .getCatalogManagerByType(ICustomizationCatalogManager.class) + .get(0); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java index 02816817be2..880705ae3cc 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManager.java @@ -1,205 +1,205 @@ -/**
- * Copyright (c) 2011-2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-public class CustomizationManager implements ICustomizationManager {
-
- private final HashSet<FacetOperation> customProperties = new HashSet<FacetOperation>();
- private final IFacetManager facetManager;
-
- public CustomizationManager(final ResourceSet resourceSet) {
- this.facetManager = IFacetManagerFactory.DEFAULT.getOrCreateFacetManager(resourceSet);
- }
-
- public CustomizationManager(final IFacetManager facetManager) {
- this.facetManager = facetManager;
- }
-
- public void addFrontManagedCustomization(final Customization customization) {
- this.facetManager.getManagedFacetSets().add(0, customization);
- }
-
- public void removeCustomization(final Customization customization) {
- this.facetManager.getManagedFacetSets().remove(customization);
- }
-
- @Override
- public List<Customization> getManagedCustomizations() {
- return new CustomizationsDelegatingList(this.facetManager.getManagedFacetSets());
- }
-
- @Override
- public <T> T getCustomValueOf(final EObject eObject,
- final FacetOperation customizationProperty,
- final Class<T> classs)
- throws CustomizationException {
- // Begin precondition checking section
- /*
- * The scope of a customization property is not available yet in new customization meta-model
- * if (!(customizationProperty.getScope().contains(
- * CustomizationPropertyScope.ECLASS) || (customizationProperty
- * .getScope().contains(CustomizationPropertyScope.FACET)))) {
- * throw new RuntimeException(
- * "The customization property is expected to be applicable on an EClass or on a Facet"); //$NON-NLS-1$
- * }
- */
- // End precondition checking section
- T result = null;
- try {
- // the structural feature : null
- final Object[] args = new Object[] { null };
- result = this.facetManager.invoke(eObject, customizationProperty,
- classs, null, args);
- } catch (final Exception e) {
- throw new CustomizationException(e);
- }
- return result;
- }
-
- @Override
- public <T> T getCustomValueOf(final EObject eObject,
- final ETypedElement eTypedElement,
- final FacetOperation customizationProperty,
- final Class<T> classs)
- throws CustomizationException {
- // Begin precondition checking section
- if (eObject == null) {
- throw new IllegalArgumentException("The parameter 'eObject' must not be null."); //$NON-NLS-1$
- }
- if (customizationProperty == null) {
- throw new IllegalArgumentException("The parameter 'customizationProperty' must not be null."); //$NON-NLS-1$
- }
- /*
- * The scope of a customization property is not available yet in new customization meta-model
- * if (!(eStructuralFeature instanceof EReference)) {
- * if (customizationProperty.getScope().equals(
- * CustomizationPropertyScope.EREFERENCE)) {
- * throw new CustomizationException(
- * "The eStructuralFeature is an instance of " //$NON-NLS-1$
- * + eStructuralFeature.getClass().getName()
- * + " but EReference is expected."); //$NON-NLS-1$
- * }
- * }
- *
- * if (!(eStructuralFeature instanceof EAttribute)) {
- * if (customizationProperty.getScope().equals(
- * CustomizationPropertyScope.EATTRIBUTE)) {
- * throw new CustomizationException(
- * "The eStructuralFeature is an instance of " //$NON-NLS-1$
- * + eStructuralFeature.getClass().getName()
- * + " but EAttribute is expected."); //$NON-NLS-1$
- * }
- * }
- */
- // End precondition checking section
- try {
- return this.facetManager.invoke(eObject, customizationProperty, classs, null, new Object[] { eTypedElement });
- } catch (Exception e) {
- throw new CustomizationException(e);
- }
- }
-
- public List<FacetOperation> getCustomizationPropertiesByName(
- final String name) {
- if (name == null) {
- throw new IllegalArgumentException("The parameter 'name' must not be null."); //$NON-NLS-1$
- }
- List<FacetOperation> results = new ArrayList<FacetOperation>();
- for (FacetOperation customizationProperty : this.customProperties) {
- if (name.equals(customizationProperty.getName())) {
- results.add(customizationProperty);
- }
- }
- return results;
- }
-
- public void addCustomization(final URI uri) {
- if (uri == null) {
- throw new IllegalArgumentException("The parameter 'uri' must not be null."); //$NON-NLS-1$
- }
- Resource resource = this.facetManager.getResourceSet().getResource(uri, true);
- Iterator<EObject> iterator = resource.getAllContents();
- while (iterator.hasNext()) {
- EObject eObject = iterator.next();
- if (eObject instanceof FacetOperation) {
- FacetOperation customizationProperty = (FacetOperation) eObject;
- this.customProperties.add(customizationProperty);
- }
- }
- }
-
- @Override
- public ResourceSet getResourceSet() {
- return this.facetManager.getResourceSet();
- }
-
- public void removeAllCustomizations() {
- List<Customization> customizationsToRemove = new LinkedList<Customization>();
- for (FacetSet facetSet : this.facetManager.getManagedFacetSets()) {
- if (facetSet instanceof Customization) {
- Customization customization = (Customization) facetSet;
- customizationsToRemove.add(customization);
- }
- }
- for (Customization customization : customizationsToRemove) {
- this.facetManager.getManagedFacetSets().remove(customization);
- }
- }
-
- @Override
- public IFacetManager getFacetManager() {
- return this.facetManager;
- }
-
- /**
- * @see org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager#getCustomValuesOf(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation, java.lang.Class)
- *
- * @param eObject
- * @param customProperty
- * @param class1
- * @return
- * @throws CustomizationException
- */
- @Override
- public <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customizationProperty, Class<T> classs) throws CustomizationException {
- List<T> result = null;
- try {
- result = this.facetManager.getOrInvokeMultiValued(eObject, customizationProperty, classs);
- } catch (final Exception e) {
- throw new CustomizationException(e);
- }
- return result;
- }
-}
+/** + * Copyright (c) 2011-2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +public class CustomizationManager implements ICustomizationManager { + + private final HashSet<FacetOperation> customProperties = new HashSet<FacetOperation>(); + private final IFacetManager facetManager; + + public CustomizationManager(final ResourceSet resourceSet) { + this.facetManager = IFacetManagerFactory.DEFAULT.getOrCreateFacetManager(resourceSet); + } + + public CustomizationManager(final IFacetManager facetManager) { + this.facetManager = facetManager; + } + + public void addFrontManagedCustomization(final Customization customization) { + this.facetManager.getManagedFacetSets().add(0, customization); + } + + public void removeCustomization(final Customization customization) { + this.facetManager.getManagedFacetSets().remove(customization); + } + + @Override + public List<Customization> getManagedCustomizations() { + return new CustomizationsDelegatingList(this.facetManager.getManagedFacetSets()); + } + + @Override + public <T> T getCustomValueOf(final EObject eObject, + final FacetOperation customizationProperty, + final Class<T> classs) + throws CustomizationException { + // Begin precondition checking section + /* + * The scope of a customization property is not available yet in new customization meta-model + * if (!(customizationProperty.getScope().contains( + * CustomizationPropertyScope.ECLASS) || (customizationProperty + * .getScope().contains(CustomizationPropertyScope.FACET)))) { + * throw new RuntimeException( + * "The customization property is expected to be applicable on an EClass or on a Facet"); //$NON-NLS-1$ + * } + */ + // End precondition checking section + T result = null; + try { + // the structural feature : null + final Object[] args = new Object[] { null }; + result = this.facetManager.invoke(eObject, customizationProperty, + classs, null, args); + } catch (final Exception e) { + throw new CustomizationException(e); + } + return result; + } + + @Override + public <T> T getCustomValueOf(final EObject eObject, + final ETypedElement eTypedElement, + final FacetOperation customizationProperty, + final Class<T> classs) + throws CustomizationException { + // Begin precondition checking section + if (eObject == null) { + throw new IllegalArgumentException("The parameter 'eObject' must not be null."); //$NON-NLS-1$ + } + if (customizationProperty == null) { + throw new IllegalArgumentException("The parameter 'customizationProperty' must not be null."); //$NON-NLS-1$ + } + /* + * The scope of a customization property is not available yet in new customization meta-model + * if (!(eStructuralFeature instanceof EReference)) { + * if (customizationProperty.getScope().equals( + * CustomizationPropertyScope.EREFERENCE)) { + * throw new CustomizationException( + * "The eStructuralFeature is an instance of " //$NON-NLS-1$ + * + eStructuralFeature.getClass().getName() + * + " but EReference is expected."); //$NON-NLS-1$ + * } + * } + * + * if (!(eStructuralFeature instanceof EAttribute)) { + * if (customizationProperty.getScope().equals( + * CustomizationPropertyScope.EATTRIBUTE)) { + * throw new CustomizationException( + * "The eStructuralFeature is an instance of " //$NON-NLS-1$ + * + eStructuralFeature.getClass().getName() + * + " but EAttribute is expected."); //$NON-NLS-1$ + * } + * } + */ + // End precondition checking section + try { + return this.facetManager.invoke(eObject, customizationProperty, classs, null, new Object[] { eTypedElement }); + } catch (Exception e) { + throw new CustomizationException(e); + } + } + + public List<FacetOperation> getCustomizationPropertiesByName( + final String name) { + if (name == null) { + throw new IllegalArgumentException("The parameter 'name' must not be null."); //$NON-NLS-1$ + } + List<FacetOperation> results = new ArrayList<FacetOperation>(); + for (FacetOperation customizationProperty : this.customProperties) { + if (name.equals(customizationProperty.getName())) { + results.add(customizationProperty); + } + } + return results; + } + + public void addCustomization(final URI uri) { + if (uri == null) { + throw new IllegalArgumentException("The parameter 'uri' must not be null."); //$NON-NLS-1$ + } + Resource resource = this.facetManager.getResourceSet().getResource(uri, true); + Iterator<EObject> iterator = resource.getAllContents(); + while (iterator.hasNext()) { + EObject eObject = iterator.next(); + if (eObject instanceof FacetOperation) { + FacetOperation customizationProperty = (FacetOperation) eObject; + this.customProperties.add(customizationProperty); + } + } + } + + @Override + public ResourceSet getResourceSet() { + return this.facetManager.getResourceSet(); + } + + public void removeAllCustomizations() { + List<Customization> customizationsToRemove = new LinkedList<Customization>(); + for (FacetSet facetSet : this.facetManager.getManagedFacetSets()) { + if (facetSet instanceof Customization) { + Customization customization = (Customization) facetSet; + customizationsToRemove.add(customization); + } + } + for (Customization customization : customizationsToRemove) { + this.facetManager.getManagedFacetSets().remove(customization); + } + } + + @Override + public IFacetManager getFacetManager() { + return this.facetManager; + } + + /** + * @see org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager#getCustomValuesOf(org.eclipse.emf.ecore.EObject, org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation, java.lang.Class) + * + * @param eObject + * @param customProperty + * @param class1 + * @return + * @throws CustomizationException + */ + @Override + public <T> List<T> getCustomValuesOf(EObject eObject, FacetOperation customizationProperty, Class<T> classs) throws CustomizationException { + List<T> result = null; + try { + result = this.facetManager.getOrInvokeMultiValued(eObject, customizationProperty, classs); + } catch (final Exception e) { + throw new CustomizationException(e); + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManagerFactory.java index fe37fd1c9d9..a79323f2bda 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationManagerFactory.java @@ -1,32 +1,32 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-
-public class CustomizationManagerFactory implements
- ICustomizationManagerFactory {
-
- public ICustomizationManager getOrCreateICustomizationManager(final ResourceSet resourceSet) {
- return new CustomizationManager(resourceSet);
- }
-
- public ICustomizationManager createICustomizationManager(
- final IFacetManager facetManager) {
- return new CustomizationManager(facetManager);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; + +public class CustomizationManagerFactory implements + ICustomizationManagerFactory { + + public ICustomizationManager getOrCreateICustomizationManager(final ResourceSet resourceSet) { + return new CustomizationManager(resourceSet); + } + + public ICustomizationManager createICustomizationManager( + final IFacetManager facetManager) { + return new CustomizationManager(facetManager); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManager.java index 646b8c4a16a..81d466306cd 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManager.java @@ -1,99 +1,99 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManager;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.exception.CustomizationCatalogRuntimeException;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationPropertiesCatalog;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationcatalogFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager;
-
-/**
- * Customization catalog implementation using the catalog manager features
- * provided by the plug-in org.eclipse.papyrus.emf.facet.util.emf.core
- *
- * @author Gregoire Dupe
- *
- */
-public class CustomizationPropertiesCatalogManager implements ICatalogManager,
- ICustomizationPropertiesCatalogManager {
-
- private static final String CUSTOM_SUFIX = "customproperties"; //$NON-NLS-1$
- private final CustomizationPropertiesCatalog catalog = CustomizationcatalogFactory.eINSTANCE
- .createCustomizationPropertiesCatalog();
-
- public boolean canBeManaged(final EObject root) {
- return root instanceof FacetSet;
- }
-
- public void manage(final EObject root) {
- if (root instanceof FacetSet) {
- final FacetSet customProperties = (FacetSet) root;
- // We have to force the integrator to use the suffix
- // "customproperties" to name them facetSet declaring custom
- // properties. Otherwise we won't be able to know if a facetSet is a
- // custom property declaration
- if (customProperties.getName().endsWith(CUSTOM_SUFIX)) {
- this.catalog.getInstalledEntries().add(customProperties);
- }
- } else {
- throw new CustomizationCatalogRuntimeException("Only facetSets must be stored in the customization properties catalog"); //$NON-NLS-1$
- }
- }
-
- public void setCatalogSet(final CatalogSet catalogSet) {
- catalogSet.getCatalogs().add(this.catalog);
- }
-
- public List<FacetSet> getAllRegisteredCustomizationPropertySet() {
- final List<FacetSet> result = new ArrayList<FacetSet>();
- for (final EObject eObject : this.catalog.getInstalledEntries()) {
- if (eObject instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) eObject;
- result.add(facetSet);
- } else {
- throw new RuntimeException("Only facetSets must be stored in the customization properties catalog"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- public List<FacetOperation> getCustomizationPropertiesByName(
- final String customPropName) {
- final List<FacetOperation> result = new ArrayList<FacetOperation>();
- for (final EObject facetSet : this.catalog.getInstalledEntries()) {
- final Iterator<EObject> iterator = facetSet.eAllContents();
- while (iterator.hasNext()) {
- final EObject eObject = iterator.next();
- if (eObject instanceof FacetOperation) {
- final FacetOperation customProperty = (FacetOperation) eObject;
- if (customPropName.equals(customProperty.getName())) {
- result.add(customProperty);
- }
- }
- }
- }
- return result;
- }
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManager; +import org.eclipse.papyrus.emf.facet.custom.core.internal.exception.CustomizationCatalogRuntimeException; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationPropertiesCatalog; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.customizationcatalog.CustomizationcatalogFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager; + +/** + * Customization catalog implementation using the catalog manager features + * provided by the plug-in org.eclipse.papyrus.emf.facet.util.emf.core + * + * @author Gregoire Dupe + * + */ +public class CustomizationPropertiesCatalogManager implements ICatalogManager, + ICustomizationPropertiesCatalogManager { + + private static final String CUSTOM_SUFIX = "customproperties"; //$NON-NLS-1$ + private final CustomizationPropertiesCatalog catalog = CustomizationcatalogFactory.eINSTANCE + .createCustomizationPropertiesCatalog(); + + public boolean canBeManaged(final EObject root) { + return root instanceof FacetSet; + } + + public void manage(final EObject root) { + if (root instanceof FacetSet) { + final FacetSet customProperties = (FacetSet) root; + // We have to force the integrator to use the suffix + // "customproperties" to name them facetSet declaring custom + // properties. Otherwise we won't be able to know if a facetSet is a + // custom property declaration + if (customProperties.getName().endsWith(CUSTOM_SUFIX)) { + this.catalog.getInstalledEntries().add(customProperties); + } + } else { + throw new CustomizationCatalogRuntimeException("Only facetSets must be stored in the customization properties catalog"); //$NON-NLS-1$ + } + } + + public void setCatalogSet(final CatalogSet catalogSet) { + catalogSet.getCatalogs().add(this.catalog); + } + + public List<FacetSet> getAllRegisteredCustomizationPropertySet() { + final List<FacetSet> result = new ArrayList<FacetSet>(); + for (final EObject eObject : this.catalog.getInstalledEntries()) { + if (eObject instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) eObject; + result.add(facetSet); + } else { + throw new RuntimeException("Only facetSets must be stored in the customization properties catalog"); //$NON-NLS-1$ + } + } + return result; + } + + public List<FacetOperation> getCustomizationPropertiesByName( + final String customPropName) { + final List<FacetOperation> result = new ArrayList<FacetOperation>(); + for (final EObject facetSet : this.catalog.getInstalledEntries()) { + final Iterator<EObject> iterator = facetSet.eAllContents(); + while (iterator.hasNext()) { + final EObject eObject = iterator.next(); + if (eObject instanceof FacetOperation) { + final FacetOperation customProperty = (FacetOperation) eObject; + if (customPropName.equals(customProperty.getName())) { + result.add(customProperty); + } + } + } + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManagerFactory.java index 03ec32b2194..544f94e8e55 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationPropertiesCatalogManagerFactory.java @@ -1,33 +1,33 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManagerFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-
-/**
- * Implementation of {@link ICustomizationPropertiesCatalogManagerFactory}.
- */
-public class CustomizationPropertiesCatalogManagerFactory implements ICustomizationPropertiesCatalogManagerFactory {
-
- public ICustomizationPropertiesCatalogManager getOrCreateCustomizationPropertiesCatalogManager(
- final ResourceSet resourceSet) {
- return ICatalogSetManagerFactory.DEFAULT
- .createICatalogSetManager(resourceSet)
- .getCatalogManagerByType(
- ICustomizationPropertiesCatalogManager.class)
- .get(0);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationPropertiesCatalogManagerFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; + +/** + * Implementation of {@link ICustomizationPropertiesCatalogManagerFactory}. + */ +public class CustomizationPropertiesCatalogManagerFactory implements ICustomizationPropertiesCatalogManagerFactory { + + public ICustomizationPropertiesCatalogManager getOrCreateCustomizationPropertiesCatalogManager( + final ResourceSet resourceSet) { + return ICatalogSetManagerFactory.DEFAULT + .createICatalogSetManager(resourceSet) + .getCatalogManagerByType( + ICustomizationPropertiesCatalogManager.class) + .get(0); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationsDelegatingList.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationsDelegatingList.java index 96c8b060226..c5dd4d802a2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationsDelegatingList.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/CustomizationsDelegatingList.java @@ -1,105 +1,105 @@ -/*******************************************************************************
- * Copyright (c) 2012, 2017 CEA LIST, Christian W. Damus, 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:
- * Nicolas Bros (Mia-Software) - Bug 374758 - [Table] repair the table
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Thomas Cicognani (Soft-Maint) - Bug 420192 - UnsupportedOperationException in a usefull method
- * Christian W. Damus - bug 515913
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.custom.core.internal;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/** Represents a list of {@link Customization}s that exists as a subset of a delegate list of {@link FacetSet}s. */
-public class CustomizationsDelegatingList extends BasicEList<Customization> {
- private static final long serialVersionUID = 1L;
-
- private final List<FacetSet> delegate;
-
- public CustomizationsDelegatingList(final List<FacetSet> delegate) {
- super(customizations(delegate));
- this.delegate = delegate;
- }
-
- /**
- * @since 3.0
- */
- @Override
- protected void didAdd(int index, Customization newObject) {
- // Insert at the corresponding location in the delegate
- if (index > 0) {
- index = delegate.indexOf(get(index - 1)) + 1;
- }
-
- delegate.add(index, newObject);
- }
-
- /**
- * @since 3.0
- */
- @Override
- protected void didSet(int index, Customization newObject, Customization oldObject) {
- index = delegate.indexOf(oldObject);
- delegate.set(index, newObject);
- }
-
- /**
- * @since 3.0
- */
- @Override
- protected void didRemove(int index, Customization oldObject) {
- delegate.remove(oldObject);
- }
-
- /**
- * @since 3.0
- */
- @Override
- protected void didClear(int size, Object[] oldObjects) {
- delegate.removeAll(Arrays.asList(oldObjects));
- }
-
- /**
- * @since 3.0
- */
- @Override
- protected void didMove(int index, Customization movedObject, int oldIndex) {
- // Move to the corresponding location in the delegate
- if (index > 0) {
- index = delegate.indexOf(get(index - 1)) + 1;
- }
- if (delegate instanceof EList<?>) {
- ((EList<FacetSet>) delegate).move(index, movedObject);
- } else {
- // Do it the hard way
- delegate.remove(movedObject);
- delegate.add(index, movedObject);
- }
- }
-
- /**
- * Obtains the subset of a list of facet-sets that are customizations.
- *
- * @param facetSets
- * the superset
- * @return the subset of customizations
- * @since 3.0
- */
- protected static List<Customization> customizations(List<FacetSet> facetSets) {
- return facetSets.stream()
- .filter(Customization.class::isInstance).map(Customization.class::cast)
- .collect(Collectors.toList());
- }
-}
+/******************************************************************************* + * Copyright (c) 2012, 2017 CEA LIST, Christian W. Damus, 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: + * Nicolas Bros (Mia-Software) - Bug 374758 - [Table] repair the table + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Thomas Cicognani (Soft-Maint) - Bug 420192 - UnsupportedOperationException in a usefull method + * Christian W. Damus - bug 515913 + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.custom.core.internal; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** Represents a list of {@link Customization}s that exists as a subset of a delegate list of {@link FacetSet}s. */ +public class CustomizationsDelegatingList extends BasicEList<Customization> { + private static final long serialVersionUID = 1L; + + private final List<FacetSet> delegate; + + public CustomizationsDelegatingList(final List<FacetSet> delegate) { + super(customizations(delegate)); + this.delegate = delegate; + } + + /** + * @since 3.0 + */ + @Override + protected void didAdd(int index, Customization newObject) { + // Insert at the corresponding location in the delegate + if (index > 0) { + index = delegate.indexOf(get(index - 1)) + 1; + } + + delegate.add(index, newObject); + } + + /** + * @since 3.0 + */ + @Override + protected void didSet(int index, Customization newObject, Customization oldObject) { + index = delegate.indexOf(oldObject); + delegate.set(index, newObject); + } + + /** + * @since 3.0 + */ + @Override + protected void didRemove(int index, Customization oldObject) { + delegate.remove(oldObject); + } + + /** + * @since 3.0 + */ + @Override + protected void didClear(int size, Object[] oldObjects) { + delegate.removeAll(Arrays.asList(oldObjects)); + } + + /** + * @since 3.0 + */ + @Override + protected void didMove(int index, Customization movedObject, int oldIndex) { + // Move to the corresponding location in the delegate + if (index > 0) { + index = delegate.indexOf(get(index - 1)) + 1; + } + if (delegate instanceof EList<?>) { + ((EList<FacetSet>) delegate).move(index, movedObject); + } else { + // Do it the hard way + delegate.remove(movedObject); + delegate.add(index, movedObject); + } + } + + /** + * Obtains the subset of a list of facet-sets that are customizations. + * + * @param facetSets + * the superset + * @return the subset of customizations + * @since 3.0 + */ + protected static List<Customization> customizations(List<FacetSet> facetSets) { + return facetSets.stream() + .filter(Customization.class::isInstance).map(Customization.class::cast) + .collect(Collectors.toList()); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exception/CustomizationCatalogRuntimeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exception/CustomizationCatalogRuntimeException.java index 641ee0f064a..6ef38c48cce 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exception/CustomizationCatalogRuntimeException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exception/CustomizationCatalogRuntimeException.java @@ -1,40 +1,40 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.exception;
-
-/**
- * @noinstantiate This class is not intended to be instantiated by clients.
- * @author Gregoire Dupe
- *
- */
-public final class CustomizationCatalogRuntimeException extends RuntimeException {
-
- private static final long serialVersionUID = 6589838701903506569L;
-
- public CustomizationCatalogRuntimeException() {
- super();
- }
-
- public CustomizationCatalogRuntimeException(final String message) {
- super(message);
- }
-
- public CustomizationCatalogRuntimeException(final Throwable cause) {
- super(cause);
- }
-
- public CustomizationCatalogRuntimeException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.exception; + +/** + * @noinstantiate This class is not intended to be instantiated by clients. + * @author Gregoire Dupe + * + */ +public final class CustomizationCatalogRuntimeException extends RuntimeException { + + private static final long serialVersionUID = 6589838701903506569L; + + public CustomizationCatalogRuntimeException() { + super(); + } + + public CustomizationCatalogRuntimeException(final String message) { + super(message); + } + + public CustomizationCatalogRuntimeException(final Throwable cause) { + super(cause); + } + + public CustomizationCatalogRuntimeException(final String message, final Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/Constants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/Constants.java index bef2bfcb734..086ca055e1e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/Constants.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/Constants.java @@ -1,21 +1,21 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.custom.core.internal.exported;
-
-public final class Constants {
-
- private Constants() {
- // Must not be used
- }
-
- public static final String CUSTOM_FILE_EXT = "custom"; //$NON-NLS-1$
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 375054 - Add validation warning for overlay on EClass + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.custom.core.internal.exported; + +public final class Constants { + + private Constants() { + // Must not be used + } + + public static final String CUSTOM_FILE_EXT = "custom"; //$NON-NLS-1$ +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java index d17f8fcc391..118b8c294a5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/exported/CustomizationUtils.java @@ -1,140 +1,140 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet
- * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented
- * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.exported;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.StyledString;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException;
-import org.eclipse.papyrus.emf.facet.custom.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-
-/**
- * @since 0.2
- */
-public final class CustomizationUtils {
-
- private static final String FILE_EXTENSION = "custom"; //$NON-NLS-1$
-
- private CustomizationUtils() {
- // Must not be used
- }
-
- public static EPackage getCustomizedEPackage(
- final Customization customization) {
- EPackage result = null;
- for (EClassifier eClassifier : customization.getEClassifiers()) {
- for (EPackage ePackage : getExtendedEPackage(eClassifier)) {
- if (ePackage != null && !(ePackage instanceof FacetSet)) {
- result = ePackage;
- break;
- }
- }
- }
- return result;
- }
-
- private static List<EPackage> getExtendedEPackage(
- final EClassifier eClassifier) {
- final List<EClassifier> extended = new ArrayList<EClassifier>();
- if (eClassifier instanceof FacetCustomization) {
- final FacetCustomization facetCustom = (FacetCustomization) eClassifier;
- extended.addAll(facetCustom.getExtendedFacets());
- } else if (eClassifier instanceof EClassCustomization) {
- final EClassCustomization eClassCustom = (EClassCustomization) eClassifier;
- extended.add(eClassCustom.getExtendedMetaclass());
- }
- final List<EPackage> ePackages = new LinkedList<EPackage>();
- for (EClassifier extCassifier : extended) {
- if (extCassifier != null) {
- ePackages.add(extCassifier.getEPackage());
- }
- }
- return ePackages;
- }
-
- /**
- * Return the default file extension of a customization file.
- *
- * @return the file extension without the dot.
- */
- public static String getDefaultFileExtension() {
- return CustomizationUtils.FILE_EXTENSION;
- }
-
- /**
- * Find a Customization with the given name among the given list of Customizations. If several Customizations have the same name,
- * then return the first one.
- *
- * @param customizations
- * where to look for
- * @param name
- * the name of the Customization to find
- * @return the Customization, or <code>null</code> if not found in the given list
- */
- public static Customization getCustomization(final Collection<Customization> customizations, final String name) {
- Customization result = null;
- for (Customization customization : customizations) {
- if (name.equals(customization.getName())) {
- result = customization;
- }
- }
- return result;
- }
-
- public static <T> T getPropertyValue(
- final ICustomizationManager customManager, final Object element,
- final FacetOperation property, final ETypedElement eTypedElement,
- final Class<T> classs) {
- T result = null;
- if (element instanceof EObject) {
- final EObject eObject = (EObject) element;
- try {
- if (eTypedElement == null) {
- result = customManager.getCustomValueOf(eObject, property,
- classs);
- } else {
- result = customManager.getCustomValueOf(eObject,
- eTypedElement, property, classs);
- }
- } catch (final CustomizationException e) {
- Logger.logError(
- e,
- "Failed to get the value of '" + property.getName() + "' for " + element, //$NON-NLS-1$ //$NON-NLS-2$
- Activator.getDefault());
- }
- }
-
- // Patch to convert StyledString to String in case of customManager provide StyleString and String is expected.
- if (result instanceof StyledString && !classs.isInstance(result)) {
- result = (T) result.toString();
- }
-
- return result;
- }
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet + * David Couvrand (Soft-Maint) - Bug 418418 - [Customization] Overlay icons not implemented + * Mickael ADAM (ALL4TEC) - mickael.adam@all4tec.net - Bug 500219 - implementation of IStyledLabelProvider + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.exported; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.StyledString; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.exception.CustomizationException; +import org.eclipse.papyrus.emf.facet.custom.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.Customization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.EClassCustomization; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.FacetCustomization; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.core.Logger; + +/** + * @since 0.2 + */ +public final class CustomizationUtils { + + private static final String FILE_EXTENSION = "custom"; //$NON-NLS-1$ + + private CustomizationUtils() { + // Must not be used + } + + public static EPackage getCustomizedEPackage( + final Customization customization) { + EPackage result = null; + for (EClassifier eClassifier : customization.getEClassifiers()) { + for (EPackage ePackage : getExtendedEPackage(eClassifier)) { + if (ePackage != null && !(ePackage instanceof FacetSet)) { + result = ePackage; + break; + } + } + } + return result; + } + + private static List<EPackage> getExtendedEPackage( + final EClassifier eClassifier) { + final List<EClassifier> extended = new ArrayList<EClassifier>(); + if (eClassifier instanceof FacetCustomization) { + final FacetCustomization facetCustom = (FacetCustomization) eClassifier; + extended.addAll(facetCustom.getExtendedFacets()); + } else if (eClassifier instanceof EClassCustomization) { + final EClassCustomization eClassCustom = (EClassCustomization) eClassifier; + extended.add(eClassCustom.getExtendedMetaclass()); + } + final List<EPackage> ePackages = new LinkedList<EPackage>(); + for (EClassifier extCassifier : extended) { + if (extCassifier != null) { + ePackages.add(extCassifier.getEPackage()); + } + } + return ePackages; + } + + /** + * Return the default file extension of a customization file. + * + * @return the file extension without the dot. + */ + public static String getDefaultFileExtension() { + return CustomizationUtils.FILE_EXTENSION; + } + + /** + * Find a Customization with the given name among the given list of Customizations. If several Customizations have the same name, + * then return the first one. + * + * @param customizations + * where to look for + * @param name + * the name of the Customization to find + * @return the Customization, or <code>null</code> if not found in the given list + */ + public static Customization getCustomization(final Collection<Customization> customizations, final String name) { + Customization result = null; + for (Customization customization : customizations) { + if (name.equals(customization.getName())) { + result = customization; + } + } + return result; + } + + public static <T> T getPropertyValue( + final ICustomizationManager customManager, final Object element, + final FacetOperation property, final ETypedElement eTypedElement, + final Class<T> classs) { + T result = null; + if (element instanceof EObject) { + final EObject eObject = (EObject) element; + try { + if (eTypedElement == null) { + result = customManager.getCustomValueOf(eObject, property, + classs); + } else { + result = customManager.getCustomValueOf(eObject, + eTypedElement, property, classs); + } + } catch (final CustomizationException e) { + Logger.logError( + e, + "Failed to get the value of '" + property.getName() + "' for " + element, //$NON-NLS-1$ //$NON-NLS-2$ + Activator.getDefault()); + } + } + + // Patch to convert StyledString to String in case of customManager provide StyleString and String is expected. + if (result instanceof StyledString && !classs.isInstance(result)) { + result = (T) result.toString(); + } + + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementation.java index 78b7be17826..d2245f98bdd 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementation.java @@ -1,83 +1,83 @@ -/**
- * Copyright (c) 2012, 2013 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- * Gregoire Dupé (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-
-/**
- * @deprecated replaced by {@link SwitchQueryImplementation}
- */
-@Deprecated
-public class ETypedElementSwitchQueryImplementation implements IDerivedTypedElementImplementation {
-
- private static final String PARAM_NAME = "eStructuralFeature"; //$NON-NLS-1$
- private boolean checkResultType = false;
- private final ETypedElementSwitchQuery query;
- private final IDerivedTypedElementManager derivedTEMgr;
-
- public ETypedElementSwitchQueryImplementation(
- final ETypedElementSwitchQuery query,
- final IDerivedTypedElementManager derivedTEMgr) {
- this.query = query;
- this.derivedTEMgr = derivedTEMgr;
- }
-
- public Object getValue(final DerivedTypedElement derivedTypedElt,
- final EObject source, final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- Object result = null;
- EStructuralFeature sfParam = null;
- for (final ParameterValue parameterValue : parameterValues) {
- if (parameterValue.getParameter().getName()
- .equals(PARAM_NAME)) {
- sfParam = (EStructuralFeature) parameterValue.getValue();
- }
-
- }
- // note: sfParam is null when there is no case query (i.e: case is always true)
- for (final ETypedElementCase eTECase : this.query.getCases()) {
- if (eTECase.getCase() == sfParam) {
- result = this.derivedTEMgr.evaluate(eTECase.getValue(), source,
- parameterValues, facetManager);
- }
- }
- return result;
- }
-
- public void setValue(final DerivedTypedElement derivedTypedElt,
- final EObject source, final List<ParameterValue> parameterValues,
- final Object newValue) throws DerivedTypedElementException {
- throw new DerivedTypedElementException("Not implemented"); //$NON-NLS-1$
- }
-
- public boolean getCheckResultType() {
- return this.checkResultType;
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-}
+/** + * Copyright (c) 2012, 2013 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 378271 - [Table] Select Columns To Hide is broken + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + * Gregoire Dupé (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; + +/** + * @deprecated replaced by {@link SwitchQueryImplementation} + */ +@Deprecated +public class ETypedElementSwitchQueryImplementation implements IDerivedTypedElementImplementation { + + private static final String PARAM_NAME = "eStructuralFeature"; //$NON-NLS-1$ + private boolean checkResultType = false; + private final ETypedElementSwitchQuery query; + private final IDerivedTypedElementManager derivedTEMgr; + + public ETypedElementSwitchQueryImplementation( + final ETypedElementSwitchQuery query, + final IDerivedTypedElementManager derivedTEMgr) { + this.query = query; + this.derivedTEMgr = derivedTEMgr; + } + + public Object getValue(final DerivedTypedElement derivedTypedElt, + final EObject source, final List<ParameterValue> parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + Object result = null; + EStructuralFeature sfParam = null; + for (final ParameterValue parameterValue : parameterValues) { + if (parameterValue.getParameter().getName() + .equals(PARAM_NAME)) { + sfParam = (EStructuralFeature) parameterValue.getValue(); + } + + } + // note: sfParam is null when there is no case query (i.e: case is always true) + for (final ETypedElementCase eTECase : this.query.getCases()) { + if (eTECase.getCase() == sfParam) { + result = this.derivedTEMgr.evaluate(eTECase.getValue(), source, + parameterValues, facetManager); + } + } + return result; + } + + public void setValue(final DerivedTypedElement derivedTypedElt, + final EObject source, final List<ParameterValue> parameterValues, + final Object newValue) throws DerivedTypedElementException { + throw new DerivedTypedElementException("Not implemented"); //$NON-NLS-1$ + } + + public boolean getCheckResultType() { + return this.checkResultType; + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementationFactory.java index 949bfc3addf..711f66fec3a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/ETypedElementSwitchQueryImplementationFactory.java @@ -1,45 +1,45 @@ -/**
- * Copyright (c) 2012, 2013 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupé (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.osgi.framework.Bundle;
-
-/**
- * @deprecated replaced by {@link SwitchQueryImplementationFactory}
- */
-@Deprecated
-public class ETypedElementSwitchQueryImplementationFactory implements IDerivedTypedElementImplementationFactory {
-
- public IDerivedTypedElementImplementation create(final Query query, final Bundle bundle, final IDerivedTypedElementManager derivedTEManager)
- throws DerivedTypedElementException {
- if (!(query instanceof ETypedElementSwitchQuery)) {
- throw new IllegalArgumentException("The given DerivedTypedElement does not have a IsOneOfQuery"); //$NON-NLS-1$
- }
- final ETypedElementSwitchQueryImplementation evaluator = new ETypedElementSwitchQueryImplementation(
- (ETypedElementSwitchQuery) query, derivedTEManager);
- evaluator.setCheckResultType(false);
- return evaluator;
- }
-
- public EClass getManagedQueryType() {
- return CustomPackage.eINSTANCE.getETypedElementSwitchQuery();
- }
-
-}
+/** + * Copyright (c) 2012, 2013 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupé (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.osgi.framework.Bundle; + +/** + * @deprecated replaced by {@link SwitchQueryImplementationFactory} + */ +@Deprecated +public class ETypedElementSwitchQueryImplementationFactory implements IDerivedTypedElementImplementationFactory { + + public IDerivedTypedElementImplementation create(final Query query, final Bundle bundle, final IDerivedTypedElementManager derivedTEManager) + throws DerivedTypedElementException { + if (!(query instanceof ETypedElementSwitchQuery)) { + throw new IllegalArgumentException("The given DerivedTypedElement does not have a IsOneOfQuery"); //$NON-NLS-1$ + } + final ETypedElementSwitchQueryImplementation evaluator = new ETypedElementSwitchQueryImplementation( + (ETypedElementSwitchQuery) query, derivedTEManager); + evaluator.setCheckResultType(false); + return evaluator; + } + + public EClass getManagedQueryType() { + return CustomPackage.eINSTANCE.getETypedElementSwitchQuery(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java index aa6a1cc0d9f..25b0a22e301 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementation.java @@ -1,104 +1,104 @@ -/**
- * Copyright (c) 2013 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public class SwitchQueryImplementation implements IQueryImplementation {
-
- private static final String PARAM_NAME = "eStructuralFeature"; //$NON-NLS-1$
-
- private final ETypedElementSwitchQuery query;
-
- private boolean checkResultType = false;
-
- /**
- * @param query
- * @param query
- * the javaQuery to be evaluated
- */
- public SwitchQueryImplementation(final ETypedElementSwitchQuery query) {
- this.query = query;
- }
-
- public Object getValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException {
-
- EStructuralFeature sfParam = null;
- Query subQuery = null;
- for (final ParameterValue parameterValue : parameterValues) {
- if (parameterValue.getParameter().getName().equals(PARAM_NAME)) {
- sfParam = (EStructuralFeature) parameterValue.getValue();
- }
- }
- for (ETypedElementCase eTECase : this.query.getCases()) {
- if (eTECase.getCase() == sfParam) {
- subQuery = eTECase.getValue();
- if (subQuery != null) {
- break;
- }
- }
- }
-
- if (subQuery == null) {
- // The case is not supported: call super operation if possible (Avoid NPEs for unsupported cases)
- if (feature instanceof FacetOperation) {
- FacetOperation operation = (FacetOperation) feature;
- DerivedTypedElement superOperation = operation.getOverride();
- if (superOperation == null) {
- return null;
- }
- if (superOperation instanceof FacetOperation) {
- FacetOperation superFacetOperation = (FacetOperation) superOperation;
-
- // We call the super-operation's query
- subQuery = superFacetOperation.getQuery();
- } else {
- // What does this mean?
- throw new UnsupportedOperationException("Overridden typed element is not a FacetOperation");
- }
- }
-
- if (subQuery == null) {
- return null;
- }
-
- }
-
- // Evaluate the nestedQuery
- return IDerivedTypedElementManager.INSTANCE.evaluate(subQuery, source, parameterValues, facetManager);
- }
-
- public void setValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) throws DerivedTypedElementException {
- throw new UnsupportedOperationException("Not implemented yet"); //$NON-NLS-1$
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
-}
+/** + * Copyright (c) 2013 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementCase; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public class SwitchQueryImplementation implements IQueryImplementation { + + private static final String PARAM_NAME = "eStructuralFeature"; //$NON-NLS-1$ + + private final ETypedElementSwitchQuery query; + + private boolean checkResultType = false; + + /** + * @param query + * @param query + * the javaQuery to be evaluated + */ + public SwitchQueryImplementation(final ETypedElementSwitchQuery query) { + this.query = query; + } + + public Object getValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) throws DerivedTypedElementException { + + EStructuralFeature sfParam = null; + Query subQuery = null; + for (final ParameterValue parameterValue : parameterValues) { + if (parameterValue.getParameter().getName().equals(PARAM_NAME)) { + sfParam = (EStructuralFeature) parameterValue.getValue(); + } + } + for (ETypedElementCase eTECase : this.query.getCases()) { + if (eTECase.getCase() == sfParam) { + subQuery = eTECase.getValue(); + if (subQuery != null) { + break; + } + } + } + + if (subQuery == null) { + // The case is not supported: call super operation if possible (Avoid NPEs for unsupported cases) + if (feature instanceof FacetOperation) { + FacetOperation operation = (FacetOperation) feature; + DerivedTypedElement superOperation = operation.getOverride(); + if (superOperation == null) { + return null; + } + if (superOperation instanceof FacetOperation) { + FacetOperation superFacetOperation = (FacetOperation) superOperation; + + // We call the super-operation's query + subQuery = superFacetOperation.getQuery(); + } else { + // What does this mean? + throw new UnsupportedOperationException("Overridden typed element is not a FacetOperation"); + } + } + + if (subQuery == null) { + return null; + } + + } + + // Evaluate the nestedQuery + return IDerivedTypedElementManager.INSTANCE.evaluate(subQuery, source, parameterValues, facetManager); + } + + public void setValue(final Query query2, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) throws DerivedTypedElementException { + throw new UnsupportedOperationException("Not implemented yet"); //$NON-NLS-1$ + } + + public boolean isCheckResultType() { + return this.checkResultType; + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementationFactory.java index 82e8c0854b4..9600d372ece 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.custom.core/src/org/eclipse/papyrus/emf/facet/custom/core/internal/query/SwitchQueryImplementationFactory.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2013 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
- */
-package org.eclipse.papyrus.emf.facet.custom.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage;
-import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.osgi.framework.Bundle;
-
-public class SwitchQueryImplementationFactory implements
- IQueryImplementationFactory {
-
- public IQueryImplementation create(final Query query, final Bundle bundle,
- final IDerivedTypedElementManager manager)
- throws DerivedTypedElementException {
- if (!(query instanceof ETypedElementSwitchQuery)) {
- throw new IllegalArgumentException("The given DerivedTypedElement does not have a ETypedElementSwitchQuery"); //$NON-NLS-1$
- }
- final ETypedElementSwitchQuery switchQuery = (ETypedElementSwitchQuery) query;
- return new SwitchQueryImplementation(switchQuery);
- }
-
- public EClass getManagedQueryType() {
- return CustomPackage.eINSTANCE.getETypedElementSwitchQuery();
- }
-}
+/** + * Copyright (c) 2013 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point + */ +package org.eclipse.papyrus.emf.facet.custom.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.CustomPackage; +import org.eclipse.papyrus.emf.facet.custom.metamodel.v0_2_0.custom.ETypedElementSwitchQuery; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.osgi.framework.Bundle; + +public class SwitchQueryImplementationFactory implements + IQueryImplementationFactory { + + public IQueryImplementation create(final Query query, final Bundle bundle, + final IDerivedTypedElementManager manager) + throws DerivedTypedElementException { + if (!(query instanceof ETypedElementSwitchQuery)) { + throw new IllegalArgumentException("The given DerivedTypedElement does not have a ETypedElementSwitchQuery"); //$NON-NLS-1$ + } + final ETypedElementSwitchQuery switchQuery = (ETypedElementSwitchQuery) query; + return new SwitchQueryImplementation(switchQuery); + } + + public EClass getManagedQueryType() { + return CustomPackage.eINSTANCE.getETypedElementSwitchQuery(); + } +} |