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

org.opencms.acacia.client.CmsChoiceMenuEntryBean Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (C) Alkacon Software (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * 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.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.acacia.client;

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

/**
 * A bean which contains the data for a choice menu entry.

*/ public class CmsChoiceMenuEntryBean { /** The child entries of this choice. */ protected List m_children = new ArrayList(); /** The parent of this entry. */ protected CmsChoiceMenuEntryBean m_parent; /** The path component (attribute id) of this menu entry. */ protected String m_pathComponent; /** * Creates a new choice menu entry bean. * * @param pathComponent the path component of the choice (attribute id) */ public CmsChoiceMenuEntryBean(String pathComponent) { // path component may be null for dummy root entries m_pathComponent = pathComponent; } /** * Adds a new child entry to this bean and returns it.

* * @param pathComponent the path component of the child * * @return the new child */ public CmsChoiceMenuEntryBean addChild(String pathComponent) { assert pathComponent != null; CmsChoiceMenuEntryBean child = new CmsChoiceMenuEntryBean(pathComponent); m_children.add(child); child.m_parent = this; return child; } /** * Gets the list of children of this entry.

* * @return the list of children */ public List getChildren() { return m_children; } /** * Gets the help text for the menu entry.

* * @param widgetService the widget service to ask for labels * * @return the help text */ public String getHelp(I_CmsWidgetService widgetService) { return widgetService.getAttributeHelp(m_pathComponent); } /** * Gets the label for the menu entry.

* * @param widgetService the widget service to ask for label texts * * @return the entry label */ public String getLabel(I_CmsWidgetService widgetService) { return widgetService.getAttributeLabel(m_pathComponent); } /** * Gets the parent entry of this entry.

* * @return the parent entry */ public CmsChoiceMenuEntryBean getParent() { return m_parent; } /** * Gets the complete path of this entry, which is a list of attribute ids.

* * @return the path of this entry */ public List getPath() { List result = new ArrayList(); CmsChoiceMenuEntryBean entry = this; while (entry != null) { String pathComponent = entry.getPathComponent(); if (pathComponent != null) { // pathComponent may be null for a dummy root entry result.add(entry.getPathComponent()); } entry = entry.m_parent; } Collections.reverse(result); return result; } /** * Gets the path component of this entry.

* * @return the path component */ public String getPathComponent() { return m_pathComponent; } /** * Returns true if this entry has no children.

* * @return true if this entry has no children */ public boolean isLeaf() { return m_children.isEmpty(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy