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