1 /**
2  * Copyright (c) 2008, 2015 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *      IBM Corporation - initial API and implementation
13  */
14 package org.eclipse.e4.ui.model.application.commands.impl;
15 
16 import org.eclipse.e4.ui.model.application.commands.MCommand;
17 import org.eclipse.e4.ui.model.application.commands.MHandler;
18 import org.eclipse.e4.ui.model.application.impl.ContributionImpl;
19 import org.eclipse.emf.common.notify.Notification;
20 import org.eclipse.emf.ecore.EClass;
21 import org.eclipse.emf.ecore.EObject;
22 import org.eclipse.emf.ecore.InternalEObject;
23 import org.eclipse.emf.ecore.impl.ENotificationImpl;
24 
25 /**
26  * <!-- begin-user-doc -->
27  * An implementation of the model object '<em><b>Handler</b></em>'.
28  * <!-- end-user-doc -->
29  * <p>
30  * The following features are implemented:
31  * </p>
32  * <ul>
33  *   <li>{@link org.eclipse.e4.ui.model.application.commands.impl.HandlerImpl#getCommand <em>Command</em>}</li>
34  * </ul>
35  *
36  * @since 1.0
37  * @generated
38  */
39 public class HandlerImpl extends ContributionImpl implements MHandler {
40 	/**
41 	 * The cached value of the '{@link #getCommand() <em>Command</em>}' reference.
42 	 * <!-- begin-user-doc -->
43 	 * <!-- end-user-doc -->
44 	 * @see #getCommand()
45 	 * @generated
46 	 * @ordered
47 	 */
48 	protected MCommand command;
49 
50 	/**
51 	 * <!-- begin-user-doc -->
52 	 * <!-- end-user-doc -->
53 	 * @generated
54 	 */
HandlerImpl()55 	protected HandlerImpl() {
56 		super();
57 	}
58 
59 	/**
60 	 * <!-- begin-user-doc -->
61 	 * <!-- end-user-doc -->
62 	 * @generated
63 	 */
64 	@Override
eStaticClass()65 	protected EClass eStaticClass() {
66 		return CommandsPackageImpl.Literals.HANDLER;
67 	}
68 
69 	/**
70 	 * <!-- begin-user-doc -->
71 	 * <!-- end-user-doc -->
72 	 * @generated
73 	 */
74 	@Override
getCommand()75 	public MCommand getCommand() {
76 		if (command != null && ((EObject) command).eIsProxy()) {
77 			InternalEObject oldCommand = (InternalEObject) command;
78 			command = (MCommand) eResolveProxy(oldCommand);
79 			if (command != oldCommand) {
80 				if (eNotificationRequired())
81 					eNotify(new ENotificationImpl(this, Notification.RESOLVE, CommandsPackageImpl.HANDLER__COMMAND,
82 							oldCommand, command));
83 			}
84 		}
85 		return command;
86 	}
87 
88 	/**
89 	 * <!-- begin-user-doc -->
90 	 * <!-- end-user-doc -->
91 	 * @generated
92 	 */
basicGetCommand()93 	public MCommand basicGetCommand() {
94 		return command;
95 	}
96 
97 	/**
98 	 * <!-- begin-user-doc -->
99 	 * <!-- end-user-doc -->
100 	 * @generated
101 	 */
102 	@Override
setCommand(MCommand newCommand)103 	public void setCommand(MCommand newCommand) {
104 		MCommand oldCommand = command;
105 		command = newCommand;
106 		if (eNotificationRequired())
107 			eNotify(new ENotificationImpl(this, Notification.SET, CommandsPackageImpl.HANDLER__COMMAND, oldCommand,
108 					command));
109 	}
110 
111 	/**
112 	 * <!-- begin-user-doc -->
113 	 * <!-- end-user-doc -->
114 	 * @generated
115 	 */
116 	@Override
eGet(int featureID, boolean resolve, boolean coreType)117 	public Object eGet(int featureID, boolean resolve, boolean coreType) {
118 		switch (featureID) {
119 		case CommandsPackageImpl.HANDLER__COMMAND:
120 			if (resolve)
121 				return getCommand();
122 			return basicGetCommand();
123 		default:
124 			return super.eGet(featureID, resolve, coreType);
125 		}
126 	}
127 
128 	/**
129 	 * <!-- begin-user-doc -->
130 	 * <!-- end-user-doc -->
131 	 * @generated
132 	 */
133 	@Override
eSet(int featureID, Object newValue)134 	public void eSet(int featureID, Object newValue) {
135 		switch (featureID) {
136 		case CommandsPackageImpl.HANDLER__COMMAND:
137 			setCommand((MCommand) newValue);
138 			return;
139 		default:
140 			super.eSet(featureID, newValue);
141 			return;
142 		}
143 	}
144 
145 	/**
146 	 * <!-- begin-user-doc -->
147 	 * <!-- end-user-doc -->
148 	 * @generated
149 	 */
150 	@Override
eUnset(int featureID)151 	public void eUnset(int featureID) {
152 		switch (featureID) {
153 		case CommandsPackageImpl.HANDLER__COMMAND:
154 			setCommand((MCommand) null);
155 			return;
156 		default:
157 			super.eUnset(featureID);
158 			return;
159 		}
160 	}
161 
162 	/**
163 	 * <!-- begin-user-doc -->
164 	 * <!-- end-user-doc -->
165 	 * @generated
166 	 */
167 	@Override
eIsSet(int featureID)168 	public boolean eIsSet(int featureID) {
169 		switch (featureID) {
170 		case CommandsPackageImpl.HANDLER__COMMAND:
171 			return command != null;
172 		default:
173 			return super.eIsSet(featureID);
174 		}
175 	}
176 
177 } //HandlerImpl
178