Class EditorManager

  • All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener, BeanInterface, PropertyChangeFirer, PropertyChangeProvider, InstanceManagerAutoDefault

    public class EditorManager
    extends Bean
    implements java.beans.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.

    • Method Detail

      • getClassDescription

        public java.lang.String getClassDescription()
        Set the title for the Preferences / Messages tab. Called by JmriUserPreferencesManager.
        Returns:
        the title string.
      • setMessagePreferencesDetails

        public void setMessagePreferencesDetails()
        Set the details for Preferences / Messages tab. Called by JmriUserPreferencesManager.

        The dialogs are in jmri.configurexml.LoadXmlConfigAction and jmri.jmrit.display.Editor. They are anchored here since the preferences system appears to need a class that can instantiated.

      • 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

        @Nonnull
        public java.util.SortedSet<EditorgetAll()
        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> java.util.SortedSet<T> getAll​(@Nonnull
                                                                java.lang.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

        @CheckForNull
        public Editor get​(@Nonnull
                          java.lang.String title)
        Get the editor with the given title.
        Parameters:
        title - the title of the editor
        Returns:
        the editor with the given title or null if no editor by that title exists
      • getByName

        @CheckForNull
        public Editor getByName​(@Nonnull
                                java.lang.String name)
        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
      • getTargetFrame

        @CheckForNull
        public Editor getTargetFrame​(@Nonnull
                                     java.lang.String name)
        Get the editor with the given name or the editor with the given target frame name.
        Parameters:
        name - the name of the editor or target frame
        Returns:
        the editor or null
      • get

        @CheckForNull
        public <T extends Editor> T get​(@Nonnull
                                        java.lang.Class<T> type,
                                        @Nonnull
                                        java.lang.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​(java.beans.PropertyChangeEvent evt)
        Specified by:
        propertyChange in interface java.beans.PropertyChangeListener
      • contains

        public boolean contains​(java.lang.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

        @Nonnull
        public java.util.List<EditorgetList()
        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> java.util.List<T> getList​(@Nonnull
                                                            java.lang.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