public class LoggerProgressMonitor extends Object implements ProgressMonitor
Logger
.Modifier and Type | Class and Description |
---|---|
static class |
LoggerProgressMonitor.LogLevel
The level to use for logging.
|
Modifier and Type | Field and Description |
---|---|
static String |
MESSAGE_VARIABLE_NAME
The variable containing the task-name (i.e.
|
static String |
MESSAGE_VARIABLE_PERCENTAGE
The variable containing the current percentage.
|
Constructor and Description |
---|
LoggerProgressMonitor(Logger logger)
Create a monitor logging to the specified logger.
|
Modifier and Type | Method and Description |
---|---|
void |
beginTask(String name,
int totalWork)
Notifies that the main task is beginning.
|
void |
done()
Notifies that the work is done; that is, either the main task is completed
or the user canceled it.
|
Logger |
getLogger()
Get the logger to which this monitor is writing.
|
LoggerProgressMonitor.LogLevel |
getLogLevel()
Get the log-level that is used when writing to the logger.
|
float |
getLogMinPercentageDifference()
Get the minimum percentage difference to trigger a new log message.
|
long |
getLogMinPeriodMSec()
Get the minimum log period in milliseconds.
|
String |
getMessage()
Get the log-message.
|
void |
internalWorked(double worked)
Internal method to handle scaling correctly.
|
boolean |
isCanceled()
Returns whether cancelation of current operation has been requested.
|
void |
setCanceled(boolean canceled)
Sets the cancel state to the given value.
|
void |
setLogLevel(LoggerProgressMonitor.LogLevel logLevel)
Set the log-level to use when writing to the logger.
|
void |
setLogMinPercentageDifference(float logMinPercentageDifference)
Set the minimum period between log messages in milliseconds.
|
void |
setLogMinPeriodMSec(long logMinPeriodMSec)
Set the minimum period between log messages in milliseconds.
|
void |
setMessage(String message)
Set the message which will be written to the logger.
|
void |
setTaskName(String name)
Sets the task name to the given value.
|
void |
subTask(String name)
Notifies that a subtask of the main task is beginning.
|
void |
worked(int work)
Notifies that a given number of work unit of the main task
has been completed.
|
public static final String MESSAGE_VARIABLE_NAME
ProgressMonitor.beginTask(String, int)
method.setMessage(String)
,
Constant Field Valuespublic static final String MESSAGE_VARIABLE_PERCENTAGE
setMessage(String)
,
Constant Field Valuespublic LoggerProgressMonitor(Logger logger)
logger
- the logger to write to. Must not be null
.public String getMessage()
setMessage(String)
.setMessage(String)
public void setMessage(String message)
Set the message which will be written to the logger.
Before writing to the logger, the variables contained in this message are replaced by their actual values. The following variables can be used:
message
- the message to be logged.getMessage()
public Logger getLogger()
LoggerProgressMonitor(Logger)
before.public long getLogMinPeriodMSec()
setLogMinPeriodMSec(long)
.setLogMinPeriodMSec(long)
public void setLogMinPeriodMSec(long logMinPeriodMSec)
Set the minimum period between log messages in milliseconds.
In order to prevent log flooding as well as to improve performance,
calling worked(int)
or internalWorked(double)
will only cause
a log message to be printed, if at least one of the following criteria are met:
logMinPeriodMSec
(i.e. by this method).
the min-percentage-difference
.
logMinPeriodMSec
- the minimum period between log messages.getLogMinPeriodMSec()
,
setLogMinPercentageDifference(float)
public float getLogMinPercentageDifference()
setLogMinPercentageDifference(float)
.setLogMinPercentageDifference(float)
public void setLogMinPercentageDifference(float logMinPercentageDifference)
Set the minimum period between log messages in milliseconds.
In order to prevent log flooding as well as to improve performance,
calling worked(int)
or internalWorked(double)
will only cause
a log message to be printed, if at least one of the following criteria are met:
logMinPeriodMSec
.
logMinPercentageDifference
(i.e. by this method).
logMinPercentageDifference
- the minimum percentage difference between log messages.getLogMinPercentageDifference()
,
setLogMinPeriodMSec(long)
public void beginTask(String name, int totalWork)
ProgressMonitor
beginTask
in interface ProgressMonitor
name
- the name (or description) of the main tasktotalWork
- the total number of work units into which
the main task is been subdivided. If the value is UNKNOWN
the implementation is free to indicate progress in a way which
doesn't require the total number of work units in advance.public void done()
ProgressMonitor
done
in interface ProgressMonitor
public void internalWorked(double worked)
ProgressMonitor
Note: EclipseRCP is strange!
internalWorked
in interface ProgressMonitor
worked
- the amount of work donepublic LoggerProgressMonitor.LogLevel getLogLevel()
public void setLogLevel(LoggerProgressMonitor.LogLevel logLevel)
logLevel
- the LoggerProgressMonitor.LogLevel
to be used.public boolean isCanceled()
ProgressMonitor
If this is true
, the long-running operation should
throw an OperationCanceledException
.
isCanceled
in interface ProgressMonitor
true
if cancellation has been requested,
and false
otherwiseProgressMonitor.setCanceled(boolean)
public void setCanceled(boolean canceled)
ProgressMonitor
setCanceled
in interface ProgressMonitor
canceled
- true
indicates that cancelation has
been requested (but not necessarily acknowledged);
false
clears this flagProgressMonitor.isCanceled()
public void setTaskName(String name)
ProgressMonitor
setTaskName
in interface ProgressMonitor
name
- the name (or description) of the main taskProgressMonitor.beginTask(java.lang.String, int)
public void subTask(String name)
ProgressMonitor
subTask
in interface ProgressMonitor
name
- the name (or description) of the subtaskpublic void worked(int work)
ProgressMonitor
worked
in interface ProgressMonitor
work
- the number of work units just completedCopyright © 2013-2014. All Rights Reserved.