Package com.biglybt.ui.swt.progress
Class ProgressReportingManager
java.lang.Object
com.biglybt.ui.swt.progress.ProgressReportingManager
- All Implemented Interfaces:
IProgressReportConstants
A manager that aggregates and forward progress information for long running operations
This is a non-intrusive implementation, such that, it does not directly manage any of the process; it simply receives and forwards information
The primary user of this class is the MainStatusBar
where it is used to display progress information
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ParameterListener
static final int
static final int
static final int
private static ProgressReportingManager
private boolean
Convenience variable tied to the parameter "auto_remove_inactive_items"private CopyOnWriteList
ACopyOnWriteList
ofIProgressReportingListener
private ProgressReporterStack
A custom stack to keep track ofProgressReporter
private int
Keeps count of allProgressReporter
created since this session started; is used as unique ID and hashCode for each instance ofProgressReporter
Fields inherited from interface com.biglybt.ui.swt.progress.IProgressReportConstants
AUTO_CLOSE, BORDER, MANAGER_EVENT_ADDED, MANAGER_EVENT_REMOVED, MANAGER_EVENT_UPDATED, MODAL, MSG_TYPE_ERROR, MSG_TYPE_INFO, MSG_TYPE_LOG, NONE, REPORT_TYPE_CANCEL, REPORT_TYPE_DISPOSED, REPORT_TYPE_DONE, REPORT_TYPE_ERROR, REPORT_TYPE_INIT, REPORT_TYPE_MODE_CHANGE, REPORT_TYPE_PROPERTY_CHANGED, REPORT_TYPE_RETRY, REPORTER_TYPE_DEFAULT, REPORTER_VISIBILITY_SYSTEM, REPORTER_VISIBILITY_USER, RETVAL_OK, RETVAL_OK_TO_DISPOSE, SHOW_TOOLBAR, STANDALONE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(IProgressReportingListener listener) addReporter
(String name) static void
private void
dispose()
Returns the current reporter, in other word, the last reporter to have reported anythingstatic final ProgressReportingManager
Returns the next active reporterprotected final int
Returns the next available ID that can be assigned to aProgressReporter
int
getReporterCount
(int whatToCount) Returns the number of reporters that have sent any event to this manager and have not been removedCOUNT_ERROR
- count all reporters in error stateCOUNT_ACTIVE
- count all reporters that are still activeCOUNT_ALL
- count all reportersgetReporters
(boolean onlyActive) Returns a modifiable list ofProgressReporter
s; manipulating this list has no effect on the internal list of reporters maintained by this managergetReportersArray
(boolean onlyActive) Returns a modifiable array ofProgressReporter
s; manipulating this array has no effect on the internal list of reporters maintained by this managerboolean
A convenience method for quickly determining whether more than one reporter is still active.private void
notifyListeners
(int eventType, IProgressReporter reporter) Notifies listeners that the givenProgressReporter
has been modifiedprotected void
notifyManager
(IProgressReporter reporter) Push this reporter on top of the stack, and notifies any listeners that a state change has occurredboolean
remove
(IProgressReporter reporter) Removes the givenProgressReporter
from this manager.void
removeListener
(IProgressReportingListener listener)
-
Field Details
-
INSTANCE
-
configListenerAutoRemoveInactive
-
progressReporters
A custom stack to keep track ofProgressReporter
-
reporterCounter
private int reporterCounterKeeps count of allProgressReporter
created since this session started; is used as unique ID and hashCode for each instance ofProgressReporter
-
COUNT_ALL
public static final int COUNT_ALL- See Also:
-
COUNT_ACTIVE
public static final int COUNT_ACTIVE- See Also:
-
COUNT_ERROR
public static final int COUNT_ERROR- See Also:
-
listeners
ACopyOnWriteList
ofIProgressReportingListener
-
isAutoRemove
private boolean isAutoRemoveConvenience variable tied to the parameter "auto_remove_inactive_items"
-
-
Constructor Details
-
ProgressReportingManager
private ProgressReportingManager()Private constructor
-
-
Method Details
-
getInstance
-
destroyInstance
public static void destroyInstance() -
dispose
private void dispose() -
addReporter
-
addReporter
-
getReporterCount
public int getReporterCount(int whatToCount) Returns the number of reporters that have sent any event to this manager and have not been removedCOUNT_ERROR
- count all reporters in error stateCOUNT_ACTIVE
- count all reporters that are still activeCOUNT_ALL
- count all reporters
- Parameters:
whatToCount
- one of the above constants; will default toCOUNT_ALL
if the parameter is unrecognized- Returns:
-
hasMultipleActive
public boolean hasMultipleActive()A convenience method for quickly determining whether more than one reporter is still active. This method can be much quicker than callinginvalid reference
#getReporterCount()
- Returns:
true
if there are at least 2 active reporters;false
otherwise
-
getNextActiveReporter
Returns the next active reporter- Returns:
- the next reporter that is still active;
null
if none are active or no reporters are found
-
getCurrentReporter
Returns the current reporter, in other word, the last reporter to have reported anything- Returns:
- the last reporter;
null
if none are found
-
getReporters
Returns a modifiable list ofProgressReporter
s; manipulating this list has no effect on the internal list of reporters maintained by this manager- Parameters:
onlyActive
-true
to filter the list to only include those reporters that are still active- Returns:
- a sorted List of
ProgressReporter
where the oldest reporter would be at position 0
-
getReportersArray
Returns a modifiable array ofProgressReporter
s; manipulating this array has no effect on the internal list of reporters maintained by this manager- Parameters:
onlyActive
-true
to filter the array to only include those reporters that are still active- Returns:
- a sorted array of
ProgressReporter
where the oldest reporter would be at position 0
-
remove
Removes the givenProgressReporter
from this manager. This has the effect that any subsequent event reported by the same reporter will not be captured nor forwarded by this manager- Parameters:
reporter
-- Returns:
-
addListener
- Parameters:
listener
-
-
removeListener
- Parameters:
listener
-
-
notifyListeners
Notifies listeners that the givenProgressReporter
has been modified- Parameters:
eventType
-reporter
-
-
notifyManager
Push this reporter on top of the stack, and notifies any listeners that a state change has occurred- Parameters:
reporter
-
-
getNextAvailableID
protected final int getNextAvailableID()Returns the next available ID that can be assigned to aProgressReporter
- Returns:
- int the next available ID
-