Mercurial > projects > dwt2
comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/observable/ConstantObservableValue.d @ 78:0a55d2d5a946
Added file for databinding
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 14 Apr 2009 11:35:29 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
76:f05e6e8b2f2d | 78:0a55d2d5a946 |
---|---|
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 module org.eclipse.core.internal.databinding.observable.ConstantObservableValue; | |
13 | |
14 import java.lang.all; | |
15 | |
16 import org.eclipse.core.databinding.observable.IChangeListener; | |
17 import org.eclipse.core.databinding.observable.IStaleListener; | |
18 import org.eclipse.core.databinding.observable.ObservableTracker; | |
19 import org.eclipse.core.databinding.observable.Realm; | |
20 import org.eclipse.core.databinding.observable.value.IObservableValue; | |
21 import org.eclipse.core.databinding.observable.value.IValueChangeListener; | |
22 import org.eclipse.core.databinding.observable.value.WritableValue; | |
23 import org.eclipse.core.runtime.Assert; | |
24 | |
25 /** | |
26 * An immutable {@link IObservableValue}. | |
27 * | |
28 * @see WritableValue | |
29 */ | |
30 public class ConstantObservableValue : IObservableValue { | |
31 final Realm realm; | |
32 final Object value; | |
33 final Object type; | |
34 | |
35 /** | |
36 * Construct a constant value of the given type, in the default realm. | |
37 * | |
38 * @param value | |
39 * immutable value | |
40 * @param type | |
41 * type | |
42 */ | |
43 public this(Object value, Object type) { | |
44 this(Realm.getDefault(), value, type); | |
45 } | |
46 | |
47 /** | |
48 * Construct a constant value of the given type, in the given realm. | |
49 * | |
50 * @param realm | |
51 * Realm | |
52 * @param value | |
53 * immutable value | |
54 * @param type | |
55 * type | |
56 */ | |
57 public this(Realm realm, Object value, Object type) { | |
58 Assert.isNotNull(realm, "Realm cannot be null"); //$NON-NLS-1$ | |
59 this.realm = realm; | |
60 this.value = value; | |
61 this.type = type; | |
62 } | |
63 | |
64 public Object getValueType() { | |
65 return type; | |
66 } | |
67 | |
68 public Object getValue() { | |
69 ObservableTracker.getterCalled(this); | |
70 return value; | |
71 } | |
72 | |
73 public void setValue(Object value) { | |
74 throw new UnsupportedOperationException(); | |
75 } | |
76 | |
77 public void addValueChangeListener(IValueChangeListener listener) { | |
78 // ignore | |
79 } | |
80 | |
81 public void removeValueChangeListener(IValueChangeListener listener) { | |
82 // ignore | |
83 } | |
84 | |
85 public void addChangeListener(IChangeListener listener) { | |
86 // ignore | |
87 } | |
88 | |
89 public void addStaleListener(IStaleListener listener) { | |
90 // ignore | |
91 } | |
92 | |
93 public void dispose() { | |
94 // nothing to dispose | |
95 } | |
96 | |
97 public Realm getRealm() { | |
98 return realm; | |
99 } | |
100 | |
101 public bool isStale() { | |
102 return false; | |
103 } | |
104 | |
105 public void removeChangeListener(IChangeListener listener) { | |
106 // ignore | |
107 } | |
108 | |
109 public void removeStaleListener(IStaleListener listener) { | |
110 // ignore | |
111 } | |
112 } |