org.fest.swing.hierarchy
Class NewHierarchy

java.lang.Object
  extended by org.fest.swing.hierarchy.ExistingHierarchy
      extended by org.fest.swing.hierarchy.NewHierarchy
All Implemented Interfaces:
ComponentHierarchy

public class NewHierarchy
extends ExistingHierarchy

Understands isolation of a component hierarchy to limit to only those components created during the lifetime of this hierarchy. Existing components (and any subsequently generated subwindows) are ignored by default.

Implicitly auto-filters windows which are disposed (i.e. generate a WINDOW_CLOSED event), but also implicitly un-filters them if they should be shown again. Any window explicitly disposed by the calling ComponentHierarchy.dispose(java.awt.Window)

Author:
Alex Ruiz

Method Summary
 Collection<Component> childrenOf(Component c)
          Returns all sub-components of the given component, omitting those which are currently filtered.
 boolean contains(Component c)
          Returns true if the given component is not filtered.
 void dispose(Window w)
          Dispose of the given window, but only if it currently exists within the hierarchy.
 void ignoreExisting()
          Make all currently existing components invisible to this hierarchy, without affecting their current state.
static NewHierarchy ignoreExistingComponents()
          Creates a new NewHierarchy which does not contain any existing GUI components.
static NewHierarchy includeExistingComponents()
          Creates a new NewHierarchy which contains existing GUI components.
 void recognize(Component c)
          Make the given component visible to this hierarchy.
 Collection<? extends Container> roots()
          Returns all available root containers, excluding those which have been filtered.
 
Methods inherited from class org.fest.swing.hierarchy.ExistingHierarchy
parentOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

ignoreExistingComponents

public static NewHierarchy ignoreExistingComponents()
Creates a new NewHierarchy which does not contain any existing GUI components.

Returns:
the created hierarchy.

includeExistingComponents

public static NewHierarchy includeExistingComponents()
Creates a new NewHierarchy which contains existing GUI components.

Returns:
the created hierarchy.

ignoreExisting

@RunsInCurrentThread
public void ignoreExisting()
Make all currently existing components invisible to this hierarchy, without affecting their current state.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.


recognize

@RunsInCurrentThread
public void recognize(Component c)
Make the given component visible to this hierarchy.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
c - the given component.

childrenOf

@RunsInCurrentThread
public Collection<Component> childrenOf(Component c)
Returns all sub-components of the given component, omitting those which are currently filtered.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Specified by:
childrenOf in interface ComponentHierarchy
Overrides:
childrenOf in class ExistingHierarchy
Parameters:
c - the given component.
Returns:
all sub-components of the given component, omitting those which are currently filtered.

contains

@RunsInCurrentThread
public boolean contains(Component c)
Returns true if the given component is not filtered.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Specified by:
contains in interface ComponentHierarchy
Overrides:
contains in class ExistingHierarchy
Parameters:
c - the given component.
Returns:
true if the given component is not filtered, false otherwise.

dispose

@RunsInCurrentThread
public void dispose(Window w)
Dispose of the given window, but only if it currently exists within the hierarchy. It will no longer appear in

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

this hierarchy or be reachable in a hierarchy walk.

Specified by:
dispose in interface ComponentHierarchy
Overrides:
dispose in class ExistingHierarchy
Parameters:
w - the window to dispose.

roots

public Collection<? extends Container> roots()
Returns all available root containers, excluding those which have been filtered.

Specified by:
roots in interface ComponentHierarchy
Overrides:
roots in class ExistingHierarchy
Returns:
all available root containers, excluding those which have been filtered.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.