Package jmri.jmrit.display
Class EditorManager
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.jmrit.display.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 namededitors
when an editor is added or removed and forwards thePropertyChangeEvent
for thetitle
property of Editors in the manager.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EDITORS
static java.lang.String
TITLE
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description EditorManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Editor editor)
Add an editor to this manager.boolean
contains(java.lang.String name)
Check if an editor with the specified name is in the manager.boolean
contains(Editor editor)
Check if an editor is in the manager.<T extends Editor>
Tget(java.lang.Class<T> type, java.lang.String name)
Get the editor with the given name and type.Editor
get(java.lang.String title)
Get the editor with the given title.java.util.SortedSet<Editor>
getAll()
Get all managed editors.<T extends Editor>
java.util.SortedSet<T>getAll(java.lang.Class<T> type)
Get all managed editors that implement the specified type.Editor
getByName(java.lang.String name)
Get the editor with the given name.java.lang.String
getClassDescription()
Set the title for the Preferences / Messages tab.java.util.List<Editor>
getList()
Get the set of all Editors as a List.<T extends Editor>
java.util.List<T>getList(java.lang.Class<T> type)
Get the set of all editors that implement the specified type.Editor
getTargetFrame(java.lang.String name)
Get the editor with the given name or the editor with the given target frame name.void
propertyChange(java.beans.PropertyChangeEvent evt)
void
remove(Editor editor)
Remove an editor from this manager.void
setMessagePreferencesDetails()
Set the details for Preferences / Messages tab.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
EDITORS
public static final java.lang.String EDITORS
- See Also:
- Constant Field Values
-
TITLE
public static final java.lang.String TITLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EditorManager
public EditorManager()
-
-
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<Editor> 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> 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 editorname
- 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 interfacejava.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<Editor> 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> 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
-
-