Debian Codegraph @

plugins/org.eclipse.emf.databinding.edit/src/org/eclipse/emf/databinding/edit/EditingDomainEObjectObservableValue.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.Realm;
14 import org.eclipse.emf.common.command.Command;
15 import org.eclipse.emf.databinding.EObjectObservableValue;
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 EditingDomainEObjectObservableValue extends EObjectObservableValue
26 {
27 /**
28 * The editing domain
29 */
30 protected EditingDomain domain;
31
32 /**
33 * Observe a list feature using a default realm
34 *
35 * @param domain
36 * the editing domain
37 * @param eObject
38 * the object instance
39 * @param eStructuralFeature
40 * the feature
41 */
42 public EditingDomainEObjectObservableValue(EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature)
43 {
44 this(Realm.getDefault(), domain, eObject, eStructuralFeature);
45 }
46
47 /**
48 * Observe a list feature using a custom realm
49 *
50 * @param realm
51 * the realm
52 * @param domain
53 * the editing domain
54 * @param eObject
55 * the object instance
56 * @param eStructuralFeature
57 * the feature
58 */
59 public EditingDomainEObjectObservableValue(Realm realm, EditingDomain domain, EObject eObject, EStructuralFeature eStructuralFeature)
60 {
61 super(realm, eObject, eStructuralFeature);
62 this.domain = domain;
63 }
64
65 @Override
66 public synchronized void dispose()
67 {
68 domain = null;
69 super.dispose();
70 }
71
72 @Override
73 protected void doSetValue(Object value)
74 {
75 Command command = SetCommand.create(domain, eObject, eStructuralFeature, value);
76 domain.getCommandStack().execute(command);
77 }
78 }