001    /*
002     * Created on Oct 19, 2007
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005     * the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
010     * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011     * specific language governing permissions and limitations under the License.
012     *
013     * Copyright @2007-2010 the original author or authors.
014     */
015    package org.fest.swing.hierarchy;
016    
017    import java.awt.*;
018    import java.util.Collection;
019    
020    import org.fest.swing.annotation.RunsInCurrentThread;
021    
022    /**
023     * Understands access to all components in a hierarchy.
024     * <p>
025     * <b>Note:</b> methods in this interface are <b>not</b> guaranteed to be executed in the event dispatch thread (EDT.)
026     * Clients are responsible for invoking them in the EDT.
027     * </p>
028     *
029     * @author Alex Ruiz
030     * @author Yvonne Wang
031     */
032    @RunsInCurrentThread
033    public interface ComponentHierarchy {
034    
035      /**
036       * Provides all root containers in the hierarchy.
037       * @return all root containers in the hierarchy.
038       */
039      Collection<? extends Container> roots();
040    
041      /**
042       * Returns all sub-components of the given component.
043       * @param c the given component.
044       * @return all sub-components of the given component.
045       */
046      Collection<Component> childrenOf(Component c);
047    
048      /**
049       * Return the parent for the given component.
050       * @param c the given component.
051       * @return the parent for the given component.
052       */
053      Container parentOf(Component c);
054    
055      /**
056       * Returns whether this hierarchy contains the given component.
057       * @param c the given component.
058       * @return <code>true</code> if this hierarchy contains the given component, <code>false</code> otherwise.
059       */
060      boolean contains(Component c);
061    
062      /**
063       * Provides proper disposal of the given window, appropriate to this hierarchy. After disposal, the window and its
064       * descendants will no longer be reachable from this hierarchy.
065       * @param w the container to window.
066       */
067      void dispose(Window w);
068    }