Package editor.actions
Class UpdateNotifier
java.lang.Object
editor.actions.UpdateNotifier
The primary goal for this class is to enable/disable components relieving them
from the chore of monitoring select events to proactively enable/disable themselves.
The idea is that in the end all components must respond to some sort of awt event
to selectively enable and disable themselves. So why not simply monitor all events
and notify components when they should update themselves? This way components are
always in the correct visual state. Components only need to supply the conditions
upon which they are enabled via the GenericAction class.
This class also provides for centralized application context state management i.e.,
display or hide user interface elements based on the applications context state[s].
Note enabling/disabling UI command components in the dispatch loop is not a new
concept. I used to do something very similar in a prior life doing old-time Windows
API programming; in a Windows message loop one could do this sort of processing during
"idle" time. And now in .NET there is a similar facility that more or less does what
I have done here.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WeakHashMap<JComponent,
Object> (package private) static UpdateNotifier
This is a singleton class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Enables/Disables registered components.void
addActionComponent
(JComponent item) Adds a component to the enable/disable map.static UpdateNotifier
instance()
void
void
Removes a component from the enable/disable map.
-
Field Details
-
_singleton
This is a singleton class. -
_mapItems
-
-
Constructor Details
-
UpdateNotifier
private UpdateNotifier()Enforce singleton access.
-
-
Method Details
-
instance
- Returns:
- The singleton instance.
-
addActionComponent
Adds a component to the enable/disable map.- Parameters:
item
- A component for which the class controls the enable state.
-
removeActionComponent
Removes a component from the enable/disable map.- Parameters:
item
- The component to remove from the map.
-
notifyActionComponentsNow
public void notifyActionComponentsNow() -
_notifyActionComponentsNow
protected void _notifyActionComponentsNow()Enables/Disables registered components.
-