1 /** 2 * Copyright (c) 2008, 2015 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 */ 14 package org.eclipse.e4.ui.model.application.ui.impl; 15 16 import org.eclipse.e4.ui.model.application.ui.MCoreExpression; 17 import org.eclipse.e4.ui.model.application.ui.MImperativeExpression; 18 import org.eclipse.e4.ui.model.application.ui.MUiFactory; 19 import org.eclipse.e4.ui.model.application.ui.SideValue; 20 import org.eclipse.emf.ecore.EClass; 21 import org.eclipse.emf.ecore.EDataType; 22 import org.eclipse.emf.ecore.EObject; 23 import org.eclipse.emf.ecore.EPackage; 24 import org.eclipse.emf.ecore.impl.EFactoryImpl; 25 import org.eclipse.emf.ecore.plugin.EcorePlugin; 26 27 /** 28 * <!-- begin-user-doc --> 29 * An implementation of the model <b>Factory</b>. 30 * <!-- end-user-doc --> 31 * @generated 32 */ 33 public class UiFactoryImpl extends EFactoryImpl implements MUiFactory { 34 /** 35 * The singleton instance of the factory. 36 * <!-- begin-user-doc --> 37 * <!-- end-user-doc --> 38 * @generated 39 */ 40 public static final UiFactoryImpl eINSTANCE = init(); 41 42 /** 43 * Creates the default factory implementation. 44 * <!-- begin-user-doc --> 45 * <!-- end-user-doc --> 46 * @generated 47 */ init()48 public static UiFactoryImpl init() { 49 try { 50 UiFactoryImpl theUiFactory = (UiFactoryImpl) EPackage.Registry.INSTANCE.getEFactory(UiPackageImpl.eNS_URI); 51 if (theUiFactory != null) { 52 return theUiFactory; 53 } 54 } catch (Exception exception) { 55 EcorePlugin.INSTANCE.log(exception); 56 } 57 return new UiFactoryImpl(); 58 } 59 60 /** 61 * Creates an instance of the factory. 62 * <!-- begin-user-doc --> 63 * <!-- end-user-doc --> 64 * @generated 65 */ UiFactoryImpl()66 public UiFactoryImpl() { 67 super(); 68 } 69 70 /** 71 * <!-- begin-user-doc --> 72 * <!-- end-user-doc --> 73 * @generated 74 */ 75 @Override create(EClass eClass)76 public EObject create(EClass eClass) { 77 switch (eClass.getClassifierID()) { 78 case UiPackageImpl.CORE_EXPRESSION: 79 return (EObject) createCoreExpression(); 80 case UiPackageImpl.IMPERATIVE_EXPRESSION: 81 return (EObject) createImperativeExpression(); 82 default: 83 throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ 84 } 85 } 86 87 /** 88 * <!-- begin-user-doc --> 89 * <!-- end-user-doc --> 90 * @generated 91 */ 92 @Override createFromString(EDataType eDataType, String initialValue)93 public Object createFromString(EDataType eDataType, String initialValue) { 94 switch (eDataType.getClassifierID()) { 95 case UiPackageImpl.SIDE_VALUE: 96 return createSideValueFromString(eDataType, initialValue); 97 default: 98 throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ 99 } 100 } 101 102 /** 103 * <!-- begin-user-doc --> 104 * <!-- end-user-doc --> 105 * @generated 106 */ 107 @Override convertToString(EDataType eDataType, Object instanceValue)108 public String convertToString(EDataType eDataType, Object instanceValue) { 109 switch (eDataType.getClassifierID()) { 110 case UiPackageImpl.SIDE_VALUE: 111 return convertSideValueToString(eDataType, instanceValue); 112 default: 113 throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ 114 } 115 } 116 117 /** 118 * <!-- begin-user-doc --> 119 * <!-- end-user-doc --> 120 * @since 1.0 121 * @generated 122 */ 123 @Override createCoreExpression()124 public MCoreExpression createCoreExpression() { 125 return new CoreExpressionImpl(); 126 } 127 128 /** 129 * <!-- begin-user-doc --> 130 * <!-- end-user-doc --> 131 * @generated 132 */ 133 @Override createImperativeExpression()134 public MImperativeExpression createImperativeExpression() { 135 return new ImperativeExpressionImpl(); 136 } 137 138 /** 139 * <!-- begin-user-doc --> 140 * <!-- end-user-doc --> 141 * @since 1.0 142 * @generated 143 */ createSideValueFromString(EDataType eDataType, String initialValue)144 public SideValue createSideValueFromString(EDataType eDataType, String initialValue) { 145 SideValue result = SideValue.get(initialValue); 146 if (result == null) 147 throw new IllegalArgumentException( 148 "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 149 return result; 150 } 151 152 /** 153 * <!-- begin-user-doc --> 154 * <!-- end-user-doc --> 155 * @since 1.0 156 * @generated 157 */ convertSideValueToString(EDataType eDataType, Object instanceValue)158 public String convertSideValueToString(EDataType eDataType, Object instanceValue) { 159 return instanceValue == null ? null : instanceValue.toString(); 160 } 161 162 /** 163 * <!-- begin-user-doc --> 164 * <!-- end-user-doc --> 165 * @generated 166 */ getUiPackage()167 public UiPackageImpl getUiPackage() { 168 return (UiPackageImpl) getEPackage(); 169 } 170 171 } //UiFactoryImpl 172