comparison org.eclipse.core.databinding.observable/src/org/eclipse/core/internal/databinding/observable/ConstantObservableValue.d @ 95:6208d4f6a277

Added trees for databinding.beans and observable
author Frank Benoit <benoit@tionex.de>
date Tue, 21 Apr 2009 10:55:51 +0200
parents
children b74ac5dfcc06
comparison
equal deleted inserted replaced
94:1d37a7813832 95:6208d4f6a277
1 /*******************************************************************************
2 * Copyright (c) 2005, 2007-2008 Matt Carter and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * Matt Carter - initial API and implementation (bug 212518)
10 * Matthew Hall - bug 212518
11 *******************************************************************************/
12 package org.eclipse.core.internal.databinding.observable;
13
14 import org.eclipse.core.databinding.observable.IChangeListener;
15 import org.eclipse.core.databinding.observable.IStaleListener;
16 import org.eclipse.core.databinding.observable.ObservableTracker;
17 import org.eclipse.core.databinding.observable.Realm;
18 import org.eclipse.core.databinding.observable.value.IObservableValue;
19 import org.eclipse.core.databinding.observable.value.IValueChangeListener;
20 import org.eclipse.core.databinding.observable.value.WritableValue;
21 import org.eclipse.core.runtime.Assert;
22
23 /**
24 * An immutable {@link IObservableValue}.
25 *
26 * @see WritableValue
27 */
28 public class ConstantObservableValue : IObservableValue {
29 final Realm realm;
30 final Object value;
31 final Object type;
32
33 /**
34 * Construct a constant value of the given type, in the default realm.
35 *
36 * @param value
37 * immutable value
38 * @param type
39 * type
40 */
41 public this(Object value, Object type) {
42 this(Realm.getDefault(), value, type);
43 }
44
45 /**
46 * Construct a constant value of the given type, in the given realm.
47 *
48 * @param realm
49 * Realm
50 * @param value
51 * immutable value
52 * @param type
53 * type
54 */
55 public this(Realm realm, Object value, Object type) {
56 Assert.isNotNull(realm, "Realm cannot be null"); //$NON-NLS-1$
57 this.realm = realm;
58 this.value = value;
59 this.type = type;
60 }
61
62 public Object getValueType() {
63 return type;
64 }
65
66 public Object getValue() {
67 ObservableTracker.getterCalled(this);
68 return value;
69 }
70
71 public void setValue(Object value) {
72 throw new UnsupportedOperationException();
73 }
74
75 public void addValueChangeListener(IValueChangeListener listener) {
76 // ignore
77 }
78
79 public void removeValueChangeListener(IValueChangeListener listener) {
80 // ignore
81 }
82
83 public void addChangeListener(IChangeListener listener) {
84 // ignore
85 }
86
87 public void addStaleListener(IStaleListener listener) {
88 // ignore
89 }
90
91 public void dispose() {
92 // nothing to dispose
93 }
94
95 public Realm getRealm() {
96 return realm;
97 }
98
99 public bool isStale() {
100 return false;
101 }
102
103 public void removeChangeListener(IChangeListener listener) {
104 // ignore
105 }
106
107 public void removeStaleListener(IStaleListener listener) {
108 // ignore
109 }
110 }