View Javadoc
1   //
2   // $Id$
3   //
4   // jupload - A file upload applet.
5   //
6   // Copyright 2015 The JUpload Team
7   //
8   // Created: 7 févr. 2015
9   // Creator: etienne_sf
10  // Last modified: $Date$
11  //
12  // This program is free software; you can redistribute it and/or modify
13  // it under the terms of the GNU General Public License as published by
14  // the Free Software Foundation; either version 2 of the License, or
15  // (at your option) any later version.
16  //
17  // This program is distributed in the hope that it will be useful,
18  // but WITHOUT ANY WARRANTY; without even the implied warranty of
19  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  // GNU General Public License for more details.
21  //
22  // You should have received a copy of the GNU General Public License
23  // along with this program; if not, write to the Free Software
24  // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  
26  package wjhk.jupload2.gui.filepanel.treeview;
27  
28  import java.util.List;
29  
30  import javax.swing.event.TreeModelEvent;
31  import javax.swing.tree.TreeModel;
32  import javax.swing.tree.TreePath;
33  
34  import wjhk.jupload2.gui.filepanel.FilePanelFlatDataModel2;
35  
36  /**
37   * @author etienne_sf
38   */
39  public interface MyTreeNode {
40  
41      /**
42       * Returns the list of direct children for this node
43       *
44       * @return the children for this node
45       */
46      List<MyTreeNode> getChildren();
47  
48      /**
49       * Returns the number of direct children for this node
50       * 
51       * @return Number of direct children
52       */
53      int getChildCount();
54  
55      /**
56       * Returns the number of children (direct children children of children...) for this node
57       * 
58       * @return Number of direct children
59       */
60      public int getTotalChildCount();
61  
62      /**
63       * Get the child with the given index number, from the direct children of this node
64       * 
65       * @param index
66       * @return
67       */
68      public MyTreeNode getChild(int index);
69  
70      /**
71       * Get the child with the name, from the direct children of this node.
72       * 
73       * @param name The name of the item we're looking for. For a file, it's the filename, not the absolute path.
74       * @return The child with this name, or null of no such child exists
75       */
76      public MyTreeNode getChild(String name);
77  
78      /**
79       * Returns the parent for this node.
80       * 
81       * @return
82       */
83      public MyTreeNode getParent();
84  
85      /**
86       * Sets the parent for this node.
87       * 
88       * @return
89       */
90      public void setParent(MyTreeNode parent);
91  
92      /**
93       * Sets the tree model for the current node. Necessary to properly send the {@link TreeModelEvent}.
94       * 
95       * @param model The model in which this node is, and to which {@link TreeModelEvent} must be sent.
96       */
97      public void setTreeModel(TreeModel model);
98  
99      /**
100      * Sets the flat model for the current node. It is necessary, as this flat model must be kept synchronized with the
101      * tree model. Each adding o f a child in the tree, must also be done in the flat model.
102      * 
103      * @param model The model, which must be kept synchronized.
104      */
105     public void setFlatModel(FilePanelFlatDataModel2 model);
106 
107     /**
108      * Removes a child from the children of this node.
109      * 
110      * @param child The child to remove
111      * @throws IllegalArgumentException If child is not an actual child of the current {@link FolderNode}.
112      */
113     public void removeChild(MyTreeNode child);
114 
115     /** Indicates whether this node has children or not ('terminal' node) */
116     boolean isLeaf();
117 
118     /**
119      * Get the {@link TreePath} for this node, in the hierarchy.
120      * 
121      * @return
122      */
123     public TreePath getTreePath();
124 
125 }