| /* |
| * Copyright (c) 2014, 2015 Eike Stepper (Berlin, Germany) 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: |
| * Eike Stepper - initial API and implementation |
| */ |
| package org.eclipse.oomph.setup.mylyn.impl; |
| |
| import org.eclipse.oomph.base.impl.ModelElementImpl; |
| import org.eclipse.oomph.setup.mylyn.MylynPackage; |
| import org.eclipse.oomph.setup.mylyn.MylynQueriesTask; |
| import org.eclipse.oomph.setup.mylyn.Query; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| 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.EcoreEMap; |
| import org.eclipse.emf.ecore.util.EcoreUtil; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Query</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.oomph.setup.mylyn.impl.QueryImpl#getTask <em>Task</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.mylyn.impl.QueryImpl#getSummary <em>Summary</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.mylyn.impl.QueryImpl#getURL <em>URL</em>}</li> |
| * <li>{@link org.eclipse.oomph.setup.mylyn.impl.QueryImpl#getAttributes <em>Attributes</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class QueryImpl extends ModelElementImpl implements Query |
| { |
| /** |
| * The default value of the '{@link #getSummary() <em>Summary</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSummary() |
| * @generated |
| * @ordered |
| */ |
| protected static final String SUMMARY_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getSummary() <em>Summary</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getSummary() |
| * @generated |
| * @ordered |
| */ |
| protected String summary = SUMMARY_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getURL() <em>URL</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getURL() |
| * @generated |
| * @ordered |
| */ |
| protected static final String URL_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getURL() <em>URL</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getURL() |
| * @generated |
| * @ordered |
| */ |
| protected String uRL = URL_EDEFAULT; |
| |
| /** |
| * The cached value of the '{@link #getAttributes() <em>Attributes</em>}' map. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getAttributes() |
| * @generated |
| * @ordered |
| */ |
| protected EMap<String, String> attributes; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected QueryImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return MylynPackage.Literals.QUERY; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public MylynQueriesTask getTask() |
| { |
| if (eContainerFeatureID() != MylynPackage.QUERY__TASK) |
| { |
| return null; |
| } |
| return (MylynQueriesTask)eInternalContainer(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetTask(MylynQueriesTask newTask, NotificationChain msgs) |
| { |
| msgs = eBasicSetContainer((InternalEObject)newTask, MylynPackage.QUERY__TASK, msgs); |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTask(MylynQueriesTask newTask) |
| { |
| if (newTask != eInternalContainer() || eContainerFeatureID() != MylynPackage.QUERY__TASK && newTask != null) |
| { |
| if (EcoreUtil.isAncestor(this, newTask)) |
| { |
| throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| } |
| NotificationChain msgs = null; |
| if (eInternalContainer() != null) |
| { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| if (newTask != null) |
| { |
| msgs = ((InternalEObject)newTask).eInverseAdd(this, MylynPackage.MYLYN_QUERIES_TASK__QUERIES, MylynQueriesTask.class, msgs); |
| } |
| msgs = basicSetTask(newTask, msgs); |
| if (msgs != null) |
| { |
| msgs.dispatch(); |
| } |
| } |
| else if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, MylynPackage.QUERY__TASK, newTask, newTask)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getSummary() |
| { |
| return summary; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSummary(String newSummary) |
| { |
| String oldSummary = summary; |
| summary = newSummary; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, MylynPackage.QUERY__SUMMARY, oldSummary, summary)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getURL() |
| { |
| return uRL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setURL(String newURL) |
| { |
| String oldURL = uRL; |
| uRL = newURL; |
| if (eNotificationRequired()) |
| { |
| eNotify(new ENotificationImpl(this, Notification.SET, MylynPackage.QUERY__URL, oldURL, uRL)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public EMap<String, String> getAttributes() |
| { |
| if (attributes == null) |
| { |
| attributes = new EcoreEMap<String, String>(MylynPackage.Literals.QUERY_ATTRIBUTE, QueryAttributeImpl.class, this, MylynPackage.QUERY__ATTRIBUTES); |
| } |
| return attributes; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| if (eInternalContainer() != null) |
| { |
| msgs = eBasicRemoveFromContainer(msgs); |
| } |
| return basicSetTask((MylynQueriesTask)otherEnd, msgs); |
| } |
| return super.eInverseAdd(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| return basicSetTask(null, msgs); |
| case MylynPackage.QUERY__ATTRIBUTES: |
| return ((InternalEList<?>)getAttributes()).basicRemove(otherEnd, msgs); |
| } |
| return super.eInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) |
| { |
| switch (eContainerFeatureID()) |
| { |
| case MylynPackage.QUERY__TASK: |
| return eInternalContainer().eInverseRemove(this, MylynPackage.MYLYN_QUERIES_TASK__QUERIES, MylynQueriesTask.class, msgs); |
| } |
| return super.eBasicRemoveFromContainerFeature(msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| return getTask(); |
| case MylynPackage.QUERY__SUMMARY: |
| return getSummary(); |
| case MylynPackage.QUERY__URL: |
| return getURL(); |
| case MylynPackage.QUERY__ATTRIBUTES: |
| if (coreType) |
| { |
| return getAttributes(); |
| } |
| else |
| { |
| return getAttributes().map(); |
| } |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| setTask((MylynQueriesTask)newValue); |
| return; |
| case MylynPackage.QUERY__SUMMARY: |
| setSummary((String)newValue); |
| return; |
| case MylynPackage.QUERY__URL: |
| setURL((String)newValue); |
| return; |
| case MylynPackage.QUERY__ATTRIBUTES: |
| ((EStructuralFeature.Setting)getAttributes()).set(newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| setTask((MylynQueriesTask)null); |
| return; |
| case MylynPackage.QUERY__SUMMARY: |
| setSummary(SUMMARY_EDEFAULT); |
| return; |
| case MylynPackage.QUERY__URL: |
| setURL(URL_EDEFAULT); |
| return; |
| case MylynPackage.QUERY__ATTRIBUTES: |
| getAttributes().clear(); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case MylynPackage.QUERY__TASK: |
| return getTask() != null; |
| case MylynPackage.QUERY__SUMMARY: |
| return SUMMARY_EDEFAULT == null ? summary != null : !SUMMARY_EDEFAULT.equals(summary); |
| case MylynPackage.QUERY__URL: |
| return URL_EDEFAULT == null ? uRL != null : !URL_EDEFAULT.equals(uRL); |
| case MylynPackage.QUERY__ATTRIBUTES: |
| return attributes != null && !attributes.isEmpty(); |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public String toString() |
| { |
| if (eIsProxy()) |
| { |
| return super.toString(); |
| } |
| |
| StringBuffer result = new StringBuffer(super.toString()); |
| result.append(" (summary: "); |
| result.append(summary); |
| result.append(", uRL: "); |
| result.append(uRL); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } // QueryImpl |