Class ProgressReporterStack

java.lang.Object
com.biglybt.ui.swt.progress.ProgressReporterStack

class ProgressReporterStack extends Object
A convenience Stack for tracking ProgressReporters

When a reporter is pushed onto the stack we remove any other occurrences of the same reporter so that there is at most one instance of a particular reporter in the stack at any time

  • Field Details

    • reporterStack

      private Stack reporterStack
    • lockObject

      private Object lockObject
      A dummy object used purely for implementing synchronized blocks
  • Constructor Details

    • ProgressReporterStack

      ProgressReporterStack()
  • Method Details

    • push

      public void push(IProgressReporter reporter)
      Pushes the given reporter on top of the stack; additionally remove any other occurrence of the reporter.
      Parameters:
      reporter -
    • peek

      public IProgressReporter peek()
      Returns the reporter at the top of the stack
      Returns:
    • remove

      public boolean remove(IProgressReporter reporter)
      Remove the given ProgressReporter;
      Returns:
      true if the given reporter is found; otherwise false
    • contains

      public boolean contains(IProgressReporter reporter)
      Returns whether or not the given IProgressReporter is already in the stack
      Parameters:
      reporter -
      Returns:
    • pop

      public IProgressReporter pop()
      Remove and return the reporter at the top of the stack
      Returns:
    • trim

      public void trim()
      Trim the list by removing all inactive reporters
    • getReporters

      public List getReporters(boolean onlyActive)
      Returns a list of reporters; this list can safely be manipulated because it is not directly referencing the internal list
      Parameters:
      onlyActive - true to return only reporters that are still active, false to return all reporters
      Returns:
      List
    • size

      public int size()
    • getActiveCount

      public int getActiveCount()
      Returns the number of reporters in the stack that are still active
      Returns:
    • getErrorCount

      public int getErrorCount()
      Returns the number of reporters in the stack that are in error state
      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 calling getActiveCount() and inspecting the returned value if the number of reporters is high since we may not have to go through the entire list before getting the result
      Returns:
      true if there are at least 2 active reporters; false otherwise
    • getNextActiveReporter

      public IProgressReporter getNextActiveReporter()
      Get the next active reporter.

      NOTE: this is different from calling peek() since the next active reporter may not be at the top of the stack

      Returns:
      ProgressReporter the next reporter on the stack that is still active; null if none are active or none are found