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 */
022package csheets.ext.deptree;
023
024import csheets.core.Cell;
025import csheets.ui.ctrl.SelectionEvent;
026import csheets.ui.ctrl.UIController;
027
028/**
029 * A tree displaying the dependents of a cell.
030 * @author Einar Pehrson
031 */
032@SuppressWarnings("serial")
033public class DependentsTree extends DependencyTree {
034
035        /**
036         * Creates a mew dependents tree.
037         * @param uiController the user interface controller
038         */
039        public DependentsTree(UIController uiController) {
040                super(uiController);
041        }
042
043        public void selectionChanged(SelectionEvent event) {
044                Cell cell = event.getCell();
045                if (event.isCellChanged())
046                        if (cell != null) {
047                                CellNode node = new DependentsNode(cell, treeModel);
048                                node.populate();
049                                treeModel.setRoot(node);
050                        } else
051                                treeModel.setRoot(null);
052        }
053}