Class NullProgressMonitor
- java.lang.Object
-
- org.openstreetmap.josm.gui.progress.NullProgressMonitor
-
- All Implemented Interfaces:
ProgressMonitor
public final class NullProgressMonitor extends java.lang.Object implements ProgressMonitor
A singleton progress monitor that does nothing.- Since:
- 1811
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.progress.ProgressMonitor
ProgressMonitor.CancelListener
-
-
Field Summary
Fields Modifier and Type Field Description static ProgressMonitorINSTANCEThe unique instance-
Fields inherited from interface org.openstreetmap.josm.gui.progress.ProgressMonitor
ALL_TICKS, DEFAULT_TICKS
-
-
Constructor Summary
Constructors Modifier Constructor Description privateNullProgressMonitor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCancelListener(ProgressMonitor.CancelListener listener)Add listener for user abort actionvoidappendLogMessage(java.lang.String message)Appends a message to the log managed by the progress monitor.voidbeginTask(java.lang.String title)Starts this progress monitor.voidbeginTask(java.lang.String title, int ticks)Starts this progress monitor.voidcancel()Abort current operation, usually called when user somehow requested an abortProgressMonitorcreateSubTaskMonitor(int ticks, boolean internal)Creates subtasks monitor.voidfinishTask()Finish this progress monitor, close the dialog or inform the parent progress monitor that it can continue with other tasks.ProgressTaskIdgetProgressTaskId()Returns the task ID of the progress dialog Should be used only by PleaseWaitRunnableintgetTicks()Get the current number of work unitsintgetTicksCount()Get the total number of work unitsjava.awt.ComponentgetWindowParent()Return the parent windows of progress dialogvoidindeterminateSubTask(java.lang.String title)Subtask that will show progress running back and forthvoidinvalidate()Can be used if method receives ProgressMonitor, but it's not interested progress monitoring.booleanisCanceled()Returns the state of user abortsvoidremoveCancelListener(ProgressMonitor.CancelListener listener)Remove listener for user abort actionvoidsetCustomText(java.lang.String text)Shows additional textvoidsetExtraText(java.lang.String text)Show extra text after normal task title.voidsetProgressTaskId(ProgressTaskId taskId)Set the task ID of the progress dialog Should be used only by PleaseWaitRunnable.voidsetTicks(int ticks)Set the current number of work unitsvoidsetTicksCount(int ticks)Set the total number of work unitsvoidsubTask(java.lang.String title)Normal subtaskvoidworked(int ticks)Increase number of already done work units by ticks
-
-
-
Field Detail
-
INSTANCE
public static final ProgressMonitor INSTANCE
The unique instance
-
-
Constructor Detail
-
NullProgressMonitor
private NullProgressMonitor()
-
-
Method Detail
-
addCancelListener
public void addCancelListener(ProgressMonitor.CancelListener listener)
Description copied from interface:ProgressMonitorAdd listener for user abort action- Specified by:
addCancelListenerin interfaceProgressMonitor- Parameters:
listener- the listener for cancel operation
-
beginTask
public void beginTask(java.lang.String title)
Description copied from interface:ProgressMonitorStarts this progress monitor. Must be called exactly once Ticks count is set to default value- Specified by:
beginTaskin interfaceProgressMonitor- Parameters:
title- title text of the task
-
beginTask
public void beginTask(java.lang.String title, int ticks)
Description copied from interface:ProgressMonitorStarts this progress monitor. Must be called exactly once- Specified by:
beginTaskin interfaceProgressMonitor- Parameters:
title- title text of the taskticks- number of work units (seeProgressMonitor.setTicksCount(int ticks))
-
cancel
public void cancel()
Description copied from interface:ProgressMonitorAbort current operation, usually called when user somehow requested an abort- Specified by:
cancelin interfaceProgressMonitor
-
createSubTaskMonitor
public ProgressMonitor createSubTaskMonitor(int ticks, boolean internal)
Description copied from interface:ProgressMonitorCreates subtasks monitor.- Specified by:
createSubTaskMonitorin interfaceProgressMonitor- Parameters:
ticks- Number of work units that should be done when subtask finishesinternal- If true then subtask can't modify task title/custom text- Returns:
- subtasks monitor
-
finishTask
public void finishTask()
Description copied from interface:ProgressMonitorFinish this progress monitor, close the dialog or inform the parent progress monitor that it can continue with other tasks. Must be called at least once (if called multiply times then further calls are ignored)- Specified by:
finishTaskin interfaceProgressMonitor
-
getTicks
public int getTicks()
Description copied from interface:ProgressMonitorGet the current number of work units- Specified by:
getTicksin interfaceProgressMonitor- Returns:
- Number of work units already done
-
indeterminateSubTask
public void indeterminateSubTask(java.lang.String title)
Description copied from interface:ProgressMonitorSubtask that will show progress running back and forth- Specified by:
indeterminateSubTaskin interfaceProgressMonitor- Parameters:
title- Can benull, in that case task title is not changed
-
invalidate
public void invalidate()
Description copied from interface:ProgressMonitorCan be used if method receives ProgressMonitor, but it's not interested progress monitoring. Basically replacesProgressMonitor.beginTask(String)andProgressMonitor.finishTask()This method can be also used in finally section if method expects that some exceptions might prevent it from passing progressMonitor away. IfProgressMonitor.beginTask(String)was already called then this method does nothing.- Specified by:
invalidatein interfaceProgressMonitor
-
isCanceled
public boolean isCanceled()
Description copied from interface:ProgressMonitorReturns the state of user aborts- Specified by:
isCanceledin interfaceProgressMonitor- Returns:
trueif user aborted operation
-
removeCancelListener
public void removeCancelListener(ProgressMonitor.CancelListener listener)
Description copied from interface:ProgressMonitorRemove listener for user abort action- Specified by:
removeCancelListenerin interfaceProgressMonitor- Parameters:
listener- the listener for cancel operation
-
setCustomText
public void setCustomText(java.lang.String text)
Description copied from interface:ProgressMonitorShows additional text- Specified by:
setCustomTextin interfaceProgressMonitor- Parameters:
text- custom text
-
setExtraText
public void setExtraText(java.lang.String text)
Description copied from interface:ProgressMonitorShow extra text after normal task title. Hack for ProgressInputStream to show number of kB already downloaded- Specified by:
setExtraTextin interfaceProgressMonitor- Parameters:
text- extra text
-
appendLogMessage
public void appendLogMessage(java.lang.String message)
Description copied from interface:ProgressMonitorAppends a message to the log managed by the progress monitor.- Specified by:
appendLogMessagein interfaceProgressMonitor- Parameters:
message- the log message. Ignored if null or white space only.
-
setTicks
public void setTicks(int ticks)
Description copied from interface:ProgressMonitorSet the current number of work units- Specified by:
setTicksin interfaceProgressMonitor- Parameters:
ticks- Number of work units already done
-
setTicksCount
public void setTicksCount(int ticks)
Description copied from interface:ProgressMonitorSet the total number of work units- Specified by:
setTicksCountin interfaceProgressMonitor- Parameters:
ticks- Number of total work units
-
subTask
public void subTask(java.lang.String title)
Description copied from interface:ProgressMonitorNormal subtask- Specified by:
subTaskin interfaceProgressMonitor- Parameters:
title- Can benull, in that case task title is not changed
-
worked
public void worked(int ticks)
Description copied from interface:ProgressMonitorIncrease number of already done work units by ticks- Specified by:
workedin interfaceProgressMonitor- Parameters:
ticks- number of ticks to add
-
getTicksCount
public int getTicksCount()
Description copied from interface:ProgressMonitorGet the total number of work units- Specified by:
getTicksCountin interfaceProgressMonitor- Returns:
- Number of total work units
-
setProgressTaskId
public void setProgressTaskId(ProgressTaskId taskId)
Description copied from interface:ProgressMonitorSet the task ID of the progress dialog Should be used only by PleaseWaitRunnable. If taskId<> nullthen "In background" button will be shown- Specified by:
setProgressTaskIdin interfaceProgressMonitor- Parameters:
taskId- the task ID
-
getProgressTaskId
public ProgressTaskId getProgressTaskId()
Description copied from interface:ProgressMonitorReturns the task ID of the progress dialog Should be used only by PleaseWaitRunnable- Specified by:
getProgressTaskIdin interfaceProgressMonitor- Returns:
- the task ID
-
getWindowParent
public java.awt.Component getWindowParent()
Description copied from interface:ProgressMonitorReturn the parent windows of progress dialog- Specified by:
getWindowParentin interfaceProgressMonitor- Returns:
- component suitable as parent for dialogs that wants to be shown in front of progress dialog
-
-