Class SwingUpdateManager
- java.lang.Object
- 
- ghidra.util.task.SwingUpdateManager
 
- 
 public class SwingUpdateManager extends java.lang.ObjectA 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 to update, 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. There is one state variable, the workCount, that is changed both in the synchronized blocks and the Swing thread which is an atomic variable. This variable must be updated/incremented when the synchronized variables are cleared to preventisBusy()from returning false when there is a gap between 'work posted' and 'work execution'.
- 
- 
Field SummaryFields Modifier and Type Field Description static intDEFAULT_MAX_DELAY
 - 
Constructor SummaryConstructors Constructor Description SwingUpdateManager(int minDelay, int maxDelay, java.lang.Runnable r)Constructs a new SwingUpdateManagerSwingUpdateManager(int minDelay, int maxDelay, java.lang.String name, java.lang.Runnable r)Constructs a new SwingUpdateManagerSwingUpdateManager(int minDelay, java.lang.Runnable r)Constructs a new SwingUpdateManagerSwingUpdateManager(java.lang.Runnable r)Constructs a new SwingUpdateManager.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()booleanhasPendingUpdates()Returns true if there is a pending request that hasn't started yet.booleanisBusy()Returns true if any work is being performed or if there is buffered work.booleanisDisposed()voidstop()Signals to stop any buffered work.java.lang.StringtoString()java.lang.StringtoStringDebug()voidupdate()Signals to perform an update.voidupdateLater()Signals to perform an update.voidupdateNow()Signals to perform an update.
 
- 
- 
- 
Field Detail- 
DEFAULT_MAX_DELAYpublic static final int DEFAULT_MAX_DELAY - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
SwingUpdateManagerpublic SwingUpdateManager(java.lang.Runnable r) Constructs a new SwingUpdateManager.- Parameters:
- r- the runnable that performs the client work.
 
 - 
SwingUpdateManagerpublic SwingUpdateManager(int minDelay, java.lang.Runnable r)Constructs a new SwingUpdateManagerNote: The minDelay will always be at least 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.
 
 - 
SwingUpdateManagerpublic SwingUpdateManager(int minDelay, int maxDelay, java.lang.Runnable r)Constructs a new SwingUpdateManagerNote: The minDelay will always be at least 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.
 
 - 
SwingUpdateManagerpublic SwingUpdateManager(int minDelay, int maxDelay, java.lang.String name, java.lang.Runnable r)Constructs a new SwingUpdateManagerNote: The minDelay will always be at least 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 logging
- r- the runnable that performs the client work.
 
 
- 
 - 
Method Detail- 
updatepublic void update() Signals to perform an update. See the class header for the usage of the various update methods.
 - 
updateLaterpublic void updateLater() Signals to perform an update. See the class header for the usage of the various update methods.
 - 
updateNowpublic void updateNow() Signals to perform an update. See the class header for the usage of the various update methods.
 - 
stoppublic void stop() Signals to stop any buffered work. This will not stop any in-progress work.
 - 
hasPendingUpdatespublic boolean hasPendingUpdates() Returns true if there is a pending request that hasn't started yet. Any currently executing requests will not affect this call.- Returns:
- true if there is a pending request that hasn't started yet.
 
 - 
isBusypublic boolean isBusy() Returns true if any work is being performed or if there is buffered work.- Returns:
- true if any work is being performed or if there is buffered work.
 
 - 
disposepublic void dispose() 
 - 
isDisposedpublic boolean isDisposed() 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
toStringDebugpublic java.lang.String toStringDebug() 
 
- 
 
-