| /** |
| * Copyright (c) 2008, 2015 IBM Corporation and others. |
| * |
| * This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| */ |
| package org.eclipse.e4.ui.model.application.ui.menu.impl; |
| |
| import java.util.Collection; |
| import java.util.List; |
| import java.util.Map; |
| import org.eclipse.e4.core.contexts.IEclipseContext; |
| import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl; |
| import org.eclipse.e4.ui.model.application.impl.StringToStringMapImpl; |
| import org.eclipse.e4.ui.model.application.ui.MContext; |
| import org.eclipse.e4.ui.model.application.ui.impl.UiPackageImpl; |
| import org.eclipse.e4.ui.model.application.ui.menu.MPopupMenu; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.common.util.EMap; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; |
| import org.eclipse.emf.ecore.util.EcoreEMap; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Popup Menu</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.impl.PopupMenuImpl#getContext <em>Context</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.impl.PopupMenuImpl#getVariables <em>Variables</em>}</li> |
| * <li>{@link org.eclipse.e4.ui.model.application.ui.menu.impl.PopupMenuImpl#getProperties <em>Properties</em>}</li> |
| * </ul> |
| * |
| * @since 1.0 |
| * @generated |
| */ |
| public class PopupMenuImpl extends MenuImpl implements MPopupMenu { |
| /** |
| * The default value of the '{@link #getContext() <em>Context</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getContext() |
| * @generated |
| * @ordered |
| */ |
| protected static final IEclipseContext CONTEXT_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getContext() <em>Context</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getContext() |
| * @generated |
| * @ordered |
| */ |
| protected IEclipseContext context = CONTEXT_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getVariables() <em>Variables</em>}' attribute list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getVariables() |
| * @generated |
| * @ordered |
| */ |
| protected EList<String> variables; |
| |
| /** |
| * The cached value of the '{@link #getProperties() <em>Properties</em>}' map. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getProperties() |
| * @generated |
| * @ordered |
| */ |
| protected EMap<String, String> properties; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected PopupMenuImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return MenuPackageImpl.Literals.POPUP_MENU; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public IEclipseContext getContext() { |
| return context; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setContext(IEclipseContext newContext) { |
| IEclipseContext oldContext = context; |
| context = newContext; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, MenuPackageImpl.POPUP_MENU__CONTEXT, oldContext, |
| context)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public List<String> getVariables() { |
| if (variables == null) { |
| variables = new EDataTypeUniqueEList<String>(String.class, this, MenuPackageImpl.POPUP_MENU__VARIABLES); |
| } |
| return variables; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Map<String, String> getProperties() { |
| if (properties == null) { |
| properties = new EcoreEMap<String, String>(ApplicationPackageImpl.Literals.STRING_TO_STRING_MAP, |
| StringToStringMapImpl.class, this, MenuPackageImpl.POPUP_MENU__PROPERTIES); |
| } |
| return properties.map(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| return ((InternalEList<?>) ((EMap.InternalMapView<String, String>) getProperties()).eMap()) |
| .basicRemove(otherEnd, msgs); |
| default: |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case MenuPackageImpl.POPUP_MENU__CONTEXT: |
| return getContext(); |
| case MenuPackageImpl.POPUP_MENU__VARIABLES: |
| return getVariables(); |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| if (coreType) |
| return ((EMap.InternalMapView<String, String>) getProperties()).eMap(); |
| else |
| return getProperties(); |
| default: |
| return super.eGet(featureID, resolve, coreType); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case MenuPackageImpl.POPUP_MENU__CONTEXT: |
| setContext((IEclipseContext) newValue); |
| return; |
| case MenuPackageImpl.POPUP_MENU__VARIABLES: |
| getVariables().clear(); |
| getVariables().addAll((Collection<? extends String>) newValue); |
| return; |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| ((EStructuralFeature.Setting) ((EMap.InternalMapView<String, String>) getProperties()).eMap()) |
| .set(newValue); |
| return; |
| default: |
| super.eSet(featureID, newValue); |
| return; |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case MenuPackageImpl.POPUP_MENU__CONTEXT: |
| setContext(CONTEXT_EDEFAULT); |
| return; |
| case MenuPackageImpl.POPUP_MENU__VARIABLES: |
| getVariables().clear(); |
| return; |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| getProperties().clear(); |
| return; |
| default: |
| super.eUnset(featureID); |
| return; |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case MenuPackageImpl.POPUP_MENU__CONTEXT: |
| return CONTEXT_EDEFAULT == null ? context != null : !CONTEXT_EDEFAULT.equals(context); |
| case MenuPackageImpl.POPUP_MENU__VARIABLES: |
| return variables != null && !variables.isEmpty(); |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| return properties != null && !properties.isEmpty(); |
| default: |
| return super.eIsSet(featureID); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == MContext.class) { |
| switch (derivedFeatureID) { |
| case MenuPackageImpl.POPUP_MENU__CONTEXT: |
| return UiPackageImpl.CONTEXT__CONTEXT; |
| case MenuPackageImpl.POPUP_MENU__VARIABLES: |
| return UiPackageImpl.CONTEXT__VARIABLES; |
| case MenuPackageImpl.POPUP_MENU__PROPERTIES: |
| return UiPackageImpl.CONTEXT__PROPERTIES; |
| default: |
| return -1; |
| } |
| } |
| return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| if (baseClass == MContext.class) { |
| switch (baseFeatureID) { |
| case UiPackageImpl.CONTEXT__CONTEXT: |
| return MenuPackageImpl.POPUP_MENU__CONTEXT; |
| case UiPackageImpl.CONTEXT__VARIABLES: |
| return MenuPackageImpl.POPUP_MENU__VARIABLES; |
| case UiPackageImpl.CONTEXT__PROPERTIES: |
| return MenuPackageImpl.POPUP_MENU__PROPERTIES; |
| default: |
| return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() { |
| if (eIsProxy()) |
| return super.toString(); |
| |
| StringBuilder result = new StringBuilder(super.toString()); |
| result.append(" (context: "); //$NON-NLS-1$ |
| result.append(context); |
| result.append(", variables: "); //$NON-NLS-1$ |
| result.append(variables); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //PopupMenuImpl |