org.openide.util
Class AsyncInitSupport

java.lang.Object
  extended by org.openide.util.AsyncInitSupport
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.HierarchyListener, java.lang.Runnable, java.util.EventListener

final class AsyncInitSupport
extends java.lang.Object
implements java.awt.event.HierarchyListener, java.lang.Runnable, java.awt.event.ActionListener

Performance helper class, allows to run post-init task for given component. Can also handle cancel logic if contained in AsyncGUIJob. Class is designed for one time use, can't be used to perform async init more then once. Restrictions: Note that for correct functionality given component must not be showing at construction time of this class, however shouldn't stay hidden forever as memory leak may occur.

Author:
Dafe Simonek

Field Summary
(package private)  javax.swing.Timer timer
          Timer for delaying asynchronous init job to enable some painting first
 
Constructor Summary
AsyncInitSupport(java.awt.Component comp4Init, AsyncGUIJob initJob)
          Creates a new instance of AsyncInitComponent
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          Impl of ActionListener, called from hierarchyChanged through a Timer, starts the job
 void hierarchyChanged(java.awt.event.HierarchyEvent evt)
          Impl of HierarchyListener, starts init job with delay when component shown, stops listening to asociated component it isn't showing anymore, calls cancel if desirable.
 void run()
          Body of task executed in RequestProcessor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

javax.swing.Timer timer
Timer for delaying asynchronous init job to enable some painting first

Constructor Detail

AsyncInitSupport

public AsyncInitSupport(java.awt.Component comp4Init,
                        AsyncGUIJob initJob)
Creates a new instance of AsyncInitComponent

Parameters:
comp4Init - Component to be initialized. Mustn't be showing at this time. IllegalStateException is thrown if component is already showing.
initJob - Instance of initialization job.
Method Detail

hierarchyChanged

public void hierarchyChanged(java.awt.event.HierarchyEvent evt)
Impl of HierarchyListener, starts init job with delay when component shown, stops listening to asociated component it isn't showing anymore, calls cancel if desirable.

Specified by:
hierarchyChanged in interface java.awt.event.HierarchyListener
Parameters:
evt - hierarchy event

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
Impl of ActionListener, called from hierarchyChanged through a Timer, starts the job

Specified by:
actionPerformed in interface java.awt.event.ActionListener

run

public void run()
Body of task executed in RequestProcessor. Runs AsyncGUIJob's worker method and after its completion posts AsyncJob's UI update method to AWT thread.

Specified by:
run in interface java.lang.Runnable