/[classpath]/classpath/javax/swing/plaf/basic/BasicTreeUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicTreeUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by langel, Wed Jul 6 20:33:15 2005 UTC revision 1.19 by rabbit78, Thu Jul 7 09:00:11 2005 UTC
# Line 1  Line 1 
1  /*  /* BasicTreeUI.java --
2   * BasicTreeUI.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc.     Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
3   *  
4   * This file is part of GNU Classpath.     This file is part of GNU Classpath.
5   *  
6   * GNU Classpath is free software; you can redistribute it and/or modify it     GNU Classpath is free software; you can redistribute it and/or modify
7   * under the terms of the GNU General Public License as published by the Free     it under the terms of the GNU General Public License as published by
8   * Software Foundation; either version 2, or (at your option) any later version.     the Free Software Foundation; either version 2, or (at your option)
9   *     any later version.
10   * GNU Classpath is distributed in the hope that it will be useful, but WITHOUT  
11   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS     GNU Classpath is distributed in the hope that it will be useful, but
12   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more     WITHOUT ANY WARRANTY; without even the implied warranty of
13   * details.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *     General Public License for more details.
15   * You should have received a copy of the GNU General Public License along with  
16   * GNU Classpath; see the file COPYING. If not, write to the Free Software     You should have received a copy of the GNU General Public License
17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.     along with GNU Classpath; see the file COPYING.  If not, write to the
18   *     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19   * Linking this library statically or dynamically with other modules is making a     02110-1301 USA.
20   * combined work based on this library. Thus, the terms and conditions of the  
21   * GNU General Public License cover the whole combination.     Linking this library statically or dynamically with other modules is
22   *     making a combined work based on this library.  Thus, the terms and
23   * As a special exception, the copyright holders of this library give you     conditions of the GNU General Public License cover the whole
24   * permission to link this library with independent modules to produce an     combination.
25   * executable, regardless of the license terms of these independent modules, and  
26   * to copy and distribute the resulting executable under terms of your choice,     As a special exception, the copyright holders of this library give you
27   * provided that you also meet, for each linked independent module, the terms     permission to link this library with independent modules to produce an
28   * and conditions of the license of that module. An independent module is a     executable, regardless of the license terms of these independent
29   * module which is not derived from or based on this library. If you modify this     modules, and to copy and distribute the resulting executable under
30   * library, you may extend this exception to your version of the library, but     terms of your choice, provided that you also meet, for each linked
31   * you are not obligated to do so. If you do not wish to do so, delete this     independent module, the terms and conditions of the license of that
32   * exception statement from your version.     module.  An independent module is a module which is not derived from
33   */     or based on this library.  If you modify this library, you may extend
34       this exception to your version of the library, but you are not
35       obligated to do so.  If you do not wish to do so, delete this
36       exception statement from your version. */
37    
38  package javax.swing.plaf.basic;  package javax.swing.plaf.basic;
39    
# Line 107  import java.util.Hashtable; Line 110  import java.util.Hashtable;
110   * @author Lillian Angel (langel@redhat.com)   * @author Lillian Angel (langel@redhat.com)
111   */   */
112  public class BasicTreeUI  public class BasicTreeUI
113                  extends TreeUI    extends TreeUI
114  {  {
115    
116          /** Collapse Icon for the tree. */    /** Collapse Icon for the tree. */
117          protected transient Icon collapsedIcon;    protected transient Icon collapsedIcon;
118    
119          /** Expanded Icon for the tree. */    /** Expanded Icon for the tree. */
120          protected transient Icon expandedIcon;    protected transient Icon expandedIcon;
121    
122          /** Distance between left margin and where vertical dashes will be drawn. */    /** Distance between left margin and where vertical dashes will be drawn. */
123          protected int leftChildIndent;    protected int leftChildIndent;
124    
125          /**    /**
126           * Distance between leftChildIndent and where cell contents will be drawn.     * Distance between leftChildIndent and where cell contents will be drawn.
127           */     */
128          protected int rightChildIndent;    protected int rightChildIndent;
129    
130          /**    /**
131           * Total fistance that will be indented. The sum of leftChildIndent and     * Total fistance that will be indented. The sum of leftChildIndent and
132           * rightChildIndent .     * rightChildIndent .
133           */     */
134          protected int totalChildIndent;    protected int totalChildIndent;
135    
136          /** Minimum preferred size. */    /** Minimum preferred size. */
137          protected Dimension preferredMinsize;    protected Dimension preferredMinsize;
138    
139          /** Index of the row that was last selected. */    /** Index of the row that was last selected. */
140          protected int lastSelectedRow;    protected int lastSelectedRow;
141    
142          /** Component that we're going to be drawing onto. */    /** Component that we're going to be drawing onto. */
143          protected JTree tree;    protected JTree tree;
144    
145          /** Renderer that is being used to do the actual cell drawing. */    /** Renderer that is being used to do the actual cell drawing. */
146          protected transient TreeCellRenderer currentCellRenderer;    protected transient TreeCellRenderer currentCellRenderer;
147    
148          /**    /**
149           * Set to true if the renderer that is currently in the tree was created by     * Set to true if the renderer that is currently in the tree was created by
150           * this instance.     * this instance.
151           */     */
152          protected boolean createdRenderer;    protected boolean createdRenderer;
153    
154          /** Editor for the tree. */    /** Editor for the tree. */
155          protected transient TreeCellEditor cellEditor;    protected transient TreeCellEditor cellEditor;
156    
157          /**    /**
158           * Set to true if editor that is currently in the tree was created by this     * Set to true if editor that is currently in the tree was created by this
159           * instance.     * instance.
160           */     */
161          protected boolean createdCellEditor;    protected boolean createdCellEditor;
162    
163          /**    /**
164           * Set to false when editing and shouldSelectCall() returns true meaning the     * Set to false when editing and shouldSelectCall() returns true meaning the
165           * node should be selected before editing, used in completeEditing.     * node should be selected before editing, used in completeEditing.
166           */     */
167          protected boolean stopEditingInCompleteEditing;    protected boolean stopEditingInCompleteEditing;
168    
169          /** Used to paint the TreeCellRenderer. */    /** Used to paint the TreeCellRenderer. */
170          protected CellRendererPane rendererPane;    protected CellRendererPane rendererPane;
171    
172          /** Size needed to completely display all the nodes. */    /** Size needed to completely display all the nodes. */
173          protected Dimension preferredSize;    protected Dimension preferredSize;
174    
175          /** Is the preferredSize valid? */    /** Is the preferredSize valid? */
176          protected boolean validCachedPreferredSize;    protected boolean validCachedPreferredSize;
177    
178          /** Object responsible for handling sizing and expanded issues. */    /** Object responsible for handling sizing and expanded issues. */
179          protected AbstractLayoutCache treeState;    protected AbstractLayoutCache treeState;
180    
181          /** Used for minimizing the drawing of vertical lines. */    /** Used for minimizing the drawing of vertical lines. */
182          protected Hashtable drawingCache;    protected Hashtable drawingCache;
183    
184          /**    /**
185           * True if doing optimizations for a largeModel. Subclasses that don't     * True if doing optimizations for a largeModel. Subclasses that don't
186           * support this may wish to override createLayoutCache to not return a     * support this may wish to override createLayoutCache to not return a
187           * FixedHeightLayoutCache instance.     * FixedHeightLayoutCache instance.
188           */     */
189          protected boolean largeModel;    protected boolean largeModel;
190    
191          /** Responsible for telling the TreeState the size needed for a node. */    /** Responsible for telling the TreeState the size needed for a node. */
192          protected AbstractLayoutCache.NodeDimensions nodeDimensions;    protected AbstractLayoutCache.NodeDimensions nodeDimensions;
193    
194          /** Used to determine what to display. */    /** Used to determine what to display. */
195          protected TreeModel treeModel;    protected TreeModel treeModel;
196    
197          /** Model maintaining the selection. */    /** Model maintaining the selection. */
198          protected TreeSelectionModel treeSelectionModel;    protected TreeSelectionModel treeSelectionModel;
199    
200          /**    /**
201           * How much the depth should be offset to properly calculate x locations.     * How much the depth should be offset to properly calculate x locations.
202           * This is based on whether or not the root is visible, and if the root     * This is based on whether or not the root is visible, and if the root
203           * handles are visible.     * handles are visible.
204           */     */
205          protected int depthOffset;    protected int depthOffset;
206    
207          /**    /**
208           * When editing, this will be the Component that is doing the actual     * When editing, this will be the Component that is doing the actual
209           * editing.     * editing.
210           */     */
211          protected Component editingComponent;    protected Component editingComponent;
212    
213          /** Path that is being edited. */    /** Path that is being edited. */
214          protected TreePath editingPath;    protected TreePath editingPath;
215    
216          /**    /**
217           * Row that is being edited. Should only be referenced if editingComponent     * Row that is being edited. Should only be referenced if editingComponent
218           * is null.     * is null.
219           */     */
220          protected int editingRow;    protected int editingRow;
221    
222          /** Set to true if the editor has a different size than the renderer. */    /** Set to true if the editor has a different size than the renderer. */
223          protected boolean editorHasDifferentSize;    protected boolean editorHasDifferentSize;
224    
225          /** Listeners */    /** Listeners */
226          private PropertyChangeListener propertyChangeListener;    private PropertyChangeListener propertyChangeListener;
227          private FocusListener focusListener;    private FocusListener focusListener;
228          private TreeSelectionListener treeSelectionListener;    private TreeSelectionListener treeSelectionListener;
229          private MouseInputListener mouseInputListener;    private MouseInputListener mouseInputListener;
230          private KeyListener keyListener;    private KeyListener keyListener;
231          private PropertyChangeListener selectionModelPropertyChangeListener;    private PropertyChangeListener selectionModelPropertyChangeListener;
232          private ComponentListener componentListener;    private ComponentListener componentListener;
233          private CellEditorListener cellEditorListener;    private CellEditorListener cellEditorListener;
234          private TreeExpansionListener treeExpansionListener;    private TreeExpansionListener treeExpansionListener;
235          private TreeModelListener treeModelListener;    private TreeModelListener treeModelListener;
236    
237          /**    /**
238           * Creates a new BasicTreeUI object.     * Creates a new BasicTreeUI object.
239           */     */
240          public BasicTreeUI()    public BasicTreeUI()
241          {    {
242                  drawingCache = new Hashtable();      drawingCache = new Hashtable();
243                  cellEditor = createDefaultCellEditor();      cellEditor = createDefaultCellEditor();
244                  currentCellRenderer = createDefaultCellRenderer();      currentCellRenderer = createDefaultCellRenderer();
245                  nodeDimensions = createNodeDimensions();      nodeDimensions = createNodeDimensions();
246                  rendererPane = createCellRendererPane();      rendererPane = createCellRendererPane();
247                  configureLayoutCache();      configureLayoutCache();
248    
249                  propertyChangeListener = createPropertyChangeListener();      propertyChangeListener = createPropertyChangeListener();
250                  focusListener = createFocusListener();      focusListener = createFocusListener();
251                  treeSelectionListener = createTreeSelectionListener();      treeSelectionListener = createTreeSelectionListener();
252                  mouseInputListener = new MouseInputHandler(null, null, null);      mouseInputListener = new MouseInputHandler(null, null, null);
253                  keyListener = createKeyListener();      keyListener = createKeyListener();
254                  selectionModelPropertyChangeListener = createSelectionModelPropertyChangeListener();      selectionModelPropertyChangeListener =
255                  componentListener = createComponentListener();        createSelectionModelPropertyChangeListener();
256                  cellEditorListener = createCellEditorListener();      componentListener = createComponentListener();
257                  treeExpansionListener = createTreeExpansionListener();      cellEditorListener = createCellEditorListener();
258                  treeModelListener = createTreeModelListener();      treeExpansionListener = createTreeExpansionListener();
259        treeModelListener = createTreeModelListener();
260                  createdRenderer = true;  
261                  createdCellEditor = true;      createdRenderer = true;
262                  editingRow = -1;      createdCellEditor = true;
263                  lastSelectedRow = -1;      editingRow = -1;
264          }      lastSelectedRow = -1;
265      }
266          /**  
267           * Returns an instance of the UI delegate for the specified component.    /**
268           *     * Returns an instance of the UI delegate for the specified component.
269           * @param c the <code>JComponent</code> for which we need a UI delegate     *
270           *        for.     * @param c the <code>JComponent</code> for which we need a UI delegate
271           * @return the <code>ComponentUI</code> for c.     *        for.
272           */     * @return the <code>ComponentUI</code> for c.
273          public static ComponentUI createUI(JComponent c)     */
274          {    public static ComponentUI createUI(JComponent c)
275                  return new BasicTreeUI();    {
276          }      return new BasicTreeUI();
277      }
278          /**  
279           * Returns the Hash color.    /**
280           *     * Returns the Hash color.
281           * @return the <code>Color</code> of the Hash.     *
282           */     * @return the <code>Color</code> of the Hash.
283          protected Color getHashColor()     */
284          {    protected Color getHashColor()
285                  return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");    {
286          }      return UIManager.getLookAndFeelDefaults().getColor("Tree.hash");
287      }
288          /**  
289           * Sets the Hash color.    /**
290           *     * Sets the Hash color.
291           * @param the <code>Color</code> to set the Hash to.     *
292           */     * @param the <code>Color</code> to set the Hash to.
293          protected void setHashColor(Color color)     */
294          {    protected void setHashColor(Color color)
295                  // FIXME: not implemented    {
296        // FIXME: not implemented
297          }      
298      }
299          /**  
300           * Sets the left child's indent value.    /**
301           *     * Sets the left child's indent value.
302           * @param newAmount is the new indent value for the left child.     *
303           */     * @param newAmount is the new indent value for the left child.
304          public void setLeftChildIndent(int newAmount)     */
305          {    public void setLeftChildIndent(int newAmount)
306                  leftChildIndent = newAmount;    {
307          }      leftChildIndent = newAmount;
308      }
309          /**  
310           * Returns the indent value for the left child.    /**
311           *     * Returns the indent value for the left child.
312           * @return the indent value for the left child.     *
313           */     * @return the indent value for the left child.
314          public int getLeftChildIndent(int newAmount)     */
315          {    public int getLeftChildIndent(int newAmount)
316                  return leftChildIndent;    {
317          }      return leftChildIndent;
318      }
319          /**  
320           * Sets the right child's indent value.    /**
321           *     * Sets the right child's indent value.
322           * @param newAmount is the new indent value for the right child.     *
323           */     * @param newAmount is the new indent value for the right child.
324          public void setRightChildIndent(int newAmount)     */
325          {    public void setRightChildIndent(int newAmount)
326                  rightChildIndent = newAmount;    {
327          }      rightChildIndent = newAmount;
328      }
329          /**  
330           * Returns the indent value for the right child.    /**
331           *     * Returns the indent value for the right child.
332           * @return the indent value for the right child.     *
333           */     * @return the indent value for the right child.
334          public int getRightChildIndent(int newAmount)     */
335          {    public int getRightChildIndent(int newAmount)
336                  return rightChildIndent;    {
337          }      return rightChildIndent;
338      }
339          /**  
340           * Sets the expanded icon.    /**
341           *     * Sets the expanded icon.
342           * @param newG is the new expanded icon.     *
343           */     * @param newG is the new expanded icon.
344          public void setExpandedIcon(Icon newG)     */
345          {    public void setExpandedIcon(Icon newG)
346                  expandedIcon = newG;    {
347          }      expandedIcon = newG;
348      }
349          /**  
350           * Returns the current expanded icon.    /**
351           *     * Returns the current expanded icon.
352           * @return the current expanded icon.     *
353           */     * @return the current expanded icon.
354          public Icon getExpandedIcon()     */
355          {    public Icon getExpandedIcon()
356                  return expandedIcon;    {
357          }      return expandedIcon;
358      }
359          /**  
360           * Sets the collapsed icon.    /**
361           *     * Sets the collapsed icon.
362           * @param newG is the new collapsed icon.     *
363           */     * @param newG is the new collapsed icon.
364          public void setCollapsedIcon(Icon newG)     */
365          {    public void setCollapsedIcon(Icon newG)
366                  collapsedIcon = newG;    {
367          }      collapsedIcon = newG;
368      }
369          /**  
370           * Returns the current collapsed icon.    /**
371           *     * Returns the current collapsed icon.
372           * @return the current collapsed icon.     *
373           */     * @return the current collapsed icon.
374          public Icon getCollapsedIcon()     */
375          {    public Icon getCollapsedIcon()
376                  return collapsedIcon;    {
377          }      return collapsedIcon;
378      }
379          /**  
380           * Updates the componentListener, if necessary.    /**
381           *     * Updates the componentListener, if necessary.
382           * @param largeModel sets this.largeModel to it.     *
383           */     * @param largeModel sets this.largeModel to it.
384          protected void setLargeModel(boolean largeModel)     */
385          {    protected void setLargeModel(boolean largeModel)
386                  if (largeModel != this.largeModel)    {
387                  {      if (largeModel != this.largeModel)
388                          tree.removeComponentListener(componentListener);        {
389                          this.largeModel = largeModel;          tree.removeComponentListener(componentListener);
390                          tree.addComponentListener(componentListener);          this.largeModel = largeModel;
391                  }          tree.addComponentListener(componentListener);
392          }        }
393      }
394          /**  
395           * Returns true if largeModel is set    /**
396           *     * Returns true if largeModel is set
397           * @return true if largeModel is set, otherwise false.     *
398           */     * @return true if largeModel is set, otherwise false.
399          protected boolean isLargeModel()     */
400          {    protected boolean isLargeModel()
401                  return largeModel;    {
402          }      return largeModel;
403      }
404          /**  
405           * Sets the row height.    /**
406           *     * Sets the row height.
407           * @param rowHeight is the height to set this.rowHeight to.     *
408           */     * @param rowHeight is the height to set this.rowHeight to.
409          protected void setRowHeight(int rowHeight)     */
410          {    protected void setRowHeight(int rowHeight)
411                  treeState.setRowHeight(rowHeight);    {
412          }      treeState.setRowHeight(rowHeight);
413      }
414          /**  
415           * Returns the current row height.    /**
416           *     * Returns the current row height.
417           * @return current row height.     *
418           */     * @return current row height.
419          protected int getRowHeight()     */
420          {    protected int getRowHeight()
421                  return treeState.getRowHeight();    {
422          }      return treeState.getRowHeight();
423      }
424          /**  
425           * Sets the TreeCellRenderer to <code>tcr</code>. This invokes    /**
426           * <code>updateRenderer</code>.     * Sets the TreeCellRenderer to <code>tcr</code>. This invokes
427           *     * <code>updateRenderer</code>.
428           * @param tcr is the new TreeCellRenderer.     *
429           */     * @param tcr is the new TreeCellRenderer.
430          protected void setCellRenderer(TreeCellRenderer tcr)     */
431          {    protected void setCellRenderer(TreeCellRenderer tcr)
432                  currentCellRenderer = tcr;    {
433                  updateRenderer();      currentCellRenderer = tcr;
434          }      updateRenderer();
435      }
436          /**  
437           * Return currentCellRenderer, which will either be the trees renderer, or    /**
438           * defaultCellRenderer, which ever was not null.     * Return currentCellRenderer, which will either be the trees renderer, or
439           *     * defaultCellRenderer, which ever was not null.
440           * @return the current Cell Renderer     *
441           */     * @return the current Cell Renderer
442          protected TreeCellRenderer getCellRenderer()     */
443          {    protected TreeCellRenderer getCellRenderer()
444                  if (currentCellRenderer != null)    {
445                          return currentCellRenderer;      if (currentCellRenderer != null)
446          return currentCellRenderer;
447                  return createDefaultCellRenderer();  
448          }      return createDefaultCellRenderer();
449      }
450          /**  
451           * Sets the tree's model.    /**
452           *     * Sets the tree's model.
453           * @param model to set the treeModel to.     *
454           */     * @param model to set the treeModel to.
455          protected void setModel(TreeModel model)     */
456          {    protected void setModel(TreeModel model)
457                  treeState.setModel(model);    {
458                  treeModel = model;      treeState.setModel(model);
459          }      treeModel = model;
460      }
461          /**  
462           * Returns the tree's model    /**
463           *     * Returns the tree's model
464           * @return treeModel     *
465           */     * @return treeModel
466          protected TreeModel getModel()     */
467          {    protected TreeModel getModel()
468                  return treeModel;    {
469          }      return treeModel;
470      }
471          /**  
472           * Sets the root to being visible.    /**
473           *     * Sets the root to being visible.
474           * @param newValue sets the visibility of the root     *
475           */     * @param newValue sets the visibility of the root
476          protected void setRootVisible(boolean newValue)     */
477          {    protected void setRootVisible(boolean newValue)
478                  treeState.setRootVisible(newValue);    {
479          }      treeState.setRootVisible(newValue);
480      }
481          /**  
482           * Returns true if the root is visible.    /**
483           *     * Returns true if the root is visible.
484           * @return true if the root is visible.     *
485           */     * @return true if the root is visible.
486          protected boolean isRootVisible()     */
487          {    protected boolean isRootVisible()
488                  return treeState.isRootVisible();    {
489          }      return treeState.isRootVisible();
490      }
491          /**  
492           * Determines whether the node handles are to be displayed.    /**
493           *     * Determines whether the node handles are to be displayed.
494           * @param newValue sets whether or not node handles should be displayed.     *
495           */     * @param newValue sets whether or not node handles should be displayed.
496          protected void setShowsRootHandles(boolean newValue)     */
497          {    protected void setShowsRootHandles(boolean newValue)
498                  tree.setShowsRootHandles(newValue);    {
499          }      tree.setShowsRootHandles(newValue);
500      }
501          /**  
502           * Returns true if the node handles are to be displayed.    /**
503           *     * Returns true if the node handles are to be displayed.
504           * @return true if the node handles are to be displayed.     *
505           */     * @return true if the node handles are to be displayed.
506          protected boolean getShowsRootHandles()     */
507          {    protected boolean getShowsRootHandles()
508                  return tree.getShowsRootHandles();    {
509          }      return tree.getShowsRootHandles();
510      }
511          /**  
512           * Sets the cell editor.    /**
513           *     * Sets the cell editor.
514           * @param editor to set the cellEditor to.     *
515           */     * @param editor to set the cellEditor to.
516          protected void setCellEditor(TreeCellEditor editor)     */
517          {    protected void setCellEditor(TreeCellEditor editor)
518                  cellEditor = editor;    {
519          }      cellEditor = editor;
520      }
521          /**  
522           * Returns the <code>TreeCellEditor</code> for this tree.    /**
523           *     * Returns the <code>TreeCellEditor</code> for this tree.
524           * @return the cellEditor for this tree.     *
525           */     * @return the cellEditor for this tree.
526          protected TreeCellEditor getCellEditor()     */
527          {    protected TreeCellEditor getCellEditor()
528                  return cellEditor;    {
529          }      return cellEditor;
530      }
531          /**  
532           * Configures the receiver to allow, or not allow, editing.    /**
533           *     * Configures the receiver to allow, or not allow, editing.
534           * @param newValue sets the receiver to allow editing if true.     *
535           */     * @param newValue sets the receiver to allow editing if true.
536          protected void setEditable(boolean newValue)     */
537          {    protected void setEditable(boolean newValue)
538                  tree.setEditable(newValue);    {
539          }      tree.setEditable(newValue);
540      }
541          /**  
542           * Returns true if the receiver allows editing.    /**
543           *     * Returns true if the receiver allows editing.
544           * @return true if the receiver allows editing.     *
545           */     * @return true if the receiver allows editing.
546          protected boolean isEditable()     */
547          {    protected boolean isEditable()
548                  return tree.isEditable();    {
549          }      return tree.isEditable();
550      }
551          /**  
552           * Resets the selection model. The appropriate listeners are installed on    /**
553           * the model.     * Resets the selection model. The appropriate listeners are installed on
554           *     * the model.
555           * @param newLSM resets the selection model.     *
556           */     * @param newLSM resets the selection model.
557          protected void setSelectionModel(TreeSelectionModel newLSM)     */
558          {    protected void setSelectionModel(TreeSelectionModel newLSM)
559                  if (newLSM != null)    {
560                  {      if (newLSM != null)
561                          treeSelectionModel = newLSM;        {
562                          tree.setSelectionModel(treeSelectionModel);          treeSelectionModel = newLSM;
563                  }          tree.setSelectionModel(treeSelectionModel);
564          }        }
565      }
566          /**  
567           * Returns the current selection model.    /**
568           *     * Returns the current selection model.
569           * @return the current selection model.     *
570           */     * @return the current selection model.
571          protected TreeSelectionModel getSelectionModel()     */
572          {    protected TreeSelectionModel getSelectionModel()
573                  return treeSelectionModel;    {
574          }      return treeSelectionModel;
575      }
576          /**  
577           * Returns the Rectangle enclosing the label portion that the last item in    /**
578           * path will be drawn to. Will return null if any component in path is     * Returns the Rectangle enclosing the label portion that the last item in
579           * currently valid.     * path will be drawn to. Will return null if any component in path is
580           *     * currently valid.
581           * @param tree is the current tree the path will be drawn to.     *
582           * @param path is the current path the tree to draw to.     * @param tree is the current tree the path will be drawn to.
583           * @return the Rectangle enclosing the label portion that the last item in     * @param path is the current path the tree to draw to.
584           *         the path will be drawn to.     * @return the Rectangle enclosing the label portion that the last item in
585           */     *         the path will be drawn to.
586          public Rectangle getPathBounds(JTree tree, TreePath path)     */
587          {    public Rectangle getPathBounds(JTree tree, TreePath path)
588                  // FIXME: not implemented    {
589                  return null;      // FIXME: not implemented
590          }      return null;
591      }
592          /**  
593           * Returns the path for passed in row. If row is not visible null is    /**
594           * returned.     * Returns the path for passed in row. If row is not visible null is
595           *     * returned.
596           * @param tree is the current tree to return path for.     *
597           * @param row is the row number of the row to return.     * @param tree is the current tree to return path for.
598           * @return the path for passed in row. If row is not visible null is     * @param row is the row number of the row to return.
599           *         returned.     * @return the path for passed in row. If row is not visible null is
600           */     *         returned.
601          public TreePath getPathForRow(JTree tree, int row)     */
602          {    public TreePath getPathForRow(JTree tree, int row)
603                  DefaultMutableTreeNode node = ((DefaultMutableTreeNode) (tree    {
604                                  .getModel()).getRoot());      DefaultMutableTreeNode node = ((DefaultMutableTreeNode)
605                                       (tree.getModel()).getRoot());
606                                    
607                  for (int i = 0; i < row; i++)      for (int i = 0; i < row; i++)
608                          node = getNextVisibleNode(node);        node = getNextVisibleNode(node);
609                                    
610                  // in case nothing was found      // in case nothing was found
611                  if (node == null)      if (node == null)
612                          return null;        return null;
613                                    
614                  // something was found      // something was found
615                  return new TreePath(node.getPath());      return new TreePath(node.getPath());
616                                                    
617          }    }
618    
619          /**    /**
620           * Get next visible node in the tree.     * Get next visible node in the tree.
621           *     *
622           * @param the current node     * @param the current node
623           * @return the next visible node in the JTree. Return null if there     * @return the next visible node in the JTree. Return null if there
624           * are no more.     * are no more.
625           */     */
626          private DefaultMutableTreeNode getNextVisibleNode(DefaultMutableTreeNode node)    private DefaultMutableTreeNode
627          {    getNextVisibleNode(DefaultMutableTreeNode node)
628                  DefaultMutableTreeNode next = null;    {
629                  TreePath current = null;      DefaultMutableTreeNode next = null;
630        TreePath current = null;
631                                    
632                  if (node != null)      if (node != null)
633                          next = node.getNextNode();        next = node.getNextNode();
634                                    
635                  if (next != null)      if (next != null)
636                  {        {
637                          current = new TreePath(next.getPath());          current = new TreePath(next.getPath());
638                          if (tree.isVisible(current))          if (tree.isVisible(current))
639                                  return next;            return next;
640                    
641                          while (next != null && !tree.isVisible(current))          while (next != null && !tree.isVisible(current))
642                          {            {
643                                  next = next.getNextNode();              next = next.getNextNode();
644                                                                    
645                                  if (next != null)              if (next != null)
646                                          current = new TreePath(next.getPath());                current = new TreePath(next.getPath());
647                          }            }
648                  }        }
649                  return next;      return next;
650          }    }
651                    
652          /**    /**
653           * Returns the row that the last item identified in path is visible at. Will     * Returns the row that the last item identified in path is visible at. Will
654           * return -1 if any of the elments in the path are not currently visible.     * return -1 if any of the elments in the path are not currently visible.
655           *     *
656           * @param tree is the current tree to return the row for.     * @param tree is the current tree to return the row for.
657           * @param path is the path used to find the row.     * @param path is the path used to find the row.
658           * @return the row that the last item identified in path is visible at. Will     * @return the row that the last item identified in path is visible at. Will
659           *         return -1 if any of the elments in the path are not currently     *         return -1 if any of the elments in the path are not currently
660           *         visible.     *         visible.
661           */     */
662          public int getRowForPath(JTree tree, TreePath path)    public int getRowForPath(JTree tree, TreePath path)
663          {    {
664                  // FIXME: check visibility      // FIXME: check visibility
665                  // right now, just returns last element because      // right now, just returns last element because
666                  // expand/collapse is not implemented      // expand/collapse is not implemented
667                  return path.getPathCount() - 1;      return path.getPathCount() - 1;
668          }    }
669    
670          /**    /**
671           * Returns the number of rows that are being displayed.     * Returns the number of rows that are being displayed.
672           *     *
673           * @param tree is the current tree to return the number of rows for.     * @param tree is the current tree to return the number of rows for.
674           * @return the number of rows being displayed.     * @return the number of rows being displayed.
675           */     */
676          public int getRowCount(JTree tree)    public int getRowCount(JTree tree)
677          {    {
678                  // FIXME: check visibility      // FIXME: check visibility
679                  return treeState.getRowCount();      return treeState.getRowCount();
680          }    }
681    
682          /**    /**
683           * Returns the path to the node that is closest to x,y. If there is nothing     * Returns the path to the node that is closest to x,y. If there is nothing
684           * currently visible this will return null, otherwise it'll always return a     * currently visible this will return null, otherwise it'll always return a
685           * valid path. If you need to test if the returned object is exactly at x,y     * valid path. If you need to test if the returned object is exactly at x,y
686           * you should get the bounds for the returned path and test x,y against     * you should get the bounds for the returned path and test x,y against
687           * that.     * that.
688           *     *
689           * @param tree the tree to search for the closest path     * @param tree the tree to search for the closest path
690           * @param x is the x coordinate of the location to search     * @param x is the x coordinate of the location to search
691           * @param y is the y coordinate of the location to search     * @param y is the y coordinate of the location to search
692           * @return the tree path closes to x,y.     * @return the tree path closes to x,y.
693           */     */
694          public TreePath getClosestPathForLocation(JTree tree, int x, int y)    public TreePath getClosestPathForLocation(JTree tree, int x, int y)
695          {    {
696                  return treeState.getPathClosestTo(x, y);      return treeState.getPathClosestTo(x, y);
697          }    }
698    
699          /**    /**
700           * Returns true if the tree is being edited. The item that is being edited     * Returns true if the tree is being edited. The item that is being edited
701           * can be returned by getEditingPath().     * can be returned by getEditingPath().
702           *     *
703           * @param tree is the tree to check for editing.     * @param tree is the tree to check for editing.
704           * @return true if the tree is being edited.     * @return true if the tree is being edited.
705           */     */
706          public boolean isEditing(JTree tree)    public boolean isEditing(JTree tree)
707          {    {
708                  // FIXME: not implemented      // FIXME: not implemented
709                  return false;      return false;
710          }    }
711    
712          /**    /**
713           * Stops the current editing session. This has no effect if the tree is not     * Stops the current editing session. This has no effect if the tree is not
714           * being edited. Returns true if the editor allows the editing session to     * being edited. Returns true if the editor allows the editing session to
715           * stop.     * stop.
716           *     *
717           * @param tree is the tree to stop the editing on     * @param tree is the tree to stop the editing on
718           * @return true if the editor allows the editing session to stop.     * @return true if the editor allows the editing session to stop.
719           */     */
720          public boolean stopEditing(JTree tree)    public boolean stopEditing(JTree tree)
721          {    {
722                  // FIXME: not implemented      // FIXME: not implemented
723                  return false;      return false;
724          }    }
725    
726          /**    /**
727           * Cancels the current editing session.     * Cancels the current editing session.
728           *     *
729           * @param tree is the tree to cancel the editing session on.     * @param tree is the tree to cancel the editing session on.
730           */     */
731          public void cancelEditing(JTree tree)    public void cancelEditing(JTree tree)
732          {    {
733                  // FIXME: not implemented      // FIXME: not implemented
734          }    }
735    
736          /**    /**
737           * Selects the last item in path and tries to edit it. Editing will fail if     * Selects the last item in path and tries to edit it. Editing will fail if
738           * the CellEditor won't allow it for the selected item.     * the CellEditor won't allow it for the selected item.
739           *     *
740           * @param tree is the tree to edit on.     * @param tree is the tree to edit on.
741           * @param path is the path in tree to edit on.     * @param path is the path in tree to edit on.
742           */     */
743          public void startEditingAtPath(JTree tree, TreePath path)    public void startEditingAtPath(JTree tree, TreePath path)
744          {    {
745                  // FIXME: not implemented      // FIXME: not implemented
746          }    }
747    
748          /**    /**
749           * Returns the path to the element that is being editted.     * Returns the path to the element that is being editted.
750           *     *
751           * @param tree is the tree to get the editing path from.     * @param tree is the tree to get the editing path from.
752           * @return the path that is being edited.     * @return the path that is being edited.
753           */     */
754          public TreePath getEditingPath(JTree tree)    public TreePath getEditingPath(JTree tree)
755          {    {
756                  // FIXME: not implemented      // FIXME: not implemented
757                  return null;      return null;
758          }    }
759    
760          /**    /**
761           * Invoked after the tree instance variable has been set, but before any     * Invoked after the tree instance variable has been set, but before any
762           * default/listeners have been installed.     * default/listeners have been installed.
763           */     */
764          protected void prepareForUIInstall()    protected void prepareForUIInstall()
765          {    {
766                  // FIXME: not implemented      // FIXME: not implemented
767          }    }
768    
769          /**    /**
770           * Invoked from installUI after all the defaults/listeners have been     * Invoked from installUI after all the defaults/listeners have been
771           * installed.     * installed.
772           */     */
773          protected void completeUIInstall()    protected void completeUIInstall()
774          {    {
775                  // FIXME: not implemented      // FIXME: not implemented
776          }    }
777    
778          /**    /**
779           * Invoked from uninstallUI after all the defaults/listeners have been     * Invoked from uninstallUI after all the defaults/listeners have been
780           * uninstalled.     * uninstalled.
781           */     */
782          protected void completeUIUninstall()    protected void completeUIUninstall()
783          {    {
784                  // FIXME: not implemented      // FIXME: not implemented
785          }    }
786    
787          /**    /**
788           * Installs the subcomponents of the tree, which is the renderer pane.     * Installs the subcomponents of the tree, which is the renderer pane.
789           */     */
790          protected void installComponents()    protected void installComponents()
791          {    {
792                  // FIXME: not implemented      // FIXME: not implemented
793          }    }
794    
795          /**    /**
796           * Creates an instance of NodeDimensions that is able to determine the size     * Creates an instance of NodeDimensions that is able to determine the size
797           * of a given node in the tree.     * of a given node in the tree.
798           *     *
799           * @return the NodeDimensions of a given node in the tree     * @return the NodeDimensions of a given node in the tree
800           */     */
801          protected AbstractLayoutCache.NodeDimensions createNodeDimensions()    protected AbstractLayoutCache.NodeDimensions createNodeDimensions()
802          {    {
803                  // FIXME: not implemented      // FIXME: not implemented
804                  return null;      return null;
805          }    }
806    
807          /**    /**
808           * Creates a listener that is reponsible for the updates the UI based on how     * Creates a listener that is reponsible for the updates the UI based on how
809           * the tree changes.     * the tree changes.
810           *     *
811           * @return the PropertyChangeListener that is reposnsible for the updates     * @return the PropertyChangeListener that is reposnsible for the updates
812           */     */
813          protected PropertyChangeListener createPropertyChangeListener()    protected PropertyChangeListener createPropertyChangeListener()
814          {    {
815                  return new PropertyChangeHandler();      return new PropertyChangeHandler();
816          }    }
817    
818          /**    /**
819           * Creates the listener responsible for updating the selection based on     * Creates the listener responsible for updating the selection based on
820           * mouse events.     * mouse events.
821           *     *
822           * @return the MouseListener responsible for updating.     * @return the MouseListener responsible for updating.
823           */     */
824          protected MouseListener createMouseListener()    protected MouseListener createMouseListener()
825          {    {
826                  return new MouseHandler();      return new MouseHandler();
827          }    }
828    
829          /**    /**
830           * Creates the listener that is responsible for updating the display when     * Creates the listener that is responsible for updating the display when
831           * focus is lost/grained.     * focus is lost/grained.
832           *     *
833           * @return the FocusListener responsible for updating.     * @return the FocusListener responsible for updating.
834           */     */
835          protected FocusListener createFocusListener()    protected FocusListener createFocusListener()
836          {    {
837                  return new FocusHandler();      return new FocusHandler();
838          }    }
839    
840          /**    /**
841           * Creates the listener reponsible for getting key events from the tree.     * Creates the listener reponsible for getting key events from the tree.
842           *     *
843           * @return the KeyListener responsible for getting key events.     * @return the KeyListener responsible for getting key events.
844           */     */
845          protected KeyListener createKeyListener()    protected KeyListener createKeyListener()
846          {    {
847                  return new KeyHandler();      return new KeyHandler();
848          }    }
849    
850          /**    /**
851           * Creates the listener responsible for getting property change events from     * Creates the listener responsible for getting property change events from
852           * the selection model.     * the selection model.
853           *     *
854           * @returns the PropertyChangeListener reponsible for getting property     * @returns the PropertyChangeListener reponsible for getting property
855           *          change events from the selection model.     *          change events from the selection model.
856           */     */
857          protected PropertyChangeListener createSelectionModelPropertyChangeListener()    protected PropertyChangeListener createSelectionModelPropertyChangeListener()
858          {    {
859                  return new SelectionModelPropertyChangeHandler();      return new SelectionModelPropertyChangeHandler();
860          }    }
861    
862          /**    /**
863           * Creates the listener that updates the display based on selection change     * Creates the listener that updates the display based on selection change
864           * methods.     * methods.
865           *     *
866           * @return the TreeSelectionListener responsible for updating.     * @return the TreeSelectionListener responsible for updating.
867           */     */
868          protected TreeSelectionListener createTreeSelectionListener()    protected TreeSelectionListener createTreeSelectionListener()
869          {    {
870                  return new TreeSelectionHandler();      return new TreeSelectionHandler();
871          }    }
872    
873          /**    /**
874           * Creates a listener to handle events from the current editor     * Creates a listener to handle events from the current editor
875           *     *
876           * @return the CellEditorListener that handles events from the current     * @return the CellEditorListener that handles events from the current
877           *         editor     *         editor
878           */     */
879          protected CellEditorListener createCellEditorListener()    protected CellEditorListener createCellEditorListener()
880          {    {
881                  return new CellEditorHandler();      return new CellEditorHandler();
882          }    }
883    
884          /**    /**
885           * Creates and returns a new ComponentHandler. This is used for the large     * Creates and returns a new ComponentHandler. This is used for the large
886           * model to mark the validCachedPreferredSize as invalid when the component     * model to mark the validCachedPreferredSize as invalid when the component
887           * moves.     * moves.
888           *     *
889           * @return a new ComponentHandler.     * @return a new ComponentHandler.
890           */     */
891          protected ComponentListener createComponentListener()    protected ComponentListener createComponentListener()
892          {    {
893                  return new ComponentHandler();      return new ComponentHandler();
894          }    }
895    
896          /**    /**
897           * Creates and returns the object responsible for updating the treestate     * Creates and returns the object responsible for updating the treestate
898           * when a nodes expanded state changes.     * when a nodes expanded state changes.
899           *     *
900           * @return the TreeExpansionListener responsible for updating the treestate     * @return the TreeExpansionListener responsible for updating the treestate
901           */     */
902          protected TreeExpansionListener createTreeExpansionListener()    protected TreeExpansionListener createTreeExpansionListener()
903          {    {
904                  return new TreeExpansionHandler();      return new TreeExpansionHandler();
905          }    }
906    
907          /**    /**
908           * Creates the object responsible for managing what is expanded, as well as     * Creates the object responsible for managing what is expanded, as well as
909           * the size of nodes.     * the size of nodes.
910           *     *
911           * @return the object responsible for managing what is expanded.     * @return the object responsible for managing what is expanded.
912           */     */
913          protected AbstractLayoutCache createLayoutCache()    protected AbstractLayoutCache createLayoutCache()
914          {    {
915                  return new FixedHeightLayoutCache();      return new FixedHeightLayoutCache();
916          }    }
917    
918          /**    /**
919           * Returns the renderer pane that renderer components are placed in.     * Returns the renderer pane that renderer components are placed in.
920           *     *
921           * @return the rendererpane that render components are placed in.     * @return the rendererpane that render components are placed in.
922           */     */
923          protected CellRendererPane createCellRendererPane()    protected CellRendererPane createCellRendererPane()
924          {    {
925                  return new CellRendererPane();      return new CellRendererPane();
926          }    }
927    
928          /**    /**
929           * Creates a default cell editor.     * Creates a default cell editor.
930           *     *
931           * @return the default cell editor.     * @return the default cell editor.
932           */     */
933          protected TreeCellEditor createDefaultCellEditor()    protected TreeCellEditor createDefaultCellEditor()
934          {    {
935                  return new DefaultTreeCellEditor(tree,      return new DefaultTreeCellEditor
936                                  (DefaultTreeCellRenderer) createDefaultCellRenderer(),        (tree,
937                                  cellEditor);         (DefaultTreeCellRenderer) createDefaultCellRenderer(),
938          }         cellEditor);
939      }
940          /**  
941           * Returns the default cell renderer that is used to do the stamping of each    /**
942           * node.     * Returns the default cell renderer that is used to do the stamping of each
943           *     * node.
944           * @return the default cell renderer that is used to do the stamping of each     *
945           *         node.     * @return the default cell renderer that is used to do the stamping of each
946           */     *         node.
947          protected TreeCellRenderer createDefaultCellRenderer()     */
948          {    protected TreeCellRenderer createDefaultCellRenderer()
949                  return new DefaultTreeCellRenderer();    {
950          }      return new DefaultTreeCellRenderer();
951      }
952          /**  
953           * Returns a listener that can update the tree when the model changes.    /**
954           *     * Returns a listener that can update the tree when the model changes.
955           * @return a listener that can update the tree when the model changes.     *
956           */     * @return a listener that can update the tree when the model changes.
957          protected TreeModelListener createTreeModelListener()     */
958          {    protected TreeModelListener createTreeModelListener()
959                  return new TreeModelHandler();    {
960          }      return new TreeModelHandler();
961      }
962          /**  
963           * Uninstall all registered listeners    /**
964           */     * Uninstall all registered listeners
965          protected void uninstallListeners()     */
966          {    protected void uninstallListeners()
967                  tree.removePropertyChangeListener(propertyChangeListener);    {
968                  tree.removeFocusListener(focusListener);      tree.removePropertyChangeListener(propertyChangeListener);
969                  tree.removeTreeSelectionListener(treeSelectionListener);      tree.removeFocusListener(focusListener);
970                  tree.removeMouseListener(mouseInputListener);      tree.removeTreeSelectionListener(treeSelectionListener);
971                  tree.removeKeyListener(keyListener);      tree.removeMouseListener(mouseInputListener);
972                  tree.removePropertyChangeListener(selectionModelPropertyChangeListener);      tree.removeKeyListener(keyListener);
973                  tree.removeComponentListener(componentListener);      tree.removePropertyChangeListener(selectionModelPropertyChangeListener);
974                  tree.getCellEditor().removeCellEditorListener(cellEditorListener);      tree.removeComponentListener(componentListener);
975                  tree.removeTreeExpansionListener(treeExpansionListener);      tree.getCellEditor().removeCellEditorListener(cellEditorListener);
976                  tree.getModel().removeTreeModelListener(treeModelListener);      tree.removeTreeExpansionListener(treeExpansionListener);
977          }      tree.getModel().removeTreeModelListener(treeModelListener);
978      }
979          /**  
980           * Uninstall all keyboard actions.    /**
981           */     * Uninstall all keyboard actions.
982          protected void uninstallKeyboardActions()     */
983          {    protected void uninstallKeyboardActions()
984          }    {
985      }
986          /**  
987           * Uninstall the rendererPane.    /**
988           */     * Uninstall the rendererPane.
989          protected void uninstallComponents()     */
990          {    protected void uninstallComponents()
991                  // FIXME: not implemented    {
992          }      // FIXME: not implemented
993      }
994          /**  
995           * The vertical element of legs between nodes starts at the bottom of the    /**
996           * parent node by default. This method makes the leg start below that.     * The vertical element of legs between nodes starts at the bottom of the
997           *     * parent node by default. This method makes the leg start below that.
998           * @return the vertical leg buffer     *
999           */     * @return the vertical leg buffer
1000          protected int getVerticalLegBuffer()     */
1001          {    protected int getVerticalLegBuffer()
1002                  // FIXME: not implemented    {
1003                  return 0;      // FIXME: not implemented
1004          }      return 0;
1005      }
1006          /**  
1007           * The horizontal element of legs between nodes starts at the right of the    /**
1008           * left-hand side of the child node by default. This method makes the leg     * The horizontal element of legs between nodes starts at the right of the
1009           * end before that.     * left-hand side of the child node by default. This method makes the leg
1010           *     * end before that.
1011           * @return the horizontal leg buffer     *
1012           */     * @return the horizontal leg buffer
1013          protected int getHorizontalLegBuffer()     */
1014          {    protected int getHorizontalLegBuffer()
1015                  // FIXME: not implemented    {
1016                  return 0;      // FIXME: not implemented
1017          }      return 0;
1018      }
1019          /**  
1020           * Make all the nodes that are expanded in JTree expanded in LayoutCache.    /**
1021           * This invokes update ExpandedDescendants with the root path.     * Make all the nodes that are expanded in JTree expanded in LayoutCache.
1022           */     * This invokes update ExpandedDescendants with the root path.
1023          protected void updateLayoutCacheExpandedNodes()     */
1024          {    protected void updateLayoutCacheExpandedNodes()
1025                  // FIXME: not implemented    {
1026          }      // FIXME: not implemented
1027      }
1028          /**  
1029           * Updates the expanded state of all the descendants of the    /**
1030           * <code>path</code> by getting the expanded descendants from the tree and     * Updates the expanded state of all the descendants of the
1031           * forwarding to the tree state.     * <code>path</code> by getting the expanded descendants from the tree and
1032           *     * forwarding to the tree state.
1033           * @param path the path used to update the expanded states     *
1034           */     * @param path the path used to update the expanded states
1035          protected void updateExpandedDescendants(TreePath path)     */
1036          {    protected void updateExpandedDescendants(TreePath path)
1037                  // FIXME: not implemented    {
1038          }      // FIXME: not implemented
1039      }
1040          /**  
1041           * Returns a path to the last child of <code>parent</code>    /**
1042           *     * Returns a path to the last child of <code>parent</code>
1043           * @param parent is the topmost path to specified     *
1044           * @return a path to the last child of parent     * @param parent is the topmost path to specified
1045           */     * @return a path to the last child of parent
1046          protected TreePath getLastChildPath(TreePath parent)     */
1047          {    protected TreePath getLastChildPath(TreePath parent)
1048                  return ((TreePath) parent.getLastPathComponent());    {
1049          }      return ((TreePath) parent.getLastPathComponent());
1050      }
1051          /**  
1052           * Updates how much each depth should be offset by.    /**
1053           */     * Updates how much each depth should be offset by.
1054          protected void updateDepthOffset()     */
1055          {    protected void updateDepthOffset()
1056                  // FIXME: not implemented    {
1057          }      // FIXME: not implemented
1058      }
1059          /**  
1060           * Updates the cellEditor based on editability of the JTree that we're    /**
1061           * contained in. Ig the tree is editable but doesn't have a cellEditor, a     * Updates the cellEditor based on editability of the JTree that we're
1062           * basic one will be used.     * contained in. Ig the tree is editable but doesn't have a cellEditor, a
1063           */     * basic one will be used.
1064          protected void updateCellEditor()     */
1065          {    protected void updateCellEditor()
1066                  // FIXME: not implemented    {
1067          }      // FIXME: not implemented
1068      }
1069          /**  
1070           * Messaged from the tree we're in when the renderer has changed.    /**
1071           */     * Messaged from the tree we're in when the renderer has changed.
1072          protected void updateRenderer()     */
1073          {    protected void updateRenderer()
1074                  // FIXME: not implemented    {
1075          }      // FIXME: not implemented
1076      }
1077          /**  
1078           * Resets the treeState instance based on the tree we're providing the look    /**
1079           * and feel for.     * Resets the treeState instance based on the tree we're providing the look
1080           */     * and feel for.
1081          protected void configureLayoutCache()     */
1082          {    protected void configureLayoutCache()
1083                  treeState = createLayoutCache();    {
1084          }      treeState = createLayoutCache();
1085      }
1086          /**  
1087           * Marks the cached size as being invalid, and messages the tree with    /**
1088           * <code>treeDidChange</code>.     * Marks the cached size as being invalid, and messages the tree with
1089           */     * <code>treeDidChange</code>.
1090          protected void updateSize()     */
1091          {    protected void updateSize()
1092                  // FIXME: not implemented    {
1093          }      // FIXME: not implemented
1094      }
1095          /**  
1096           * Updates the <code>preferredSize</code> instance variable, which is    /**
1097           * returned from <code>getPreferredSize()</code>. For left to right     * Updates the <code>preferredSize</code> instance variable, which is
1098           * orientations, the size is determined from the current     * returned from <code>getPreferredSize()</code>. For left to right
1099           * AbstractLayoutCache. For RTL orientations, the preferred size becomes the     * orientations, the size is determined from the current
1100           * width minus the minimum x position.     * AbstractLayoutCache. For RTL orientations, the preferred size becomes the
1101           */     * width minus the minimum x position.
1102          protected void updateCachedPreferredSize()     */
1103          {    protected void updateCachedPreferredSize()
1104                  // FIXME: not implemented    {
1105          }      // FIXME: not implemented
1106      }
1107          /**  
1108           * Messaged from the VisibleTreeNode after it has been expanded.    /**
1109           *     * Messaged from the VisibleTreeNode after it has been expanded.
1110           * @param path is the path that has been expanded.     *
1111           */     * @param path is the path that has been expanded.
1112          protected void pathWasExpanded(TreePath path)     */
1113          {    protected void pathWasExpanded(TreePath path)
1114                  // FIXME: not implemented    {
1115          }      // FIXME: not implemented
1116      }
1117          /**  
1118           * Messaged from the VisibleTreeNode after it has collapsed    /**
1119           */     * Messaged from the VisibleTreeNode after it has collapsed
1120          protected void pathWasCollapsed(TreePath path)     */
1121          {    protected void pathWasCollapsed(TreePath path)
1122                  // FIXME: not implemented    {
1123          }      // FIXME: not implemented
1124      }
1125          /**  
1126           * Install all defaults for the tree.    /**
1127           *     * Install all defaults for the tree.
1128           * @param tree is the JTree to install defaults for     *
1129           */     * @param tree is the JTree to install defaults for
1130          protected void installDefaults(JTree tree)     */
1131          {    protected void installDefaults(JTree tree)
1132                  UIDefaults defaults = UIManager.getLookAndFeelDefaults();    {
1133        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
1134                  tree.setFont(defaults.getFont("Tree.font"));  
1135                  tree.setForeground(defaults.getColor("Tree.foreground"));      tree.setFont(defaults.getFont("Tree.font"));
1136                  tree.setBackground(defaults.getColor("Tree.background"));      tree.setForeground(defaults.getColor("Tree.foreground"));
1137                  tree.setOpaque(true);      tree.setBackground(defaults.getColor("Tree.background"));
1138        tree.setOpaque(true);
1139                  rightChildIndent = defaults.getInt("Tree.rightChildIndent");  
1140                  leftChildIndent = defaults.getInt("Tree.leftChildIndent");      rightChildIndent = defaults.getInt("Tree.rightChildIndent");
1141                  setRowHeight(defaults.getInt("Tree.rowHeight"));      leftChildIndent = defaults.getInt("Tree.leftChildIndent");
1142          }      setRowHeight(defaults.getInt("Tree.rowHeight"));
1143      }
1144          /**  
1145           * Install all keyboard actions for this    /**
1146           */     * Install all keyboard actions for this
1147          protected void installKeyboardActions()     */
1148          {    protected void installKeyboardActions()
1149          }    {
1150      }
1151          /**  
1152           * Install all listeners for this    /**
1153           */     * Install all listeners for this
1154          protected void installListeners()     */
1155          {    protected void installListeners()
1156                  tree.addPropertyChangeListener(propertyChangeListener);    {
1157                  tree.addFocusListener(focusListener);      tree.addPropertyChangeListener(propertyChangeListener);
1158                  tree.addTreeSelectionListener(treeSelectionListener);      tree.addFocusListener(focusListener);
1159                  tree.addMouseListener(mouseInputListener);      tree.addTreeSelectionListener(treeSelectionListener);
1160                  tree.addKeyListener(keyListener);      tree.addMouseListener(mouseInputListener);
1161                  tree.addPropertyChangeListener(selectionModelPropertyChangeListener);      tree.addKeyListener(keyListener);
1162                  tree.addComponentListener(componentListener);      tree.addPropertyChangeListener(selectionModelPropertyChangeListener);
1163                  cellEditor.addCellEditorListener(cellEditorListener);      tree.addComponentListener(componentListener);
1164                  tree.addTreeExpansionListener(treeExpansionListener);      cellEditor.addCellEditorListener(cellEditorListener);
1165                  treeModel.addTreeModelListener(treeModelListener);      tree.addTreeExpansionListener(treeExpansionListener);
1166          }      treeModel.addTreeModelListener(treeModelListener);
1167      }
1168          /**  
1169           * Install the UI for the component    /**
1170           *     * Install the UI for the component
1171           * @param c the component to install UI for     *
1172           */     * @param c the component to install UI for
1173          public void installUI(JComponent c)     */
1174          {    public void installUI(JComponent c)
1175                  super.installUI(c);    {
1176                  installDefaults((JTree) c);      super.installUI(c);
1177                  tree = (JTree) c;      installDefaults((JTree) c);
1178                  setModel(tree.getModel());      tree = (JTree) c;
1179                  treeSelectionModel = tree.getSelectionModel();      setModel(tree.getModel());
1180                  installListeners();      treeSelectionModel = tree.getSelectionModel();
1181                  installKeyboardActions();      installListeners();
1182                  completeUIInstall();      installKeyboardActions();
1183          }      completeUIInstall();
1184      }
1185          /**  
1186           * Uninstall the defaults for the tree    /**
1187           *     * Uninstall the defaults for the tree
1188           * @param tree to uninstall defaults for     *
1189           */     * @param tree to uninstall defaults for
1190          protected void uninstallDefaults(JTree tree)     */
1191          {    protected void uninstallDefaults(JTree tree)
1192                  UIDefaults defaults = UIManager.getLookAndFeelDefaults();    {
1193                  tree.setFont(null);      UIDefaults defaults = UIManager.getLookAndFeelDefaults();
1194                  tree.setForeground(null);      tree.setFont(null);
1195                  tree.setBackground(null);      tree.setForeground(null);
1196                  tree.setCellRenderer(null);      tree.setBackground(null);
1197          }      tree.setCellRenderer(null);
1198      }
1199          /**  
1200           * Uninstall the UI for the component    /**
1201           *     * Uninstall the UI for the component
1202           * @param c the component to uninstall UI for     *
1203           */     * @param c the component to uninstall UI for
1204          public void uninstallUI(JComponent c)     */
1205          {    public void uninstallUI(JComponent c)
1206                  uninstallDefaults((JTree) c);    {
1207                  uninstallKeyboardActions();      uninstallDefaults((JTree) c);
1208                  uninstallListeners();      uninstallKeyboardActions();
1209                  tree = null;      uninstallListeners();
1210                  completeUIUninstall();      tree = null;
1211          }      completeUIUninstall();
1212      }
1213          /**  
1214           *     Paints the specified component appropriate for the look and feel.    /**
1215           *     This method is invoked from the ComponentUI.update method when the     *     Paints the specified component appropriate for the look and feel.
1216           *     specified component is being painted. Subclasses should override     *     This method is invoked from the ComponentUI.update method when the
1217           *     this method and use the specified Graphics object to render the     *     specified component is being painted. Subclasses should override
1218           *     content of the component.     *     this method and use the specified Graphics object to render the
1219           *         *     content of the component.
1220           *     @param g the Graphics context in which to paint     *    
1221           *     @param c the component being painted; this argument is often     *     @param g the Graphics context in which to paint
1222           *     ignored, but might be used if the UI object is stateless and     *     @param c the component being painted; this argument is often
1223           *     shared by multiple components     *     ignored, but might be used if the UI object is stateless and
1224           */     *     shared by multiple components
1225          public void paint(Graphics g, JComponent c)     */
1226          {    public void paint(Graphics g, JComponent c)
1227                  JTree tree = (JTree) c;    {
1228                  TreeModel mod = tree.getModel();      JTree tree = (JTree) c;
1229                  g.translate(10, 10);      TreeModel mod = tree.getModel();
1230                  paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());      g.translate(10, 10);
1231                  g.translate(-10, -10);      paintRecursive(g, 0, 0, 0, 0, tree, mod, mod.getRoot());
1232          }      g.translate(-10, -10);
1233      }
1234          /**  
1235           * Ensures that the rows identified by beginRow through endRow are visible.    /**
1236           *     * Ensures that the rows identified by beginRow through endRow are visible.
1237           * @param beginRow is the first row     *
1238           * @param endRow is the last row     * @param beginRow is the first row
1239           */     * @param endRow is the last row
1240          protected void ensureRowsAreVisible(int beginRow, int endRow)     */
1241          {    protected void ensureRowsAreVisible(int beginRow, int endRow)
1242                  // FIXME: not implemented    {
1243          }      // FIXME: not implemented
1244      }
1245          /**  
1246           * Sets the preferred minimum size.    /**
1247           *     * Sets the preferred minimum size.
1248           * @param newSize is the new preferred minimum size.     *
1249           */     * @param newSize is the new preferred minimum size.
1250          public void setPreferredMinSize(Dimension newSize)     */
1251          {    public void setPreferredMinSize(Dimension newSize)
1252                  // FIXME: not implemented    {
1253          }      // FIXME: not implemented
1254      }
1255          /**  
1256           * Gets the preferred minimum size.    /**
1257           *     * Gets the preferred minimum size.
1258           * @returns the preferred minimum size.     *
1259           */     * @returns the preferred minimum size.
1260          public Dimension getPreferredMinSize()     */
1261          {    public Dimension getPreferredMinSize()
1262                  // FIXME: not implemented    {
1263                  return null;      // FIXME: not implemented
1264          }      return null;
1265      }
1266          /**  
1267           * Returns the preferred size to properly display the tree, this is a cover    /**
1268           * method for getPreferredSize(c, false).     * Returns the preferred size to properly display the tree, this is a cover
1269           *     * method for getPreferredSize(c, false).
1270           * @param c the component whose preferred size is being queried; this     *
1271           *        argument is often ignored but might be used if the UI object is     * @param c the component whose preferred size is being queried; this
1272           *        stateless and shared by multiple components     *        argument is often ignored but might be used if the UI object is
1273           * @return the preferred size     *        stateless and shared by multiple components
1274           */     * @return the preferred size
1275          public Dimension getPreferredSize(JComponent c)     */
1276          {    public Dimension getPreferredSize(JComponent c)
1277                  return getPreferredSize(c, false);    {
1278          }      return getPreferredSize(c, false);
1279      }
1280          /**  
1281           * Returns the preferred size to represent the tree in c. If    /**
1282           * checkConsistancy is true, checkConsistancy is messaged first.     * Returns the preferred size to represent the tree in c. If
1283           *     * checkConsistancy is true, checkConsistancy is messaged first.
1284           * @param c the component whose preferred size is being queried.     *
1285           * @param checkConsistancy if true must check consistancy     * @param c the component whose preferred size is being queried.
1286           * @return the preferred size     * @param checkConsistancy if true must check consistancy
1287           */     * @return the preferred size
1288          public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)     */
1289          {    public Dimension getPreferredSize(JComponent c, boolean checkConsistancy)
1290                  // FIXME: not implemented    {
1291                  return new Dimension(200, 900);      // FIXME: not implemented
1292          }      return new Dimension(200, 900);
1293      }
1294          /**  
1295           * Returns the minimum size for this component. Which will be the min    /**
1296           * preferred size or (0,0).     * Returns the minimum size for this component. Which will be the min
1297           *     * preferred size or (0,0).
1298           * @param c the component whose min size is being queried.     *
1299           * @returns the preferred size or null     * @param c the component whose min size is being queried.
1300           */     * @returns the preferred size or null
1301          public Dimension getMinimumSize(JComponent c)     */
1302          {    public Dimension getMinimumSize(JComponent c)
1303                  // FIXME: not implemented    {
1304                  return new Dimension(200, 900);      // FIXME: not implemented
1305          }      return new Dimension(200, 900);
1306      }
1307          /**  
1308           * Returns the maximum size for the component, which will be the preferred    /**
1309           * size if the instance is currently in JTree or (0,0).     * Returns the maximum size for the component, which will be the preferred
1310           *     * size if the instance is currently in JTree or (0,0).
1311           * @param c the component whose preferred size is being queried     *
1312           * @return the max size or null     * @param c the component whose preferred size is being queried
1313           */     * @return the max size or null
1314          public Dimension getMaximumSize(JComponent c)     */
1315          {    public Dimension getMaximumSize(JComponent c)
1316                  // FIXME: not implemented    {
1317                  return new Dimension(200, 900);      // FIXME: not implemented
1318          }      return new Dimension(200, 900);
1319      }
1320          /**  
1321           * Messages to stop the editing session. If the UI the receiver is providing    /**
1322           * the look and feel for returns true from     * Messages to stop the editing session. If the UI the receiver is providing
1323           * <code>getInvokesStopCellEditing</code>, stopCellEditing will be     * the look and feel for returns true from
1324           * invoked on the current editor. Then completeEditing will be messaged with     * <code>getInvokesStopCellEditing</code>, stopCellEditing will be
1325           * false, true, false to cancel any lingering editing.     * invoked on the current editor. Then completeEditing will be messaged with
1326           */     * false, true, false to cancel any lingering editing.
1327          protected void completeEditing()     */
1328          {    protected void completeEditing()
1329                  // FIXME: not implemented    {
1330          }      // FIXME: not implemented
1331      }
1332          /**  
1333           * Stops the editing session. If messageStop is true, the editor is messaged    /**
1334           * with stopEditing, if messageCancel is true the editor is messaged with     * Stops the editing session. If messageStop is true, the editor is messaged
1335           * cancelEditing. If messageTree is true, the treeModel is messaged with     * with stopEditing, if messageCancel is true the editor is messaged with
1336           * valueForPathChanged.     * cancelEditing. If messageTree is true, the treeModel is messaged with
1337           *     * valueForPathChanged.
1338           * @param messageStop message to stop editing     *
1339           * @param messageCancel message to cancel editing     * @param messageStop message to stop editing
1340           * @param messageTree message to treeModel     * @param messageCancel message to cancel editing
1341           */     * @param messageTree message to treeModel
1342          protected void completeEditing(boolean messageStop, boolean messageCancel,     */
1343                          boolean messageTree)    protected void completeEditing(boolean messageStop, boolean messageCancel,
1344          {                                   boolean messageTree)
1345                  // FIXME: not implemented    {
1346          }      // FIXME: not implemented
1347      }
1348          /**  
1349           * Will start editing for node if there is a cellEditor and shouldSelectCall    /**
1350           * returns true. This assumes that path is valid and visible.     * Will start editing for node if there is a cellEditor and shouldSelectCall
1351           *     * returns true. This assumes that path is valid and visible.
1352           * @param path is the path to start editing     *
1353           * @param event is the MouseEvent performed on the path     * @param path is the path to start editing
1354           * @return true if successful     * @param event is the MouseEvent performed on the path
1355           */     * @return true if successful
1356          protected boolean startEditing(TreePath path, MouseEvent event)     */
1357          {    protected boolean startEditing(TreePath path, MouseEvent event)
1358                  // FIXME: not implemented    {
1359                  return false;      // FIXME: not implemented
1360          }      return false;
1361      }
1362          /**  
1363           * If the <code>mouseX</code> and <code>mouseY</code> are in the expand    /**
1364           * or collapse region of the row, this will toggle the row.     * If the <code>mouseX</code> and <code>mouseY</code> are in the expand
1365           *     * or collapse region of the row, this will toggle the row.
1366           * @param path the path we are concerned with     *
1367           * @param mouseX is the cursor's x position     * @param path the path we are concerned with
1368           * @param mouseY is the cursor's y position     * @param mouseX is the cursor's x position
1369           */     * @param mouseY is the cursor's y position
1370          protected void checkForClickInExpandControl(TreePath path, int mouseX,     */
1371                          int mouseY)    protected void checkForClickInExpandControl(TreePath path, int mouseX,
1372          {                                                int mouseY)
1373                  // FIXME: not implemented    {
1374          }      // FIXME: not implemented
1375      }
1376          /**  
1377           * Returns true if the <code>mouseX</code> and <code>mouseY</code> fall    /**
1378           * in the area of row that is used to expand/collpse the node and the node     * Returns true if the <code>mouseX</code> and <code>mouseY</code> fall
1379           * at row does not represent a leaf.     * in the area of row that is used to expand/collpse the node and the node
1380           *     * at row does not represent a leaf.
1381           * @param path the path we are concerned with     *
1382           * @param mouseX is the cursor's x position     * @param path the path we are concerned with
1383           * @param mouseY is the cursor's y position     * @param mouseX is the cursor's x position
1384           * @return true if the <code>mouseX</code> and <code>mouseY</code> fall     * @param mouseY is the cursor's y position
1385           *         in the area of row that is used to expand/collpse the node and     * @return true if the <code>mouseX</code> and <code>mouseY</code> fall
1386           *         the node at row does not represent a leaf.     *         in the area of row that is used to expand/collpse the node and
1387           */     *         the node at row does not represent a leaf.
1388          protected boolean isLocationInExpandControl(TreePath path, int mouseX,     */
1389                          int mouseY)    protected boolean isLocationInExpandControl(TreePath path, int mouseX,
1390          {                                                int mouseY)
1391                  // FIXME: not implemented    {
1392                  return false;      // FIXME: not implemented
1393          }      return false;
1394      }
1395          /**  
1396           * Messaged when the user clicks the particular row, this invokes    /**
1397           * toggleExpandState.     * Messaged when the user clicks the particular row, this invokes
1398           *     * toggleExpandState.
1399           * @param path the path we are concerned with     *
1400           * @param mouseX is the cursor's x position     * @param path the path we are concerned with
1401           * @param mouseY is the cursor's y position     * @param mouseX is the cursor's x position
1402           */     * @param mouseY is the cursor's y position
1403          protected void handleExpandControlClick(TreePath path, int mouseX,     */
1404                          int mouseY)    protected void handleExpandControlClick(TreePath path, int mouseX,
1405          {                                            int mouseY)
1406                  // FIXME: not implemented    {
1407          }      // FIXME: not implemented
1408      }
1409          /**  
1410           * Expands path if it is not expanded, or collapses row if it is expanded.    /**
1411           * If expanding a path and JTree scroll on expand, ensureRowsAreVisible is     * Expands path if it is not expanded, or collapses row if it is expanded.
1412           * invoked to scroll as many of the children to visible as possible (tries     * If expanding a path and JTree scroll on expand, ensureRowsAreVisible is
1413           * to scroll to last visible descendant of path).     * invoked to scroll as many of the children to visible as possible (tries
1414           *     * to scroll to last visible descendant of path).
1415           * @param path the path we are concerned with     *
1416           */     * @param path the path we are concerned with
1417          protected void toggleExpandState(TreePath path)     */
1418          {    protected void toggleExpandState(TreePath path)
1419                  // FIXME: not implemented    {
1420          }      // FIXME: not implemented
1421      }
1422          /**  
1423           * Returning true signifies a mouse event on the node should toggle the    /**
1424           * selection of only the row under the mouse.     * Returning true signifies a mouse event on the node should toggle the
1425           *     * selection of only the row under the mouse.
1426           * @param event is the MouseEvent performed on the row.     *
1427           * @return true signifies a mouse event on the node should toggle the     * @param event is the MouseEvent performed on the row.
1428           *         selection of only the row under the mouse.     * @return true signifies a mouse event on the node should toggle the
1429           */     *         selection of only the row under the mouse.
1430          protected boolean isToggleSelectionEvent(MouseEvent event)     */
1431          {    protected boolean isToggleSelectionEvent(MouseEvent event)
1432                  // FIXME: not implemented    {
1433                  return false;      // FIXME: not implemented
1434          }      return false;
1435      }
1436          /**  
1437           * Returning true signifies a mouse event on the node should select from the    /**
1438           * anchor point.     * Returning true signifies a mouse event on the node should select from the
1439           *     * anchor point.
1440           * @param event is the MouseEvent performed on the node.     *
1441           * @return true signifies a mouse event on the node should select from the     * @param event is the MouseEvent performed on the node.
1442           *         anchor point.     * @return true signifies a mouse event on the node should select from the
1443           */     *         anchor point.
1444          protected boolean isMultiSelectEvent(MouseEvent event)     */
1445          {    protected boolean isMultiSelectEvent(MouseEvent event)
1446                  // FIXME: not implemented    {
1447                  return false;      // FIXME: not implemented
1448          }      return false;
1449      }
1450          /**  
1451           * Returning true indicates the row under the mouse should be toggled based    /**
1452           * on the event. This is invoked after checkForClickInExpandControl,     * Returning true indicates the row under the mouse should be toggled based
1453           * implying the location is not in the expand (toggle) control.     * on the event. This is invoked after checkForClickInExpandControl,
1454           *     * implying the location is not in the expand (toggle) control.
1455           * @param event is the MouseEvent performed on the row.     *
1456           * @return true indicates the row under the mouse should be toggled based on     * @param event is the MouseEvent performed on the row.
1457           *         the event.     * @return true indicates the row under the mouse should be toggled based on
1458           */     *         the event.
1459          protected boolean isToggleEvent(MouseEvent event)     */
1460          {    protected boolean isToggleEvent(MouseEvent event)
1461                  // FIXME: not implemented    {
1462                  return false;      // FIXME: not implemented
1463          }      return false;
1464      }
1465          /**  
1466           * Messaged to update the selection based on a MouseEvent over a particular    /**
1467           * row. If the even is a toggle selection event, the row is either selected,     * Messaged to update the selection based on a MouseEvent over a particular
1468           * or deselected. If the event identifies a multi selection event, the     * row. If the even is a toggle selection event, the row is either selected,
1469           * selection is updated from the anchor point. Otherwise, the row is     * or deselected. If the event identifies a multi selection event, the
1470           * selected, and if the even specified a toggle event the row is     * selection is updated from the anchor point. Otherwise, the row is
1471           * expanded/collapsed.     * selected, and if the even specified a toggle event the row is
1472           *     * expanded/collapsed.
1473           * @param path is the path selected for an event     *
1474           * @param event is the MouseEvent performed on the path.     * @param path is the path selected for an event
1475           */     * @param event is the MouseEvent performed on the path.
1476          protected void selectPathForEvent(TreePath path, MouseEvent event)     */
1477          {    protected void selectPathForEvent(TreePath path, MouseEvent event)
1478                  // FIXME: not implemented    {
1479          }      // FIXME: not implemented
1480      }
1481          /**  
1482           * Returns true if the node at <code>row</code> is a leaf.    /**
1483           *     * Returns true if the node at <code>row</code> is a leaf.
1484           * @param row is the row we are concerned with.     *
1485           * @return true if the node at <code>row</code> is a leaf.     * @param row is the row we are concerned with.
1486           */     * @return true if the node at <code>row</code> is a leaf.
1487          protected boolean isLeaf(int row)     */
1488          {    protected boolean isLeaf(int row)
1489                  TreePath pathForRow = getPathForRow(tree, row);    {
1490                  if (pathForRow == null)      TreePath pathForRow = getPathForRow(tree, row);
1491                          return true;      if (pathForRow == null)
1492          return true;
1493                                    
1494                  Object node = pathForRow.getLastPathComponent();      Object node = pathForRow.getLastPathComponent();
1495                                    
1496                  if (node instanceof TreeNode)      if (node instanceof TreeNode)
1497                          return ((TreeNode) node).isLeaf();        return ((TreeNode) node).isLeaf();
1498                  else      else
1499                          return true;        return true;
1500          }    }
1501    
1502          /* * INTERNAL CLASSES * */    /* * INTERNAL CLASSES * */
1503    
1504          /**    /**
1505           * Updates the preferred size when scrolling, if necessary.     * Updates the preferred size when scrolling, if necessary.
1506           */     */
1507          public class ComponentHandler    public class ComponentHandler
1508                          extends ComponentAdapter      extends ComponentAdapter
1509                          implements ActionListener      implements ActionListener
1510          {    {
1511                  /**      /**
1512                   * Timer used when inside a scrollpane and the scrollbar is adjusting       * Timer used when inside a scrollpane and the scrollbar is adjusting
1513                   */       */
1514                  protected Timer timer;      protected Timer timer;
1515    
1516                  /** ScrollBar that is being adjusted */      /** ScrollBar that is being adjusted */
1517                  protected JScrollBar scrollBar;      protected JScrollBar scrollBar;
1518    
1519                  /**      /**
1520                   * Constructor       * Constructor
1521                   */       */
1522                  public ComponentHandler()      public ComponentHandler()
1523                  {      {
1524                  }      }
1525    
1526                  /**      /**
1527                   * Invoked when the component's position changes.       * Invoked when the component's position changes.
1528                   *       *
1529                   * @param e the event that occurs when moving the component       * @param e the event that occurs when moving the component
1530                   */       */
1531                  public void componentMoved(ComponentEvent e)      public void componentMoved(ComponentEvent e)
1532                  {      {
1533                  }      }
1534    
1535                  /**      /**
1536                   * Creats, if necessary, and starts a Timer to check if needed to resize       * Creats, if necessary, and starts a Timer to check if needed to resize
1537                   * the bounds       * the bounds
1538                   */       */
1539                  protected void startTimer()      protected void startTimer()
1540                  {      {
1541                  }      }
1542    
1543                  /**      /**
1544                   * Returns the JScrollPane housing the JTree, or null if one isn't       * Returns the JScrollPane housing the JTree, or null if one isn't
1545                   * found.       * found.
1546                   *       *
1547                   * @return JScrollPane housing the JTree, or null if one isn't found.       * @return JScrollPane housing the JTree, or null if one isn't found.
1548                   */       */
1549                  protected JScrollPane getScrollPane()      protected JScrollPane getScrollPane()
1550                  {      {
1551                          return null;        return null;
1552                  }      }
1553    
1554                  /**      /**
1555                   * Public as a result of Timer. If the scrollBar is null, or not       * Public as a result of Timer. If the scrollBar is null, or not
1556                   * adjusting, this stops the timer and updates the sizing.       * adjusting, this stops the timer and updates the sizing.
1557                   *       *
1558                   * @param ae is the action performed       * @param ae is the action performed
1559                   */       */
1560                  public void actionPerformed(ActionEvent ae)      public void actionPerformed(ActionEvent ae)
1561                  {      {
1562                  }      }
1563          }// ComponentHandler    }// ComponentHandler
1564    
1565          /**    /**
1566           * Listener responsible for getting cell editing events and updating the     * Listener responsible for getting cell editing events and updating the
1567           * tree accordingly.     * tree accordingly.
1568           */     */
1569          public class CellEditorHandler    public class CellEditorHandler
1570                          implements CellEditorListener      implements CellEditorListener
1571          {    {
1572                  /**      /**
1573                   * Constructor       * Constructor
1574                   */       */
1575                  public CellEditorHandler()      public CellEditorHandler()
1576                  {      {
1577                  }      }
1578    
1579                  /**      /**
1580                   * Messaged when editing has stopped in the tree. Tells the listeners       * Messaged when editing has stopped in the tree. Tells the listeners
1581                   * editing has stopped.       * editing has stopped.
1582                   *       *
1583                   * @param e is the notification event       * @param e is the notification event
1584                   */       */
1585                  public void editingStopped(ChangeEvent e)      public void editingStopped(ChangeEvent e)
1586                  {      {
1587                  }      }
1588    
1589                  /**      /**
1590                   * Messaged when editing has been canceled in the tree. This tells the       * Messaged when editing has been canceled in the tree. This tells the
1591                   * listeners the editor has canceled editing.       * listeners the editor has canceled editing.
1592                   *       *
1593                   * @param e is the notification event       * @param e is the notification event
1594                   */       */
1595                  public void editingCanceled(ChangeEvent e)      public void editingCanceled(ChangeEvent e)
1596                  {      {
1597                  }      }
1598          }// CellEditorHandler    }// CellEditorHandler
1599    
1600          /**    /**
1601           * Repaints the lead selection row when focus is lost/grained.     * Repaints the lead selection row when focus is lost/grained.
1602           */     */
1603          public class FocusHandler    public class FocusHandler
1604                          implements FocusListener      implements FocusListener
1605          {    {
1606                  /**      /**
1607                   * Constructor       * Constructor
1608                   */       */
1609                  public FocusHandler()      public FocusHandler()
1610                  {      {
1611                  }      }
1612    
1613                  /**      /**
1614                   * Invoked when focus is activated on the tree we're in, redraws the       * Invoked when focus is activated on the tree we're in, redraws the
1615                   * lead row. Invoked when a component gains the keyboard focus.       * lead row. Invoked when a component gains the keyboard focus.
1616                   *       *
1617                   * @param e is the focus event that is activated       * @param e is the focus event that is activated
1618                   */       */
1619                  public void focusGained(FocusEvent e)      public void focusGained(FocusEvent e)
1620                  {      {
1621                  }      }
1622    
1623                  /**      /**
1624                   * Invoked when focus is deactivated on the tree we're in, redraws the       * Invoked when focus is deactivated on the tree we're in, redraws the
1625                   * lead row. Invoked when a component loses the keyboard focus.       * lead row. Invoked when a component loses the keyboard focus.
1626                   *       *
1627                   * @param e is the focus event that is deactivated       * @param e is the focus event that is deactivated
1628                   */       */
1629                  public void focusLost(FocusEvent e)      public void focusLost(FocusEvent e)
1630                  {      {
1631                  }      }
1632          }// FocusHandler    }// FocusHandler
1633    
1634          /**    /**
1635           * This is used to get multiple key down events to appropriately genereate     * This is used to get multiple key down events to appropriately genereate
1636           * events.     * events.
1637           */     */
1638          public class KeyHandler    public class KeyHandler
1639                          extends KeyAdapter      extends KeyAdapter
1640          {    {
1641                  /** Key code that is being generated for. */      /** Key code that is being generated for. */
1642                  protected Action repeatKeyAction;      protected Action repeatKeyAction;
1643    
1644                  /** Set to true while keyPressed is active */      /** Set to true while keyPressed is active */
1645                  protected boolean isKeyDown;      protected boolean isKeyDown;
1646    
1647                  /**      /**
1648                   * Constructor       * Constructor
1649                   */       */
1650                  public KeyHandler()      public KeyHandler()
1651                  {      {
1652                  }      }
1653    
1654                  /**      /**
1655                   * Invoked when a key has been typed. Moves the keyboard focus to the       * Invoked when a key has been typed. Moves the keyboard focus to the
1656                   * first element whose first letter matches the alphanumeric key pressed       * first element whose first letter matches the alphanumeric key pressed
1657                   * by the user. Subsequent same key presses move the keyboard focus to       * by the user. Subsequent same key presses move the keyboard focus to
1658                   * the next object that starts with the same letter.       * the next object that starts with the same letter.
1659                   *       *
1660                   * @param e the key typed       * @param e the key typed
1661                   */       */
1662                  public void keyTyped(KeyEvent e)      public void keyTyped(KeyEvent e)
1663                  {      {
1664                  }      }
1665    
1666                  /**      /**
1667                   * Invoked when a key has been pressed.       * Invoked when a key has been pressed.
1668                   *       *
1669                   * @param e the key pressed       * @param e the key pressed
1670                   */       */
1671                  public void keyPressed(KeyEvent e)      public void keyPressed(KeyEvent e)
1672                  {      {
1673                  }      }
1674    
1675                  /**      /**
1676                   * Invoked when a key has been released       * Invoked when a key has been released
1677                   *       *
1678                   * @param e the key released       * @param e the key released
1679                   */       */
1680                  public void keyReleased(KeyEvent e)      public void keyReleased(KeyEvent e)
1681                  {      {
1682                  }      }
1683          }// KeyHandler    }// KeyHandler
1684    
1685          /**    /**
1686           * MouseListener is responsible for updating the selevtion based on mouse     * MouseListener is responsible for updating the selevtion based on mouse
1687           * events.     * events.
1688           */     */
1689          public class MouseHandler    public class MouseHandler
1690                          extends MouseAdapter      extends MouseAdapter
1691                          implements MouseMotionListener      implements MouseMotionListener
1692          {    {
1693                  /**      /**
1694                   * Constructor       * Constructor
1695                   */       */
1696                  public MouseHandler()      public MouseHandler()
1697                  {      {
1698                  }      }
1699    
1700                  /**      /**
1701                   * Invoked when a mouse button has been pressed on a component.       * Invoked when a mouse button has been pressed on a component.
1702                   *       *
1703                   * @param e is the mouse event that occured       * @param e is the mouse event that occured
1704                   */       */
1705                  public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
1706                  {      {
1707                  }      }
1708    
1709                  /**      /**
1710                   * Invoked when a mouse button is pressed on a component and then       * Invoked when a mouse button is pressed on a component and then
1711                   * dragged. MOUSE_DRAGGED events will continue to be delivered to the       * dragged. MOUSE_DRAGGED events will continue to be delivered to the
1712                   * component where the drag originated until the mouse button is       * component where the drag originated until the mouse button is
1713                   * released (regardless of whether the mouse position is within the       * released (regardless of whether the mouse position is within the
1714                   * bounds of the component).       * bounds of the component).
1715                   *       *
1716                   * @param e is the mouse event that occured       * @param e is the mouse event that occured
1717                   */       */
1718                  public void mouseDragged(MouseEvent e)      public void mouseDragged(MouseEvent e)
1719                  {      {
1720                  }      }
1721    
1722                  /**      /**
1723                   * Invoked when the mouse button has been moved on a component (with no       * Invoked when the mouse button has been moved on a component (with no
1724                   * buttons no down).       * buttons no down).
1725                   *       *
1726                   * @param e the mouse event that occured       * @param e the mouse event that occured
1727                   */       */
1728                  public void mouseMoved(MouseEvent e)      public void mouseMoved(MouseEvent e)
1729                  {      {
1730                  }      }
1731    
1732                  /**      /**
1733                   * Invoked when a mouse button has been released on a component.       * Invoked when a mouse button has been released on a component.
1734                   *       *
1735                   * @param e is the mouse event that occured       * @param e is the mouse event that occured
1736                   */       */
1737                  public void mouseReleased(MouseEvent e)      public void mouseReleased(MouseEvent e)
1738                  {      {
1739                  }      }
1740          }// MouseHandler    }// MouseHandler
1741    
1742          /**    /**
1743           * MouseInputHandler handles passing all mouse events, including mouse     * MouseInputHandler handles passing all mouse events, including mouse
1744           * motion events, until the mouse is released to the destination it is     * motion events, until the mouse is released to the destination it is
1745           * constructed with.     * constructed with.
1746           */     */
1747          public class MouseInputHandler    public class MouseInputHandler
1748                          implements MouseInputListener      implements MouseInputListener
1749          {    {
1750                  /** Source that events are coming from */      /** Source that events are coming from */
1751                  protected Component source;      protected Component source;
1752    
1753                  /** Destination that receives all events. */      /** Destination that receives all events. */
1754                  protected Component destination;      protected Component destination;
1755    
1756                  /**      /**
1757                   * Constructor       * Constructor
1758                   *       *
1759                   * @param source that events are coming from       * @param source that events are coming from
1760                   * @param destination that receives all events       * @param destination that receives all events
1761                   * @param event is the event received       * @param event is the event received
1762                   */       */
1763                  public MouseInputHandler(Component source, Component destination,      public MouseInputHandler(Component source, Component destination,
1764                                  MouseEvent e)                               MouseEvent e)
1765                  {      {
1766                  }      }
1767    
1768                  /**      /**
1769                   * Invoked when the mouse button has been clicked (pressed and released)       * Invoked when the mouse button has been clicked (pressed and released)
1770                   * on a component.       * on a component.
1771                   *       *
1772                   * @param e mouse event that occured       * @param e mouse event that occured
1773                   */       */
1774                  public void mouseClicked(MouseEvent e)      public void mouseClicked(MouseEvent e)
1775                  {      {
1776                          Point click = e.getPoint();        Point click = e.getPoint();
1777                          int row = ((int) click.getY() / getRowHeight()) - 1;        int row = ((int) click.getY() / getRowHeight()) - 1;
1778                          TreePath path = BasicTreeUI.this.tree.getPathForRow(row);        TreePath path = BasicTreeUI.this.tree.getPathForRow(row);
1779    
1780                          if (path == null)        if (path == null)
1781                          {          {
1782                                  // nothing should be selected if user clicks outside of tree            // nothing should be selected if user clicks outside of tree
1783                                  BasicTreeUI.this.tree.getSelectionModel().clearSelection();            BasicTreeUI.this.tree.getSelectionModel().clearSelection();
1784                                  BasicTreeUI.this.tree.repaint();            BasicTreeUI.this.tree.repaint();
1785                          }          }
1786                                                    
1787                          if (BasicTreeUI.this.tree.isVisible(path))        if (BasicTreeUI.this.tree.isVisible(path))
1788                          {          {
1789                                  if (BasicTreeUI.this.tree.isExpanded(path))            if (BasicTreeUI.this.tree.isExpanded(path))
1790                                  {              {
1791                                          BasicTreeUI.this.tree.collapsePath(path);                BasicTreeUI.this.tree.collapsePath(path);
1792                                          BasicTreeUI.this.tree.fireTreeCollapsed(path);                BasicTreeUI.this.tree.fireTreeCollapsed(path);
1793                                  }              }
1794                                  else            else
1795                                  {              {
1796                                          BasicTreeUI.this.tree.expandPath(path);                BasicTreeUI.this.tree.expandPath(path);
1797                                          BasicTreeUI.this.tree.fireTreeExpanded(path);                BasicTreeUI.this.tree.fireTreeExpanded(path);
1798                                  }              }
1799                                                                    
1800                                  if (BasicTreeUI.this.tree.isRowSelected(row))            if (BasicTreeUI.this.tree.isRowSelected(row))
1801                                          BasicTreeUI.this.tree.removeSelectionRow(row);              BasicTreeUI.this.tree.removeSelectionRow(row);
1802                                  else if (BasicTreeUI.this.tree.getSelectionModel()            else if (BasicTreeUI.this.tree.getSelectionModel()
1803                                                  .getSelectionMode() == treeSelectionModel                     .getSelectionMode() == treeSelectionModel
1804                                                  .SINGLE_TREE_SELECTION)                     .SINGLE_TREE_SELECTION)
1805                                  {              {
1806                                          BasicTreeUI.this.tree.getSelectionModel().clearSelection();                BasicTreeUI.this.tree.getSelectionModel().clearSelection();
1807                                          BasicTreeUI.this.tree.addSelectionRow(row);                BasicTreeUI.this.tree.addSelectionRow(row);
1808                                  }              }
1809                                  else if (BasicTreeUI.this.tree.getSelectionModel()            else if (BasicTreeUI.this.tree.getSelectionModel()
1810                                                  .getSelectionMode() == treeSelectionModel                     .getSelectionMode() == treeSelectionModel
1811                                                  .CONTIGUOUS_TREE_SELECTION)                     .CONTIGUOUS_TREE_SELECTION)
1812                                  {              {
1813                                          // TODO                // TODO
1814                                  }              }
1815                                  else            else
1816                                  {              {
1817                                          BasicTreeUI.this.tree.getSelectionModel().setSelectionMode(                BasicTreeUI.this.tree.getSelectionModel().setSelectionMode
1818                                                          treeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);                  (treeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
1819                                          BasicTreeUI.this.tree.addSelectionRow(row);                BasicTreeUI.this.tree.addSelectionRow(row);
1820                                  }              }
1821                          }                        }              
1822                  }      }
1823    
1824                  /**      /**
1825                   * Invoked when a mouse button has been pressed on a component.       * Invoked when a mouse button has been pressed on a component.
1826                   *       *
1827                   * @param e mouse event that occured       * @param e mouse event that occured
1828                   */       */
1829                  public void mousePressed(MouseEvent e)      public void mousePressed(MouseEvent e)
1830                  {      {
1831                  }      }
1832    
1833                  /**      /**
1834                   * Invoked when a mouse button has been released on a component.       * Invoked when a mouse button has been released on a component.
1835                   *       *
1836                   * @param e mouse event that occured       * @param e mouse event that occured
1837                   */       */
1838                  public void mouseReleased(MouseEvent e)      public void mouseReleased(MouseEvent e)
1839                  {      {
1840                  }      }
1841    
1842                  /**      /**
1843                   * Invoked when the mouse enters a component.       * Invoked when the mouse enters a component.
1844                   *       *
1845                   * @param e mouse event that occured       * @param e mouse event that occured
1846                   */       */
1847                  public void mouseEntered(MouseEvent e)      public void mouseEntered(MouseEvent e)
1848                  {      {
1849                  }      }
1850    
1851                  /**      /**
1852                   * Invoked when the mouse exits a component.       * Invoked when the mouse exits a component.
1853                   *       *
1854                   * @param e mouse event that occured       * @param e mouse event that occured
1855                   */       */
1856                  public void mouseExited(MouseEvent e)      public void mouseExited(MouseEvent e)
1857                  {      {
1858                  }      }
1859    
1860                  /**      /**
1861                   * Invoked when a mouse button is pressed on a component and then       * Invoked when a mouse button is pressed on a component and then
1862                   * dragged. MOUSE_DRAGGED events will continue to be delivered to the       * dragged. MOUSE_DRAGGED events will continue to be delivered to the
1863                   * component where the drag originated until the mouse button is       * component where the drag originated until the mouse button is
1864                   * released (regardless of whether the mouse position is within the       * released (regardless of whether the mouse position is within the
1865                   * bounds of the component).       * bounds of the component).
1866                   *       *
1867                   * @param e mouse event that occured       * @param e mouse event that occured
1868                   */       */
1869                  public void mouseDragged(MouseEvent e)      public void mouseDragged(MouseEvent e)
1870                  {      {
1871                  }      }
1872    
1873                  /**      /**
1874                   * Invoked when the mouse cursor has been moved onto a component but no       * Invoked when the mouse cursor has been moved onto a component but no
1875                   * buttons have been pushed.       * buttons have been pushed.
1876                   *       *
1877                   * @param e mouse event that occured       * @param e mouse event that occured
1878                   */       */
1879                  public void mouseMoved(MouseEvent e)      public void mouseMoved(MouseEvent e)
1880                  {      {
1881                  }      }
1882    
1883                  /**      /**
1884                   * Removes event from the source       * Removes event from the source
1885                   */       */
1886                  protected void removeFromSource()      protected void removeFromSource()
1887                  {      {
1888                  }      }
1889          }// MouseInputHandler    }// MouseInputHandler
1890    
1891          /**    /**
1892           * Class responsible for getting size of node, method is forwarded to     * Class responsible for getting size of node, method is forwarded to
1893           * BasicTreeUI method. X location does not include insets, that is handled     * BasicTreeUI method. X location does not include insets, that is handled
1894           * in getPathBounds.     * in getPathBounds.
1895           */     */
1896          public class NodeDimensionsHandler    public class NodeDimensionsHandler
1897                          extends AbstractLayoutCache.NodeDimensions      extends AbstractLayoutCache.NodeDimensions
1898          {    {
1899                  /**      /**
1900                   * Constructor       * Constructor
1901                   */       */
1902                  public NodeDimensionsHandler()      public NodeDimensionsHandler()
1903                  {      {
1904                  }      }
1905    
1906                  /**      /**
1907                   * Responsible for getting the size of a particular node.       * Responsible for getting the size of a particular node.
1908                   *       *
1909                   * @param value the value to be represented       * @param value the value to be represented
1910                   * @param row row being queried       * @param row row being queried
1911                   * @param depth the depth of the row       * @param depth the depth of the row
1912                   * @param expanded true if row is expanded       * @param expanded true if row is expanded
1913                   * @param size a Rectangle containing the size needed to represent value       * @param size a Rectangle containing the size needed to represent value
1914                   * @return containing the node dimensions, or null if node has no       * @return containing the node dimensions, or null if node has no
1915                   *         dimension       *         dimension
1916                   */       */
1917                  public Rectangle getNodeDimensions(Object value, int row, int depth,      public Rectangle getNodeDimensions(Object value, int row, int depth,
1918                                  boolean expanded, Rectangle size)                                         boolean expanded, Rectangle size)
1919                  {      {
1920                          return null;        return null;
1921                  }      }
1922    
1923                  /**      /**
1924                   * Returns the amount to indent the given row       * Returns the amount to indent the given row
1925                   *       *
1926                   * @return amount to indent the given row.       * @return amount to indent the given row.
1927                   */       */
1928                  protected int getRowX(int row, int depth)      protected int getRowX(int row, int depth)
1929                  {      {
1930                          return 0;        return 0;
1931                  }      }
1932          }// NodeDimensionsHandler    }// NodeDimensionsHandler
1933    
1934          /**    /**
1935           * PropertyChangeListener for the tree. Updates the appropriate varaible, or     * PropertyChangeListener for the tree. Updates the appropriate varaible, or
1936           * TreeState, based on what changes.     * TreeState, based on what changes.
1937           */     */
1938          public class PropertyChangeHandler    public class PropertyChangeHandler
1939                          implements PropertyChangeListener      implements PropertyChangeListener
1940          {    {
1941    
1942                  /**      /**
1943                   * Constructor       * Constructor
1944                   */       */
1945                  public PropertyChangeHandler()      public PropertyChangeHandler()
1946                  {      {
1947                  }      }
1948    
1949                  /**      /**
1950                   * This method gets called when a bound property is changed.       * This method gets called when a bound property is changed.
1951                   *       *
1952                   * @param event A PropertyChangeEvent object describing the event source       * @param event A PropertyChangeEvent object describing the event source
1953                   *        and the property that has changed.       *        and the property that has changed.
1954                   */       */
1955                  public void propertyChange(PropertyChangeEvent event)      public void propertyChange(PropertyChangeEvent event)
1956                  {      {
1957                  }      }
1958          }// PropertyChangeHandler    }// PropertyChangeHandler
1959    
1960          /**    /**
1961           * Listener on the TreeSelectionModel, resets the row selection if any of     * Listener on the TreeSelectionModel, resets the row selection if any of
1962           * the properties of the model change.     * the properties of the model change.
1963           */     */
1964          public class SelectionModelPropertyChangeHandler    public class SelectionModelPropertyChangeHandler
1965                          implements PropertyChangeListener      implements PropertyChangeListener
1966          {    {
1967    
1968                  /**      /**
1969                   * Constructor       * Constructor
1970                   */       */
1971                  public SelectionModelPropertyChangeHandler()      public SelectionModelPropertyChangeHandler()
1972                  {      {
1973                  }      }
1974    
1975                  /**      /**
1976                   * This method gets called when a bound property is changed.       * This method gets called when a bound property is changed.
1977                   *       *
1978                   * @param event A PropertyChangeEvent object describing the event source       * @param event A PropertyChangeEvent object describing the event source
1979                   *        and the property that has changed.       *        and the property that has changed.
1980                   */       */
1981                  public void propertyChange(PropertyChangeEvent event)      public void propertyChange(PropertyChangeEvent event)
1982                  {      {
1983                  }      }
1984          }// SelectionModelPropertyChangeHandler    }// SelectionModelPropertyChangeHandler
1985    
1986          /**    /**
1987           * ActionListener that invokes cancelEditing when action performed.     * ActionListener that invokes cancelEditing when action performed.
1988           */     */
1989          public class TreeCancelEditingAction    public class TreeCancelEditingAction
1990                          extends AbstractAction      extends AbstractAction
1991          {    {
1992    
1993                  /**      /**
1994                   * Constructor       * Constructor
1995                   */       */
1996                  public TreeCancelEditingAction()      public TreeCancelEditingAction()
1997                  {      {
1998                  }      }
1999    
2000                  /**      /**
2001                   * Invoked when an action occurs.       * Invoked when an action occurs.
2002                   *       *
2003                   * @param e event that occured       * @param e event that occured
2004                   */       */
2005                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2006                  {      {
2007                  }      }
2008    
2009                  /**      /**
2010                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2011                   *       *
2012                   * @return true if the action is enabled, false otherwise       * @return true if the action is enabled, false otherwise
2013                   */       */
2014                  public boolean isEnabled()      public boolean isEnabled()
2015                  {      {
2016                          return false;        return false;
2017                  }      }
2018          }// TreeCancelEditingAction    }// TreeCancelEditingAction
2019    
2020          /**    /**
2021           * Updates the TreeState in response to nodes expanding/collapsing.     * Updates the TreeState in response to nodes expanding/collapsing.
2022           */     */
2023          public class TreeExpansionHandler    public class TreeExpansionHandler
2024                          implements TreeExpansionListener      implements TreeExpansionListener
2025          {    {
2026    
2027                  /**      /**
2028                   * Constructor       * Constructor
2029                   */       */
2030                  public TreeExpansionHandler()      public TreeExpansionHandler()
2031                  {      {
2032                  }      }
2033    
2034                  /**      /**
2035                   * Called whenever an item in the tree has been expanded.       * Called whenever an item in the tree has been expanded.
2036                   *       *
2037                   * @param event is the event that occured       * @param event is the event that occured
2038                   */       */
2039                  public void treeExpanded(TreeExpansionEvent event)      public void treeExpanded(TreeExpansionEvent event)
2040                  {      {
2041                          BasicTreeUI.this.tree.repaint();        BasicTreeUI.this.tree.repaint();
2042                  }      }
2043    
2044                  /**      /**
2045                   * Called whenever an item in the tree has been collapsed.       * Called whenever an item in the tree has been collapsed.
2046                   *       *
2047                   * @param event is the event that occured       * @param event is the event that occured
2048                   */       */
2049                  public void treeCollapsed(TreeExpansionEvent event)      public void treeCollapsed(TreeExpansionEvent event)
2050                  {      {
2051                          BasicTreeUI.this.tree.repaint();        BasicTreeUI.this.tree.repaint();
2052                  }      }
2053          }// TreeExpansionHandler    }// TreeExpansionHandler
2054    
2055          /**    /**
2056           * TreeHomeAction is used to handle end/home actions. Scrolls either the     * TreeHomeAction is used to handle end/home actions. Scrolls either the
2057           * first or last cell to be visible based on direction.     * first or last cell to be visible based on direction.
2058           */     */
2059          public class TreeHomeAction    public class TreeHomeAction
2060                          extends AbstractAction      extends AbstractAction
2061          {    {
2062    
2063                  /** direction is either home or end */      /** direction is either home or end */
2064                  protected int direction;      protected int direction;
2065    
2066                  /**      /**
2067                   * Constructor       * Constructor
2068                   *       *
2069                   * @param direction - it is home or end       * @param direction - it is home or end
2070                   * @param name is the name of the direction       * @param name is the name of the direction
2071                   */       */
2072                  public TreeHomeAction(int direction, String name)      public TreeHomeAction(int direction, String name)
2073                  {      {
2074                  }      }
2075    
2076                  /**      /**
2077                   * Invoked when an action occurs.       * Invoked when an action occurs.
2078                   *       *
2079                   * @param e is the event that occured       * @param e is the event that occured
2080                   */       */
2081                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2082                  {      {
2083                  }      }
2084    
2085                  /**      /**
2086                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2087                   *       *
2088                   * @return true if the action is enabled.       * @return true if the action is enabled.
2089                   */       */
2090                  public boolean isEnabled()      public boolean isEnabled()
2091                  {      {
2092                          return false;        return false;
2093                  }      }
2094          }// TreeHomeAction    }// TreeHomeAction
2095    
2096          /**    /**
2097           * TreeIncrementAction is used to handle up/down actions. Selection is moved     * TreeIncrementAction is used to handle up/down actions. Selection is moved
2098           * up or down based on direction.     * up or down based on direction.
2099           */     */
2100          public class TreeIncrementAction    public class TreeIncrementAction
2101                          extends AbstractAction      extends AbstractAction
2102          {    {
2103    
2104                  /** Specifies the direction to adjust the selection by. */      /** Specifies the direction to adjust the selection by. */
2105                  protected int direction;      protected int direction;
2106    
2107                  /**      /**
2108                   * Constructor       * Constructor
2109                   *       *
2110                   * @param direction up or down       * @param direction up or down
2111                   * @param name is the name of the direction       * @param name is the name of the direction
2112                   */       */
2113                  public TreeIncrementAction(int direction, String name)      public TreeIncrementAction(int direction, String name)
2114                  {      {
2115                  }      }
2116    
2117                  /**      /**
2118                   * Invoked when an action occurs.       * Invoked when an action occurs.
2119                   *       *
2120                   * @param e is the event that occured       * @param e is the event that occured
2121                   */       */
2122                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2123                  {      {
2124                  }      }
2125    
2126                  /**      /**
2127                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2128                   *       *
2129                   * @return true if the action is enabled.       * @return true if the action is enabled.
2130                   */       */
2131                  public boolean isEnabled()      public boolean isEnabled()
2132                  {      {
2133                          return false;        return false;
2134                  }      }
2135          }// TreeIncrementAction    }// TreeIncrementAction
2136    
2137          /**    /**
2138           * Forwards all TreeModel events to the TreeState.     * Forwards all TreeModel events to the TreeState.
2139           */     */
2140          public class TreeModelHandler    public class TreeModelHandler
2141                          implements TreeModelListener      implements TreeModelListener
2142          {    {
2143                  /**      /**
2144                   * Constructor       * Constructor
2145                   */       */
2146                  public TreeModelHandler()      public TreeModelHandler()
2147                  {      {
2148                  }      }
2149    
2150                  /**      /**
2151                   * Invoked after a node (or a set of siblings) has changed in some way.       * Invoked after a node (or a set of siblings) has changed in some way.
2152                   * The node(s) have not changed locations in the tree or altered their       * The node(s) have not changed locations in the tree or altered their
2153                   * children arrays, but other attributes have changed and may affect       * children arrays, but other attributes have changed and may affect
2154                   * presentation. Example: the name of a file has changed, but it is in       * presentation. Example: the name of a file has changed, but it is in
2155                   * the same location in the file system. To indicate the root has       * the same location in the file system. To indicate the root has
2156                   * changed, childIndices and children will be null. Use e.getPath() to       * changed, childIndices and children will be null. Use e.getPath() to
2157                   * get the parent of the changed node(s). e.getChildIndices() returns       * get the parent of the changed node(s). e.getChildIndices() returns
2158                   * the index(es) of the changed node(s).       * the index(es) of the changed node(s).
2159                   *       *
2160                   * @param e is the event that occured       * @param e is the event that occured
2161                   */       */
2162                  public void treeNodesChanged(TreeModelEvent e)      public void treeNodesChanged(TreeModelEvent e)
2163                  {      {
2164                  }      }
2165    
2166                  /**      /**
2167                   * Invoked after nodes have been inserted into the tree. Use e.getPath()       * Invoked after nodes have been inserted into the tree. Use e.getPath()
2168                   * to get the parent of the new node(s). e.getChildIndices() returns the       * to get the parent of the new node(s). e.getChildIndices() returns the
2169                   * index(es) of the new node(s) in ascending order.       * index(es) of the new node(s) in ascending order.
2170                   *       *
2171                   * @param e is the event that occured       * @param e is the event that occured
2172                   */       */
2173                  public void treeNodesInserted(TreeModelEvent e)      public void treeNodesInserted(TreeModelEvent e)
2174                  {      {
2175                  }      }
2176    
2177                  /**      /**
2178                   * Invoked after nodes have been removed from the tree. Note that if a       * Invoked after nodes have been removed from the tree. Note that if a
2179                   * subtree is removed from the tree, this method may only be invoked       * subtree is removed from the tree, this method may only be invoked
2180                   * once for the root of the removed subtree, not once for each       * once for the root of the removed subtree, not once for each
2181                   * individual set of siblings removed. Use e.getPath() to get the former       * individual set of siblings removed. Use e.getPath() to get the former
2182                   * parent of the deleted node(s). e.getChildIndices() returns, in       * parent of the deleted node(s). e.getChildIndices() returns, in
2183                   * ascending order, the index(es) the node(s) had before being deleted.       * ascending order, the index(es) the node(s) had before being deleted.
2184                   *       *
2185                   * @param e is the event that occured       * @param e is the event that occured
2186                   */       */
2187                  public void treeNodesRemoved(TreeModelEvent e)      public void treeNodesRemoved(TreeModelEvent e)
2188                  {      {
2189                  }      }
2190    
2191                  /**      /**
2192                   * Invoked after the tree has drastically changed structure from a given       * Invoked after the tree has drastically changed structure from a given
2193                   * node down. If the path returned by e.getPath() is of length one and       * node down. If the path returned by e.getPath() is of length one and
2194                   * the first element does not identify the current root node the first       * the first element does not identify the current root node the first
2195                   * element should become the new root of the tree. Use e.getPath() to       * element should become the new root of the tree. Use e.getPath() to
2196                   * get the path to the node. e.getChildIndices() returns null.       * get the path to the node. e.getChildIndices() returns null.
2197                   *       *
2198                   * @param e is the event that occured       * @param e is the event that occured
2199                   */       */
2200                  public void treeStructureChanged(TreeModelEvent e)      public void treeStructureChanged(TreeModelEvent e)
2201                  {      {
2202                  }      }
2203          }// TreeModelHandler    }// TreeModelHandler
2204    
2205          /**    /**
2206           * TreePageAction handles page up and page down events.     * TreePageAction handles page up and page down events.
2207           */     */
2208          public class TreePageAction    public class TreePageAction
2209                          extends AbstractAction      extends AbstractAction
2210          {    {
2211                  /** Specifies the direction to adjust the selection by. */      /** Specifies the direction to adjust the selection by. */
2212                  protected int direction;      protected int direction;
2213    
2214                  /**      /**
2215                   * Constructor       * Constructor
2216                   *       *
2217                   * @param direction up or down       * @param direction up or down
2218                   * @param name is the name of the direction       * @param name is the name of the direction
2219                   */       */
2220                  public TreePageAction(int direction, String name)      public TreePageAction(int direction, String name)
2221                  {      {
2222                  }      }
2223    
2224                  /**      /**
2225                   * Invoked when an action occurs.       * Invoked when an action occurs.
2226                   *       *
2227                   * @param e is the event that occured       * @param e is the event that occured
2228                   */       */
2229                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2230                  {      {
2231                  }      }
2232    
2233                  /**      /**
2234                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2235                   *       *
2236                   * @return true if the action is enabled.       * @return true if the action is enabled.
2237                   */       */
2238                  public boolean isEnabled()      public boolean isEnabled()
2239                  {      {
2240                          return false;        return false;
2241                  }      }
2242          }// TreePageAction    }// TreePageAction
2243    
2244          /**    /**
2245           * Listens for changes in the selection model and updates the display     * Listens for changes in the selection model and updates the display
2246           * accordingly.     * accordingly.
2247           */     */
2248          public class TreeSelectionHandler    public class TreeSelectionHandler
2249                          implements TreeSelectionListener      implements TreeSelectionListener
2250          {    {
2251                  /**      /**
2252                   * Constructor       * Constructor
2253                   */       */
2254                  public TreeSelectionHandler()      public TreeSelectionHandler()
2255                  {      {
2256                  }      }
2257    
2258                  /**      /**
2259                   * Messaged when the selection changes in the tree we're displaying for.       * Messaged when the selection changes in the tree we're displaying for.
2260                   * Stops editing, messages super and displays the changed paths.       * Stops editing, messages super and displays the changed paths.
2261                   *       *
2262                   * @param event the event that characterizes the change.       * @param event the event that characterizes the change.
2263                   */       */
2264                  public void valueChanged(TreeSelectionEvent event)      public void valueChanged(TreeSelectionEvent event)
2265                  {      {
2266                  }      }
2267          }// TreeSelectionHandler    }// TreeSelectionHandler
2268    
2269          /**    /**
2270           * For the first selected row expandedness will be toggled.     * For the first selected row expandedness will be toggled.
2271           */     */
2272          public class TreeToggleAction    public class TreeToggleAction
2273                          extends AbstractAction      extends AbstractAction
2274          {    {
2275                  /**      /**
2276                   * Constructor       * Constructor
2277                   *       *
2278                   * @param name is the name of <code>Action</code> field       * @param name is the name of <code>Action</code> field
2279                   */       */
2280                  public TreeToggleAction(String name)      public TreeToggleAction(String name)
2281                  {      {
2282                  }      }
2283    
2284                  /**      /**
2285                   * Invoked when an action occurs.       * Invoked when an action occurs.
2286                   *       *
2287                   * @param e the event that occured       * @param e the event that occured
2288                   */       */
2289                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2290                  {      {
2291                  }      }
2292    
2293                  /**      /**
2294                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2295                   *       *
2296                   * @return true if the action is enabled, false otherwise       * @return true if the action is enabled, false otherwise
2297                   */       */
2298                  public boolean isEnabled()      public boolean isEnabled()
2299                  {      {
2300                          return false;        return false;
2301                  }      }
2302          } // TreeToggleAction    } // TreeToggleAction
2303    
2304          /**    /**
2305           * TreeTraverseAction is the action used for left/right keys. Will toggle     * TreeTraverseAction is the action used for left/right keys. Will toggle
2306           * the expandedness of a node, as well as potentially incrementing the     * the expandedness of a node, as well as potentially incrementing the
2307           * selection.     * selection.
2308           */     */
2309          public class TreeTraverseAction    public class TreeTraverseAction
2310                          extends AbstractAction      extends AbstractAction
2311          {    {
2312                  /**      /**
2313                   * Determines direction to traverse, 1 means expand, -1 means collapse.       * Determines direction to traverse, 1 means expand, -1 means collapse.
2314                   */       */
2315                  protected int direction;      protected int direction;
2316    
2317                  /**      /**
2318                   * Constructor       * Constructor
2319                   *       *
2320                   * @param direction to traverse       * @param direction to traverse
2321                   * @param name is the name of the direction       * @param name is the name of the direction
2322                   */       */
2323                  public TreeTraverseAction(int direction, String name)      public TreeTraverseAction(int direction, String name)
2324                  {      {
2325                  }      }
2326    
2327                  /**      /**
2328                   * Invoked when an action occurs.       * Invoked when an action occurs.
2329                   *       *
2330                   * @param e the event that occured       * @param e the event that occured
2331                   */       */
2332                  public void actionPerformed(ActionEvent e)      public void actionPerformed(ActionEvent e)
2333                  {      {
2334                  }      }
2335    
2336                  /**      /**
2337                   * Returns true if the action is enabled.       * Returns true if the action is enabled.
2338                   *       *
2339                   * @return true if the action is enabled, false otherwise       * @return true if the action is enabled, false otherwise
2340                   */       */
2341                  public boolean isEnabled()      public boolean isEnabled()
2342                  {      {
2343                          return false;        return false;
2344                  }      }
2345          } // TreeTraverseAction    } // TreeTraverseAction
2346    
2347          /* * HELPER METHODS FOR PAINTING * */    /* * HELPER METHODS FOR PAINTING * */
2348                    
2349          /**    /**
2350           * Returns the cell bounds for painting selected cells     * Returns the cell bounds for painting selected cells
2351           *     *
2352           * @param x is the x location of the cell     * @param x is the x location of the cell
2353           * @param y is the y location of the cell     * @param y is the y location of the cell
2354           * @param cell is the Object to get the bounds for     * @param cell is the Object to get the bounds for
2355           *     *
2356           * @returns Rectangle that represents the cell bounds     * @returns Rectangle that represents the cell bounds
2357           */     */
2358          private Rectangle getCellBounds(int x, int y, Object cell)    private Rectangle getCellBounds(int x, int y, Object cell)
2359          {    {
2360                  String s = cell.toString();      String s = cell.toString();
2361                  Font f = tree.getFont();      Font f = tree.getFont();
2362                  FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());      FontMetrics fm = tree.getToolkit().getFontMetrics(tree.getFont());
2363    
2364                  return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s), fm      return new Rectangle(x, y, SwingUtilities.computeStringWidth(fm, s), fm
2365                                  .getHeight());                           .getHeight());
2366          }    }
2367                    
2368          /**    /**
2369           * Paints a leaf in the tree     * Paints a leaf in the tree
2370           *     *
2371           * @param g the Graphics context in which to paint     * @param g the Graphics context in which to paint
2372           * @param x the x location of the leaf     * @param x the x location of the leaf
2373           * @param y the y location of the leaf     * @param y the y location of the leaf
2374           * @param tree the tree to draw on     * @param tree the tree to draw on
2375           * @param leaf the object to draw     * @param leaf the object to draw
2376           */     */
2377          private void paintLeaf(Graphics g, int x, int y, JTree tree, Object leaf)    private void paintLeaf(Graphics g, int x, int y, JTree tree, Object leaf)
2378          {    {
2379                  TreePath curr = new TreePath(((DefaultMutableTreeNode) leaf)      TreePath curr = new TreePath(((DefaultMutableTreeNode) leaf)
2380                                  .getPath());                                   .getPath());
2381                  boolean selected = tree.isPathSelected(curr);      boolean selected = tree.isPathSelected(curr);
2382    
2383                  if (tree.isVisible(curr))      if (tree.isVisible(curr))
2384                          if (selected)        if (selected)
2385                          {          {
2386                                  Component comp = tree.getCellRenderer()            Component comp = tree.getCellRenderer()
2387                                                  .getTreeCellRendererComponent(tree, leaf, true, false,              .getTreeCellRendererComponent(tree, leaf, true, false,
2388                                                                  true, 0, false);                                            true, 0, false);
2389                                  rendererPane.paintComponent(g, comp, tree,            rendererPane.paintComponent(g, comp, tree,
2390                                                  getCellBounds(x, y, leaf));                                        getCellBounds(x, y, leaf));
2391                          }          }
2392                          else        else
2393                          {          {
2394                                  Component c = tree.getCellRenderer()            Component c = tree.getCellRenderer()
2395                                  .getTreeCellRendererComponent(tree,              .getTreeCellRendererComponent(tree,
2396                                                  leaf, false, false, true, 0, false);                                            leaf, false, false, true, 0, false);
2397                                                                    
2398                                  g.translate(x, y);            g.translate(x, y);
2399                                  c.paint(g);            c.paint(g);
2400                                  g.translate(-x, -y);            g.translate(-x, -y);
2401                          }          }
2402          }    }
2403    
2404          /**    /**
2405           * Paints a non-leaf in the tree     * Paints a non-leaf in the tree
2406           *     *
2407           * @param g the Graphics context in which to paint     * @param g the Graphics context in which to paint
2408           * @param x the x location of the non-leaf     * @param x the x location of the non-leaf
2409           * @param y the y location of the non-leaf     * @param y the y location of the non-leaf
2410           * @param tree the tree to draw on     * @param tree the tree to draw on
2411           * @param nonLeaf the object to draw     * @param nonLeaf the object to draw
2412           */     */
2413          private void paintNonLeaf(Graphics g, int x, int y, JTree tree,    private void paintNonLeaf(Graphics g, int x, int y, JTree tree,
2414                          Object nonLeaf)                              Object nonLeaf)
2415          {          {    
2416                  TreePath curr = new TreePath(((DefaultMutableTreeNode) nonLeaf)      TreePath curr = new TreePath(((DefaultMutableTreeNode) nonLeaf)
2417                                                                  .getPath());                                   .getPath());
2418                  boolean selected = tree.isPathSelected(curr);      boolean selected = tree.isPathSelected(curr);
2419                  boolean expanded = tree.isExpanded(curr);      boolean expanded = tree.isExpanded(curr);
2420                                    
2421                  if (tree.isVisible(curr))      if (tree.isVisible(curr))
2422                          if (selected)        if (selected)
2423                          {          {
2424                                  Component comp = tree.getCellRenderer()            Component comp = tree.getCellRenderer()
2425                                                  .getTreeCellRendererComponent(tree, nonLeaf, true,              .getTreeCellRendererComponent(tree, nonLeaf, true,
2426                                                                  expanded, false, 0, false);                                            expanded, false, 0, false);
2427                                  rendererPane.paintComponent(g, comp, tree,            rendererPane.paintComponent(g, comp, tree,
2428                                                  getCellBounds(x, y, nonLeaf));                                        getCellBounds(x, y, nonLeaf));
2429                          }          }
2430                          else        else
2431                          {          {
2432                                  Component c = tree.getCellRenderer()            Component c = tree.getCellRenderer()
2433                                                  .getTreeCellRendererComponent(tree,              .getTreeCellRendererComponent(tree, nonLeaf, false, expanded,
2434                                                                  nonLeaf, false, expanded, false, 0, false);                                            false, 0, false);
2435                                                                    
2436                                  g.translate(x, y);            g.translate(x, y);
2437                                  c.paint(g);            c.paint(g);
2438                                  g.translate(-x, -y);            g.translate(-x, -y);
2439                          }          }
2440          }    }
2441    
2442          /**    /**
2443           * Recursively paints all elements of the tree     * Recursively paints all elements of the tree
2444           *     *
2445           * @param g the Graphics context in which to paint     * @param g the Graphics context in which to paint
2446           * @param indentation of the current object     * @param indentation of the current object
2447           * @param descent is the number of elements drawn     * @param descent is the number of elements drawn
2448           * @param childNumber is the index of the current child in the tree     * @param childNumber is the index of the current child in the tree
2449           * @param depth is the depth of the current object in the tree     * @param depth is the depth of the current object in the tree
2450           * @param tree is the tree to draw to     * @param tree is the tree to draw to
2451           * @param mod is the TreeModel we are using to draw     * @param mod is the TreeModel we are using to draw
2452           * @param curr is the current object to draw     * @param curr is the current object to draw
2453           *     *
2454           * @return int - current descent of the tree     * @return int - current descent of the tree
2455           */     */
2456          private int paintRecursive(Graphics g, int indentation, int descent,    private int paintRecursive(Graphics g, int indentation, int descent,
2457                          int childNumber, int depth, JTree tree, TreeModel mod, Object curr)                               int childNumber, int depth, JTree tree,
2458          {                               TreeModel mod, Object curr)
2459                  Rectangle clip = g.getClipBounds();    {
2460                  if (indentation > clip.x + clip.width + rightChildIndent      Rectangle clip = g.getClipBounds();
2461                                  || descent > clip.y + clip.height + getRowHeight())      if (indentation > clip.x + clip.width + rightChildIndent
2462                          return descent;          || descent > clip.y + clip.height + getRowHeight())
2463          return descent;
2464                  int halfHeight = getRowHeight() / 2;  
2465                  int halfWidth = rightChildIndent / 2;      int halfHeight = getRowHeight() / 2;
2466                  int y0 = descent + halfHeight;      int halfWidth = rightChildIndent / 2;
2467        int y0 = descent + halfHeight;
2468                  if (mod.isLeaf(curr))  
2469                  {      if (mod.isLeaf(curr))
2470                          paintLeaf(g, indentation, descent, tree, curr);        {
2471                          descent += getRowHeight();          paintLeaf(g, indentation, descent, tree, curr);
2472                  }          descent += getRowHeight();
2473                  else        }
2474                  {      else
2475                          if (depth > 0 || tree.isRootVisible())        {
2476                          {          if (depth > 0 || tree.isRootVisible())
2477                                  paintNonLeaf(g, indentation, descent, tree, curr);            {
2478                                  descent += getRowHeight();              paintNonLeaf(g, indentation, descent, tree, curr);
2479                                  y0 += halfHeight;              descent += getRowHeight();
2480                          }              y0 += halfHeight;
2481                          int max = mod.getChildCount(curr);            }
2482                          if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)          int max = mod.getChildCount(curr);
2483                                                                                                                  .getPath())))          if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)
2484                                  for (int i = 0; i < max; ++i)                                           .getPath())))
2485                                  {            for (int i = 0; i < max; ++i)
2486                                          g.setColor(getHashColor());              {
2487                                          g.drawLine(indentation + halfWidth, descent + halfHeight,                g.setColor(getHashColor());
2488                                                          indentation + rightChildIndent,                g.drawLine(indentation + halfWidth, descent + halfHeight,
2489                                                          descent + halfHeight);                           indentation + rightChildIndent,
2490                                          descent = paintRecursive(g, indentation + rightChildIndent,                           descent + halfHeight);
2491                                                          descent, i, depth + 1, tree, mod,                descent = paintRecursive(g, indentation + rightChildIndent,
2492                                                          mod.getChild(curr, i));                                         descent, i, depth + 1, tree, mod,
2493                                  }                                         mod.getChild(curr, i));
2494                  }              }
2495          }
2496    
2497                  int y1 = descent - halfHeight;      int y1 = descent - halfHeight;
2498                                    
2499                  if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)      if (tree.isExpanded(new TreePath(((DefaultMutableTreeNode) curr)
2500                                                                                                                                  .getPath())))                                       .getPath())))
2501                          if (y0 != y1)        if (y0 != y1)
2502                          {          {
2503                                  g.setColor(getHashColor());            g.setColor(getHashColor());
2504                                  g.drawLine(indentation + halfWidth, y0, indentation            g.drawLine(indentation + halfWidth, y0, indentation
2505                                                                  + halfWidth, y1);                       + halfWidth, y1);
2506                          }          }
2507                  return descent;      return descent;
2508          }    }
2509    
2510  } // BasicTreeUI  } // BasicTreeUI

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26