Class UpdateNotifier

java.lang.Object
editor.actions.UpdateNotifier

public class UpdateNotifier extends Object
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 Details

  • Constructor Details

    • UpdateNotifier

      private UpdateNotifier()
      Enforce singleton access.
  • Method Details

    • instance

      public static UpdateNotifier instance()
      Returns:
      The singleton instance.
    • addActionComponent

      public void addActionComponent(JComponent item)
      Adds a component to the enable/disable map.
      Parameters:
      item - A component for which the class controls the enable state.
    • removeActionComponent

      public void removeActionComponent(JComponent item)
      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.