public abstract class AbstractProgressMonitor extends Object implements ProgressMonitor
Modifier and Type | Class and Description |
---|---|
private static class |
AbstractProgressMonitor.Request |
protected static class |
AbstractProgressMonitor.State |
ProgressMonitor.CancelListener
Modifier and Type | Field and Description |
---|---|
private CancelHandler |
cancelHandler |
private int |
childTicks |
private AbstractProgressMonitor |
currentChild |
private String |
customText |
private String |
extraText |
private boolean |
intermediateTask |
private AbstractProgressMonitor.Request |
requestedState |
private Queue<AbstractProgressMonitor.Request> |
requests |
private String |
shownCustomText |
private String |
shownTitle |
protected AbstractProgressMonitor.State |
state |
private String |
taskTitle |
private int |
ticks |
private int |
ticksCount |
ALL_TICKS, DEFAULT_TICKS
Modifier | Constructor and Description |
---|---|
protected |
AbstractProgressMonitor(CancelHandler cancelHandler) |
Modifier and Type | Method and Description |
---|---|
void |
addCancelListener(ProgressMonitor.CancelListener listener)
Add listener for user abort action
|
void |
appendLogMessage(String message)
Default implementation is empty.
|
private void |
applyChildRequest(AbstractProgressMonitor.Request request) |
private void |
applyThisRequest(AbstractProgressMonitor.Request request) |
void |
beginTask(String title)
Starts this progress monitor.
|
void |
beginTask(String title,
int ticks)
Starts this progress monitor.
|
void |
cancel()
Abort current operation, usually called when user somehow requested an abort
|
protected void |
checkState(AbstractProgressMonitor.State... expectedStates) |
protected void |
childFinished(AbstractProgressMonitor child) |
protected void |
childSetCustomText(AbstractProgressMonitor child,
String customText) |
protected void |
childSetIntermediate(AbstractProgressMonitor child,
boolean value) |
protected void |
childSetProgress(AbstractProgressMonitor child,
double value) |
protected void |
childSetTitle(AbstractProgressMonitor child,
String title) |
ProgressMonitor |
createSubTaskMonitor(int ticks,
boolean internal)
Creates subtasks monitor.
|
protected abstract void |
doBeginTask() |
protected abstract void |
doFinishTask() |
protected abstract void |
doSetCustomText(String title) |
protected abstract void |
doSetIntermediate(boolean value) |
protected abstract void |
doSetTitle(String title) |
void |
finishTask()
Finish this progress monitor, close the dialog or inform the parent progress monitor
that it can continue with other tasks.
|
private AbstractProgressMonitor.Request |
getRequest(AbstractProgressMonitor child) |
int |
getTicks()
Get the current number of work units
|
int |
getTicksCount()
Get the total number of work units
|
void |
indeterminateSubTask(String title)
Subtask that will show progress running back and forth
|
private void |
internalUpdateProgress(double childProgress) |
void |
invalidate()
Can be used if method receive ProgressMonitor but it's not interested progress monitoring.
|
boolean |
isCanceled()
Returns the state of user aborts
|
void |
removeCancelListener(ProgressMonitor.CancelListener listener)
Remove listener for user abort action
|
private void |
resetState() |
void |
setCustomText(String text)
Shows additional text
|
void |
setExtraText(String text)
Show extra text after normal task title.
|
void |
setTicks(int ticks)
Set the current number of work units
|
void |
setTicksCount(int ticks)
Set the total number of work units
|
void |
subTask(String title)
Normal subtask
|
(package private) abstract void |
updateProgress(double value) |
void |
worked(int ticks)
Increase number of already done work units by ticks
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProgressTaskId, getWindowParent, setProgressTaskId
private final CancelHandler cancelHandler
protected AbstractProgressMonitor.State state
private int ticksCount
private int ticks
private int childTicks
private String customText
private String shownTitle
private String shownCustomText
private boolean intermediateTask
private final Queue<AbstractProgressMonitor.Request> requests
private AbstractProgressMonitor currentChild
private AbstractProgressMonitor.Request requestedState
protected AbstractProgressMonitor(CancelHandler cancelHandler)
protected abstract void doBeginTask()
protected abstract void doFinishTask()
protected abstract void doSetIntermediate(boolean value)
protected abstract void doSetTitle(String title)
protected abstract void doSetCustomText(String title)
protected void checkState(AbstractProgressMonitor.State... expectedStates)
public void beginTask(String title)
ProgressMonitor
beginTask
in interface ProgressMonitor
title
- title text of the taskpublic void beginTask(String title, int ticks)
ProgressMonitor
beginTask
in interface ProgressMonitor
title
- title text of the taskticks
- number of work units (see ProgressMonitor.setTicksCount(int ticks)
)public void finishTask()
ProgressMonitor
finishTask
in interface ProgressMonitor
public void invalidate()
ProgressMonitor
ProgressMonitor.beginTask(String)
and ProgressMonitor.finishTask()
This method can be also used in finally section if method expects that some exception
might prevent it from passing progressMonitor away. If ProgressMonitor.beginTask(String)
was
already called then this method does nothing.invalidate
in interface ProgressMonitor
public void subTask(String title)
ProgressMonitor
subTask
in interface ProgressMonitor
title
- Can be null
, in that case task title is not changedpublic void indeterminateSubTask(String title)
ProgressMonitor
indeterminateSubTask
in interface ProgressMonitor
title
- Can be null
, in that case task title is not changedpublic void setCustomText(String text)
ProgressMonitor
setCustomText
in interface ProgressMonitor
text
- custom textpublic void setExtraText(String text)
ProgressMonitor
setExtraText
in interface ProgressMonitor
text
- extra textpublic void appendLogMessage(String message)
appendLogMessage
in interface ProgressMonitor
message
- the log message. Ignored if null or white space only.private void resetState()
public void cancel()
ProgressMonitor
cancel
in interface ProgressMonitor
public boolean isCanceled()
ProgressMonitor
isCanceled
in interface ProgressMonitor
true
if user aborted operationpublic void addCancelListener(ProgressMonitor.CancelListener listener)
ProgressMonitor
addCancelListener
in interface ProgressMonitor
listener
- the listener for cancel operationpublic void removeCancelListener(ProgressMonitor.CancelListener listener)
ProgressMonitor
removeCancelListener
in interface ProgressMonitor
listener
- the listener for cancel operationabstract void updateProgress(double value)
public void setTicks(int ticks)
ProgressMonitor
setTicks
in interface ProgressMonitor
ticks
- Number of work units already donepublic void setTicksCount(int ticks)
ProgressMonitor
setTicksCount
in interface ProgressMonitor
ticks
- Number of total work unitspublic void worked(int ticks)
ProgressMonitor
worked
in interface ProgressMonitor
ticks
- number of ticks to addprivate void internalUpdateProgress(double childProgress)
public int getTicks()
ProgressMonitor
getTicks
in interface ProgressMonitor
public int getTicksCount()
ProgressMonitor
getTicksCount
in interface ProgressMonitor
public ProgressMonitor createSubTaskMonitor(int ticks, boolean internal)
ProgressMonitor
createSubTaskMonitor
in interface ProgressMonitor
ticks
- Number of work units that should be done when subtask finishesinternal
- If true then subtask can't modify task title/custom textprivate void applyChildRequest(AbstractProgressMonitor.Request request)
private void applyThisRequest(AbstractProgressMonitor.Request request)
protected void childFinished(AbstractProgressMonitor child)
private AbstractProgressMonitor.Request getRequest(AbstractProgressMonitor child)
protected void childSetProgress(AbstractProgressMonitor child, double value)
protected void childSetTitle(AbstractProgressMonitor child, String title)
protected void childSetCustomText(AbstractProgressMonitor child, String customText)
protected void childSetIntermediate(AbstractProgressMonitor child, boolean value)