menuitem.java

来自「开源项目CRM之OpenCustomer」· Java 代码 · 共 166 行

JAVA
166
字号
/*******************************************************************************
 * ***** BEGIN LICENSE BLOCK Version: MPL 1.1
 * 
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with the
 * License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 * 
 * The Original Code is the OpenCustomer CRM.
 * 
 * The Initial Developer of the Original Code is Thomas Bader (Bader & Jene
 * Software-Ingenieurb黵o). Portions created by the Initial Developer are
 * Copyright (C) 2005 the Initial Developer. All Rights Reserved.
 * 
 * Contributor(s): Thomas Bader <thomas.bader@bader-jene.de>
 * 
 * ***** END LICENSE BLOCK *****
 */

package org.opencustomer.util.menu;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.opencustomer.application.auth.Right;

public class MenuItem
{
    private String path;

    private String messageKey;

    private String imageKey;

    private Right[] rights = new Right[0];

    private List<MenuItem> items = new ArrayList<MenuItem>();

    private boolean active;

    private boolean jspInclude;

    public MenuItem()
    {
    }

    public MenuItem(String messageKey)
    {
        this.messageKey = messageKey;
    }

    public MenuItem(String messageKey, String imageKey)
    {
        this.messageKey = messageKey;
        this.imageKey = imageKey;
    }

    public MenuItem(String path, String messageKey, Right... right)
    {
        this.messageKey = messageKey;
        this.path = path;
        if (right != null)
            this.rights = right;
    }

    public static MenuItem getJspInclude(String path)
    {
        MenuItem item = new MenuItem();
        item.setJspInclude(true);
        item.setPath(path);

        return item;
    }

    public List<MenuItem> getItems()
    {
        return items;
    }

    public void setItems(List<MenuItem> items)
    {
        if (items == null)
            this.items = new ArrayList<MenuItem>();
        else
            this.items = items;
    }

    public String getMessageKey()
    {
        return messageKey;
    }

    public void setMessageKey(String messageKey)
    {
        this.messageKey = messageKey;
    }

    public Right[] getRights()
    {
        return rights;
    }

    public void setRights(Right[] rights)
    {
        this.rights = rights;
    }

    public String getPath()
    {
        return path;
    }

    public void setPath(String path)
    {
        this.path = path;
    }

    public boolean isActive()
    {
        return active;
    }

    public void setActive(boolean active)
    {
        this.active = active;
    }

    public String getImageKey()
    {
        return imageKey;
    }

    public void setImageKey(String imageKey)
    {
        this.imageKey = imageKey;
    }

    public final boolean isJspInclude()
    {
        return jspInclude;
    }

    public final void setJspInclude(boolean jspInclude)
    {
        this.jspInclude = jspInclude;
    }

    public String toString()
    {
        ToStringBuilder builder = new ToStringBuilder(this);

        builder.append("path=" + path);
        builder.append("messageKey=" + messageKey);
        builder.append("rights=" + rights);
        builder.append("items=" + items);
        builder.append("active=" + active);
        builder.append("jspInclude=" + jspInclude);

        return builder.toString();
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?