001    /*
002     * Copyright (c) 2005 Einar Pehrson, Malin Johansson and Sofia Nilsson
003     *
004     * This file is part of
005     * CleanSheets Extension for Dependency Trees
006     *
007     * CleanSheets Extension for Dependency Trees is free software; you can
008     * redistribute it and/or modify it under the terms of the GNU General Public
009     * License as published by the Free Software Foundation; either version 2 of
010     * the License, or (at your option) any later version.
011     *
012     * CleanSheets Extension for Dependency Trees is distributed in the hope that
013     * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
014     * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
015     * See the GNU General Public License for more details.
016     *
017     * You should have received a copy of the GNU General Public License
018     * along with CleanSheets Extension for Dependency Trees; if not, write to the
019     * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
020     * Boston, MA  02111-1307  USA
021     */
022    package csheets.ext.deptree;
023    
024    import javax.swing.tree.DefaultMutableTreeNode;
025    import javax.swing.tree.DefaultTreeModel;
026    
027    import csheets.core.Cell;
028    import csheets.core.Spreadsheet;
029    import csheets.core.formula.Reference;
030    import csheets.ui.ctrl.UIController;
031    
032    /**
033     * A mutable tree node containing a reference. The addresses that the reference
034     * points to are added as child nodes.
035     * @author Einar Pehrson
036     */
037    @SuppressWarnings("serial")
038    public class ReferenceNode extends DefaultMutableTreeNode {
039    
040            /**
041             * Creates a new reference node.
042             * @param reference the reference of the node
043             * @param treeModel the data model to which the node belongs
044             * @param uiController the user interface controller
045             */
046            public ReferenceNode(Reference reference, Spreadsheet spreadsheet,
047                    DefaultTreeModel treeModel, UIController uiController) {
048                    super(reference);
049    
050                    // Adds children
051                    for (Cell cell : reference.getCells())
052                            add(new PrecedentsNode(cell, treeModel, uiController));
053            }
054    }