com.groovemanager.gui.custom
Class ProgressMonitor

java.lang.Object
  extended by org.eclipse.jface.window.Window
      extended by org.eclipse.jface.dialogs.Dialog
          extended by com.groovemanager.gui.custom.ProgressMonitor
All Implemented Interfaces:
ProgressListener

public class ProgressMonitor
extends org.eclipse.jface.dialogs.Dialog
implements ProgressListener

This class can be used for showing a status dialog for monitoring a longer running operation (ProgressThread)

Author:
Manu Robledo
See Also:
ProgressThread

Nested Class Summary
private  class ProgressMonitor.ProgBarChanger
          A Runnable implementation for thread-safe updating of the ProgressBar
 
Nested classes inherited from class org.eclipse.jface.window.Window
org.eclipse.jface.window.Window.IExceptionHandler
 
Field Summary
private  boolean cancelled
          Indicates whether the user has pressed Cancel or not
private  java.lang.Runnable closer
          Runnable for thread-safe closing of the dialog
private  org.eclipse.swt.widgets.Display d
          The current Display
private  org.eclipse.swt.widgets.ProgressBar indetProgBar
          The ProgressBar for displaying the progress
private  int max
          Minimum value for the ProgressBar
private  java.lang.String message
          The message displayed inside the dialog
private  org.eclipse.swt.widgets.Label messageLabel
          The Label containing the message
private  int min
          Minimum value for the ProgressBar
private  ProgressMonitor.ProgBarChanger pbChanger
          Runnable for thread-safe updating of the ProgressBar
private  org.eclipse.swt.widgets.Composite pbComp
          The Composite containing the two different ProgressBars
private  int pos
          Minimum value for the ProgressBar
private  org.eclipse.swt.widgets.ProgressBar progBar
          The ProgressBar for displaying the progress
private  ProgressThread pThread
          The ProgressThread to monitor
private  org.eclipse.swt.custom.StackLayout stack
          The Layout to use for the two different progress bars
private  java.lang.String title
          The message displayed inside the dialog
 
Fields inherited from class org.eclipse.jface.dialogs.Dialog
buttonBar, dialogArea, DLG_IMG_ERROR, DLG_IMG_INFO, DLG_IMG_MESSAGE_ERROR, DLG_IMG_MESSAGE_INFO, DLG_IMG_MESSAGE_WARNING, DLG_IMG_QUESTION, DLG_IMG_WARNING
 
Fields inherited from class org.eclipse.jface.window.Window
CANCEL, OK
 
Constructor Summary
ProgressMonitor(org.eclipse.swt.widgets.Shell parent, ProgressThread t)
          Construct a new ProgressMonitor without title or message
ProgressMonitor(org.eclipse.swt.widgets.Shell parent, ProgressThread t, java.lang.String title, java.lang.String message)
          Construct a new ProgressMonitor with the given title and message
 
Method Summary
protected  void cancelPressed()
           
protected  void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
           
 org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
           
 void progressCancelled()
          Notification that the operation has been cancelled before finishing
 void progressElapsed(int i)
          The part of te operation elapsed so far
 void progressFinished()
          Notification htat the operation has been finished
 void progressStarted()
          Notification about the start of the operation
 void progressTotal(int i)
          The total length of the operation
 void setMax(int i)
          Set the ProgressBarīs maximum value
 void setMessage(java.lang.String m)
          Set the dialogīs message
 void setPosition(int i)
          Set the ProgressBarīs selection value
 void setTitle(java.lang.String t)
          Set the dialogīs title
 java.lang.Object start()
          Start the ProgressThread and open this dialog
 
Methods inherited from class org.eclipse.jface.dialogs.Dialog
applyDialogFont, buttonPressed, close, configureShell, constrainShellSize, convertHeightInCharsToPixels, convertHeightInCharsToPixels, convertHorizontalDLUsToPixels, convertHorizontalDLUsToPixels, convertVerticalDLUsToPixels, convertVerticalDLUsToPixels, convertWidthInCharsToPixels, convertWidthInCharsToPixels, createButton, createButtonBar, createContents, getButton, getButtonBar, getCancelButton, getDialogArea, getImage, getOKButton, initializeBounds, initializeDialogUnits, okPressed, setButtonLayoutData, setButtonLayoutFormData
 
Methods inherited from class org.eclipse.jface.window.Window
canHandleShellCloseEvent, create, createShell, getContents, getDefaultImage, getInitialLocation, getInitialSize, getParentShell, getReturnCode, getShell, getShellListener, getShellStyle, getWindowManager, handleFontChange, handleShellCloseEvent, open, setBlockOnOpen, setDefaultImage, setExceptionHandler, setReturnCode, setShellStyle, setWindowManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cancelled

private boolean cancelled
Indicates whether the user has pressed Cancel or not


closer

private java.lang.Runnable closer
Runnable for thread-safe closing of the dialog


d

private org.eclipse.swt.widgets.Display d
The current Display


indetProgBar

private org.eclipse.swt.widgets.ProgressBar indetProgBar
The ProgressBar for displaying the progress


max

private int max
Minimum value for the ProgressBar


message

private java.lang.String message
The message displayed inside the dialog


messageLabel

private org.eclipse.swt.widgets.Label messageLabel
The Label containing the message


min

private int min
Minimum value for the ProgressBar


pbChanger

private ProgressMonitor.ProgBarChanger pbChanger
Runnable for thread-safe updating of the ProgressBar


pbComp

private org.eclipse.swt.widgets.Composite pbComp
The Composite containing the two different ProgressBars


pos

private int pos
Minimum value for the ProgressBar


progBar

private org.eclipse.swt.widgets.ProgressBar progBar
The ProgressBar for displaying the progress


pThread

private final ProgressThread pThread
The ProgressThread to monitor


stack

private org.eclipse.swt.custom.StackLayout stack
The Layout to use for the two different progress bars


title

private java.lang.String title
The message displayed inside the dialog

Constructor Detail

ProgressMonitor

public ProgressMonitor(org.eclipse.swt.widgets.Shell parent,
                       ProgressThread t)
Construct a new ProgressMonitor without title or message

Parameters:
parent - The parent Shell for the dialog
t - The ProgressThread to monitor

ProgressMonitor

public ProgressMonitor(org.eclipse.swt.widgets.Shell parent,
                       ProgressThread t,
                       java.lang.String title,
                       java.lang.String message)
Construct a new ProgressMonitor with the given title and message

Parameters:
parent - The parent Shell for the dialog
t - The ProgressThread to monitor
title - The dialog title
message - The dialog message
Method Detail

cancelPressed

protected void cancelPressed()
Overrides:
cancelPressed in class org.eclipse.jface.dialogs.Dialog

createButtonsForButtonBar

protected void createButtonsForButtonBar(org.eclipse.swt.widgets.Composite parent)
Overrides:
createButtonsForButtonBar in class org.eclipse.jface.dialogs.Dialog

createDialogArea

public org.eclipse.swt.widgets.Control createDialogArea(org.eclipse.swt.widgets.Composite parent)
Overrides:
createDialogArea in class org.eclipse.jface.dialogs.Dialog

progressCancelled

public void progressCancelled()
Description copied from interface: ProgressListener
Notification that the operation has been cancelled before finishing

Specified by:
progressCancelled in interface ProgressListener
See Also:
ProgressListener.progressCancelled()

progressElapsed

public void progressElapsed(int i)
Description copied from interface: ProgressListener
The part of te operation elapsed so far

Specified by:
progressElapsed in interface ProgressListener
Parameters:
i - The length of the part of the operation elapsed so far. The unit to use for this value is free defineable
See Also:
ProgressListener.progressElapsed(int)

progressFinished

public void progressFinished()
Description copied from interface: ProgressListener
Notification htat the operation has been finished

Specified by:
progressFinished in interface ProgressListener
See Also:
ProgressListener.progressFinished()

progressStarted

public void progressStarted()
Description copied from interface: ProgressListener
Notification about the start of the operation

Specified by:
progressStarted in interface ProgressListener
See Also:
ProgressListener.progressStarted()

progressTotal

public void progressTotal(int i)
Description copied from interface: ProgressListener
The total length of the operation

Specified by:
progressTotal in interface ProgressListener
Parameters:
i - The length, the operation will take. The unit to use for this value is free defineable. If the total length of the operation can not be specified, -1 will be returned to indicate "unknown".
See Also:
ProgressListener.progressTotal(int)

setMax

public void setMax(int i)
Set the ProgressBarīs maximum value

Parameters:
i - The maximum value

setMessage

public void setMessage(java.lang.String m)
Set the dialogīs message

Parameters:
m - The new message

setPosition

public void setPosition(int i)
Set the ProgressBarīs selection value

Parameters:
i - The new selection value

setTitle

public void setTitle(java.lang.String t)
Set the dialogīs title

Parameters:
t - The new title

start

public java.lang.Object start()
                       throws NotFinishedException
Start the ProgressThread and open this dialog

Returns:
The ProgressThreadīs result or null, if it didnīt finish
Throws:
NotFinishedException - If the ProgressThread didnīt finish