/**
 * License Agreement.
 *
 *  JBoss RichFaces - Ajax4jsf Component Library
 *
 * Copyright (C) 2007  Exadel, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 */

package org.ajax4jsf.bean;

import javax.faces.event.ActionEvent;

public class RichPanelTestBean {
    private String value;

    private int value2;

    private Object panelValue;

    private Object panelValue2;

    private String itemAction;

    private boolean rendered;

    private String content;

    private String switchType = "server";

    public RichPanelTestBean() {
        value = "";
        value2 = 0;
        rendered = true;
        content = "content";
    }

    /**
     * Gets value of switchType field.
     * @return value of switchType field
     */
    public String getSwitchType() {
        return switchType;
    }

    /**
     * Set a new value for switchType field.
     * @param switchType a new value for switchType field
     */
    public void setSwitchType(String switchType) {
        this.switchType = switchType;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getValue2() {
        return value2;
    }

    public void setValue2(int value2) {
        this.value2 = value2;
    }

    public Object getPanelValue() {
        return panelValue;
    }

    public void setPanelValue(Object panelValue) {
        this.panelValue = panelValue;
    }

    public Object getPanelValue2() {
        return panelValue2;
    }

    public void setPanelValue2(Object panelValue2) {
        this.panelValue2 = panelValue2;
    }

    /**
     * Gets value of content field.
     * @return value of content field
     */
    public String getContent() {
        return content;
    }

    /**
     * Set a new value for content field.
     * @param content a new value for content field
     */
    public void setContent(String content) {
        this.content = content;
    }

    /**
     * Gets value of itemAction field.
     * 
     * @return value of itemAction field
     */
    public String getItemAction() {
        return itemAction;
    }

    /**
     * Set a new value for itemAction field.
     * 
     * @param itemAction
     *                a new value for itemAction field
     */
    public void setItemAction(String itemAction) {
        this.itemAction = itemAction;
    }

    /**
     * Gets value of rendered field.
     * @return value of rendered field
     */
    public boolean isRendered() {
        return rendered;
    }

    /**
     * Set a new value for rendered field.
     * @param rendered a new value for rendered field
     */
    public void setRendered(boolean rendered) {
        this.rendered = rendered;
    }

    public void actionListener(ActionEvent event) {
        this.value = event.getComponent().getId();
    }

    public void itemActionServer() {
        setItemAction("server");
    }

    public void itemActionAjax() {
        setItemAction("ajax");
    }

    public void itemActionNone() {
        setItemAction("NOT none");
    }

    public String increment() {
        if (4 == this.value2) {
            this.value2 = 0;
        }
        this.value2++;
        return null;
    }

    public void hide() {
        rendered = false;
    }
    
    public void reset2Server() {
        cleanValues();
        content = "";
        switchType = "server";
    }

    public void reset2Ajax() {
        cleanValues();
        content = "";
        switchType = "ajax";
    }

    public void reset2Client() {
        cleanValues();
        content = "";
        switchType = "client";
    }

    public void cleanValues() {
        value = "";
        value2 = 0;
        panelValue = null;
        panelValue2 = null;
        itemAction = "";
        rendered = true;
        content = "content";
    }
}
