public class TLcdStatusEvent<T> extends EventObject
EventObject
that is sent out to ILcdStatusListener
objects whenever the status of a process changes.
It has the following properties:
Modifier and Type | Class and Description |
---|---|
static class |
TLcdStatusEvent.Progress<T>
Helper object for sending out status events for a particular task.
|
static class |
TLcdStatusEvent.Severity
Enumeration representing the severity of the
TLcdStatusEvent |
Modifier and Type | Field and Description |
---|---|
static int |
END_BUSY
Indicates that the process has ended.
|
static int |
MESSAGE
Indicates that the event contains a message.
|
static int |
PROGRESS
Indicates that the process is in progress.
|
static int |
START_BUSY
Indicates that the process has started.
|
source
Constructor and Description |
---|
TLcdStatusEvent(T aSource,
int aID,
String aMessage)
Deprecated.
Use one of the factory methods available on this class instead.
|
TLcdStatusEvent(T aSource,
int aID,
String aMessage,
double aProgress)
Deprecated.
Use one of the factory methods available on this class instead.
|
TLcdStatusEvent(T aSource,
int aID,
String aMessage,
double aProgress,
boolean aBlockingHint)
Deprecated.
Use one of the factory methods available on this class instead.
|
Modifier and Type | Method and Description |
---|---|
static <T> TLcdStatusEvent<T> |
cloneAs(T aSource,
TLcdStatusEvent<?> aStatusEvent)
Returns a clone of
aStatusEvent where the source is replaced by aSource . |
int |
getID()
Returns the ID of this TLcdStatusEvent.
|
String |
getMessage()
Returns the message of this TLcdStatusEvent.
|
double |
getProgress()
Returns the progress value of this TLcdStatusEvent.
|
TLcdStatusEvent.Severity |
getSeverity()
Returns the severity of this message
|
T |
getSource() |
String |
getTaskID()
Returns an identifier for the task this update pertains to.
|
double |
getValue()
Returns the progress value of this TLcdStatusEvent.
|
boolean |
isBlockingHint()
Returns the blocking hint.
|
boolean |
isProgressIndeterminate()
Returns
true if the progress is indeterminate. |
static <T> void |
sendMessage(ILcdStatusListener<T> aStatusListener,
T aSource,
String aMessage,
TLcdStatusEvent.Severity aSeverity)
Sends a new
message status event. |
void |
setBlockingHint(boolean aBlockingHint)
Sets the blocking hint.
|
void |
setMessage(String aMessage)
Sets the message of this event to aMessage.
|
static <T> TLcdStatusEvent.Progress<T> |
startIndeterminateProgress(ILcdStatusListener<T> aListener,
T aSource,
String aMessage)
Starts reporting of a new task where the progress is not known.
|
static <T> TLcdStatusEvent.Progress<T> |
startProgress(ILcdStatusListener<T> aListener,
T aSource,
String aMessage)
Starts reporting of a new task where the progress is known.
|
String |
toString()
Returns a human readable description of this event, including all its properties.
|
public static final int MESSAGE
public static final int START_BUSY
public static final int END_BUSY
public static final int PROGRESS
@Deprecated public TLcdStatusEvent(T aSource, int aID, String aMessage)
TLcdStatusEvent
with the given information.
This event will return true
for isProgressIndeterminate()
because the progress value was not
specified. This constructor should only be used when the progress cannot be
predicted, for instance when waiting for a connection over the internet.
When progress can be predicted,
TLcdStatusEvent(Object, int, String, double)
should be used.
getValue()
will return 0.5
.
aSource
- the sender of the event.aID
- the ID of the event: MESSAGE, START_BUSY, END_BUSY, PROGRESS.aMessage
- a message describing the event.@Deprecated public TLcdStatusEvent(T aSource, int aID, String aMessage, double aProgress)
TLcdStatusEvent
with the given information.
The given value must lie in the range [0,1] or be NaN. If the value lies outside this
range it will be clamped to this range.
If the value is not NaN isProgressIndeterminate()
will return false
. Otherwise
isProgressIndeterminate()
will return true
.aSource
- the sender of the event.aID
- the ID of the event: MESSAGE, START_BUSY, END_BUSY, PROGRESS.aMessage
- a message describing the event.aProgress
- the progress of the event. This value must lie in the range [0,1] or be NaN.@Deprecated public TLcdStatusEvent(T aSource, int aID, String aMessage, double aProgress, boolean aBlockingHint)
TLcdStatusEvent
with the given information.
The given value must lie in the range [0,1] or be NaN. If the value lies outside this
range it will be clamped to this range.
If the value is not NaN isProgressIndeterminate()
will return false
. Otherwise
isProgressIndeterminate()
will return true
.aSource
- the sender of the event.aID
- the ID of the event: MESSAGE, START_BUSY, END_BUSY, PROGRESS.aMessage
- a message describing the event.aProgress
- the progress of the event. This value must lie in the range [0,1] or be NaN.aBlockingHint
- the blocking hint value.public static <T> void sendMessage(ILcdStatusListener<T> aStatusListener, T aSource, String aMessage, TLcdStatusEvent.Severity aSeverity)
message
status event.aStatusListener
- The listener to which the event must be sendaSource
- The source of the eventaMessage
- The messageaSeverity
- The severity of the messagepublic static <T> TLcdStatusEvent.Progress<T> startProgress(ILcdStatusListener<T> aListener, T aSource, String aMessage)
startIndeterminateProgress(ILcdStatusListener, Object, String)
when the progress is unknown.aListener
- The listener to inform of the statusaSource
- The source of the eventaMessage
- The messageTLcdStatusEvent.Progress
public static <T> TLcdStatusEvent.Progress<T> startIndeterminateProgress(ILcdStatusListener<T> aListener, T aSource, String aMessage)
startProgress(ILcdStatusListener, Object, String)
when the progress is known.aListener
- The listener to inform of the statusaSource
- The source of the eventaMessage
- The messageTLcdStatusEvent.Progress
public static <T> TLcdStatusEvent<T> cloneAs(T aSource, TLcdStatusEvent<?> aStatusEvent)
aStatusEvent
where the source is replaced by aSource
.
A typical use case for this method is if you have to forward status events from a delegate object, e.g. when
writing a decorator.aSource
- The source for the returned status eventaStatusEvent
- The event to cloneaStatusEvent
where the source has been replaced by aSource
public T getSource()
getSource
in class EventObject
public String getTaskID()
startProgress(ILcdStatusListener, Object, String)
and
startIndeterminateProgress(ILcdStatusListener, Object, String)
, and reused when calling methods on the progress
objects.
In all other cases, the name of the thread that created the event is returned.public boolean isProgressIndeterminate()
true
if the progress is indeterminate. This means the
sender of the event has no clue about what progress has been made, and
therefore getValue()
does not return a truly meaningful value.
This can happen for instance when waiting for a connection over the
internet.
Returns false
if the progress is defined. This means getValue()
returns a meaningful value.
True
if progress is indeterminate, false
otherwise.public String getMessage()
setMessage(java.lang.String)
public void setMessage(String aMessage)
aMessage
- the message of this TLcdStatusEvent.getMessage()
public double getValue()
Before using this method, it is useful to use isProgressIndeterminate()
to find out if the value is truly
meaningful.
getProgress()
public double getProgress()
isProgressIndeterminate()
returns false
. Otherwise the returned value will be NaN.public int getID()
public boolean isBlockingHint()
Note that this is only a hint; no assumptions can be made that the receiver of this event sticks to this hint.
Default is true.
setBlockingHint(boolean)
public void setBlockingHint(boolean aBlockingHint)
true
means the receiver of the event is suggested
to block the user interface. If false, the receiver of the event is
suggested not to block the user interface, so to perform the task on the
background.Note that this is only a hint; no assumptions can be made that the receiver of this event sticks to this hint.
aBlockingHint
- True to suggest blocking, false to suggest
non-blocking.isBlockingHint()
public TLcdStatusEvent.Severity getSeverity()
public String toString()
toString
in class EventObject