| /******************************************************************************* |
| * 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 v1.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 org.eclipse.rcptt.tesla.core.ui.Button; |
| import org.eclipse.rcptt.tesla.core.ui.ButtonKind; |
| import org.eclipse.rcptt.tesla.core.ui.Image; |
| import org.eclipse.rcptt.tesla.core.ui.UiPackage; |
| |
| import org.eclipse.rcptt.tesla.core.ui.WithImage; |
| import org.eclipse.emf.common.notify.Notification; |
| |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.ecore.EClass; |
| |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Button</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#getImage <em>Image</em>}</li> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#getCaption <em>Caption</em>}</li> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#getTooltip <em>Tooltip</em>}</li> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#isSelected <em>Selected</em>}</li> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#isGrayed <em>Grayed</em>}</li> |
| * <li>{@link org.eclipse.rcptt.tesla.core.ui.impl.ButtonImpl#getKind <em>Kind</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class ButtonImpl extends ControlImpl implements Button { |
| /** |
| * The cached value of the '{@link #getImage() <em>Image</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getImage() |
| * @generated |
| * @ordered |
| */ |
| protected Image image; |
| |
| /** |
| * 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 #getTooltip() <em>Tooltip</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTooltip() |
| * @generated |
| * @ordered |
| */ |
| protected static final String TOOLTIP_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getTooltip() <em>Tooltip</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getTooltip() |
| * @generated |
| * @ordered |
| */ |
| protected String tooltip = TOOLTIP_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #isSelected() <em>Selected</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isSelected() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean SELECTED_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isSelected() <em>Selected</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isSelected() |
| * @generated |
| * @ordered |
| */ |
| protected boolean selected = SELECTED_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #isGrayed() <em>Grayed</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isGrayed() |
| * @generated |
| * @ordered |
| */ |
| protected static final boolean GRAYED_EDEFAULT = false; |
| |
| /** |
| * The cached value of the '{@link #isGrayed() <em>Grayed</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #isGrayed() |
| * @generated |
| * @ordered |
| */ |
| protected boolean grayed = GRAYED_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKind() |
| * @generated |
| * @ordered |
| */ |
| protected static final ButtonKind KIND_EDEFAULT = ButtonKind.PUSH; |
| |
| /** |
| * The cached value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getKind() |
| * @generated |
| * @ordered |
| */ |
| protected ButtonKind kind = KIND_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected ButtonImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return UiPackage.Literals.BUTTON; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Image getImage() { |
| return image; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetImage(Image newImage, NotificationChain msgs) { |
| Image oldImage = image; |
| image = newImage; |
| if (eNotificationRequired()) { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__IMAGE, oldImage, newImage); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setImage(Image newImage) { |
| if (newImage != image) { |
| NotificationChain msgs = null; |
| if (image != null) |
| msgs = ((InternalEObject)image).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UiPackage.BUTTON__IMAGE, null, msgs); |
| if (newImage != null) |
| msgs = ((InternalEObject)newImage).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UiPackage.BUTTON__IMAGE, null, msgs); |
| msgs = basicSetImage(newImage, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__IMAGE, newImage, newImage)); |
| } |
| |
| /** |
| * <!-- 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.BUTTON__CAPTION, oldCaption, caption)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public String getTooltip() { |
| return tooltip; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setTooltip(String newTooltip) { |
| String oldTooltip = tooltip; |
| tooltip = newTooltip; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__TOOLTIP, oldTooltip, tooltip)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isSelected() { |
| return selected; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setSelected(boolean newSelected) { |
| boolean oldSelected = selected; |
| selected = newSelected; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__SELECTED, oldSelected, selected)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public boolean isGrayed() { |
| return grayed; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setGrayed(boolean newGrayed) { |
| boolean oldGrayed = grayed; |
| grayed = newGrayed; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__GRAYED, oldGrayed, grayed)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ButtonKind getKind() { |
| return kind; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public void setKind(ButtonKind newKind) { |
| ButtonKind oldKind = kind; |
| kind = newKind == null ? KIND_EDEFAULT : newKind; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, UiPackage.BUTTON__KIND, oldKind, kind)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| switch (featureID) { |
| case UiPackage.BUTTON__IMAGE: |
| return basicSetImage(null, 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.BUTTON__IMAGE: |
| return getImage(); |
| case UiPackage.BUTTON__CAPTION: |
| return getCaption(); |
| case UiPackage.BUTTON__TOOLTIP: |
| return getTooltip(); |
| case UiPackage.BUTTON__SELECTED: |
| return isSelected(); |
| case UiPackage.BUTTON__GRAYED: |
| return isGrayed(); |
| case UiPackage.BUTTON__KIND: |
| return getKind(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case UiPackage.BUTTON__IMAGE: |
| setImage((Image)newValue); |
| return; |
| case UiPackage.BUTTON__CAPTION: |
| setCaption((String)newValue); |
| return; |
| case UiPackage.BUTTON__TOOLTIP: |
| setTooltip((String)newValue); |
| return; |
| case UiPackage.BUTTON__SELECTED: |
| setSelected((Boolean)newValue); |
| return; |
| case UiPackage.BUTTON__GRAYED: |
| setGrayed((Boolean)newValue); |
| return; |
| case UiPackage.BUTTON__KIND: |
| setKind((ButtonKind)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case UiPackage.BUTTON__IMAGE: |
| setImage((Image)null); |
| return; |
| case UiPackage.BUTTON__CAPTION: |
| setCaption(CAPTION_EDEFAULT); |
| return; |
| case UiPackage.BUTTON__TOOLTIP: |
| setTooltip(TOOLTIP_EDEFAULT); |
| return; |
| case UiPackage.BUTTON__SELECTED: |
| setSelected(SELECTED_EDEFAULT); |
| return; |
| case UiPackage.BUTTON__GRAYED: |
| setGrayed(GRAYED_EDEFAULT); |
| return; |
| case UiPackage.BUTTON__KIND: |
| setKind(KIND_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case UiPackage.BUTTON__IMAGE: |
| return image != null; |
| case UiPackage.BUTTON__CAPTION: |
| return CAPTION_EDEFAULT == null ? caption != null : !CAPTION_EDEFAULT.equals(caption); |
| case UiPackage.BUTTON__TOOLTIP: |
| return TOOLTIP_EDEFAULT == null ? tooltip != null : !TOOLTIP_EDEFAULT.equals(tooltip); |
| case UiPackage.BUTTON__SELECTED: |
| return selected != SELECTED_EDEFAULT; |
| case UiPackage.BUTTON__GRAYED: |
| return grayed != GRAYED_EDEFAULT; |
| case UiPackage.BUTTON__KIND: |
| return kind != KIND_EDEFAULT; |
| } |
| return super.eIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| if (baseClass == WithImage.class) { |
| switch (derivedFeatureID) { |
| case UiPackage.BUTTON__IMAGE: return UiPackage.WITH_IMAGE__IMAGE; |
| 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 == WithImage.class) { |
| switch (baseFeatureID) { |
| case UiPackage.WITH_IMAGE__IMAGE: return UiPackage.BUTTON__IMAGE; |
| default: return -1; |
| } |
| } |
| return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| } |
| |
| /** |
| * <!-- 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(", tooltip: "); |
| result.append(tooltip); |
| result.append(", selected: "); |
| result.append(selected); |
| result.append(", grayed: "); |
| result.append(grayed); |
| result.append(", kind: "); |
| result.append(kind); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| } //ButtonImpl |