001/*
002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
003 * 
004 * This software is open source. 
005 * See the bottom of this file for the licence.
006 * 
007 * $Id: DocumentTreeModel.java,v 1.1 2001/04/10 19:12:08 jstrachan Exp $
008 */
009
010package org.dom4j.swing;
011
012import javax.swing.tree.DefaultTreeModel;
013   
014import org.dom4j.Document;
015
016/** <p><code>DocumentTreeModel</code> implements a Swing TreeModel
017  * for a dom4j XML Document.</p>
018  *
019  * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> (james.strachan@metastuff.com)
020  * @author Jakob Jenkov
021  * @version $Revision: 1.1 $ 
022  */
023public class DocumentTreeModel extends DefaultTreeModel {
024
025    /** The document for this model */
026    protected Document document;
027
028    
029    public DocumentTreeModel(Document document) {
030        super( new BranchTreeNode( document ) );
031        this.document = document;
032    }
033    
034    
035    
036    // Properties
037    //-------------------------------------------------------------------------                
038    
039    /** @return the <code>Document</code> instance that this 
040      * <code>TreeModel</code> is based on 
041      */
042    public Document getDocument() {
043        return document;
044    }
045    
046    /** Sets the <code>Document</code> instance that this 
047      * <code>TreeModel</code> is based on 
048      */
049    public void setDocument(Document document) {
050        this.document = document;
051        setRoot( new BranchTreeNode( document ) );
052    }
053    
054}
055
056
057
058
059/*
060 * Redistribution and use of this software and associated documentation
061 * ("Software"), with or without modification, are permitted provided
062 * that the following conditions are met:
063 *
064 * 1. Redistributions of source code must retain copyright
065 *    statements and notices.  Redistributions must also contain a
066 *    copy of this document.
067 *
068 * 2. Redistributions in binary form must reproduce the
069 *    above copyright notice, this list of conditions and the
070 *    following disclaimer in the documentation and/or other
071 *    materials provided with the distribution.
072 *
073 * 3. The name "DOM4J" must not be used to endorse or promote
074 *    products derived from this Software without prior written
075 *    permission of MetaStuff, Ltd.  For written permission,
076 *    please contact dom4j-info@metastuff.com.
077 *
078 * 4. Products derived from this Software may not be called "DOM4J"
079 *    nor may "DOM4J" appear in their names without prior written
080 *    permission of MetaStuff, Ltd. DOM4J is a registered
081 *    trademark of MetaStuff, Ltd.
082 *
083 * 5. Due credit should be given to the DOM4J Project
084 *    (http://dom4j.org/).
085 *
086 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
087 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
088 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
089 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
090 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
091 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
092 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
093 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
094 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
095 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
096 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
097 * OF THE POSSIBILITY OF SUCH DAMAGE.
098 *
099 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
100 *
101 * $Id: DocumentTreeModel.java,v 1.1 2001/04/10 19:12:08 jstrachan Exp $
102 */