KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > databinding > internal > beans > BeanObservableValueDecorator


1 /*******************************************************************************
2  * Copyright (c) 2007 Brad Reynolds 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  * Brad Reynolds - initial API and implementation
10  ******************************************************************************/

11
12 package org.eclipse.core.internal.databinding.internal.beans;
13
14 import java.beans.PropertyDescriptor JavaDoc;
15
16 import org.eclipse.core.databinding.beans.IBeanObservable;
17 import org.eclipse.core.databinding.observable.IChangeListener;
18 import org.eclipse.core.databinding.observable.IStaleListener;
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
23 /**
24  * {@link IBeanObservable} decorator for an {@link IObservableValue}.
25  *
26  * @since 3.3
27  */

28 public class BeanObservableValueDecorator implements IObservableValue,
29         IBeanObservable {
30     private final IObservableValue delegate;
31     private final PropertyDescriptor JavaDoc descriptor;
32     private final IObservableValue observed;
33
34     /**
35      * @param delegate
36      * @param observed
37      * @param descriptor
38      */

39     public BeanObservableValueDecorator(IObservableValue delegate, IObservableValue observed,
40             PropertyDescriptor JavaDoc descriptor) {
41         this.delegate = delegate;
42         this.observed = observed;
43         this.descriptor = descriptor;
44     }
45
46     public void addChangeListener(IChangeListener listener) {
47         delegate.addChangeListener(listener);
48     }
49
50     public void addStaleListener(IStaleListener listener) {
51         delegate.addStaleListener(listener);
52     }
53
54     public void addValueChangeListener(IValueChangeListener listener) {
55         delegate.addValueChangeListener(listener);
56     }
57
58     public void dispose() {
59         delegate.dispose();
60     }
61     
62     public boolean equals(Object JavaDoc obj) {
63         return delegate.equals(obj);
64     }
65
66     public Realm getRealm() {
67         return delegate.getRealm();
68     }
69
70     public Object JavaDoc getValue() {
71         return delegate.getValue();
72     }
73
74     public Object JavaDoc getValueType() {
75         return delegate.getValueType();
76     }
77     
78     public int hashCode() {
79         return delegate.hashCode();
80     }
81
82     public boolean isStale() {
83         return delegate.isStale();
84     }
85
86     public void removeChangeListener(IChangeListener listener) {
87         delegate.removeChangeListener(listener);
88     }
89
90     public void removeStaleListener(IStaleListener listener) {
91         delegate.removeStaleListener(listener);
92     }
93
94     public void removeValueChangeListener(IValueChangeListener listener) {
95         delegate.removeValueChangeListener(listener);
96     }
97
98     public void setValue(Object JavaDoc value) {
99         delegate.setValue(value);
100     }
101
102     /*
103      * (non-Javadoc)
104      *
105      * @see org.eclipse.core.databinding.beans.IBeanObservable#getObserved()
106      */

107     public Object JavaDoc getObserved() {
108         return observed.getValue();
109     }
110
111     /*
112      * (non-Javadoc)
113      *
114      * @see org.eclipse.core.databinding.beans.IBeanObservable#getPropertyDescriptor()
115      */

116     public PropertyDescriptor JavaDoc getPropertyDescriptor() {
117         return descriptor;
118     }
119     
120     /**
121      * @return observable value delegate
122      */

123     public IObservableValue getDelegate() {
124         return delegate;
125     }
126 }
127
Popular Tags