blob: b8bc02719689a3f106039a8b7df78bf6dfdfd6ab [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2019 Xored Software Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.rcptt.tesla.core.ui.impl;
import java.util.Collection;
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.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.rcptt.tesla.core.ui.Cell;
import org.eclipse.rcptt.tesla.core.ui.Item;
import org.eclipse.rcptt.tesla.core.ui.UiPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Item</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ItemImpl#getCaption <em>Caption</em>}</li>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ItemImpl#isSelection <em>Selection</em>}</li>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ItemImpl#isEnablement <em>Enablement</em>}</li>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ItemImpl#getIndex <em>Index</em>}</li>
* <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ItemImpl#getCells <em>Cells</em>}</li>
* </ul>
*
* @generated
*/
public class ItemImpl extends WidgetImpl implements Item {
/**
* The default value of the '{@link #getCaption() <em>Caption</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getCaption()
* @generated
* @ordered
*/
protected static final String CAPTION_EDEFAULT = null;
/**
* The cached value of the '{@link #getCaption() <em>Caption</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getCaption()
* @generated
* @ordered
*/
protected String caption = CAPTION_EDEFAULT;
/**
* The default value of the '{@link #isSelection() <em>Selection</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isSelection()
* @generated
* @ordered
*/
protected static final boolean SELECTION_EDEFAULT = false;
/**
* The cached value of the '{@link #isSelection() <em>Selection</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isSelection()
* @generated
* @ordered
*/
protected boolean selection = SELECTION_EDEFAULT;
/**
* The default value of the '{@link #isEnablement() <em>Enablement</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isEnablement()
* @generated
* @ordered
*/
protected static final boolean ENABLEMENT_EDEFAULT = false;
/**
* The cached value of the '{@link #isEnablement() <em>Enablement</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #isEnablement()
* @generated
* @ordered
*/
protected boolean enablement = ENABLEMENT_EDEFAULT;
/**
* The default value of the '{@link #getIndex() <em>Index</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getIndex()
* @generated
* @ordered
*/
protected static final int INDEX_EDEFAULT = 0;
/**
* The cached value of the '{@link #getIndex() <em>Index</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getIndex()
* @generated
* @ordered
*/
protected int index = INDEX_EDEFAULT;
/**
* The cached value of the '{@link #getCells() <em>Cells</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getCells()
* @generated
* @ordered
*/
protected EList<Cell> cells;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ItemImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return UiPackage.Literals.ITEM;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public String getCaption() {
return caption;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setCaption(String newCaption) {
String oldCaption = caption;
caption = newCaption;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.ITEM__CAPTION, oldCaption, caption));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public boolean isSelection() {
return selection;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setSelection(boolean newSelection) {
boolean oldSelection = selection;
selection = newSelection;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.ITEM__SELECTION, oldSelection, selection));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public boolean isEnablement() {
return enablement;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setEnablement(boolean newEnablement) {
boolean oldEnablement = enablement;
enablement = newEnablement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.ITEM__ENABLEMENT, oldEnablement, enablement));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public int getIndex() {
return index;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setIndex(int newIndex) {
int oldIndex = index;
index = newIndex;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.ITEM__INDEX, oldIndex, index));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<Cell> getCells() {
if (cells == null) {
cells = new EObjectContainmentEList<Cell>(Cell.class, this, UiPackage.ITEM__CELLS);
}
return cells;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case UiPackage.ITEM__CELLS:
return ((InternalEList<?>)getCells()).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 UiPackage.ITEM__CAPTION:
return getCaption();
case UiPackage.ITEM__SELECTION:
return isSelection();
case UiPackage.ITEM__ENABLEMENT:
return isEnablement();
case UiPackage.ITEM__INDEX:
return getIndex();
case UiPackage.ITEM__CELLS:
return getCells();
}
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 UiPackage.ITEM__CAPTION:
setCaption((String)newValue);
return;
case UiPackage.ITEM__SELECTION:
setSelection((Boolean)newValue);
return;
case UiPackage.ITEM__ENABLEMENT:
setEnablement((Boolean)newValue);
return;
case UiPackage.ITEM__INDEX:
setIndex((Integer)newValue);
return;
case UiPackage.ITEM__CELLS:
getCells().clear();
getCells().addAll((Collection<? extends Cell>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case UiPackage.ITEM__CAPTION:
setCaption(CAPTION_EDEFAULT);
return;
case UiPackage.ITEM__SELECTION:
setSelection(SELECTION_EDEFAULT);
return;
case UiPackage.ITEM__ENABLEMENT:
setEnablement(ENABLEMENT_EDEFAULT);
return;
case UiPackage.ITEM__INDEX:
setIndex(INDEX_EDEFAULT);
return;
case UiPackage.ITEM__CELLS:
getCells().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case UiPackage.ITEM__CAPTION:
return CAPTION_EDEFAULT == null ? caption != null : !CAPTION_EDEFAULT.equals(caption);
case UiPackage.ITEM__SELECTION:
return selection != SELECTION_EDEFAULT;
case UiPackage.ITEM__ENABLEMENT:
return enablement != ENABLEMENT_EDEFAULT;
case UiPackage.ITEM__INDEX:
return index != INDEX_EDEFAULT;
case UiPackage.ITEM__CELLS:
return cells != null && !cells.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(" (caption: ");
result.append(caption);
result.append(", selection: ");
result.append(selection);
result.append(", enablement: ");
result.append(enablement);
result.append(", index: ");
result.append(index);
result.append(')');
return result.toString();
}
} // ItemImpl