com.alee.extended.dock.DockablePaneSettingsProcessor 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.dock;
import com.alee.api.annotations.NotNull;
import com.alee.api.data.CompassDirection;
import com.alee.managers.settings.Configuration;
import com.alee.managers.settings.SettingsProcessor;
/**
* {@link SettingsProcessor} implementation that handles {@link WebDockablePane} settings.
*
* @author Mikle Garin
* @see How to use WebDockablePane
* @see WebDockablePane
* @see How to use SettingsManager
* @see com.alee.managers.settings.UISettingsManager
* @see com.alee.managers.settings.SettingsManager
* @see SettingsProcessor
*/
public class DockablePaneSettingsProcessor extends SettingsProcessor>
{
/**
* {@link DockableFrameListener} for tracking {@link WebDockablePane} frames location and state changes.
*/
protected transient DockablePaneListener dockablePaneListener;
/**
* Constructs new {@link DockablePaneSettingsProcessor}.
*
* @param dockablePane {@link WebDockablePane} which settings are being managed
* @param configuration {@link Configuration}
*/
public DockablePaneSettingsProcessor ( final WebDockablePane dockablePane, final Configuration configuration )
{
super ( dockablePane, configuration );
}
@Override
protected void register ( @NotNull final WebDockablePane dockablePane )
{
dockablePaneListener = new DockablePaneAdapter ()
{
@Override
public void frameStateChanged ( @NotNull final WebDockableFrame frame, @NotNull final DockableFrameState oldState,
@NotNull final DockableFrameState newState )
{
save ();
}
@Override
public void frameMoved ( @NotNull final WebDockableFrame frame, @NotNull final CompassDirection position )
{
save ();
}
};
dockablePane.addDockablePaneListener ( dockablePaneListener );
}
@Override
protected void unregister ( @NotNull final WebDockablePane dockablePane )
{
dockablePane.removeDockablePaneListener ( dockablePaneListener );
dockablePaneListener = null;
}
@Override
protected void loadSettings ( @NotNull final WebDockablePane dockablePane )
{
final DockablePaneState state = loadSettings ();
if ( state != null )
{
state.apply ( dockablePane );
}
}
@Override
protected void saveSettings ( @NotNull final WebDockablePane dockablePane )
{
saveSettings ( new DockablePaneState ( dockablePane ) );
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy