com.alee.extended.date.DateFieldSettingsProcessor Maven / Gradle / Ivy
/*
* This file is part of WebLookAndFeel library.
*
* WebLookAndFeel library is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* WebLookAndFeel library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with WebLookAndFeel library. If not, see .
*/
package com.alee.extended.date;
import com.alee.api.annotations.NotNull;
import com.alee.api.annotations.Nullable;
import com.alee.managers.settings.Configuration;
import com.alee.managers.settings.SettingsProcessor;
import java.util.Date;
/**
* {@link SettingsProcessor} implementation that handles {@link WebDateField} settings.
*
* @author Mikle Garin
* @see How to use SettingsManager
* @see com.alee.managers.settings.UISettingsManager
* @see com.alee.managers.settings.SettingsManager
* @see SettingsProcessor
*/
public class DateFieldSettingsProcessor extends SettingsProcessor>
{
/**
* {@link DateListener} for tracking {@link WebDateField} date changes.
*/
protected transient DateListener dateListener;
/**
* Constructs new {@link DateFieldSettingsProcessor}.
*
* @param dateField {@link WebDateField} which settings are being managed
* @param configuration {@link Configuration}
*/
public DateFieldSettingsProcessor ( final WebDateField dateField, final Configuration configuration )
{
super ( dateField, configuration );
}
@Override
protected void register ( @NotNull final WebDateField dateField )
{
dateListener = new DateListener ()
{
@Override
public void dateChanged ( @Nullable final Date date )
{
save ();
}
};
dateField.addDateListener ( dateListener );
}
@Override
protected void unregister ( @NotNull final WebDateField dateField )
{
dateField.removeDateListener ( dateListener );
dateListener = null;
}
@Nullable
@Override
protected DateFieldState createDefaultValue ()
{
return new DateFieldState ( component () );
}
@Override
protected void loadSettings ( @NotNull final WebDateField dateField )
{
loadSettings ().apply ( dateField );
}
@Override
protected void saveSettings ( @NotNull final WebDateField dateField )
{
saveSettings ( new DateFieldState ( dateField ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy