All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alee.extended.collapsible.CollapsiblePaneState Maven / Gradle / Ivy

There is a newer version: 1.2.14
Show newest version
/*
 * 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.collapsible;

import com.alee.api.merge.Mergeable;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

import java.io.Serializable;

/**
 * {@link WebCollapsiblePane} state holder.
 *
 * @author Mikle Garin
 * @see How to use WebCollapsiblePane
 * @see WebCollapsiblePane
 * @see How to use SettingsManager
 * @see CollapsiblePaneSettingsProcessor
 * @see com.alee.managers.settings.UISettingsManager
 * @see com.alee.managers.settings.SettingsManager
 * @see com.alee.managers.settings.SettingsProcessor
 */
@XStreamAlias ( "CollapsiblePaneState" )
public class CollapsiblePaneState implements Mergeable, Cloneable, Serializable
{
    /**
     * Whether or not {@link WebCollapsiblePane} is expanded.
     */
    @XStreamAsAttribute
    protected final Boolean expanded;

    /**
     * Constructs default {@link CollapsiblePaneState}.
     */
    public CollapsiblePaneState ()
    {
        this ( ( Boolean ) null );
    }

    /**
     * Constructs new {@link CollapsiblePaneState} with settings from {@link WebCollapsiblePane}.
     *
     * @param collapsiblePane {@link WebCollapsiblePane} to retrieve settings from
     */
    public CollapsiblePaneState ( final WebCollapsiblePane collapsiblePane )
    {
        this ( collapsiblePane.isExpanded () );
    }

    /**
     * Constructs new {@link CollapsiblePaneState} with specified settings.
     *
     * @param expanded whether or not {@link WebCollapsiblePane} is expanded
     */
    public CollapsiblePaneState ( final Boolean expanded )
    {
        this.expanded = expanded;
    }

    /**
     * Returns whether or not {@link WebCollapsiblePane} is expanded.
     *
     * @return {@code true} if {@link WebCollapsiblePane} is expanded, {@code false} otherwise
     */
    public Boolean isExpanded ()
    {
        return expanded != null && expanded;
    }

    /**
     * Applies this {@link CollapsiblePaneState} to the specified {@link WebCollapsiblePane}.
     *
     * @param collapsiblePane {@link WebCollapsiblePane} to apply this {@link CollapsiblePaneState} to
     */
    public void apply ( final WebCollapsiblePane collapsiblePane )
    {
        if ( expanded != null && collapsiblePane.isExpanded () != expanded )
        {
            collapsiblePane.setExpanded ( expanded );
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy