org.springframework.richclient.application.statusbar.support
Class StatusBarProgressMonitor

java.lang.Object
  extended by org.springframework.richclient.application.support.ApplicationServicesAccessor
      extended by org.springframework.richclient.factory.AbstractControlFactory
          extended by org.springframework.richclient.application.statusbar.support.StatusBarProgressMonitor
All Implemented Interfaces:
ControlFactory, ProgressMonitor

public class StatusBarProgressMonitor
extends AbstractControlFactory
implements ProgressMonitor

ProgressMonitor implementation that handles its own controls:

Initally the progress bar and button are hidden, and shown when a task is running longer than the delayProgress property (default is 500 ms).

Author:
Peter De Bruycker

Field Summary
static int DEFAULT_DELAY_PROGRESS
          Progress bar creation is delayed by this ms
static int UNKNOWN
           
 
Fields inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
logger
 
Constructor Summary
StatusBarProgressMonitor()
           
 
Method Summary
protected  JButton createCancelButton()
           
protected  JComponent createControl()
          Subclasses must override this method to create a new instance of the control that this factory produces.
protected  JProgressBar createProgressBar()
           
 void done()
          Notifies that the work is done; that is, either the main task is completed or the user cancelled it.
 Icon getCancelIcon()
           
protected  JProgressBar getProgressBar()
           
protected  void hideProgress()
           
 boolean isCanceled()
          Returns true if the user does some UI action to cancel this operation.
 void setCanceled(boolean b)
          Attempts to cancel the monitored task.
 void setCancelEnabled(boolean enabled)
           
 void setCancelIcon(Icon icon)
           
 void setDelayProgress(int delayProgress)
           
 void subTaskStarted(String name)
          Notifies that a subtask of the main task is beginning.
 void taskStarted(String name, int totalWork)
          Notifies that the main task is beginning.
 void worked(int work)
          Notifies that a percentage of the work has been completed.
 
Methods inherited from class org.springframework.richclient.factory.AbstractControlFactory
createControlIfNecessary, getControl, isControlCreated, isSingleton, setSingleton
 
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DELAY_PROGRESS

public static final int DEFAULT_DELAY_PROGRESS
Progress bar creation is delayed by this ms

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values
Constructor Detail

StatusBarProgressMonitor

public StatusBarProgressMonitor()
Method Detail

createCancelButton

protected JButton createCancelButton()

createControl

protected JComponent createControl()
Description copied from class: AbstractControlFactory
Subclasses must override this method to create a new instance of the control that this factory produces.

Specified by:
createControl in class AbstractControlFactory
Returns:
The newly created control, never null.

createProgressBar

protected JProgressBar createProgressBar()

done

public void done()
Description copied from interface: ProgressMonitor
Notifies that the work is done; that is, either the main task is completed or the user cancelled it. done() can be called more than once; an implementation should be prepared to handle this case.

Specified by:
done in interface ProgressMonitor

getCancelIcon

public Icon getCancelIcon()

getProgressBar

protected JProgressBar getProgressBar()

hideProgress

protected void hideProgress()

isCanceled

public boolean isCanceled()
Description copied from interface: ProgressMonitor
Returns true if the user does some UI action to cancel this operation. (like hitting the Cancel button on the progress dialog). The long running operation typically polls isCanceled().

Specified by:
isCanceled in interface ProgressMonitor

setCanceled

public void setCanceled(boolean b)
Description copied from interface: ProgressMonitor
Attempts to cancel the monitored task.

Specified by:
setCanceled in interface ProgressMonitor

setCancelEnabled

public void setCancelEnabled(boolean enabled)

setCancelIcon

public void setCancelIcon(Icon icon)

subTaskStarted

public void subTaskStarted(String name)
Description copied from interface: ProgressMonitor
Notifies that a subtask of the main task is beginning. Subtasks are optional; the main task might not have subtasks.

Specified by:
subTaskStarted in interface ProgressMonitor
Parameters:
name - the name (or description) of the subtask

taskStarted

public void taskStarted(String name,
                        int totalWork)
Description copied from interface: ProgressMonitor
Notifies that the main task is beginning.

Specified by:
taskStarted in interface ProgressMonitor
Parameters:
name - the name (or description) of the main task
totalWork - the total number of work units into which the main task is been subdivided. If the value is 0 or UNKNOWN the implemenation is free to indicate progress in a way which doesn't require the total number of work units in advance. In general users should use the UNKNOWN value if they don't know the total amount of work units.

worked

public void worked(int work)
Description copied from interface: ProgressMonitor
Notifies that a percentage of the work has been completed. This is called by clients when the work is performed and is used to update the progress monitor.

Specified by:
worked in interface ProgressMonitor
Parameters:
work - the percentage complete (0..100)

setDelayProgress

public void setDelayProgress(int delayProgress)


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.