001/* 002 * (C) Copyright 2006-2008 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.webengine.ui.tree; 023 024import java.io.Serializable; 025 026/** 027 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 028 */ 029public interface ContentProvider extends Serializable { 030 031 /** 032 * Gets the name of the object. 033 * <p> 034 * The name must be an unique identifier relative to the parent item. It will be used as node names in the tree so 035 * that they will construct the item path. 036 * 037 * @param obj the object 038 * @return the name 039 */ 040 String getName(Object obj); 041 042 /** 043 * Gets the label to be used when displaying the given object. 044 * 045 * @param obj the object 046 * @return the label 047 */ 048 String getLabel(Object obj); 049 050 /** 051 * Gets the object facets. 052 * <p> 053 * Facets are arbitrary strings that should describe object capabilities and can be used to decorate later the item. 054 * <p> 055 * In a web environment they may be translated to CSS classes. 056 * 057 * @return item facets 058 */ 059 String[] getFacets(Object object); 060 061 /** 062 * Whether the given object may have children (e.g it's a container). 063 * 064 * @param obj the object to test 065 * @return true if it may have children, false otherwise 066 */ 067 boolean isContainer(Object obj); 068 069 /** 070 * Gets the top level items. 071 * <p> 072 * The items will be shown on the top level of the tree. These items are computed from the tree input that will be 073 * considered the tree root. The tree root is not visible. 074 * 075 * @param input the tree view input 076 * @return the top level items 077 */ 078 Object[] getElements(Object input); 079 080 /** 081 * Gets the children for the given object. 082 * <p> 083 * This method is used to populate the nested branches of the tree. 084 * 085 * @param obj the object 086 * @return the children or null if no children are supported 087 */ 088 Object[] getChildren(Object obj); 089 090}