001: /*
002: * Copyright (C) 2004 NNL Technology AB
003: * Visit www.infonode.net for information about InfoNode(R)
004: * products and how to contact NNL Technology AB.
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
019: * MA 02111-1307, USA.
020: */
021:
022: // $Id: TabbedUtils.java,v 1.10 2005/02/16 11:28:15 jesper Exp $
023: package net.infonode.tabbedpanel;
024:
025: import net.infonode.gui.hover.hoverable.HoverManager;
026:
027: import java.awt.*;
028:
029: /**
030: * Utility methods
031: *
032: * @author $Author: jesper $
033: * @version $Revision: 1.10 $
034: */
035: public class TabbedUtils {
036: private TabbedUtils() {
037: }
038:
039: /**
040: * <p>Gets the tab for whom the given component is a child.</p>
041: *
042: * <p><strong>Note:</strong> This is not a method for retrieving the tab for a specific content
043: * component. This method is only useful for finding the Tab for components that
044: * have been added to a Tab.</p>
045: *
046: * @param c the component
047: * @return the tab or null if component is not a child of any tab
048: */
049: public static Tab getParentTab(Component c) {
050: while (c != null) {
051: if (c instanceof Tab)
052: return (Tab) c;
053: c = c.getParent();
054: }
055: return null;
056: }
057:
058: /**
059: * Gets the tabbed panel for whom the given component is a child
060: *
061: * @param c the component
062: * @return the tabbed panel or null if component is not a child of any tabbed panel
063: */
064: public static TabbedPanel getParentTabbedPanel(Component c) {
065: while (c != null) {
066: if (c instanceof TabbedPanel)
067: return (TabbedPanel) c;
068: c = c.getParent();
069: }
070:
071: return null;
072: }
073:
074: /**
075: * Gets the TabbedPanelContentPanel for whom the given component is a child
076: *
077: * @param c the component
078: * @return the content panel or null if component is not a child of any
079: * tabbed panel content panel
080: */
081: public static TabbedPanelContentPanel getParentTabbedPanelContentPanel(
082: Component c) {
083: while (c != null) {
084: if (c instanceof TabbedPanelContentPanel)
085: return (TabbedPanelContentPanel) c;
086:
087: c = c.getParent();
088: }
089:
090: return null;
091: }
092:
093: /**
094: * <p>
095: * Checks to see if hover is enabled i.e. if the AWTPermission "listenToAllAWTEvents" has been
096: * granted so that hover can be used.
097: * </p>
098: *
099: * <p>
100: * Note: This method is not meant to be used for permission checks, only as a convenience to
101: * check if hover is enabled or not.
102: * </p>
103: *
104: * @return true if hover is enabled, otherwise false
105: * @since ITP 1.3.0
106: */
107: public static boolean isHoverEnabled() {
108: return HoverManager.getInstance().isEventListeningActive();
109: }
110: }
|