ActTreeSelectionChanged.java :  » Swing-Library » swingexplorer » org » swingexplorer » Java Open Source

Java Open Source » Swing Library » swingexplorer 
swingexplorer » org » swingexplorer » ActTreeSelectionChanged.java
/*
 * Swing Explorer. Tool for developers exploring Java/Swing-based application internals. 
 * Copyright (C) 2008, Maxim Zakharenkov
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 * 
 * $Header: /cvs/swingexplorer/src/org/swingexplorer/ActTreeSelectionChanged.java,v 1.2 2008/02/06 08:36:08 maxz1 Exp $
 */
package org.swingexplorer;

import java.awt.Component;

import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;

/**
 *
 * @author Maxim Zakharenkov
 */
public class ActTreeSelectionChanged implements TreeSelectionListener {
    
    MdlSwingExplorer model;
    PNLComponentTree pnlComponentTree;
    
    /** Creates a new instance of ActTreeSelectionChanged */
    public ActTreeSelectionChanged(MdlSwingExplorer modelP, PNLComponentTree pnlComponentTreeP) {
        model = modelP;
        pnlComponentTree = pnlComponentTreeP;
    }

    public void valueChanged(TreeSelectionEvent e) {
      TreePath[] paths = e.getPaths();
    for (TreePath curPath : paths) {

      Component component = pnlComponentTree.getComponent(curPath);

      if (e.isAddedPath(curPath)) {
        model.addSelection(component);
      } else {
        model.removeSelection(component);
      }
    }
    }    
}
/*
 * $Log: ActTreeSelectionChanged.java,v $
 * Revision 1.2  2008/02/06 08:36:08  maxz1
 * Changed license header
 *
 * Revision 1.1  2007/06/27 19:41:37  maxz1
 * new
 *
 */
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.