Venice 0.7beta

org.mov.ui
Class ProgressDialogManager

java.lang.Object
  extended by org.mov.ui.ProgressDialogManager

public class ProgressDialogManager
extends java.lang.Object

This class controls progress dialog creation/deletion in venice. It controls progress dialogs by allowing each thread in venice to have only a single progress dialog running at anyone time. If, in a thread, a request for another progress dialog is called, it will use the current progress dialog being displayed for that thread. By using a proxy progress dialog class (SecondaryProgressDialog), we can control how much the second comer can change the current progress, without the caller even knowing.

How to Display Progress

 // Get the current thread - we'll need this to see 
 // if the user has cancelled the dialog
 Thread thread = Thread.currentThread();

 // Create the progress dialog, configure it and show it.
 ProgressDialog progress = ProgressDialogManager.getProgressDialog();
 progress.setMaximum(3);
 progress.setProgress(0);
 progress.show("Performing Task");

 for(int i = 0; i < 3; i++) {
    Task(i);

    // If the progress dialog is cancelled. The thread will be interrupted.
    // Has the user cancelled the dialog? If the user has, we should stop 
    // what we are doing.
    if(thread.isInterrupted())
       break;

    progress.increment();
 }

 ProgressDialogManager.closeProgressDialog(progress);
 
Master Dialogs

Sometimes when you are displaying progress you might be performing several tasks, where some of the tasks display their own progress. In this situation it might be undesirable for the contained tasks to show their progress. You can stop them by making your progress dialog a master dialog.

 progress.setMaster(true);
 
This will stop their progress being displayed. The only thing they will have control over is the note field.

On the other side, if you set a contained task to be a master, it will show its progress, even if its container task is set to be a master. This is useful for initialisation tasks that can be very slow and should always be shown to the user.

See Also:
ProgressDialog, PrimaryProgressDialog, SecondaryProgressDialog

Method Summary
static void closeProgressDialog(ProgressDialog progressDialog)
          Closes and removes the progress dialog associated with the current thread.
static ProgressDialog getProgressDialog()
          Create a new PrimaryProgressDialog if one is not already being displayed for the current thread.
static ProgressDialog getProgressDialog(boolean isCancelButtonToBePainted)
          Create a new PrimaryProgressDialog if one is not already being displayed for the current thread.
static boolean isProgressDialogUp()
          Returns whether a progress dialog is currently on screen.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getProgressDialog

public static ProgressDialog getProgressDialog()
Create a new PrimaryProgressDialog if one is not already being displayed for the current thread. If one is displayed, return a proxy to the current dialog, i.e. a SecondaryProgressDialog. The secondary progress dialog may or may not have full control over the real dialog.

Returns:
progress dialog
See Also:
PrimaryProgressDialog, SecondaryProgressDialog

getProgressDialog

public static ProgressDialog getProgressDialog(boolean isCancelButtonToBePainted)
Create a new PrimaryProgressDialog if one is not already being displayed for the current thread. If one is displayed, return a proxy to the current dialog, i.e. a SecondaryProgressDialog. The secondary progress dialog may or may not have full control over the real dialog.

Parameters:
isCancelButtonToBePainted - true if we need to paint a cancel button
Returns:
progress dialog
See Also:
PrimaryProgressDialog, SecondaryProgressDialog

isProgressDialogUp

public static boolean isProgressDialogUp()
Returns whether a progress dialog is currently on screen.

Returns:
TRUE if a progress dialog is being displayed.

closeProgressDialog

public static void closeProgressDialog(ProgressDialog progressDialog)
Closes and removes the progress dialog associated with the current thread.


Venice 0.7beta