Class EditorManager

java.lang.Object
jmri.beans.UnboundBean
jmri.beans.Bean
jmri.jmrit.display.EditorManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, BeanInterface, PropertyChangeFirer, PropertyChangeProvider, InstanceManagerAutoDefault

public class EditorManager
extends Bean
implements PropertyChangeListener, InstanceManagerAutoDefault
Manager for JMRI Editors. This manager tracks editors, extending the Set interface to do so (so it can be interacted with as a normal set), while also providing some methods specific to editors.

This manager listens to the title property of Editors to be notified to changes to the title of the Editor that could affect the order of editors.

This manager generates an IndexedPropertyChangeEvent for the property named editors when an editor is added or removed and forwards the PropertyChangeEvent for the title property of Editors in the manager.

  • Field Details

  • Constructor Details

  • Method Details

    • add

      public void add​(@Nonnull Editor editor)
      Add an editor to this manager.
      Parameters:
      editor - the editor to add
    • contains

      public boolean contains​(@Nonnull Editor editor)
      Check if an editor is in the manager.
      Parameters:
      editor - the editor to check for
      Returns:
      true if this manager contains an editor with name; false otherwise
    • getAll

      Get all managed editors. This set is sorted by the title of the editor.
      Returns:
      the set of all editors
    • getAll

      @Nonnull public <T extends Editor> SortedSet<T> getAll​(@Nonnull Class<T> type)
      Get all managed editors that implement the specified type. This set is sorted by the title of the editor.
      Type Parameters:
      T - the specified type
      Parameters:
      type - the specified type
      Returns:
      the set of all editors of the specified type
    • get

      Get the editor with the given name.
      Parameters:
      name - the name of the editor
      Returns:
      the editor with the given name or null if no editor by that name exists
    • get

      @CheckForNull public <T extends Editor> T get​(@Nonnull Class<T> type, @Nonnull String name)
      Get the editor with the given name and type.
      Type Parameters:
      T - the type of the editor
      Parameters:
      type - the type of the editor
      name - the name of the editor
      Returns:
      the editor with the given name or null if no editor by that name exists
    • remove

      public void remove​(@Nonnull Editor editor)
      Remove an editor from this manager.
      Parameters:
      editor - the editor to remove
    • propertyChange

      public void propertyChange​(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • contains

      public boolean contains​(String name)
      Check if an editor with the specified name is in the manager.
      Parameters:
      name - the name to check for
      Returns:
      true if this manager contains an editor with name; false otherwise
    • getList

      Get the set of all Editors as a List. This is a convenience method for use in scripts.
      Returns:
      the set of all Editors
    • getList

      @Nonnull public <T extends Editor> List<T> getList​(@Nonnull Class<T> type)
      Get the set of all editors that implement the specified type. This is a convenience method for use in scripts.
      Type Parameters:
      T - the specified type
      Parameters:
      type - the specified type
      Returns:
      the set of all editors that implement the specified type
    • getEditorsList

      Deprecated.
      since 4.19.6; use getAll() instead
      Get a List of the currently-existing Editor objects. The returned list is a copy made at the time of the call, so it can be manipulated as needed by the caller.
      Returns:
      a List of Editors
    • getEditorsList

      @Deprecated public <T extends Editor> List<T> getEditorsList​(@Nonnull Class<T> type)
      Deprecated.
      since 4.19.6; use getAll(java.lang.Class) instead
      Get a list of currently-existing Editor objects that are specific sub-classes of Editor.

      The returned list is a copy made at the time of the call, so it can be manipulated as needed by the caller.

      Type Parameters:
      T - the type of Editor
      Parameters:
      type - the Class the list should be limited to.
      Returns:
      a List of Editors.
    • getEditor

      @Deprecated public Editor getEditor​(String name)
      Deprecated.
      since 4.19.6; use get(java.lang.String) instead
      Get an Editor of a particular name. If more than one exists, there's no guarantee as to which is returned.
      Parameters:
      name - the editor to get
      Returns:
      the first matching Editor or null if no matching Editor could be found
    • addEditor

      @Deprecated public boolean addEditor​(@Nonnull Editor editor)
      Deprecated.
      since 4.19.6; use add(jmri.jmrit.display.Editor) instead
      Add an Editor to the set of Editors. This only changes the set of Editors if the Editor is not already in the set.
      Parameters:
      editor - the editor to add
      Returns:
      true if the set was changed; false otherwise
    • removeEditor

      @Deprecated public boolean removeEditor​(@Nonnull Editor editor)
      Deprecated.
      since 4.19.6; use remove(jmri.jmrit.display.Editor) instead
      Add an Editor from the set of Editors. This only changes the set of Editors if the Editor is in the set.
      Parameters:
      editor - the editor to remove
      Returns:
      true if the set was changed; false otherwise