001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.swing.tabcontrol;
043:
044: import javax.accessibility.Accessible;
045: import javax.accessibility.AccessibleRole;
046: import javax.swing.event.ChangeEvent;
047: import org.netbeans.swing.tabcontrol.event.TabActionEvent;
048: import org.netbeans.swing.tabcontrol.plaf.AquaEditorTabDisplayerUI;
049: import org.netbeans.swing.tabcontrol.plaf.AquaViewTabDisplayerUI;
050: import org.netbeans.swing.tabcontrol.plaf.BasicSlidingTabDisplayerUI;
051: import org.netbeans.swing.tabcontrol.plaf.WinClassicEditorTabDisplayerUI;
052: import org.netbeans.swing.tabcontrol.plaf.WinClassicViewTabDisplayerUI;
053:
054: import javax.swing.*;
055: import javax.swing.plaf.ComponentUI;
056: import java.awt.*;
057: import java.awt.event.ActionListener;
058: import java.awt.event.MouseEvent;
059: import java.util.ArrayList;
060: import java.util.Collections;
061: import java.util.List;
062: import javax.accessibility.AccessibleContext;
063: import javax.accessibility.AccessibleSelection;
064: import javax.swing.event.ChangeListener;
065: import org.netbeans.swing.tabcontrol.plaf.ToolbarTabDisplayerUI;
066: import org.netbeans.swing.tabcontrol.plaf.WinXPEditorTabDisplayerUI;
067: import org.netbeans.swing.tabcontrol.plaf.WinXPViewTabDisplayerUI;
068:
069: /**
070: * A Component which displays tabs supplied by a TabDataModel. This is
071: * essentially the upper (or lower) portion of a tabbed pane, without the
072: * part that displays components. It can be used to provide tab-like
073: * selection over a data model containing anything, not just components.
074: * <p>
075: * It has a three display modes (more fully described in the overview for
076: * <a href="TabbedContainer.html">TabbedContainer</a>), to provide different
077: * styles of tab display, such as scrolling tabs and others.
078: * <p>
079: * TabDisplayer is completely model driven - the class itself is little more
080: * than an aggregation point for a data model, a selection model, and so forth.
081: * The logic that allows it to operate is implemented in the UI delegates,
082: * which are installed by (and can be replaced via) the standard Swing
083: * UIManager mechanisms.
084: * <p>
085: * Some TabDisplayer UI's support an <i>orientation</i> property, which is provided
086: * via the client property <code>PROP_ORIENTATION</code>.
087: *
088: * @author Tim Boudreau
089: */
090: public final class TabDisplayer extends JComponent implements
091: Accessible {
092:
093: private boolean initialized = false;
094: private TabDataModel model;
095: private SingleSelectionModel sel = null;
096: private boolean active;
097: private final int type;
098:
099: /**
100: * Displayer type for view tabs, which do not scroll and simply divide the
101: * available space between themselves. The value of this field is mapped to
102: * TabbedContainer.TYPE_VIEW
103: */
104: public static final int TYPE_VIEW = TabbedContainer.TYPE_VIEW;
105: /**
106: * Displayer type for editor tabs, which scroll (typically - depends on what
107: * the UI does). The value of this field is mapped to
108: * TabbedContainer.TYPE_EDITOR
109: */
110: public static final int TYPE_EDITOR = TabbedContainer.TYPE_EDITOR;
111:
112: public static final int TYPE_SLIDING = TabbedContainer.TYPE_SLIDING;
113:
114: public static final int TYPE_TOOLBAR = TabbedContainer.TYPE_TOOLBAR;
115:
116: /**
117: * Property indicating the tab displayer should be painted as
118: * "active". This is typically used to indicate keyboard focus.
119: * The valud of this field is mapped to TabbedContainer.PROP_ACTIVE
120: */
121: public static final String PROP_ACTIVE = TabbedContainer.PROP_ACTIVE;
122:
123: /**
124: * Action command indicating that the action event signifies the user
125: * clicking the Close button on a tab.
126: */
127: public static final String COMMAND_CLOSE = TabbedContainer.COMMAND_CLOSE;
128:
129: /**
130: * Action command indicating that the action event fired signifies the user
131: * selecting a tab
132: */
133: public static final String COMMAND_SELECT = TabbedContainer.COMMAND_SELECT;
134:
135: /**
136: * Action command indicating that the action event fired signifies the user
137: * requesting a popup menu over a tab
138: */
139: public static final String COMMAND_POPUP_REQUEST = TabbedContainer.COMMAND_POPUP_REQUEST;
140:
141: /**
142: * Action command indicating that the action event fired signifies the user
143: * has double clicked a tab
144: */
145: public static final String COMMAND_MAXIMIZE = TabbedContainer.COMMAND_MAXIMIZE;
146:
147: /**
148: * Action command indicating that the action event fired signifies the user
149: * has shift-clicked the close button on a tab
150: */
151: public static final String COMMAND_CLOSE_ALL = TabbedContainer.COMMAND_CLOSE_ALL; //NOI18N
152:
153: /**
154: * Action command indicating that the action event fired signifies the user
155: * has alt-clicked the close button on a tab
156: */
157: public static final String COMMAND_CLOSE_ALL_BUT_THIS = TabbedContainer.COMMAND_CLOSE_ALL_BUT_THIS; //NOI18N
158:
159: /**
160: * Action command indicating that the action event signifies the user
161: * clicking the Pin button on a tab.
162: */
163: public static final String COMMAND_ENABLE_AUTO_HIDE = TabbedContainer.COMMAND_ENABLE_AUTO_HIDE; //NOI18N
164:
165: /**
166: * Action command indicating that the action event signifies the user
167: * clicking the Pin button on a tab.
168: */
169: public static final String COMMAND_DISABLE_AUTO_HIDE = TabbedContainer.COMMAND_DISABLE_AUTO_HIDE; //NOI18N
170:
171: /**
172: * UIManager key for the UI Delegate to be used for "editor" style TabbedContainers
173: */
174: public static final String EDITOR_TAB_DISPLAYER_UI_CLASS_ID = "EditorTabDisplayerUI"; //NOI18N
175:
176: /**
177: * UIManager key for the UI Delegate to be used for "view" style TabbedContainers
178: */
179: public static final String VIEW_TAB_DISPLAYER_UI_CLASS_ID = "ViewTabDisplayerUI"; //NOI18N
180:
181: /**
182: * UIManager key for the UI delegate to be used in "sliding" style
183: * containers */
184: public static final String SLIDING_TAB_DISPLAYER_UI_CLASS_ID = "SlidingTabDisplayerUI"; //NOI18N
185:
186: /**
187: * UIManager key for the UI delegate to be used for toolbar style tabs
188: */
189: public static final String TOOLBAR_TAB_DISPLAYER_UI_CLASS_ID = "ToolbarTabDisplayerUI"; //NOI18N
190:
191: /** Client property to indicate the orientation, which determines what
192: * side the tabs are displayed on. Currently this is only honored by
193: * the sliding tabs ui delegate. */
194: public static final String PROP_ORIENTATION = "orientation"; //NOI18N
195:
196: /** Client property value to display tabs on the left side of the control.
197: */
198: public static final Object ORIENTATION_EAST = "east"; //NOI18N
199: /** Client property value to display tabs on the right side of the control
200: */
201: public static final Object ORIENTATION_WEST = "west"; //NOI18N
202: /** Client property value to display tabs on the top edge of the control
203: */
204: public static final Object ORIENTATION_NORTH = "north"; //NOI18N
205: /** Client property value to display tabs on the bottom edge of the control
206: */
207: public static final Object ORIENTATION_SOUTH = "south"; //NOI18N
208: /** Client property value for pin button to have neutral orientation
209: */
210: public static final Object ORIENTATION_CENTER = "center"; //NOI18N
211:
212: /** Client property value for pin button to be invisible
213: */
214: public static final Object ORIENTATION_INVISIBLE = "invisible"; //NOI18N
215:
216: /**
217: * Utility field holding list of ActionListeners.
218: */
219: private transient List<ActionListener> actionListenerList;
220:
221: private WinsysInfoForTabbed winsysInfo = null;
222:
223: @Deprecated
224: private LocationInformer locationInformer = null;
225:
226: private boolean showClose = !Boolean
227: .getBoolean("nb.tabs.suppressCloseButton"); //NOI18N
228:
229: public TabDisplayer() {
230: this (new DefaultTabDataModel(), TYPE_VIEW);
231: }
232:
233: /**
234: * Creates a new instance of TabDisplayer
235: */
236: public TabDisplayer(TabDataModel model, int type) {
237: this (model, type, (WinsysInfoForTabbed) null);
238: }
239:
240: /**
241: * Depreacated, please use constructor with WinsysInfoForTabbed param.
242: */
243: @Deprecated
244: public TabDisplayer(TabDataModel model, int type,
245: LocationInformer locationInformer) {
246: this (model, type, (WinsysInfoForTabbed) null);
247: this .locationInformer = locationInformer;
248: }
249:
250: /**
251: * Creates a new instance of TabDisplayer
252: */
253: public TabDisplayer(TabDataModel model, int type,
254: WinsysInfoForTabbed winsysInfo) {
255: switch (type) {
256: case TYPE_VIEW:
257: case TYPE_EDITOR:
258: case TYPE_SLIDING:
259: case TYPE_TOOLBAR:
260: break;
261: default:
262: throw new IllegalArgumentException("Unknown UI type: "
263: + type); //NOI18N
264: }
265: this .model = model;
266: this .type = type;
267: this .winsysInfo = winsysInfo;
268: putClientProperty(PROP_ORIENTATION, ORIENTATION_NORTH);
269: initialized = true;
270: updateUI();
271: setFocusable(false);
272: // Color fillC = (Color)UIManager.get("nb_workplace_fill"); //NOI18N
273: // if (fillC != null) setBackground (fillC);
274: }
275:
276: public final TabDisplayerUI getUI() {
277: return (TabDisplayerUI) ui;
278: }
279:
280: /** Overridden to block the call from the superclass constructor, which
281: * comes before the <code>type</code> property is initialized. Provides
282: * a reasonable fallback UI for use on unknown look and feels.
283: */
284: public final void updateUI() {
285: if (!initialized) {
286: return;
287: }
288:
289: if (type == TYPE_TOOLBAR) {
290: setUI(new ToolbarTabDisplayerUI(this ));
291: return;
292: } else if (type == TYPE_SLIDING) {
293: setUI(new BasicSlidingTabDisplayerUI(this ));
294: return;
295: }
296:
297: ComponentUI ui = null;
298: if (UIManager.get(getUIClassID()) != null) { //Avoid Error stack trace
299: try {
300: ui = UIManager.getUI(this );
301: } catch (Error error) {
302: System.err.println("Could not load a UI for "
303: + getUIClassID() + " - missing class?");
304: }
305: } else {
306: ui = findUIStandalone();
307: }
308:
309: if (ui == null) {
310: ui = getType() == TYPE_VIEW ? WinClassicViewTabDisplayerUI
311: .createUI(this ) : WinClassicEditorTabDisplayerUI
312: .createUI(this );
313: }
314: setUI((TabDisplayerUI) ui);
315:
316: }
317:
318: /**
319: * Allows the tabcontrol to find the correct UI if the plaf library is
320: * not present (no UI class defined in UIManager).
321: */
322: private ComponentUI findUIStandalone() {
323: ComponentUI result = null;
324: String lf = UIManager.getLookAndFeel().getID();
325: switch (type) {
326: case TYPE_VIEW:
327: if ("Aqua".equals(lf)) { //NOI18N
328: result = AquaViewTabDisplayerUI.createUI(this );
329: } else if ("Windows".equals(lf)) { //NOI18N
330: result = isXPLF() ? WinXPViewTabDisplayerUI
331: .createUI(this ) : WinClassicViewTabDisplayerUI
332: .createUI(this );
333: }
334: break;
335: case TYPE_EDITOR:
336: if ("Aqua".equals(lf)) { //NOI18N
337: result = AquaEditorTabDisplayerUI.createUI(this );
338: } else if ("Windows".equals(lf)) { //NOI18N
339: result = isXPLF() ? WinXPEditorTabDisplayerUI
340: .createUI(this )
341: : WinClassicEditorTabDisplayerUI.createUI(this );
342: }
343: break;
344: }
345: return result;
346: }
347:
348: /** Finds if windows LF with XP theme is active.
349: * @return true if windows LF and XP theme is active, false otherwise */
350: private static boolean isXPLF() {
351: Boolean isXP = (Boolean) Toolkit.getDefaultToolkit()
352: .getDesktopProperty("win.xpstyle.themeActive"); //NOI18N
353: return isXP == null ? false : isXP.booleanValue();
354: }
355:
356: /** Returns an different UIClassID depending on the value of the <code>type</code>
357: * property. */
358: public String getUIClassID() {
359: switch (getType()) {
360: case TYPE_VIEW:
361: return VIEW_TAB_DISPLAYER_UI_CLASS_ID;
362: case TYPE_EDITOR:
363: return EDITOR_TAB_DISPLAYER_UI_CLASS_ID;
364: case TYPE_SLIDING:
365: return SLIDING_TAB_DISPLAYER_UI_CLASS_ID;
366: case TYPE_TOOLBAR:
367: return TOOLBAR_TAB_DISPLAYER_UI_CLASS_ID;
368: default:
369: throw new IllegalArgumentException("Unknown UI type: "
370: + getType());
371: }
372: }
373:
374: /**
375: * Returns whether this control uses the view tab look or the scrolling
376: * editor tab look. This is set in the constructor.
377: */
378: public final int getType() {
379: return type;
380: }
381:
382: public final Dimension getPreferredSize() {
383: return getUI().getPreferredSize(this );
384: }
385:
386: public final Dimension getMinimumSize() {
387: return getUI().getMinimumSize(this );
388: }
389:
390: /**
391: * Cause the specified tab to flash or otherwise call attention to itself
392: * without changing selection or focus. Supported by VIEW and EDITOR type
393: * UIs.
394: */
395: public final void requestAttention(int tab) {
396: getUI().requestAttention(tab);
397: }
398:
399: /**
400: * Cause a tab, if blinking, to stop.
401: */
402: public final void cancelRequestAttention(int tab) {
403: getUI().cancelRequestAttention(tab);
404: }
405:
406: public final boolean requestAttention(TabData data) {
407: int idx = getModel().indexOf(data);
408: boolean result = idx >= 0;
409: if (result) {
410: requestAttention(idx);
411: }
412: return result;
413: }
414:
415: /**
416: * Accessor only for TabDisplayerUI when installing the UI
417: */
418: void setSelectionModel(SingleSelectionModel sel) {
419: this .sel = sel;
420: }
421:
422: /** Get the selection model, which determines which tab is selected.
423: * To change the selection, get the selection model and call
424: * setSelectedIndex(). */
425: public SingleSelectionModel getSelectionModel() {
426: return sel;
427: }
428:
429: /** Get the data model that defines the contents which are displayed */
430: public final TabDataModel getModel() {
431: return model;
432: }
433:
434: /** Set the active state of the component */
435: public final void setActive(boolean active) {
436: if (active != this .active) {
437: this .active = active;
438: firePropertyChange(PROP_ACTIVE, !active, active); //NOI18N
439: }
440: }
441:
442: /** Gets the "active" state of this component. If the component
443: * is active, most UIs will paint the selected tab differently to indicate
444: * that focus is somewhere in the container */
445: public final boolean isActive() {
446: return active;
447: }
448:
449: /**
450: * Gets tooltip for the tab corresponding to the mouse event, or if no
451: * tab, delegates to the default implementation.
452: */
453: public final String getToolTipText(MouseEvent event) {
454: if (ui != null) {
455: Point p = event.getPoint();
456: if (event.getSource() != this ) {
457: Component c = (Component) event.getSource();
458: p = SwingUtilities.convertPoint(c, p, this );
459: }
460: int index = getUI().tabForCoordinate(p);
461: if (index != -1) {
462: return getModel().getTab(index).tip;
463: }
464: }
465: return super .getToolTipText(event);
466: }
467:
468: /** Make a tab visible. In the case of scrolling UIs, a tab is not
469: * always visible. This call will make it scroll into view */
470: public final void makeTabVisible(int index) {
471: getUI().makeTabVisible(index);
472: }
473:
474: /** Get the rectangle that a given tab occupies */
475: public final Rectangle getTabRect(int tab, Rectangle dest) {
476: if (dest == null) {
477: dest = new Rectangle();
478: }
479: getUI().getTabRect(tab, dest);
480: return dest;
481: }
482:
483: @Deprecated
484: public final Image getDragImage(int index) {
485: return null;
486: }
487:
488: /**
489: * Register an ActionListener. TabbedContainer and TabDisplayer guarantee
490: * that the type of event fired will always be TabActionEvent. There are
491: * two special things about TabActionEvent: <ol> <li>There are methods on
492: * TabActionEvent to find the index of the tab the event was performed on,
493: * and if present, retrieve the mouse event that triggered it, for clients
494: * that wish to provide different handling for different mouse buttons</li>
495: * <li>TabActionEvents can be consumed. If a listener consumes the event,
496: * the UI will take no action - the selection will not be changed, the tab
497: * will not be closed. Consuming the event means taking responsibility for
498: * doing whatever would normally happen automatically. This is useful for,
499: * for example, showing a dialog and possibly aborting closing a tab if it
500: * contains unsaved data, for instance.</li> </ol> Action events will be
501: * fired <strong>before</strong> any action has been taken to alter the
502: * state of the control to match the action, so that they may be vetoed or
503: * modified by consuming the event.
504: *
505: * @param listener The listener to register.
506: */
507: public final synchronized void addActionListener(
508: ActionListener listener) {
509: if (actionListenerList == null) {
510: actionListenerList = new ArrayList<ActionListener>();
511: }
512: actionListenerList.add(listener);
513: }
514:
515: /**
516: * Removes ActionListener from the list of listeners.
517: *
518: * @param listener The listener to remove.
519: */
520: public final synchronized void removeActionListener(
521: ActionListener listener) {
522: if (actionListenerList != null) {
523: actionListenerList.remove(listener);
524: }
525: }
526:
527: public void registerShortcuts(JComponent comp) {
528: getUI().registerShortcuts(comp);
529: }
530:
531: public void unregisterShortcuts(JComponent comp) {
532: getUI().unregisterShortcuts(comp);
533: }
534:
535: /**
536: * Notifies all registered listeners about the event.
537: *
538: * @param event The event to be fired
539: */
540: protected final void postActionEvent(TabActionEvent event) {
541: List<ActionListener> list;
542: synchronized (this ) {
543: if (actionListenerList == null) {
544: return;
545: }
546: list = Collections.unmodifiableList(actionListenerList);
547: }
548: for (int i = 0; i < list.size(); i++) {
549: list.get(i).actionPerformed(event);
550: }
551: }
552:
553: public int tabForCoordinate(Point p) {
554: return getUI().tabForCoordinate(p);
555: }
556:
557: public WinsysInfoForTabbed getWinsysInfo() {
558: return winsysInfo;
559: }
560:
561: @Deprecated
562: public LocationInformer getLocationInformer() {
563: return locationInformer;
564: }
565:
566: public AccessibleContext getAccessibleContext() {
567: if (accessibleContext == null) {
568: accessibleContext = new AccessibleTabDisplayer();
569: }
570: return accessibleContext;
571: }
572:
573: /**
574: * Set whether or not the close button should be visible.
575: * This can be defaulted by setting the system property
576: * <code>nb.tabs.suppressCloseButton</code>. The default is
577: * true.
578: */
579: public final void setShowCloseButton(boolean val) {
580: boolean wasShow = isShowCloseButton();
581: if (wasShow != val) {
582: showClose = val;
583: if (isShowing()) {
584: repaint();
585: }
586: firePropertyChange("showCloseButton", !val, val);
587: }
588: }
589:
590: /** Find out if this displayer is set to show close buttons */
591: public final boolean isShowCloseButton() {
592: return showClose;
593: }
594:
595: protected class AccessibleTabDisplayer extends AccessibleJComponent
596: implements AccessibleSelection, ChangeListener {
597:
598: /**
599: * Constructs an AccessibleTabDisplayer
600: */
601: public AccessibleTabDisplayer() {
602: super ();
603: getModel().addChangeListener(this );
604: }
605:
606: public void stateChanged(ChangeEvent e) {
607: Object o = e.getSource();
608: firePropertyChange(
609: AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
610: null, o);
611: }
612:
613: /**
614: * Get the role of this object.
615: *
616: * @return an instance of AccessibleRole describing the role of
617: * the object
618: */
619: public AccessibleRole getAccessibleRole() {
620: return AccessibleRole.PAGE_TAB_LIST;
621: }
622:
623: /**
624: * Returns the number of accessible children in the object.
625: *
626: * @return the number of accessible children in the object.
627: */
628: public int getAccessibleChildrenCount() {
629: return getModel().size();
630: }
631:
632: /**
633: * Return the specified Accessible child of the object.
634: *
635: * @param i zero-based index of child
636: * @return the Accessible child of the object
637: * @exception IllegalArgumentException if index is out of bounds
638: */
639: public Accessible getAccessibleChild(int i) {
640: if (i < 0 || i >= getModel().size()) {
641: return null;
642: }
643: TabData data = getModel().getTab(i);
644: if (data.getComponent() instanceof Accessible) {
645: return (Accessible) data.getComponent();
646: }
647: return null;
648: }
649:
650: /**
651: * Gets the <code>AccessibleSelection</code> associated with
652: * this object. In the implementation of the Java
653: * Accessibility API for this class,
654: * returns this object, which is responsible for implementing the
655: * <code>AccessibleSelection</code> interface on behalf of itself.
656: *
657: * @return this object
658: */
659: public AccessibleSelection getAccessibleSelection() {
660: return this ;
661: }
662:
663: /**
664: * Returns the <code>Accessible</code> child contained at
665: * the local coordinate <code>Point</code>, if one exists.
666: * Otherwise returns the currently selected tab.
667: *
668: * @return the <code>Accessible</code> at the specified
669: * location, if it exists
670: */
671: public Accessible getAccessibleAt(Point p) {
672: int tab = tabForCoordinate(p);
673: if (tab == -1) {
674: tab = getSelectionModel().getSelectedIndex();
675: }
676: return getAccessibleChild(tab);
677: }
678:
679: /**
680: * Returns the number of Accessible children currently selected.
681: * If no children are selected, the return value will be 0.
682: *
683: * @return the number of items currently selected.
684: */
685: public int getAccessibleSelectionCount() {
686: return 1;
687: }
688:
689: /**
690: * Returns an Accessible representing the specified selected child
691: * of the object. If there isn't a selection, or there are
692: * fewer children selected than the integer passed in, the return
693: * value will be null.
694: * <p>Note that the index represents the i-th selected child, which
695: * is different from the i-th child.
696: *
697: * @param i the zero-based index of selected children
698: * @return the i-th selected child
699: * @see #getAccessibleSelectionCount
700: */
701: public Accessible getAccessibleSelection(int i) {
702: // always just one selected.. -> ignore i
703: int index = getSelectionModel().getSelectedIndex();
704: return getAccessibleChild(index);
705: }
706:
707: /**
708: * Determines if the current child of this object is selected.
709: *
710: * @return true if the current child of this object is selected; else false.
711: * @param i the zero-based index of the child in this Accessible object.
712: * @see AccessibleContext#getAccessibleChild
713: */
714: public boolean isAccessibleChildSelected(int i) {
715: return i == getSelectionModel().getSelectedIndex();
716: }
717:
718: /**
719: * Adds the specified Accessible child of the object to the object's
720: * selection. If the object supports multiple selections,
721: * the specified child is added to any existing selection, otherwise
722: * it replaces any existing selection in the object. If the
723: * specified child is already selected, this method has no effect.
724: *
725: * @param i the zero-based index of the child
726: * @see AccessibleContext#getAccessibleChild
727: */
728: public void addAccessibleSelection(int i) {
729: //TODO?
730: }
731:
732: /**
733: * Removes the specified child of the object from the object's
734: * selection. If the specified item isn't currently selected, this
735: * method has no effect.
736: *
737: * @param i the zero-based index of the child
738: * @see AccessibleContext#getAccessibleChild
739: */
740: public void removeAccessibleSelection(int i) {
741: //TODO?
742: }
743:
744: /**
745: * Clears the selection in the object, so that no children in the
746: * object are selected.
747: */
748: public void clearAccessibleSelection() {
749: //TODO?
750: }
751:
752: /**
753: * Causes every child of the object to be selected
754: * if the object supports multiple selections.
755: */
756: public void selectAllAccessibleSelection() {
757: //TODO?
758: }
759: }
760:
761: }
|