KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > swing > tabcontrol > TabDisplayer


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.swing.tabcontrol;
21
22 import javax.accessibility.Accessible JavaDoc;
23 import javax.accessibility.AccessibleRole JavaDoc;
24 import javax.swing.event.ChangeEvent JavaDoc;
25 import org.netbeans.swing.tabcontrol.event.TabActionEvent;
26 import org.netbeans.swing.tabcontrol.plaf.AquaEditorTabDisplayerUI;
27 import org.netbeans.swing.tabcontrol.plaf.AquaViewTabDisplayerUI;
28 import org.netbeans.swing.tabcontrol.plaf.BasicSlidingTabDisplayerUI;
29 import org.netbeans.swing.tabcontrol.plaf.WinClassicEditorTabDisplayerUI;
30 import org.netbeans.swing.tabcontrol.plaf.WinClassicViewTabDisplayerUI;
31
32 import javax.swing.*;
33 import javax.swing.plaf.ComponentUI JavaDoc;
34 import java.awt.*;
35 import java.awt.event.ActionListener JavaDoc;
36 import java.awt.event.MouseEvent JavaDoc;
37 import java.util.ArrayList JavaDoc;
38 import java.util.Collections JavaDoc;
39 import java.util.List JavaDoc;
40 import javax.accessibility.AccessibleContext JavaDoc;
41 import javax.accessibility.AccessibleSelection JavaDoc;
42 import javax.swing.event.ChangeListener JavaDoc;
43 import org.netbeans.swing.tabcontrol.plaf.ToolbarTabDisplayerUI;
44 import org.netbeans.swing.tabcontrol.plaf.WinXPEditorTabDisplayerUI;
45 import org.netbeans.swing.tabcontrol.plaf.WinXPViewTabDisplayerUI;
46
47
48 /**
49  * A Component which displays tabs supplied by a TabDataModel. This is
50  * essentially the upper (or lower) portion of a tabbed pane, without the
51  * part that displays components. It can be used to provide tab-like
52  * selection over a data model containing anything, not just components.
53  * <p>
54  * It has a three display modes (more fully described in the overview for
55  * <a HREF="TabbedContainer.html">TabbedContainer</a>), to provide different
56  * styles of tab display, such as scrolling tabs and others.
57  * <p>
58  * TabDisplayer is completely model driven - the class itself is little more
59  * than an aggregation point for a data model, a selection model, and so forth.
60  * The logic that allows it to operate is implemented in the UI delegates,
61  * which are installed by (and can be replaced via) the standard Swing
62  * UIManager mechanisms.
63  * <p>
64  * Some TabDisplayer UI's support an <i>orientation</i> property, which is provided
65  * via the client property <code>PROP_ORIENTATION</code>.
66  *
67  * @author Tim Boudreau
68  */

69 public final class TabDisplayer extends JComponent implements Accessible JavaDoc {
70     
71     private boolean initialized = false;
72     private TabDataModel model;
73     private SingleSelectionModel sel = null;
74     private boolean active;
75     private final int type;
76
77     /**
78      * Displayer type for view tabs, which do not scroll and simply divide the
79      * available space between themselves. The value of this field is mapped to
80      * TabbedContainer.TYPE_VIEW
81      */

82     public static final int TYPE_VIEW = TabbedContainer.TYPE_VIEW;
83     /**
84      * Displayer type for editor tabs, which scroll (typically - depends on what
85      * the UI does). The value of this field is mapped to
86      * TabbedContainer.TYPE_EDITOR
87      */

88     public static final int TYPE_EDITOR = TabbedContainer.TYPE_EDITOR;
89     
90     public static final int TYPE_SLIDING = TabbedContainer.TYPE_SLIDING;
91     
92     public static final int TYPE_TOOLBAR = TabbedContainer.TYPE_TOOLBAR;
93     
94     /**
95      * Property indicating the tab displayer should be painted as
96      * &quot;active&quot;. This is typically used to indicate keyboard focus.
97      * The valud of this field is mapped to TabbedContainer.PROP_ACTIVE
98      */

99     public static final String JavaDoc PROP_ACTIVE = TabbedContainer.PROP_ACTIVE;
100
101
102     /**
103      * Action command indicating that the action event signifies the user
104      * clicking the Close button on a tab.
105      */

106     public static final String JavaDoc COMMAND_CLOSE = TabbedContainer.COMMAND_CLOSE;
107
108     /**
109      * Action command indicating that the action event fired signifies the user
110      * selecting a tab
111      */

112     public static final String JavaDoc COMMAND_SELECT = TabbedContainer.COMMAND_SELECT;
113
114     /**
115      * Action command indicating that the action event fired signifies the user
116      * requesting a popup menu over a tab
117      */

118     public static final String JavaDoc COMMAND_POPUP_REQUEST = TabbedContainer.COMMAND_POPUP_REQUEST;
119
120     /**
121      * Action command indicating that the action event fired signifies the user
122      * has double clicked a tab
123      */

124     public static final String JavaDoc COMMAND_MAXIMIZE = TabbedContainer.COMMAND_MAXIMIZE;
125
126     /**
127      * Action command indicating that the action event fired signifies the user
128      * has shift-clicked the close button on a tab
129      */

130     public static final String JavaDoc COMMAND_CLOSE_ALL = TabbedContainer.COMMAND_CLOSE_ALL; //NOI18N
131

132     /**
133      * Action command indicating that the action event fired signifies the user
134      * has alt-clicked the close button on a tab
135      */

136     public static final String JavaDoc COMMAND_CLOSE_ALL_BUT_THIS = TabbedContainer.COMMAND_CLOSE_ALL_BUT_THIS; //NOI18N
137

138     /**
139      * Action command indicating that the action event signifies the user
140      * clicking the Pin button on a tab.
141      */

142     public static final String JavaDoc COMMAND_ENABLE_AUTO_HIDE = TabbedContainer.COMMAND_ENABLE_AUTO_HIDE; //NOI18N
143

144     /**
145      * Action command indicating that the action event signifies the user
146      * clicking the Pin button on a tab.
147      */

148     public static final String JavaDoc COMMAND_DISABLE_AUTO_HIDE = TabbedContainer.COMMAND_DISABLE_AUTO_HIDE; //NOI18N
149

150     /**
151      * UIManager key for the UI Delegate to be used for &quot;editor&quot; style TabbedContainers
152      */

153     public static final String JavaDoc EDITOR_TAB_DISPLAYER_UI_CLASS_ID = "EditorTabDisplayerUI"; //NOI18N
154

155     /**
156      * UIManager key for the UI Delegate to be used for &quot;view&quot; style TabbedContainers
157      */

158     public static final String JavaDoc VIEW_TAB_DISPLAYER_UI_CLASS_ID = "ViewTabDisplayerUI"; //NOI18N
159

160     /**
161      * UIManager key for the UI delegate to be used in &quot;sliding&quot; style
162      * containers */

163     public static final String JavaDoc SLIDING_TAB_DISPLAYER_UI_CLASS_ID = "SlidingTabDisplayerUI"; //NOI18N
164

165     /**
166      * UIManager key for the UI delegate to be used for toolbar style tabs
167      */

168     public static final String JavaDoc TOOLBAR_TAB_DISPLAYER_UI_CLASS_ID = "ToolbarTabDisplayerUI"; //NOI18N
169

170     /** Client property to indicate the orientation, which determines what
171      * side the tabs are displayed on. Currently this is only honored by
172      * the sliding tabs ui delegate. */

173     public static final String JavaDoc PROP_ORIENTATION = "orientation"; //NOI18N
174

175     /** Client property value to display tabs on the left side of the control.
176      */

177     public static final Object JavaDoc ORIENTATION_EAST = "east"; //NOI18N
178
/** Client property value to display tabs on the right side of the control
179      */

180     public static final Object JavaDoc ORIENTATION_WEST = "west"; //NOI18N
181
/** Client property value to display tabs on the top edge of the control
182      */

183     public static final Object JavaDoc ORIENTATION_NORTH = "north"; //NOI18N
184
/** Client property value to display tabs on the bottom edge of the control
185      */

186     public static final Object JavaDoc ORIENTATION_SOUTH = "south"; //NOI18N
187
/** Client property value for pin button to have neutral orientation
188      */

189     public static final Object JavaDoc ORIENTATION_CENTER = "center"; //NOI18N
190

191     /** Client property value for pin button to be invisible
192      */

193     public static final Object JavaDoc ORIENTATION_INVISIBLE = "invisible"; //NOI18N
194

195     
196     /**
197      * Utility field holding list of ActionListeners.
198      */

199     private transient List JavaDoc<ActionListener JavaDoc> actionListenerList;
200     
201     private WinsysInfoForTabbed winsysInfo = null;
202     
203     @Deprecated JavaDoc
204     private LocationInformer locationInformer = null;
205
206     private boolean showClose = !Boolean.getBoolean(
207         "nb.tabs.suppressCloseButton"); //NOI18N
208

209     public TabDisplayer () {
210         this (new DefaultTabDataModel(), TYPE_VIEW);
211     }
212     
213     /**
214      * Creates a new instance of TabDisplayer
215      */

216     public TabDisplayer(TabDataModel model, int type) {
217         this (model, type, (WinsysInfoForTabbed)null);
218     }
219     
220     /**
221      * Depreacated, please use constructor with WinsysInfoForTabbed param.
222      */

223     @Deprecated JavaDoc
224     public TabDisplayer(TabDataModel model, int type, LocationInformer locationInformer) {
225         this (model, type, (WinsysInfoForTabbed)null);
226         this.locationInformer = locationInformer;
227     }
228         
229     /**
230      * Creates a new instance of TabDisplayer
231      */

232     public TabDisplayer(TabDataModel model, int type, WinsysInfoForTabbed winsysInfo) {
233         switch (type) {
234             case TYPE_VIEW:
235             case TYPE_EDITOR:
236             case TYPE_SLIDING:
237             case TYPE_TOOLBAR:
238                 break;
239             default :
240                 throw new IllegalArgumentException JavaDoc("Unknown UI type: " + type); //NOI18N
241
}
242         this.model = model;
243         this.type = type;
244         this.winsysInfo = winsysInfo;
245         putClientProperty (PROP_ORIENTATION, ORIENTATION_NORTH);
246         initialized = true;
247         updateUI();
248         setFocusable(false);
249 // Color fillC = (Color)UIManager.get("nb_workplace_fill"); //NOI18N
250
// if (fillC != null) setBackground (fillC);
251
}
252
253     public final TabDisplayerUI getUI() {
254         return (TabDisplayerUI) ui;
255     }
256
257     /** Overridden to block the call from the superclass constructor, which
258      * comes before the <code>type</code> property is initialized. Provides
259      * a reasonable fallback UI for use on unknown look and feels.
260      */

261     public final void updateUI() {
262         if (!initialized) {
263             return;
264         }
265         
266         if (type == TYPE_TOOLBAR) {
267             setUI (new ToolbarTabDisplayerUI(this));
268             return;
269         } else if (type == TYPE_SLIDING) {
270             setUI (new BasicSlidingTabDisplayerUI(this));
271             return;
272         }
273         
274         ComponentUI JavaDoc ui = null;
275         if (UIManager.get(getUIClassID()) != null) { //Avoid Error stack trace
276
try {
277                 ui = UIManager.getUI(this);
278             } catch (Error JavaDoc error) {
279                 System.err.println("Could not load a UI for " + getUIClassID() +
280                     " - missing class?");
281             }
282         } else {
283             ui = findUIStandalone();
284         }
285         
286         if (ui == null) {
287             ui = getType() == TYPE_VIEW ?
288                     WinClassicViewTabDisplayerUI.createUI(this) :
289                     WinClassicEditorTabDisplayerUI.createUI(this);
290         }
291         setUI((TabDisplayerUI) ui);
292         
293     }
294     
295     /**
296      * Allows the tabcontrol to find the correct UI if the plaf library is
297      * not present (no UI class defined in UIManager).
298      */

299     private ComponentUI JavaDoc findUIStandalone() {
300         ComponentUI JavaDoc result = null;
301         String JavaDoc lf = UIManager.getLookAndFeel().getID();
302         switch (type) {
303             case TYPE_VIEW :
304                 if ("Aqua".equals(lf)) { //NOI18N
305
result = AquaViewTabDisplayerUI.createUI(this);
306                 } else if ("Windows".equals(lf)) { //NOI18N
307
result = isXPLF() ?
308                         WinXPViewTabDisplayerUI.createUI(this) :
309                         WinClassicViewTabDisplayerUI.createUI(this);
310                 }
311                 break;
312             case TYPE_EDITOR :
313                 if ("Aqua".equals(lf)) { //NOI18N
314
result = AquaEditorTabDisplayerUI.createUI(this);
315                 } else if ("Windows".equals(lf)) { //NOI18N
316
result = isXPLF() ?
317                         WinXPEditorTabDisplayerUI.createUI(this) :
318                         WinClassicEditorTabDisplayerUI.createUI(this);
319                 }
320                 break;
321         }
322         return result;
323     }
324     
325     /** Finds if windows LF with XP theme is active.
326      * @return true if windows LF and XP theme is active, false otherwise */

327     private static boolean isXPLF () {
328         Boolean JavaDoc isXP = (Boolean JavaDoc)Toolkit.getDefaultToolkit().
329                         getDesktopProperty("win.xpstyle.themeActive"); //NOI18N
330
return isXP == null ? false : isXP.booleanValue();
331     }
332     
333
334     /** Returns an different UIClassID depending on the value of the <code>type</code>
335      * property. */

336     public String JavaDoc getUIClassID() {
337         switch (getType()) {
338             case TYPE_VIEW : return VIEW_TAB_DISPLAYER_UI_CLASS_ID;
339             case TYPE_EDITOR : return EDITOR_TAB_DISPLAYER_UI_CLASS_ID;
340             case TYPE_SLIDING : return SLIDING_TAB_DISPLAYER_UI_CLASS_ID;
341             case TYPE_TOOLBAR : return TOOLBAR_TAB_DISPLAYER_UI_CLASS_ID;
342             default :
343                 throw new IllegalArgumentException JavaDoc ("Unknown UI type: " +
344                     getType());
345         }
346     }
347
348     /**
349      * Returns whether this control uses the view tab look or the scrolling
350      * editor tab look. This is set in the constructor.
351      */

352     public final int getType() {
353         return type;
354     }
355
356     public final Dimension getPreferredSize() {
357         return getUI().getPreferredSize(this);
358     }
359
360     public final Dimension getMinimumSize() {
361         return getUI().getMinimumSize(this);
362     }
363     
364     /**
365      * Cause the specified tab to flash or otherwise call attention to itself
366      * without changing selection or focus. Supported by VIEW and EDITOR type
367      * UIs.
368      */

369     public final void requestAttention (int tab) {
370         getUI().requestAttention(tab);
371     }
372     
373     /**
374      * Cause a tab, if blinking, to stop.
375      */

376     public final void cancelRequestAttention (int tab) {
377         getUI().cancelRequestAttention (tab);
378     }
379     
380     public final boolean requestAttention (TabData data) {
381         int idx = getModel().indexOf(data);
382         boolean result = idx >= 0;
383         if (result) {
384             requestAttention (idx);
385         }
386         return result;
387     }
388
389     /**
390      * Accessor only for TabDisplayerUI when installing the UI
391      */

392     void setSelectionModel(SingleSelectionModel sel) {
393         this.sel = sel;
394     }
395
396     /** Get the selection model, which determines which tab is selected.
397      * To change the selection, get the selection model and call
398      * setSelectedIndex(). */

399     public SingleSelectionModel getSelectionModel() {
400         return sel;
401     }
402
403     /** Get the data model that defines the contents which are displayed */
404     public final TabDataModel getModel() {
405         return model;
406     }
407
408     /** Set the active state of the component */
409     public final void setActive(boolean active) {
410         if (active != this.active) {
411             this.active = active;
412             firePropertyChange(PROP_ACTIVE, !active, active); //NOI18N
413
}
414     }
415
416     /** Gets the &quot;active&quot; state of this component. If the component
417      * is active, most UIs will paint the selected tab differently to indicate
418      * that focus is somewhere in the container */

419     public final boolean isActive() {
420         return active;
421     }
422
423     /**
424      * Gets tooltip for the tab corresponding to the mouse event, or if no
425      * tab, delegates to the default implementation.
426      */

427     public final String JavaDoc getToolTipText(MouseEvent JavaDoc event) {
428         if (ui != null) {
429             Point p = event.getPoint();
430             if (event.getSource() != this) {
431                 Component c = (Component) event.getSource();
432                 p = SwingUtilities.convertPoint(c, p, this);
433             }
434             int index = getUI().tabForCoordinate(p);
435             if (index != -1) {
436                 return getModel().getTab(index).tip;
437             }
438         }
439         return super.getToolTipText(event);
440     }
441
442     /** Make a tab visible. In the case of scrolling UIs, a tab is not
443      * always visible. This call will make it scroll into view */

444     public final void makeTabVisible(int index) {
445         getUI().makeTabVisible(index);
446     }
447
448     /** Get the rectangle that a given tab occupies */
449     public final Rectangle getTabRect(int tab, Rectangle dest) {
450         if (dest == null) {
451             dest = new Rectangle();
452         }
453         getUI().getTabRect(tab, dest);
454         return dest;
455     }
456
457     @Deprecated JavaDoc
458     public final Image getDragImage(int index) {
459         return null;
460     }
461
462     /**
463      * Register an ActionListener. TabbedContainer and TabDisplayer guarantee
464      * that the type of event fired will always be TabActionEvent. There are
465      * two special things about TabActionEvent: <ol> <li>There are methods on
466      * TabActionEvent to find the index of the tab the event was performed on,
467      * and if present, retrieve the mouse event that triggered it, for clients
468      * that wish to provide different handling for different mouse buttons</li>
469      * <li>TabActionEvents can be consumed. If a listener consumes the event,
470      * the UI will take no action - the selection will not be changed, the tab
471      * will not be closed. Consuming the event means taking responsibility for
472      * doing whatever would normally happen automatically. This is useful for,
473      * for example, showing a dialog and possibly aborting closing a tab if it
474      * contains unsaved data, for instance.</li> </ol> Action events will be
475      * fired <strong>before</strong> any action has been taken to alter the
476      * state of the control to match the action, so that they may be vetoed or
477      * modified by consuming the event.
478      *
479      * @param listener The listener to register.
480      */

481     public final synchronized void addActionListener(ActionListener JavaDoc listener) {
482         if (actionListenerList == null) {
483             actionListenerList = new ArrayList JavaDoc<ActionListener JavaDoc>();
484         }
485         actionListenerList.add(listener);
486     }
487
488     /**
489      * Removes ActionListener from the list of listeners.
490      *
491      * @param listener The listener to remove.
492      */

493     public final synchronized void removeActionListener(ActionListener JavaDoc listener) {
494         if (actionListenerList != null) {
495             actionListenerList.remove(listener);
496         }
497     }
498
499     public void registerShortcuts(JComponent comp) {
500         getUI().registerShortcuts(comp);
501     }
502     
503     public void unregisterShortcuts(JComponent comp) {
504         getUI().unregisterShortcuts(comp);
505     }
506
507     /**
508      * Notifies all registered listeners about the event.
509      *
510      * @param event The event to be fired
511      */

512     protected final void postActionEvent(TabActionEvent event) {
513         List JavaDoc<ActionListener JavaDoc> list;
514         synchronized (this) {
515             if (actionListenerList == null) {
516                 return;
517             }
518             list = Collections.unmodifiableList(actionListenerList);
519         }
520         for (int i = 0; i < list.size(); i++) {
521             list.get(i).actionPerformed(event);
522         }
523     }
524
525     public int tabForCoordinate(Point p) {
526         return getUI().tabForCoordinate(p);
527     }
528     
529     public WinsysInfoForTabbed getWinsysInfo() {
530         return winsysInfo;
531     }
532     
533     @Deprecated JavaDoc
534     public LocationInformer getLocationInformer() {
535         return locationInformer;
536     }
537     
538     public AccessibleContext JavaDoc getAccessibleContext() {
539         if (accessibleContext == null) {
540             accessibleContext = new AccessibleTabDisplayer();
541         }
542         return accessibleContext;
543     }
544
545     /**
546      * Set whether or not the close button should be visible.
547      * This can be defaulted by setting the system property
548      * <code>nb.tabs.suppressCloseButton</code>. The default is
549      * true.
550      */

551     public final void setShowCloseButton (boolean val) {
552         boolean wasShow = isShowCloseButton();
553         if (wasShow != val) {
554             showClose = val;
555             if (isShowing()) {
556                 repaint();
557             }
558             firePropertyChange ("showCloseButton", !val, val);
559         }
560     }
561     
562     /** Find out if this displayer is set to show close buttons */
563     public final boolean isShowCloseButton () {
564         return showClose;
565     }
566     
567     
568     protected class AccessibleTabDisplayer extends AccessibleJComponent
569                                            implements AccessibleSelection JavaDoc, ChangeListener JavaDoc {
570                                                
571          /**
572          * Constructs an AccessibleTabDisplayer
573          */

574         public AccessibleTabDisplayer() {
575             super();
576             getModel().addChangeListener(this);
577         }
578
579         public void stateChanged(ChangeEvent JavaDoc e) {
580             Object JavaDoc o = e.getSource();
581             firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
582                                null, o);
583         }
584
585         
586         /**
587          * Get the role of this object.
588          *
589          * @return an instance of AccessibleRole describing the role of
590          * the object
591          */

592         public AccessibleRole JavaDoc getAccessibleRole() {
593             return AccessibleRole.PAGE_TAB_LIST;
594         }
595         
596         /**
597          * Returns the number of accessible children in the object.
598          *
599          * @return the number of accessible children in the object.
600          */

601         public int getAccessibleChildrenCount() {
602             return getModel().size();
603         }
604
605         /**
606          * Return the specified Accessible child of the object.
607          *
608          * @param i zero-based index of child
609          * @return the Accessible child of the object
610          * @exception IllegalArgumentException if index is out of bounds
611          */

612         public Accessible JavaDoc getAccessibleChild(int i) {
613             if (i < 0 || i >= getModel().size()) {
614                 return null;
615             }
616             TabData data = getModel().getTab(i);
617             if (data.getComponent() instanceof Accessible JavaDoc) {
618                 return (Accessible JavaDoc)data.getComponent();
619             }
620             return null;
621         }
622         
623         
624
625         /**
626          * Gets the <code>AccessibleSelection</code> associated with
627          * this object. In the implementation of the Java
628          * Accessibility API for this class,
629      * returns this object, which is responsible for implementing the
630          * <code>AccessibleSelection</code> interface on behalf of itself.
631      *
632      * @return this object
633          */

634         public AccessibleSelection JavaDoc getAccessibleSelection() {
635            return this;
636         }
637         
638         /**
639          * Returns the <code>Accessible</code> child contained at
640          * the local coordinate <code>Point</code>, if one exists.
641          * Otherwise returns the currently selected tab.
642          *
643          * @return the <code>Accessible</code> at the specified
644          * location, if it exists
645          */

646         public Accessible JavaDoc getAccessibleAt(Point p) {
647             int tab = tabForCoordinate(p);
648             if (tab == -1) {
649                 tab = getSelectionModel().getSelectedIndex();
650             }
651             return getAccessibleChild(tab);
652         }
653         
654         /**
655          * Returns the number of Accessible children currently selected.
656          * If no children are selected, the return value will be 0.
657          *
658          * @return the number of items currently selected.
659          */

660         public int getAccessibleSelectionCount() {
661             return 1;
662         }
663         
664         /**
665          * Returns an Accessible representing the specified selected child
666          * of the object. If there isn't a selection, or there are
667          * fewer children selected than the integer passed in, the return
668          * value will be null.
669          * <p>Note that the index represents the i-th selected child, which
670          * is different from the i-th child.
671          *
672          * @param i the zero-based index of selected children
673          * @return the i-th selected child
674          * @see #getAccessibleSelectionCount
675          */

676         public Accessible JavaDoc getAccessibleSelection(int i) {
677             // always just one selected.. -> ignore i
678
int index = getSelectionModel().getSelectedIndex();
679             return getAccessibleChild(index);
680         }
681         
682         /**
683          * Determines if the current child of this object is selected.
684          *
685          * @return true if the current child of this object is selected; else false.
686          * @param i the zero-based index of the child in this Accessible object.
687          * @see AccessibleContext#getAccessibleChild
688          */

689         public boolean isAccessibleChildSelected(int i) {
690             return i == getSelectionModel().getSelectedIndex();
691         }
692         
693         /**
694          * Adds the specified Accessible child of the object to the object's
695          * selection. If the object supports multiple selections,
696          * the specified child is added to any existing selection, otherwise
697          * it replaces any existing selection in the object. If the
698          * specified child is already selected, this method has no effect.
699          *
700          * @param i the zero-based index of the child
701          * @see AccessibleContext#getAccessibleChild
702          */

703         public void addAccessibleSelection(int i) {
704             //TODO?
705
}
706         
707         /**
708          * Removes the specified child of the object from the object's
709          * selection. If the specified item isn't currently selected, this
710          * method has no effect.
711          *
712          * @param i the zero-based index of the child
713          * @see AccessibleContext#getAccessibleChild
714          */

715         public void removeAccessibleSelection(int i) {
716             //TODO?
717
}
718         
719         /**
720          * Clears the selection in the object, so that no children in the
721          * object are selected.
722          */

723         public void clearAccessibleSelection() {
724             //TODO?
725
}
726         
727         /**
728          * Causes every child of the object to be selected
729          * if the object supports multiple selections.
730          */

731         public void selectAllAccessibleSelection() {
732             //TODO?
733
}
734     }
735     
736 }
737
Popular Tags