blob: a65f32ed24175064d69688f0cdec87b13d9dcf9f [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.runtime.web.vaadin.databinding.model.internal;
import org.eclipse.core.databinding.property.INativePropertyListener;
import org.eclipse.core.databinding.property.ISimplePropertyListener;
import org.eclipse.osbp.runtime.web.vaadin.databinding.properties.AbstractVaadinValueProperty;
import org.eclipse.osbp.runtime.web.vaadin.databinding.properties.Util;
import com.vaadin.data.Property;
/**
* A property that is responsible for single selections.
*/
public class SingleSelectionProperty extends AbstractVaadinValueProperty {
private final Class<?> type;
public SingleSelectionProperty(Class<?> type) {
this.type = type;
}
public INativePropertyListener adaptListener(
ISimplePropertyListener listener) {
return new PropertyValueChangeListener(this, listener);
}
@Override
public Object getValueType() {
return type;
}
@Override
protected Object doGetValue(Object source) {
Property<?> property = Util.getProperty(source);
return property.getValue();
}
@Override
protected void doSetValue(Object source, Object value) {
Property<Object> property = Util.getProperty(source);
property.setValue(value);
}
}