001/* 002 * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * bstefanescu 016 * 017 * $Id$ 018 */ 019 020package org.nuxeo.ecm.webengine.ui.tree; 021 022import java.io.Serializable; 023 024/** 025 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 026 */ 027public interface ContentProvider extends Serializable { 028 029 /** 030 * Gets the name of the object. 031 * <p> 032 * The name must be an unique identifier relative to the parent item. It will be used as node names in the tree so 033 * that they will construct the item path. 034 * 035 * @param obj the object 036 * @return the name 037 */ 038 String getName(Object obj); 039 040 /** 041 * Gets the label to be used when displaying the given object. 042 * 043 * @param obj the object 044 * @return the label 045 */ 046 String getLabel(Object obj); 047 048 /** 049 * Gets the object facets. 050 * <p> 051 * Facets are arbitrary strings that should describe object capabilities and can be used to decorate later the item. 052 * <p> 053 * In a web environment they may be translated to CSS classes. 054 * 055 * @return item facets 056 */ 057 String[] getFacets(Object object); 058 059 /** 060 * Whether the given object may have children (e.g it's a container). 061 * 062 * @param obj the object to test 063 * @return true if it may have children, false otherwise 064 */ 065 boolean isContainer(Object obj); 066 067 /** 068 * Gets the top level items. 069 * <p> 070 * The items will be shown on the top level of the tree. These items are computed from the tree input that will be 071 * considered the tree root. The tree root is not visible. 072 * 073 * @param input the tree view input 074 * @return the top level items 075 */ 076 Object[] getElements(Object input); 077 078 /** 079 * Gets the children for the given object. 080 * <p> 081 * This method is used to populate the nested branches of the tree. 082 * 083 * @param obj the object 084 * @return the children or null if no children are supported 085 */ 086 Object[] getChildren(Object obj); 087 088}