blob: 8911c6bf776745edf05a28eaaae22166bf4b63c8 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2008 Matthew Hall and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Matthew Hall - initial API and implementation (bug 221704)
* Matthew Hall - bug 246625
******************************************************************************/
package org.eclipse.core.internal.databinding.beans;
import java.beans.PropertyDescriptor;
import org.eclipse.core.databinding.beans.IBeanObservable;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.IObserving;
import org.eclipse.core.databinding.observable.map.DecoratingObservableMap;
import org.eclipse.core.databinding.observable.map.IObservableMap;
/**
* {@link IBeanObservable} decorator for an {@link IObservableMap}.
*
* @param <K>
* @param <V>
*
* @since 3.3
*/
public class BeanObservableMapDecorator<K, V> extends
DecoratingObservableMap<K, V> implements IBeanObservable {
private PropertyDescriptor propertyDescriptor;
/**
* @param decorated
* @param propertyDescriptor
*/
public BeanObservableMapDecorator(IObservableMap<K, V> decorated,
PropertyDescriptor propertyDescriptor) {
super(decorated, true);
this.propertyDescriptor = propertyDescriptor;
}
public synchronized void dispose() {
this.propertyDescriptor = null;
super.dispose();
}
public Object getObserved() {
IObservable decorated = getDecorated();
if (decorated instanceof IObserving)
return ((IObserving) decorated).getObserved();
return null;
}
public PropertyDescriptor getPropertyDescriptor() {
return propertyDescriptor;
}
}