Package ghidra.util.task
Class SwingUpdateManager
java.lang.Object
ghidra.util.task.AbstractSwingUpdateManager
ghidra.util.task.SwingUpdateManager
A class to allow clients to buffer events. UI components may receive numbers events to make
changes to their underlying data model. Further, for many of these clients, it is sufficient
to perform one update to capture all of the changes. In this scenario, the client can use this
class to keep pushing off internal updates until: 1) the flurry of events has settled down, or
2) some specified amount of time has expired.
The various methods dictate when the client will get a callback:
update()
- if this is the first call toupdate
, then do the work immediately; otherwise, buffer the update request until the timeout has expired.updateNow()
- perform the callback now.updateLater()
- buffer the update request until the timeout has expired.- Non-blocking update now - this is a conceptual use-case, where the client wishes to perform an
immediate update, but not during the current Swing event. To achieve
this, you could call something like:
SwingUtilities.invokeLater(() -> updateManager.updateNow());
This class is safe to use in a multi-threaded environment. State variables are guarded via synchronization on this object. The Swing thread is used to perform updates, which guarantees that only one update will happen at a time.
-
Field Summary
Fields inherited from class ghidra.util.task.AbstractSwingUpdateManager
DEFAULT_MAX_DELAY, DEFAULT_MIN_DELAY, DEFAULT_NAME, isWorking, MIN_DELAY_FLOOR, NONE, timer
-
Constructor Summary
ConstructorDescriptionSwingUpdateManager
(int minDelay, int maxDelay, Runnable r) Constructs a new SwingUpdateManagerSwingUpdateManager
(int minDelay, int maxDelay, String name, Runnable r) Constructs a new SwingUpdateManagerSwingUpdateManager
(int minDelay, Runnable r) Constructs a new SwingUpdateManagerConstructs a new SwingUpdateManager with default values for min and max delay. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
The subclass callback to perform work.void
update()
Signals to perform an update.void
Signals to perform an update.void
Signals to perform an update.Methods inherited from class ghidra.util.task.AbstractSwingUpdateManager
checkForWork, dispose, flush, hasPendingUpdates, isBusy, isDisposed, scheduleCheckForWork, stop, toString, toStringDebug
-
Constructor Details
-
SwingUpdateManager
Constructs a new SwingUpdateManager with default values for min and max delay. SeeAbstractSwingUpdateManager.DEFAULT_MIN_DELAY
and 30000.- Parameters:
r
- the runnable that performs the client work.
-
SwingUpdateManager
Constructs a new SwingUpdateManagerNote: The
minDelay
will always be at leastAbstractSwingUpdateManager.MIN_DELAY_FLOOR
, regardless of the given value.- Parameters:
minDelay
- the minimum number of milliseconds to wait once the event stream stops coming in before actually updating the screen.r
- the runnable that performs the client work.
-
SwingUpdateManager
Constructs a new SwingUpdateManagerNote: The
minDelay
will always be at leastAbstractSwingUpdateManager.MIN_DELAY_FLOOR
, regardless of the given value.- Parameters:
minDelay
- the minimum number of milliseconds to wait once the event stream stops coming in before actually updating the screen.maxDelay
- the maximum amount of time to wait between gui updates.r
- the runnable that performs the client work.
-
SwingUpdateManager
Constructs a new SwingUpdateManagerNote: The
minDelay
will always be at leastAbstractSwingUpdateManager.MIN_DELAY_FLOOR
, regardless of the given value.- Parameters:
minDelay
- the minimum number of milliseconds to wait once the event stream stops coming in before actually updating the screen.maxDelay
- the maximum amount of time to wait between gui updates.name
- The name of this update manager; this allows for selective trace loggingr
- the runnable that performs the client work.
-
-
Method Details
-
swingDoWork
protected void swingDoWork()Description copied from class:AbstractSwingUpdateManager
The subclass callback to perform work.- Specified by:
swingDoWork
in classAbstractSwingUpdateManager
-
update
public void update()Signals to perform an update. See the class header for the usage of the various update methods.- Overrides:
update
in classAbstractSwingUpdateManager
-
updateLater
public void updateLater()Signals to perform an update. See the class header for the usage of the various update methods.- Overrides:
updateLater
in classAbstractSwingUpdateManager
-
updateNow
public void updateNow()Signals to perform an update. See the class header for the usage of the various update methods.- Overrides:
updateNow
in classAbstractSwingUpdateManager
-