From d0d5df142ca0087f00b5fbd88ab8d91973428b10 Mon Sep 17 00:00:00 2001 From: René Brandstetter Date: Thu, 21 Nov 2013 16:38:25 +0100 Subject: Bug 419888 - [Model] [API] Extend the EModelService#createModelElement(*) to read EMF extensions Fix of the TODO's mentinoned in the implementation. -) remove if-else generator until a performance problem arises -) remove deprecated check, because this should be the job of the compiler Change-Id: Id4ce967a658a1a29b68e6d1c85518db634abcffa Signed-off-by: René Brandstetter --- .../GenericMApplicationElementFactoryImpl.java | 36 ---------------------- .../e4/ui/internal/workbench/ModelServiceImpl.java | 8 ----- 2 files changed, 44 deletions(-) diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/GenericMApplicationElementFactoryImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/GenericMApplicationElementFactoryImpl.java index f3358b33f32..d24b2b81df6 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/GenericMApplicationElementFactoryImpl.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/GenericMApplicationElementFactoryImpl.java @@ -25,7 +25,6 @@ import org.eclipse.core.runtime.IRegistryEventListener; import org.eclipse.e4.ui.model.application.MApplicationElement; import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl; import org.eclipse.e4.ui.workbench.modeling.EModelService; -import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; @@ -90,47 +89,12 @@ final class GenericMApplicationElementFactoryImpl { public EObject createEObject(Class clazz) { EClass eClass = emfGeneratedPackages.getEClass(clazz); if (eClass != null) { - checkDeprecation(eClass); return EcoreUtil.create(eClass); } return null; } - /** - * Checks if the given {@link EClass} is marked as "deprecated". - * - *

- * The method will check if the {@link EClass} was annotated with - * {@code "http://www.eclipse.org/ui/2010/UIModel/application/deprecated"} and if so a warning - * will be logged via the {@link LogService}. - *

- * - * @param eClass - * the class to check - */ - private static void checkDeprecation(EClass eClass) { - if (eClass == null) - return; - - // TODO (if you want to keep it): find a good place for a constant variable and a valid - // "source" value - EAnnotation deprecated = eClass - .getEAnnotation("http://www.eclipse.org/ui/2010/UIModel/application/deprecated"); //$NON-NLS-1$ - if (deprecated != null) { - StringBuilder sb = new StringBuilder("The element '").append(eClass.getInstanceTypeName()).append("' is already deprecated!"); //$NON-NLS-1$ //$NON-NLS-2$ - - // TODO (if you want to keep it): adapted it the way you need it (or remove it, - // because it was just a show-case of what would be possible) - String since = deprecated.getDetails().get("since"); //$NON-NLS-1$ - if (since != null) { - sb.append(" (since version: ").append(since).append(')'); //$NON-NLS-1$ - } - - Activator.log(LogService.LOG_WARNING, sb.toString()); - } - } - /** * An Eclipse ExtensionRegistry-Listener which will build the required map to find the * {@link EClass} for the given {@link Class}. diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java index a22b9206af0..9b851ded3b5 100644 --- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java +++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java @@ -115,14 +115,6 @@ public class ModelServiceImpl implements EModelService { throw new NullPointerException("Argument cannot be null."); //$NON-NLS-1$ } - /* - * TODO: We can even tune the performance of this method if we add the previous generated - * if-else-if-else... block. The eObjectFactory#createEObject(Class) could afterwards be the - * fallback if a user specific model element should be created. But for this we need to - * adapt the generator of Paul Elder and to be honest I wasn't able to find it (either its - * call during the build nor its template) ;-( . - */ - T back = (T) mApplicationElementFactory.createEObject(elementType); if (back != null) { return back; -- cgit v1.2.3