org.assertj.swing.hierarchy
Class NewHierarchy

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

public class NewHierarchy
extends ExistingHierarchy

Isolates a ComponentHierarchy to limit to only those components created during the lifetime of this hierarchy. Existing AWT or Swing Components (and any subsequently generated sub-windows) are ignored by default.

Implicitly auto-filters Windows which are disposed (i.e. generates a WindowEvent#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) will be ignored permanently.

Author:
Alex Ruiz

Method Summary
 Collection<Component> childrenOf(Component c)
           Returns all the children of the given AWT or Swing Component, omitting those which are currently filtered.
 boolean contains(Component c)
           Returns true if the given AWT or Swing Component is not ignored.
 void dispose(Window w)
           Disposes the given Window, but only if it currently exists within the hierarchy.
 void ignoreExisting()
           Makes all currently existing AWT and Swing Component invisible to this hierarchy, without affecting their current state.
static NewHierarchy ignoreExistingComponents()
          Creates a new NewHierarchy which does not contain any existing AWT or Swing Components.
static NewHierarchy includeExistingComponents()
          Creates a new NewHierarchy which contains existing AWT or Swing Components.
 void recognize(Component c)
           Make the given AWT or Swing Component visible to this hierarchy.
 Collection<Container> roots()
           
 
Methods inherited from class org.assertj.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

@Nonnull
public static NewHierarchy ignoreExistingComponents()
Creates a new NewHierarchy which does not contain any existing AWT or Swing Components.

Returns:
the created hierarchy.

includeExistingComponents

@Nonnull
public static NewHierarchy includeExistingComponents()
Creates a new NewHierarchy which contains existing AWT or Swing Components.

Returns:
the created hierarchy.

ignoreExisting

@RunsInCurrentThread
public void ignoreExisting()

Makes all currently existing AWT and Swing Component invisible to this hierarchy, without affecting their current state.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.


recognize

@RunsInCurrentThread
public void recognize(@Nonnull
                                          Component c)

Make the given AWT or Swing Component visible to this hierarchy.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Parameters:
c - the given Component.

childrenOf

@RunsInCurrentThread
@Nonnull
public Collection<Component> childrenOf(@Nonnull
                                                                    Component c)

Returns all the children of the given AWT or Swing Component, omitting those which are currently filtered.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

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

contains

@RunsInCurrentThread
public boolean contains(@Nonnull
                                            Component c)

Returns true if the given AWT or Swing Component is not ignored.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call 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 ignored, false otherwise.

dispose

@RunsInCurrentThread
public void dispose(@Nonnull
                                        Window w)

Disposes the given Window, but only if it currently exists within the hierarchy. It will no longer appear in this hierarchy or be reachable in a hierarchy walk.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

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

roots

@Nonnull
public Collection<Container> roots()
Specified by:
roots in interface ComponentHierarchy
Overrides:
roots in class ExistingHierarchy
Returns:
all available root containers, excluding those which have been filtered.


Copyright © 2014–2015 AssertJ. All rights reserved.