comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/observable/UnmodifiableObservableValue.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) 2008 Matthew Hall 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 * Matthew Hall - initial API and implementation (bug 219909)
10 ******************************************************************************/
11
12 module org.eclipse.core.internal.databinding.observable.UnmodifiableObservableValue;
13
14 import java.lang.all;
15
16 import org.eclipse.core.databinding.observable.IStaleListener;
17 import org.eclipse.core.databinding.observable.StaleEvent;
18 import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
19 import org.eclipse.core.databinding.observable.value.IObservableValue;
20 import org.eclipse.core.databinding.observable.value.IValueChangeListener;
21 import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
22
23 /**
24 * An unmodifiable wrapper class for IObservableValue instances.
25 * @since 1.1
26 */
27 public class UnmodifiableObservableValue : AbstractObservableValue {
28 private IObservableValue wrappedValue;
29
30 /**
31 * Constructs an UnmodifiableObservableValue which wraps the given
32 * observable value
33 *
34 * @param wrappedValue
35 * the observable value to wrap in an unmodifiable instance.
36 */
37 public this(IObservableValue wrappedValue) {
38 super(wrappedValue.getRealm());
39
40 this.wrappedValue = wrappedValue;
41 wrappedValue.addValueChangeListener(new class() IValueChangeListener {
42 public void handleValueChange(ValueChangeEvent event) {
43 fireValueChange(event.diff);
44 }
45 });
46 wrappedValue.addStaleListener(new class() IStaleListener {
47 public void handleStale(StaleEvent staleEvent) {
48 fireStale();
49 }
50 });
51 }
52
53 protected Object doGetValue() {
54 return wrappedValue.getValue();
55 }
56
57 public Object getValueType() {
58 return wrappedValue.getValueType();
59 }
60 }