/[classpath]/classpath/javax/swing/JTree.java
ViewVC logotype

Diff of /classpath/javax/swing/JTree.java

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

revision 1.38 by rabbit78, Tue Sep 13 09:17:20 2005 UTC revision 1.39 by langel, Tue Sep 13 20:46:02 2005 UTC
# Line 37  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package javax.swing;  package javax.swing;
39    
40    import java.awt.Color;
41    import java.awt.Cursor;
42  import java.awt.Dimension;  import java.awt.Dimension;
43    import java.awt.Font;
44    import java.awt.FontMetrics;
45    import java.awt.Point;
46  import java.awt.Rectangle;  import java.awt.Rectangle;
47    import java.awt.event.FocusListener;
48    import java.beans.PropertyChangeListener;
49  import java.io.Serializable;  import java.io.Serializable;
50  import java.util.Enumeration;  import java.util.Enumeration;
51  import java.util.Hashtable;  import java.util.Hashtable;
52  import java.util.Iterator;  import java.util.Iterator;
53    import java.util.Locale;
54  import java.util.Vector;  import java.util.Vector;
55    
56  import javax.accessibility.Accessible;  import javax.accessibility.Accessible;
57    import javax.accessibility.AccessibleAction;
58    import javax.accessibility.AccessibleComponent;
59  import javax.accessibility.AccessibleContext;  import javax.accessibility.AccessibleContext;
60    import javax.accessibility.AccessibleRole;
61    import javax.accessibility.AccessibleSelection;
62    import javax.accessibility.AccessibleStateSet;
63    import javax.accessibility.AccessibleText;
64    import javax.accessibility.AccessibleValue;
65  import javax.swing.event.TreeExpansionEvent;  import javax.swing.event.TreeExpansionEvent;
66  import javax.swing.event.TreeExpansionListener;  import javax.swing.event.TreeExpansionListener;
67  import javax.swing.event.TreeModelEvent;  import javax.swing.event.TreeModelEvent;
# Line 73  public class JTree Line 88  public class JTree
88                          implements Scrollable, Accessible                          implements Scrollable, Accessible
89  {  {
90    
91      /**
92       * This class implements accessibility support for the JTree class. It
93       * provides an implementation of the Java Accessibility API appropriate
94       * to tree user-interface elements.
95       */
96      protected class AccessibleJTree extends JComponent.AccessibleJComponent
97          implements AccessibleSelection, TreeSelectionListener, TreeModelListener,
98          TreeExpansionListener
99      {
100        
101        /**
102         * This class implements accessibility support for the JTree child. It provides
103         * an implementation of the Java Accessibility API appropriate to tree nodes.
104         */
105        protected class AccessibleJTreeNode extends AccessibleContext
106           implements Accessible, AccessibleComponent, AccessibleSelection,
107           AccessibleAction
108        {
109          
110          private JTree tree;
111          private TreePath tp;
112          private Accessible acc;
113          
114          /**
115           * Constructs an AccessibleJTreeNode
116           */
117          public AccessibleJTreeNode(JTree t, TreePath p, Accessible ap)
118          {
119            tree = t;
120            tp = p;
121            acc = ap;
122          }      
123          
124          /**
125           * Adds the specified selected item in the object to the object's
126           * selection.
127           */
128          public void addAccessibleSelection(int i)
129          {
130          }
131          
132          /**
133           * Adds the specified focus listener to receive focus events
134           * from this component.
135           */
136          public void addFocusListener(FocusListener l)
137          {
138            AccessibleJTree.this.addFocusListener(l);
139          }
140          
141          /**
142           * Add a PropertyChangeListener to the listener list.
143           */
144          public void addPropertyChangeListener(PropertyChangeListener l)
145          {
146            AccessibleJTree.this.addPropertyChangeListener(l);
147          }
148          
149          /**
150           * Clears the selection in the object, so that nothing in the
151           * object is selected.
152           */
153          public void clearAccessibleSelection()
154          {
155          }
156          
157          /**
158           * Checks whether the specified point is within this object's
159           * bounds, where the point's x and y coordinates are defined to be
160           * relative to the coordinate system of the object.
161           */
162          public boolean contains(Point p)
163          {
164            return false;
165          }
166          
167          /**
168           * Perform the specified Action on the tree node.
169           */
170          public boolean doAccessibleAction(int i)
171          {
172            return false;
173          }
174          
175          /**
176           * Get the AccessibleAction associated with this object.
177           */
178          public AccessibleAction getAccessibleAction()
179          {
180            return super.getAccessibleAction();
181          }
182          
183          /**
184           * Returns the number of accessible actions available in this tree node.
185           */
186          public int getAccessibleActionCount()
187          {
188            return 0;
189          }
190          
191          /**
192           * Return a description of the specified action of the tree node.
193           */
194          public String getAccessibleActionDescription(int i)
195          {
196            return null;
197          }
198          
199          /**
200           * Returns the Accessible child, if one exists, contained at the
201           * local coordinate Point.
202           */
203          public Accessible getAccessibleAt(Point p)
204          {
205            return null;
206          }
207          
208          /**
209           * Return the specified Accessible child of the object.
210           */
211          public Accessible getAccessibleChild(int i)
212          {
213            return AccessibleJTree.this.getAccessibleChild(i);
214          }
215          
216          /**
217           * Returns the number of accessible children in the object.
218           */
219          public int getAccessibleChildrenCount()
220          {
221            return AccessibleJTree.this.getAccessibleChildrenCount();
222          }
223          
224          /**
225           * Get the AccessibleComponent associated with this object.
226           */
227          public AccessibleComponent getAccessibleComponent()
228          {
229            return super.getAccessibleComponent();
230          }
231          
232          /**
233           * Get the AccessibleContext associated with this tree node.
234           */
235          public AccessibleContext getAccessibleContext()
236          {
237            return acc.getAccessibleContext();
238          }
239          
240          /**
241           * Get the accessible description of this object.
242           */
243          public String getAccessibleDescription()
244          {
245            return AccessibleJTree.this.getAccessibleDescription();
246          }
247          
248          /**
249           * Get the index of this object in its accessible parent.
250           */
251          public int getAccessibleIndexInParent()
252          {
253            return 0;
254          }
255          
256          /**
257           * Get the accessible name of this object.
258           */
259          public String getAccessibleName()
260          {
261            return AccessibleJTree.this.getAccessibleName();
262          }
263          
264          /**
265           * Get the Accessible parent of this object.
266           */
267          public Accessible getAccessibleParent()
268          {
269            return super.getAccessibleParent();
270          }
271          
272          /**
273           * Get the role of this object.
274           */
275          public AccessibleRole getAccessibleRole()
276          {
277            return AccessibleJTree.this.getAccessibleRole();
278          }
279          
280          /**
281           * Get the AccessibleSelection associated with this object if one exists.
282           */
283          public AccessibleSelection getAccessibleSelection()
284          {
285            return super.getAccessibleSelection();
286          }
287          
288          /**
289           * Returns an Accessible representing the specified selected item
290           * in the object.
291           */
292          public Accessible getAccessibleSelection(int i)
293          {
294            return null;
295          }
296          
297          /**
298           * Returns the number of items currently selected.
299           */
300          public int getAccessibleSelectionCount()
301          {
302            return 0;
303          }
304          
305          /**
306           * Get the state set of this object.
307           */
308          public AccessibleStateSet getAccessibleStateSet()
309          {
310            return AccessibleJTree.this.getAccessibleStateSet();
311          }
312          
313          /**
314           * Get the AccessibleText associated with this object if one exists.
315           */
316          public AccessibleText getAccessibleText()
317          {
318            return super.getAccessibleText();
319          }
320          
321          /**
322           * Get the AccessibleValue associated with this object if one exists.
323           */
324          public AccessibleValue getAccessibleValue()
325          {
326            return super.getAccessibleValue();
327          }
328          
329          /**
330           * Get the background color of this object.
331           */
332          public Color getBackground()
333          {
334            return null;
335          }
336          
337          /**
338           * Gets the bounds of this object in the form of a Rectangle object.
339           */
340          public Rectangle getBounds()
341          {
342            return null;
343          }
344          
345          /**
346           * Gets the Cursor of this object.
347           */
348          public Cursor getCursor()
349          {
350            return null;
351          }
352          
353          /**
354           * Gets the Font of this object.
355           */
356          public Font getFont()
357          {
358            return null;
359          }
360          
361          /**
362           * Gets the FontMetrics of this object.
363           */
364          public FontMetrics getFontMetrics(Font f)
365          {
366            return null;
367          }
368          
369          /**
370           * Get the foreground color of this object.
371           */
372          public Color getForeground()
373          {
374            return null;
375          }
376          
377          /**
378           * Gets the locale of the component.
379           */
380          public Locale getLocale()
381          {
382            return null;
383          }
384          
385          /**
386           * Gets the location of the object relative to the
387           * parent in the form of a point specifying the object's
388           * top-left corner in the screen's coordinate space.
389           */
390          public Point getLocation()
391          {
392            return null;
393          }
394          
395          /**
396           * Returns the location in the tree.
397           */
398          protected  Point getLocationInJTree()
399          {
400            return null;
401          }
402          
403          /**
404           * Returns the location of the object on the screen.
405           */
406          public Point getLocationOnScreen()
407          {
408            return null;
409          }
410          
411          /**
412           * Returns the size of this object in the form of a Dimension object.
413           */
414          public Dimension getSize()
415          {
416            return null;
417          }
418          
419          /**
420           * Returns true if the current child of this object is selected.
421           */
422          public boolean isAccessibleChildSelected(int i)
423          {
424            return false;
425          }
426          
427          /**
428           * Determines if the object is enabled.
429           */
430          public boolean isEnabled()
431          {
432            return false;
433          }
434          
435          /**
436           * Returns whether this object can accept focus or not.
437           */
438          public boolean isFocusTraversable()
439          {
440            return false;
441          }
442          
443          /**
444           * Determines if the object is showing.
445           */
446          public boolean isShowing()
447          {
448            return false;
449          }
450          
451          /**
452           * Determines if the object is visible.
453           */
454          public boolean isVisible()
455          {
456            return false;
457          }
458          
459          /**
460           * Removes the specified selected item in the object from the
461           * object's selection.
462           */
463          public void removeAccessibleSelection(int i)
464          {
465          }
466          
467          /**
468           * Removes the specified focus listener so it no longer receives focus
469           * events from this component.
470           */
471          public void removeFocusListener(FocusListener l)
472          {
473            AccessibleJTree.this.removeFocusListener(l);
474          }
475          
476          /**
477           * Remove a PropertyChangeListener from the listener list.
478           */
479          public void removePropertyChangeListener(PropertyChangeListener l)
480          {
481            AccessibleJTree.this.removePropertyChangeListener(l);
482          }
483          
484          /**
485           * Requests focus for this object.
486           */
487          public void requestFocus()
488          {
489          }
490          
491          /**
492           * Causes every selected item in the object to be selected if the object
493           * supports multiple selections.
494           */
495          public void selectAllAccessibleSelection()
496          {
497          }
498          
499          /**
500           * Set the accessible description of this object.
501           */
502          public void setAccessibleDescription(String s)
503          {
504          }
505          
506          /**
507           * Set the localized accessible name of this object.
508           */
509          public void setAccessibleName(String s)
510          {
511          }
512          
513          /**
514           * Set the background color of this object.
515           */
516          public void setBackground(Color c)
517          {
518          }
519          
520          /**
521           * Sets the bounds of this object in the form of a Rectangle object.
522           */
523          public void setBounds(Rectangle r)
524          {
525          }
526          
527          /**
528           * Sets the Cursor of this object.
529           */
530          public void setCursor(Cursor c)
531          {
532          }
533          
534          /**
535           * Sets the enabled state of the object.
536           */
537          public void setEnabled(boolean b)
538          {
539          }
540          
541          /**
542           * Sets the Font of this object.
543           */
544          public void setFont(Font f)
545          {
546          }
547          
548          /**
549           * Sets the foreground color of this object.
550           */
551          public void setForeground(Color c)
552          {
553          }
554          
555          /**
556           * Sets the location of the object relative to the parent.
557           */
558          public void setLocation(Point p)
559          {
560          }
561          
562          /**
563           * Resizes this object so that it has width and height.
564           */
565          public void setSize(Dimension d)
566          {
567          }
568          
569          /**
570           * Sets the visible state of the object.
571           */
572          public void setVisible(boolean b)
573          {
574          }
575        }
576        
577        public AccessibleJTree()
578        {
579        }
580        
581        /**
582         * Adds the specified selected item in the object to the object's selection.
583         */
584        public void addAccessibleSelection(int i)
585        {
586        }
587        
588        /**
589         * Clears the selection in the object, so that nothing in the object is selected.
590         */
591        public void clearAccessibleSelection()
592        {
593        }
594        
595        /**
596         * Fire a visible data property change notification.
597         */
598        public void fireVisibleDataPropertyChange()
599        {
600        }
601        
602        /**
603         * Returns the Accessible child, if one exists, contained at the local
604         * coordinate Point.
605         */
606        public Accessible getAccessibleAt(Point p)
607        {
608          return null;
609        }
610        
611        /**
612         * Return the nth Accessible child of the object.
613         */
614        public Accessible getAccessibleChild(int i)
615        {
616          return super.getAccessibleChild(i);
617        }
618        
619        /**
620         * Returns the number of top-level children nodes of this JTree.
621         */
622        public int getAccessibleChildrenCount()
623        {
624          return super.getAccessibleChildrenCount();
625        }
626        
627        /**
628         * Get the index of this object in its accessible parent.
629         */
630        public int getAccessibleIndexInParent()
631        {
632          return 0;
633        }
634        
635        /**
636         * Get the role of this object.
637         */
638        public AccessibleRole getAccessibleRole()
639        {
640          return AccessibleRole.TREE;
641        }
642        
643        /**
644         * Get the AccessibleSelection associated with this object.
645         */
646        public AccessibleSelection getAccessibleSelection()
647        {
648          return null;
649        }
650        
651        /**
652         * Returns an Accessible representing the specified selected item in the object.
653         */
654        public Accessible getAccessibleSelection(int i)
655        {
656          return null;
657        }
658        
659        /**
660         * Returns the number of items currently selected.
661         */
662        public int getAccessibleSelectionCount()
663        {
664          return 0;
665        }
666        
667        /**
668         * Returns true if the current child of this object is selected.
669         */
670        public boolean isAccessibleChildSelected(int i)
671        {
672          return false;
673        }
674        
675        /**
676         * Removes the specified selected item in the object from the object's
677         * selection.
678         */
679        public void removeAccessibleSelection(int i)
680        {
681        }
682        
683        /**
684         * Causes every selected item in the object to be selected if the object
685         * supports multiple selections.
686         */
687        public void selectAllAccessibleSelection()
688        {
689        }
690        
691        /**
692         * Tree Collapsed notification
693         */
694        public void treeCollapsed(TreeExpansionEvent e)
695        {
696        }
697      
698        /**
699         * Tree Model Expansion notification.
700         */
701        public void treeExpanded(TreeExpansionEvent e)
702        {
703        }
704        
705        /**
706         * Tree Model Node change notification.
707         */
708        public void treeNodesChanged(TreeModelEvent e)
709        {
710        }
711        
712        /**
713         * Tree Model Node change notification.
714         */
715        public void treeNodesInserted(TreeModelEvent e)
716        {
717        }
718        
719        /**
720         * Tree Model Node change notification.
721         */
722        public void treeNodesRemoved(TreeModelEvent e)
723        {
724        }
725        
726        /**
727         * Tree Model structure change change notification.
728         */
729        public void treeStructureChanged(TreeModelEvent e)
730        {
731        }
732        
733        /**
734         * Tree Selection Listener value change method.
735         */
736        public void valueChanged(TreeSelectionEvent e)
737        {
738        }
739      }
740      
741    public static class DynamicUtilTreeNode extends DefaultMutableTreeNode    public static class DynamicUtilTreeNode extends DefaultMutableTreeNode
742    {    {
743      protected Object childValue;      protected Object childValue;
# Line 1845  public class JTree Line 2510  public class JTree
2510        }        }
2511      return removedSomething;      return removedSomething;
2512    }    }
2513      
2514      /**
2515       * Removes any descendants of the TreePaths in toRemove that have been
2516       * expanded.
2517       *
2518       * @param toRemove - Enumeration of TreePaths that need to be removed from
2519       * cache of toggled tree paths.
2520       */
2521      protected void removeDescendantToggledPaths(Enumeration toRemove)
2522      {
2523        while (toRemove.hasMoreElements())
2524          {
2525            TreePath current = (TreePath) toRemove.nextElement();
2526            Enumeration descendants = getDescendantToggledPaths(current);
2527            
2528            while (descendants.hasMoreElements())
2529              {
2530                TreePath currentDes = (TreePath) descendants.nextElement();
2531                if (isExpanded(currentDes))
2532                    nodeStates.remove(currentDes);
2533              }
2534          }
2535      }
2536      
2537      /**
2538       * Sent when the tree has changed enough that we need to resize the bounds,
2539       * but not enough that we need to remove the expanded node set (e.g nodes
2540       * were expanded or collapsed, or nodes were inserted into the tree). You
2541       * should never have to invoke this, the UI will invoke this as it needs to.
2542       */
2543      public void treeDidChange()
2544      {
2545        repaint();
2546      }
2547  }  }

Legend:
Removed from v.1.38  
changed lines
  Added in v.1.39

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