blob: 8aa67ce8f397d620468f2caf8c6c2b2dee2357be [file] [log] [blame]
/***********************************************************************************************************************
* Copyright (c) 2010 Attensity Europe GmbH.
* 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
**********************************************************************************************************************/
package org.eclipse.smila.processing.designer.model.processor.impl;
import java.util.Collection;
import java.util.List;
import org.eclipse.bpel.model.impl.ExtensibleElementImpl;
import org.eclipse.bpel.model.util.ReconciliationHelper;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.*;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.smila.processing.designer.model.processor.*;
import org.eclipse.smila.processing.designer.model.processor.util.DOMUtils;
import org.eclipse.smila.processing.designer.model.processor.util.ProcessorConstants;
import org.w3c.dom.Element;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Pipelet Configuration</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.smila.processing.designer.model.processor.impl.PipeletConfigurationImpl#getProperties <em>Properties</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PipeletConfigurationImpl extends ExtensibleElementImpl implements PipeletConfiguration
{
/**
* The cached value of the '{@link #getProperties() <em>Properties</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getProperties()
* @generated
* @ordered
*/
protected EList<Property> properties;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PipeletConfigurationImpl()
{
super();
}
@Override
protected void adoptContent(EReference reference, Object object)
{
if (!ReconciliationHelper.isLoading(this) && object instanceof Property)
{
// Modified ReconciliationHelper.adoptChild for our use case
Property property = (Property) object;
boolean oldUpdatingDom = isUpdatingDOM();
try
{
setUpdatingDOM(true);
if (getContainer() instanceof InvokePipeletImpl && ((InvokePipeletImpl) getContainer()).fixContent())
{
Element parentElement = getElement();
Element propertyElement = property.getElement();
if (propertyElement == null)
{
propertyElement =
parentElement.getOwnerDocument().createElementNS(ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_PROPERTY);
property.setElement(propertyElement);
propertyElement.setPrefix(ProcessorPackage.eNS_PREFIX);
if (property.getName() != null)
{
propertyElement.setAttribute(ProcessorConstants.ATT_NAME, property.getName());
}
}
if (propertyElement.getParentNode() != parentElement)
{
int index = properties.indexOf(property);
List<Element> elements =
DOMUtils.getChildElements(parentElement, ProcessorPackage.eNS_URI,
ProcessorConstants.NODE_PROPERTY);
DOMUtils.insertIndented(parentElement, propertyElement,
index >= elements.size() ? null : elements.get(index));
}
}
}
finally
{
setUpdatingDOM(oldUpdatingDom);
}
}
super.adoptContent(reference, object);
}
@Override
protected void orphanContent(EReference reference, Object obj)
{
if (obj instanceof Property && !isReconciling())
{
ReconciliationHelper.orphanChild(this, (Property) obj);
}
super.orphanContent(reference, obj);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return ProcessorPackage.Literals.PIPELET_CONFIGURATION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public EList<Property> getProperties()
{
if (properties == null)
{
properties =
new EObjectContainmentEList<Property>(Property.class, this,
ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES);
}
return properties;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES :
return ((InternalEList<?>) getProperties()).basicRemove(otherEnd, msgs);
}
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 ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES :
return getProperties();
}
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 ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES :
getProperties().clear();
getProperties().addAll((Collection<? extends Property>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES :
getProperties().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case ProcessorPackage.PIPELET_CONFIGURATION__PROPERTIES :
return properties != null && !properties.isEmpty();
}
return super.eIsSet(featureID);
}
} //PipeletConfigurationImpl