Debian Codegraph @

plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableMap.java

raw
1 /**
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v2.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v20.html
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 */
11 package org.eclipse.emf.databinding.edit;
12
13 import org.eclipse.core.databinding.observable.set.IObservableSet;
14 import org.eclipse.emf.common.command.Command;
15 import org.eclipse.emf.databinding.EObjectObservableMap;
16 import org.eclipse.emf.ecore.EObject;
17 import org.eclipse.emf.ecore.EStructuralFeature;
18 import org.eclipse.emf.edit.command.SetCommand;
19 import org.eclipse.emf.edit.domain.EditingDomain;
20
21
22 /**
23 * <p><b>PROVISIONAL:</b> This API is subject to arbitrary change, including renaming or removal.</p>
24 */
25 public class EditingDomainEObjectObservableMap extends EObjectObservableMap
26 {
27 /**
28 * The editing domain
29 */
30 protected EditingDomain domain;
31
32 /**
33 * Create a new observable for the set of features
34 * @param domain
35 * the editing domain
36 * @param objects
37 * the objects to observe
38 * @param eStructuralFeature
39 * the feature
40 */
41 public EditingDomainEObjectObservableMap(EditingDomain domain, IObservableSet objects, EStructuralFeature eStructuralFeature)
42 {
43 super(objects, eStructuralFeature);
44 this.domain = domain;
45 }
46
47 @Override
48 protected Object doPut(Object key, Object value)
49 {
50 EObject eObject = (EObject)key;
51 Object result = eObject.eGet(eStructuralFeature);
52 Command command = SetCommand.create(domain, eObject, eStructuralFeature, value);
53 domain.getCommandStack().execute(command);
54
55 eObject.eSet(eStructuralFeature, value);
56 return result;
57 }
58 }