
it.tidalwave.util.ui.FormModel Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - Android - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile
* SCM: https://java.net/hg/bluebill-mobile~android-src
*
**********************************************************************************************************************/
package it.tidalwave.util.ui;
import javax.annotation.Nonnull;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.Getter;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public class FormModel
{
private static final Logger log = LoggerFactory.getLogger(FormProperty.class);
public static final String PROP_VALID = "valid";
@Getter
private boolean valid = false;
private final PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected void revalidate()
{
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected void setValid (final boolean valid)
{
log.trace("{}.setValid({})", this, valid);
final boolean oldValid = this.valid;
this.valid = valid;
propertyChangeSupport.firePropertyChange(PROP_VALID, oldValid, valid);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public synchronized void addPropertyChangeListener (final @Nonnull PropertyChangeListener listener)
{
propertyChangeSupport.addPropertyChangeListener(listener);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public synchronized void addPropertyChangeListener (final @Nonnull String propertyName,
final @Nonnull PropertyChangeListener listener)
{
propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public synchronized void removePropertyChangeListener (final @Nonnull PropertyChangeListener listener)
{
propertyChangeSupport.removePropertyChangeListener(listener);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public synchronized void removePropertyChangeListener (final @Nonnull String propertyName,
final @Nonnull PropertyChangeListener listener)
{
propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public synchronized boolean hasListeners (final @Nonnull String propertyName)
{
return propertyChangeSupport.hasListeners(propertyName);
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Nonnull
public synchronized PropertyChangeListener[] getPropertyChangeListeners()
{
return propertyChangeSupport.getPropertyChangeListeners();
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
@Nonnull
public synchronized PropertyChangeListener[] getPropertyChangeListeners (final @Nonnull String propertyName)
{
return propertyChangeSupport.getPropertyChangeListeners(propertyName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy