Package editor.util
Class ProgressFeedback
- java.lang.Object
-
- editor.util.ProgressFeedback
-
- All Implemented Interfaces:
IProgressCallback,java.awt.event.ActionListener,java.util.EventListener
public class ProgressFeedback extends java.lang.Object implements IProgressCallback, java.awt.event.ActionListener
A helper class for displaying aProgressWindowwhile a task executes in a worker thread.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProgressFeedback.ProgressFeedbackThread
-
Field Summary
Fields Modifier and Type Field Description private boolean_bAbortprivate boolean_bHideAbortButtonprivate boolean_bShowInStudioGlassPaneprivate boolean_changeLengthprivate java.lang.String_currentMessageprivate int_currentValueprivate int_lengthprivate ProgressPanel_ppprivate ProgressWindow_pwprivate java.lang.String_strNoticeprivate javax.swing.Timer_timerprivate static intUPDATE_DELAY
-
Constructor Summary
Constructors Modifier Constructor Description protectedProgressFeedback(java.lang.String strNotice, boolean bHideAbortButton, boolean bShowInStudioGlassPane)Construct a ProgressFeedback with a given text notice.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)(package private) voiddispose()Hides and disposes theProgressWindow.intgetProgress()booleanincrementProgress(java.lang.String strMessage, java.lang.String... args)booleanisAbort()Should the operation abort?voidoperationComplete()Signals that the operation is completestatic <T> TrunWithPossibleDialog(java.util.concurrent.Callable<T> callable, java.lang.String message)protected static ProgressFeedbackrunWithProgress(IRunnableWithProgress task, ProgressFeedback progressFeedback)static ProgressFeedbackrunWithProgress(java.lang.String strNotice, IRunnableWithProgress task)A helper method that executes a task in a worker thread and displays feedback in a progress windows.static ProgressFeedbackrunWithProgress(java.lang.String strNotice, IRunnableWithProgress task, boolean bHideAbortBtn)static ProgressFeedbackrunWithProgress(java.lang.String strNotice, IRunnableWithProgress task, boolean bHideAbortBtn, boolean bShowInStudioGlassPane)private voidsetCurrentMessage(java.lang.String strMessage, java.lang.String[] args)voidsetLength(int iLength)How long is this operation in units? For a StagedProgressFeedback, this moves to the next stageprivate static booleanshortWait(long delay, boolean[] done)private voidstartTimer()private voidstopTimer()booleanupdateProgress(int iProgress, java.lang.String strMessage, java.lang.String... args)Call this when a unit of progress completes.booleanupdateProgress(java.lang.String strMessage, java.lang.String... args)Call this to update the progress message without modifying the amount of progress completed.private static voidwaitForProgress(boolean[] done)
-
-
-
Field Detail
-
UPDATE_DELAY
private static final int UPDATE_DELAY
- See Also:
- Constant Field Values
-
_strNotice
private java.lang.String _strNotice
-
_pp
private ProgressPanel _pp
-
_pw
private ProgressWindow _pw
-
_bAbort
private boolean _bAbort
-
_bHideAbortButton
private boolean _bHideAbortButton
-
_bShowInStudioGlassPane
private boolean _bShowInStudioGlassPane
-
_currentMessage
private java.lang.String _currentMessage
-
_currentValue
private int _currentValue
-
_length
private int _length
-
_changeLength
private boolean _changeLength
-
_timer
private javax.swing.Timer _timer
-
-
Constructor Detail
-
ProgressFeedback
protected ProgressFeedback(java.lang.String strNotice, boolean bHideAbortButton, boolean bShowInStudioGlassPane)Construct a ProgressFeedback with a given text notice.- Parameters:
strNotice- The text notice to display in the ProgressWindow.bHideAbortButton- will hide abort buttonbShowInStudioGlassPane- will show in studio pane
-
-
Method Detail
-
runWithProgress
public static ProgressFeedback runWithProgress(java.lang.String strNotice, IRunnableWithProgress task)
A helper method that executes a task in a worker thread and displays feedback in a progress windows.- Parameters:
strNotice- The text notice to display in the ProgressWindow.task- The task to execute in a separate (worker) thread.
-
runWithProgress
public static ProgressFeedback runWithProgress(java.lang.String strNotice, IRunnableWithProgress task, boolean bHideAbortBtn)
-
runWithProgress
public static ProgressFeedback runWithProgress(java.lang.String strNotice, IRunnableWithProgress task, boolean bHideAbortBtn, boolean bShowInStudioGlassPane)
-
runWithProgress
protected static ProgressFeedback runWithProgress(IRunnableWithProgress task, ProgressFeedback progressFeedback)
-
runWithPossibleDialog
public static <T> T runWithPossibleDialog(java.util.concurrent.Callable<T> callable, java.lang.String message)
-
shortWait
private static boolean shortWait(long delay, boolean[] done)
-
waitForProgress
private static void waitForProgress(boolean[] done)
-
dispose
void dispose()
Hides and disposes theProgressWindow.
-
startTimer
private void startTimer()
-
stopTimer
private void stopTimer()
-
setLength
public void setLength(int iLength)
Description copied from interface:IProgressCallbackHow long is this operation in units? For a StagedProgressFeedback, this moves to the next stage- Specified by:
setLengthin interfaceIProgressCallback- Parameters:
iLength- The number of units the operation is expected to execute.
-
updateProgress
public boolean updateProgress(int iProgress, java.lang.String strMessage, java.lang.String... args)Description copied from interface:IProgressCallbackCall this when a unit of progress completes.- Specified by:
updateProgressin interfaceIProgressCallback- Parameters:
iProgress- The unit of progress completed.strMessage- A short message describing the progress.- Returns:
- Whether or not the operation should abort. True to abort operation.
-
incrementProgress
public boolean incrementProgress(java.lang.String strMessage, java.lang.String... args)- Specified by:
incrementProgressin interfaceIProgressCallback
-
setCurrentMessage
private void setCurrentMessage(java.lang.String strMessage, java.lang.String[] args)
-
updateProgress
public boolean updateProgress(java.lang.String strMessage, java.lang.String... args)Description copied from interface:IProgressCallbackCall this to update the progress message without modifying the amount of progress completed.- Specified by:
updateProgressin interfaceIProgressCallback
-
getProgress
public int getProgress()
- Specified by:
getProgressin interfaceIProgressCallback
-
isAbort
public boolean isAbort()
Description copied from interface:IProgressCallbackShould the operation abort?- Specified by:
isAbortin interfaceIProgressCallback- Returns:
- True if the operation should abort.
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener
-
operationComplete
public void operationComplete()
Description copied from interface:IProgressCallbackSignals that the operation is complete- Specified by:
operationCompletein interfaceIProgressCallback
-
-