/*******************************************************************************
* Copyright (c) 2008 Hallvard Traetteberg.
* 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:
* Hallvard Traetteberg - initial API and implementation
******************************************************************************/
/**
* <copyright>
* </copyright>
*
* $Id: CheckBoxImpl.java,v 1.4 2009/10/23 12:40:32 htraetteb Exp $
*/
package org.eclipse.e4.tm.widgets.impl;
import org.eclipse.e4.tm.widgets.CheckBox;
import org.eclipse.e4.tm.widgets.WidgetsPackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Check Box</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.e4.tm.widgets.impl.CheckBoxImpl#isSelection <em>Selection</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class CheckBoxImpl extends ButtonImpl implements CheckBox {
/**
* 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;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CheckBoxImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return WidgetsPackage.Literals.CHECK_BOX;
}
/**
* <!-- 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, WidgetsPackage.CHECK_BOX__SELECTION, oldSelection, selection));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case WidgetsPackage.CHECK_BOX__SELECTION:
return isSelection();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case WidgetsPackage.CHECK_BOX__SELECTION:
setSelection((Boolean)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case WidgetsPackage.CHECK_BOX__SELECTION:
setSelection(SELECTION_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case WidgetsPackage.CHECK_BOX__SELECTION:
return selection != SELECTION_EDEFAULT;
}
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(" (selection: ");
result.append(selection);
result.append(')');
return result.toString();
}
} //CheckBoxImpl