001: /***************************************************************
002: * This file is part of the [fleXive](R) project.
003: *
004: * Copyright (c) 1999-2007
005: * UCS - unique computing solutions gmbh (http://www.ucs.at)
006: * All rights reserved
007: *
008: * The [fleXive](R) project is free software; you can redistribute
009: * it and/or modify it under the terms of the GNU General Public
010: * License as published by the Free Software Foundation;
011: * either version 2 of the License, or (at your option) any
012: * later version.
013: *
014: * The GNU General Public License can be found at
015: * http://www.gnu.org/copyleft/gpl.html.
016: * A copy is found in the textfile GPL.txt and important notices to the
017: * license from the author are found in LICENSE.txt distributed with
018: * these libraries.
019: *
020: * This library is distributed in the hope that it will be useful,
021: * but WITHOUT ANY WARRANTY; without even the implied warranty of
022: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
023: * GNU General Public License for more details.
024: *
025: * For further information about UCS - unique computing solutions gmbh,
026: * please see the company website: http://www.ucs.at
027: *
028: * For further information about [fleXive](R), please see the
029: * project website: http://www.flexive.org
030: *
031: *
032: * This copyright notice MUST APPEAR in all copies of the file!
033: ***************************************************************/package com.flexive.faces.components.menu;
034:
035: import com.flexive.faces.FxJsfComponentUtils;
036: import com.flexive.faces.FxJsfUtils;
037: import com.flexive.faces.components.Tree;
038: import com.flexive.faces.javascript.menu.MenuItem;
039: import com.flexive.faces.javascript.menu.MenuItemContainer;
040:
041: import javax.faces.component.UIOutput;
042: import javax.faces.context.FacesContext;
043: import java.io.IOException;
044: import java.util.ArrayList;
045: import java.util.List;
046:
047: /**
048: * Tree context menu container.
049: *
050: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
051: * @version $Rev: 1 $
052: */
053: public class TreeContextMenu extends UIOutput implements
054: MenuItemContainer {
055: private final List<MenuItem> menuItems = new ArrayList<MenuItem>();
056: private String showHandler;
057:
058: public TreeContextMenu() {
059: }
060:
061: /**
062: * {@inheritDoc}
063: */
064: @Override
065: public boolean getRendersChildren() {
066: return true;
067: }
068:
069: /**
070: * {@inheritDoc}
071: */
072: @Override
073: public void encodeBegin(FacesContext facesContext)
074: throws IOException {
075: // attach menu to enclosing tree
076: FxJsfUtils.findAncestor(this , Tree.class).setContextMenu(this );
077: }
078:
079: /**
080: * {@inheritDoc}
081: */
082: public void addMenuItem(MenuItem menuItem) {
083: menuItems.add(menuItem);
084: }
085:
086: /**
087: * {@inheritDoc}
088: */
089: public List<MenuItem> getMenuItems() {
090: return menuItems;
091: }
092:
093: public String getShowHandler() {
094: if (showHandler == null) {
095: showHandler = FxJsfComponentUtils.getStringValue(this ,
096: "showHandler");
097: }
098: return showHandler;
099: }
100:
101: public void setShowHandler(String showHandler) {
102: this.showHandler = showHandler;
103: }
104: }
|