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

com.alkacon.acacia.client.ChoiceMenuEntryBean Maven / Gradle / Ivy

Go to download

A GWT based resource editor. This component is used as a part of OpenCms, 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.

The newest version!
/*
 * This library is part of the Acacia Editor -
 * an open source inline and form based content editor for GWT.
 *
 * Copyright (c) Alkacon Software GmbH (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
 * 
 * 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 com.alkacon.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 ChoiceMenuEntryBean { /** The child entries of this choice. */ protected List m_children = new ArrayList(); /** The parent of this entry. */ protected ChoiceMenuEntryBean 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 ChoiceMenuEntryBean(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 ChoiceMenuEntryBean addChild(String pathComponent) { assert pathComponent != null; ChoiceMenuEntryBean child = new ChoiceMenuEntryBean(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_WidgetService 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_WidgetService widgetService) { return widgetService.getAttributeLabel(m_pathComponent); } /** * Gets the parent entry of this entry.

* * @return the parent entry */ public ChoiceMenuEntryBean 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(); ChoiceMenuEntryBean 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