Extension SDK 10.1.2

oracle.ide.dialogs
Class ProgressBar

java.lang.Object
  extended byoracle.ide.dialogs.ProgressBar
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.lang.Runnable

public class ProgressBar
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable

The ProgressBar provides the user with feedback while a long-running process is in progress. The dialog consists of a label known as the progressText, a progress indicator, and another label known as the stepText. This layout follows the standards in the Oracle Dialogs User Interface Specification, Version 2.0 Dated May 10, 2001. The progress indicator displayed is either the javax.swing.JProgressBar or the Bali BusyBar, depending on a value passed in the constructor. The BusyBar should be used when you cannot estimate the amount of work to be done or remaining while the long-running process is executing. Client code must implement the Runnable interface in order to use the ProgressBar. The ProgressBar will create a new thread and invoke the run() method in the Runnable passed in via the constructor. This is done so the UI can be repainted while the long-running process is executing. Typical implementation: ### describe here ###


Constructor Summary
ProgressBar(java.awt.Component parent, java.lang.String dialogTitle, java.lang.Runnable runnable, boolean useBusyBar)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This is invoked when an action is performed.
 boolean hasUserCancelled()
          The client code's run() method that implements the long-running process should call this method to determine if the user has pressed the Cancel button on the ProgressBar's dialog to terminate the long-running process.
 boolean isCancelable()
           
 void run()
          The entrypoint for the thread that executes the long-running process.
 void setCancelable(boolean canCancel)
           
 void setDoneStatus()
          The client code should call this when the long-running process is complete.
 void sleepForUIToRepaint()
          The client code should call this in it's run() method that implements the long-running process.
 void start(java.lang.String initialText, java.lang.String stepText)
          Starts the ProgressBar.
 void updateProgress(int completionStatus, java.lang.String progressText, java.lang.String stepText)
          The client code's run() method that implements the long-running process should use this method to update the ProgressBar to indicate the progress made in the long-running process.
 void updateProgress(java.lang.String progressText, java.lang.String stepText)
          The client code's run() method that implements the long-running process should use this method to update the ProgressBar to indicate the progress made in the long-running process.
 void waitUntilDone()
          The client code should call this to wait until the long-running process is complete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProgressBar

public ProgressBar(java.awt.Component parent,
                   java.lang.String dialogTitle,
                   java.lang.Runnable runnable,
                   boolean useBusyBar)
Constructor. Creates the ProgressBar object

Parameters:
parent - The UI object to use as the ProgressBar dialog's parent
dialogTitle - The title to use for the ProgressBar dialog
runnable - The Runnable object whose run() method implements the long-running process
useBusyBar - Set to true when the BusyBar is to be used; false when the JProgressBar is to be used
Method Detail

setCancelable

public void setCancelable(boolean canCancel)

isCancelable

public boolean isCancelable()

start

public void start(java.lang.String initialText,
                  java.lang.String stepText)
Starts the ProgressBar.

Parameters:
initialText - The text to display just above the progress indicator. An example might be "Downloading components."
stepText - The text to display just below the progress indicator. An example might be "Retrieving file abc.jar."

updateProgress

public void updateProgress(int completionStatus,
                           java.lang.String progressText,
                           java.lang.String stepText)
The client code's run() method that implements the long-running process should use this method to update the ProgressBar to indicate the progress made in the long-running process. Use this method only when the indicator used is the JProgressBar not the BusyBar.

Parameters:
completionStatus - The amount of progress that has been made.
progressText - The text to display just above the progress indicator. If a null string or zero-length string is passed in the text will not be updated.
stepText - The text to display just below the progress indicator. If a null string or zero-length string is passed in the text will not be updated.

updateProgress

public void updateProgress(java.lang.String progressText,
                           java.lang.String stepText)
The client code's run() method that implements the long-running process should use this method to update the ProgressBar to indicate the progress made in the long-running process. Use this method only when the indicator used is the BusyBar not the JProgressBar.

Parameters:
progressText - The text to display just above the progress indicator. If a null string or zero-length string is passed in the text will not be updated.
stepText - The text to display just below the progress indicator. If a null string or zero-length string is passed in the text will not be updated.

hasUserCancelled

public boolean hasUserCancelled()
The client code's run() method that implements the long-running process should call this method to determine if the user has pressed the Cancel button on the ProgressBar's dialog to terminate the long-running process. The long-running process should call this method fairly often and should clean up as necessary if the Cancel button has been pressed.

Returns:
true if the user has pressed the cancel button, false otherwise.

sleepForUIToRepaint

public void sleepForUIToRepaint()
The client code should call this in it's run() method that implements the long-running process. This method forces the long-running process to sleep for a little bit periodically to give the UI thread a chance to repaint. Every second or so force a sleep to make sure the UI has caught up.


waitUntilDone

public void waitUntilDone()
The client code should call this to wait until the long-running process is complete. ### Provide sample implementation ###


setDoneStatus

public void setDoneStatus()
The client code should call this when the long-running process is complete. ### provide sample implementation ###


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
This is invoked when an action is performed. In this case, it should only be a Timer event. Client code should not invoke this method, it is public only to match the ActionInterface.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - the action event

run

public void run()
The entrypoint for the thread that executes the long-running process. This method should not be called by client code, it is public only because it must be public to match the Runnable interface.

Specified by:
run in interface java.lang.Runnable

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.