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 024import org.nuxeo.common.utils.Path; 025 026/** 027 * A tree view manage a tree structure of items. The tree data is lazy loaded by using the data provider specified at 028 * tree view creation. 029 * 030 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a> 031 */ 032public interface TreeModel extends Serializable { 033 034 /** 035 * Gets the content provider used by this tree. 036 */ 037 ContentProvider getContentProvider(); 038 039 /** 040 * Sets the content provider to be used by this tree. 041 */ 042 void setContentProvider(ContentProvider provider); 043 044 /** 045 * Sets the input data. 046 * 047 * @param input (may be null) 048 */ 049 void setInput(Object input); 050 051 /** 052 * Gets the current input of the tree. 053 * 054 * @return the tree input data. may be null. 055 */ 056 Object getInput(); 057 058 /** 059 * Get the tree root item, or null if tree has no input. 060 * 061 * @return the root 062 */ 063 TreeItem getRoot(); 064 065 /** 066 * Find the item at the given path. Only loaded items are searched. This operation will not load any extra item. 067 * 068 * @param path the path to search 069 * @return the item at the given path or null if none 070 */ 071 TreeItem find(String path); 072 073 /** 074 * Find and item given it's path and expand parents if needed. The returned item is not explicitly expanded so it 075 * may be collapsed or its children if any not yet loaded 076 * 077 * @param path the path to search 078 * @return the item or null if none 079 */ 080 TreeItem findAndReveal(String path); 081 082 /** 083 * Like {@link #find(Path)} but the path is expressed as a {@link Path} object. 084 * 085 * @see #find(String) 086 */ 087 TreeItem find(Path path); 088 089 /** 090 * Like {@link #findAndReveal(Path)} but the path is expressed as a {@link Path} object. 091 * 092 * @see #findAndReveal(String) 093 */ 094 TreeItem findAndReveal(Path path); 095 096}