blob: d52aa8e87590e10838f7826f10864aeb5ce23ca9 [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.IProperty;
import org.eclipse.core.databinding.property.ISimplePropertyListener;
import org.eclipse.core.databinding.property.NativePropertyListener;
import com.vaadin.data.Property;
import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
/**
*/
@SuppressWarnings("serial")
public class PropertyReadonlyChangeListener extends NativePropertyListener
implements Property.ReadOnlyStatusChangeListener {
public PropertyReadonlyChangeListener(IProperty property,
ISimplePropertyListener listener) {
super(property, listener);
}
protected void doAddTo(Object source) {
if (source instanceof Property.ReadOnlyStatusChangeNotifier) {
Property.ReadOnlyStatusChangeNotifier notifier = (Property.ReadOnlyStatusChangeNotifier) source;
notifier.addReadOnlyStatusChangeListener(this);
}
}
protected void doRemoveFrom(Object source) {
if (source instanceof Property.ReadOnlyStatusChangeNotifier) {
Property.ReadOnlyStatusChangeNotifier notifier = (Property.ReadOnlyStatusChangeNotifier) source;
notifier.removeReadOnlyStatusChangeListener(this);
}
}
@Override
public void readOnlyStatusChange(ReadOnlyStatusChangeEvent event) {
fireChange(event.getProperty().isReadOnly(), null);
}
}