projectviewer.vpt
Class VPTFileListModel

java.lang.Object
  extended byjavax.swing.tree.DefaultTreeModel
      extended byprojectviewer.vpt.VPTFileListModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.tree.TreeModel

public class VPTFileListModel
extends javax.swing.tree.DefaultTreeModel

A tree model that represents all files in a project without any relationship to the nodes they are a child of.

This model, similarly to the other "flat model": VPTWorkingFileList, is a little dumb, for the sake of code simplicity. Using "insertNodeInto" or similar methods will not work for these models. The only structure change supported is the nodeStructureChanged() method. So, classes that change the tree structure in some way should wait until all changes are made and then call this method for the project node or the root node of the tree, preferably using the "broadcast" method available in the ProjectViewer class.

Version:
$Id: VPTFileListModel.java 9433 2007-04-15 01:45:09Z vanza $
Author:
Marcelo Vanzin
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultTreeModel
asksAllowsChildren, listenerList, root
 
Constructor Summary
VPTFileListModel(VPTNode rootNode)
          Create a new VPTFileListModel.
 
Method Summary
 void cleanup(VPTProject p)
           
 java.lang.Object getChild(java.lang.Object parent, int index)
          Returns the child at the given index of the given parent.
 int getChildCount(java.lang.Object parent)
          Returns the child at the given index of the given parent.
 int getIndexOfChild(java.lang.Object parent, java.lang.Object child)
           
 javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode)
           
 void nodeChanged(javax.swing.tree.TreeNode node)
          Handles a node changed request.
 void nodeStructureChanged(javax.swing.tree.TreeNode node)
          Called when some node in the tree is changed.
 
Methods inherited from class javax.swing.tree.DefaultTreeModel
addTreeModelListener, asksAllowsChildren, fireTreeNodesChanged, fireTreeNodesInserted, fireTreeNodesRemoved, fireTreeStructureChanged, getListeners, getPathToRoot, getRoot, getTreeModelListeners, insertNodeInto, isLeaf, nodesChanged, nodesWereInserted, nodesWereRemoved, reload, reload, removeNodeFromParent, removeTreeModelListener, setAsksAllowsChildren, setRoot, valueForPathChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VPTFileListModel

public VPTFileListModel(VPTNode rootNode)
Create a new VPTFileListModel.

Parameters:
rootNode - The root node of the tree.
Method Detail

getChildCount

public int getChildCount(java.lang.Object parent)
Returns the child at the given index of the given parent. If the parent is a project, returns the number of files in the project, not just the files that are direct children of the project.


getChild

public java.lang.Object getChild(java.lang.Object parent,
                                 int index)
Returns the child at the given index of the given parent. If the parent is a project, treats the children in such a way to allow all files in the project to be displayed in a flat list.


nodeStructureChanged

public void nodeStructureChanged(javax.swing.tree.TreeNode node)
Called when some node in the tree is changed. If not the root, then tracks down which project was changed and updates the child list.


getIndexOfChild

public int getIndexOfChild(java.lang.Object parent,
                           java.lang.Object child)

getPathToRoot

public javax.swing.tree.TreeNode[] getPathToRoot(javax.swing.tree.TreeNode aNode)

nodeChanged

public void nodeChanged(javax.swing.tree.TreeNode node)
Handles a node changed request.


cleanup

public void cleanup(VPTProject p)