org.geotools.gui.swing.worker
Class BlockingSwingWorker

java.lang.Object
  extended byorg.geotools.gui.swing.worker.BlockingSwingWorker

public abstract class BlockingSwingWorker
extends java.lang.Object

This is a variant of the SwingWorker It works in conjunction with the GlassPane class to allow users to execute timeconsuming task on a separate thread The GlassPane addition can prevent users from executing another SwingWorker task while one SwingWorker task is already executing. A message popup to provide an explaination for the long wait and beep on click capability can be also requested

Author:
Yexin Chen, Andrea Aime

Constructor Summary
BlockingSwingWorker(java.awt.Component aComponent)
          Start a thread that will call the construct method and then exit.
BlockingSwingWorker(java.awt.Component aComponent, java.lang.String title, java.lang.String message, boolean beep)
          Start a thread that will call the construct method and then exit.
 
Method Summary
protected abstract  void doNonUILogic()
          This method will be implemented by the inner class of SwingWorker It should only consist of the logic that's unrelated to UI
protected  void doUIUpdateLogic()
          This method will be implemented by the inner class of SwingWorker It should only consist of the logic that's related to UI updating, after the doNonUILogic() method is done.
protected  void finished()
          Called on the event dispatching thread (not on the worker thread) after the construct method has returned.
protected  java.awt.Component getAComponent()
          Getter method
protected  GlassPane getGlassPane()
          Getter method
 void interrupt()
          A new method that interrupts the worker thread.
protected  void setAComponent(java.awt.Component newAComponent)
          Setter method
protected  void setGlassPane(GlassPane newGlassPane)
          Setter method
 void start()
          Start the worker thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingSwingWorker

public BlockingSwingWorker(java.awt.Component aComponent)
Start a thread that will call the construct method and then exit. No message nor beeps will be activated

Parameters:
aComponent - a reference to the UI component that's directly using SwingWorker

BlockingSwingWorker

public BlockingSwingWorker(java.awt.Component aComponent,
                           java.lang.String title,
                           java.lang.String message,
                           boolean beep)
Start a thread that will call the construct method and then exit.

Parameters:
aComponent - a reference to the UI component that's directly using SwingWorker
title - DOCUMENT ME!
message - if non null, a pupup showing the message will appar while the worker is performing the long task
beep - if true, when the user clicks on the blocked user interface or pressed a key, a beep will be produced using the standard operating system beep
Method Detail

doNonUILogic

protected abstract void doNonUILogic()
                              throws java.lang.RuntimeException
This method will be implemented by the inner class of SwingWorker It should only consist of the logic that's unrelated to UI

Throws:
java.lang.RuntimeException - thrown if there are any errors in the non-ui logic

doUIUpdateLogic

protected void doUIUpdateLogic()
                        throws java.lang.RuntimeException
This method will be implemented by the inner class of SwingWorker It should only consist of the logic that's related to UI updating, after the doNonUILogic() method is done.

Throws:
java.lang.RuntimeException - thrown if there are any problems executing the ui update logic

finished

protected void finished()
Called on the event dispatching thread (not on the worker thread) after the construct method has returned.


getAComponent

protected java.awt.Component getAComponent()
Getter method

Returns:
java.awt.Component

getGlassPane

protected GlassPane getGlassPane()
Getter method

Returns:
GlassPane

interrupt

public void interrupt()
A new method that interrupts the worker thread. Call this method to force the worker to stop what it's doing.


setAComponent

protected void setAComponent(java.awt.Component newAComponent)
Setter method

Parameters:
newAComponent - java.awt.Component

setGlassPane

protected void setGlassPane(GlassPane newGlassPane)
Setter method

Parameters:
newGlassPane - GlassPane

start

public void start()
Start the worker thread.



Copyright © GeoTools. All Rights Reserved.