// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   ProductCategoryForm.java

package com.keyshop.shop.product.controller;

import com.keyshop.pub.controller.PubForm;
import com.keyshop.pub.model.PubBean;
import com.keyshop.pub.util.StringUtil;
import com.keyshop.shop.product.model.ProductCategory;
import java.util.ArrayList;
import java.util.List;
import org.apache.struts.upload.FormFile;

public class ProductCategoryForm extends PubForm
{

    List openCategorys;
    List checkCategorys;
    String currentCategory;
    FormFile navImageData;
    public static String RELATION = "product_category_relation";
    String treeType;
    public PubBean bean;

    public ProductCategoryForm()
    {
        openCategorys = new ArrayList();
        checkCategorys = new ArrayList();
        currentCategory = "";
        navImageData = null;
        treeType = "";
        bean = new ProductCategory();
    }

    public PubBean getBean()
    {
        return bean;
    }

    public void clear()
    {
        super.clear();
        bean = new ProductCategory();
        openCategorys = new ArrayList();
        checkCategorys = new ArrayList();
        currentCategory = "";
        treeType = "";
    }

    public void setBean(PubBean bean)
    {
        this.bean = bean;
    }

    public boolean isOpen(String categoryId)
    {
        if(StringUtil.isEmpty(categoryId))
            return false;
        for(int i = 0; i < openCategorys.size(); i++)
        {
            String category = (String)openCategorys.get(i);
            if(categoryId.equals(category))
                return true;
        }

        return false;
    }

    public String getCurrentCategory()
    {
        return currentCategory;
    }

    public List getOpenCategorys()
    {
        return openCategorys;
    }

    public void setCurrentCategory(String currentCategory)
    {
        this.currentCategory = currentCategory;
    }

    public void setOpenCategorys(List openCategorys)
    {
        this.openCategorys = openCategorys;
    }

    public void selCategory(String categoryId)
    {
        if(StringUtil.isEmpty(categoryId))
            return;
        boolean isIn = false;
        for(int i = 0; i < openCategorys.size(); i++)
        {
            String c = (String)openCategorys.get(i);
            if(c.equals(categoryId))
            {
                openCategorys.remove(i);
                isIn = true;
            }
        }

        if(!isIn)
            openCategorys.add(categoryId);
    }

    public void checkCategory(String categoryId)
    {
        if(StringUtil.isEmpty(categoryId))
            return;
        boolean isIn = false;
        for(int i = 0; i < checkCategorys.size(); i++)
        {
            String c = (String)checkCategorys.get(i);
            if(c.equals(categoryId))
            {
                checkCategorys.remove(i);
                isIn = true;
            }
        }

        if(!isIn)
            checkCategorys.add(categoryId);
    }

    public List getCheckCategorys()
    {
        return checkCategorys;
    }

    public void setCheckCategorys(List checkCategorys)
    {
        this.checkCategorys = checkCategorys;
    }

    public String getTreeType()
    {
        return treeType;
    }

    public void setTreeType(String treeType)
    {
        this.treeType = treeType;
    }

    public FormFile getNavImageData()
    {
        return navImageData;
    }

    public void setNavImageData(FormFile navImageData)
    {
        this.navImageData = navImageData;
    }

}
