org.netbeans.modules.editor.lib2/1 1.43.1 10

org.netbeans.api.editor
Class EditorRegistry

java.lang.Object
  extended by org.netbeans.api.editor.EditorRegistry

public final class EditorRegistry
extends Object

Registry maintaining JTextComponents in most-recently-used order.
The particular text component needs to register itself first (to avoid dealing with all the JTextFields etc.). Then the registry will attach a focus listener to the text component and once the component gains the focus it will move to the head of the components list.
The registry will also fire a change in case a document property of the focused component changes (by calling component.setDocument()).


Field Summary
static String COMPONENT_REMOVED_PROPERTY
          Fired when a component (returned previously from componentList()) is removed from component hierarchy (so it's likely that the component will be released completely and garbage-collected).
static String FOCUS_GAINED_PROPERTY
          Fired when focus was delivered to a registered text component.
static String FOCUS_LOST_PROPERTY
          Fired when a registered focused component has lost the focus.
static String FOCUSED_DOCUMENT_PROPERTY
          Fired when document property of the focused component changes i.e.
static String LAST_FOCUSED_REMOVED_PROPERTY
          Fired when the last focused component (returned previously from lastFocusedComponent()) was removed from component hierarchy (so it's likely that the component will be released completely and garbage-collected).
 
Method Summary
static void addPropertyChangeListener(PropertyChangeListener l)
          Add a property change listener for either of the following properties: FOCUS_GAINED_PROPERTY FOCUS_LOST_PROPERTY FOCUSED_DOCUMENT_PROPERTY .
static List<? extends JTextComponent> componentList()
          Get list of all components present in the registry starting with the most active and ending with least active component.
static JTextComponent focusedComponent()
          Return the last focused component if it currently has a focus or return null if none of the registered components currently have the focus.
static JTextComponent lastFocusedComponent()
          Return last focused text component (from the ones included in the registry).
static void removePropertyChangeListener(PropertyChangeListener l)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOCUS_GAINED_PROPERTY

public static final String FOCUS_GAINED_PROPERTY
Fired when focus was delivered to a registered text component.
The focused component will become the first in the components list.
The PropertyChangeEvent.getOldValue() will be a component losing the focus FocusEvent.getOppositeComponent(). The PropertyChangeEvent.getNewValue() will be the text component gaining the focus.

See Also:
Constant Field Values

FOCUS_LOST_PROPERTY

public static final String FOCUS_LOST_PROPERTY
Fired when a registered focused component has lost the focus.
The focused component will remain the first in the components list.
The PropertyChangeEvent.getOldValue() will be the text component losing the focus and the PropertyChangeEvent.getNewValue() will be the component gaining the focus FocusEvent.getOppositeComponent().

See Also:
Constant Field Values

FOCUSED_DOCUMENT_PROPERTY

public static final String FOCUSED_DOCUMENT_PROPERTY
Fired when document property of the focused component changes i.e. someone has called JTextComponent.setDocument(Document).
The PropertyChangeEvent.getOldValue() will be the original document of the focused text component and the PropertyChangeEvent.getNewValue() will be the new document set to the focused text component.

See Also:
Constant Field Values

COMPONENT_REMOVED_PROPERTY

public static final String COMPONENT_REMOVED_PROPERTY
Fired when a component (returned previously from componentList()) is removed from component hierarchy (so it's likely that the component will be released completely and garbage-collected).
Such component will no longer be returned from componentList() or lastFocusedComponent().
The PropertyChangeEvent.getOldValue() will be the removed component.
The PropertyChangeEvent.getNewValue() returns null

See Also:
Constant Field Values

LAST_FOCUSED_REMOVED_PROPERTY

public static final String LAST_FOCUSED_REMOVED_PROPERTY
Fired when the last focused component (returned previously from lastFocusedComponent()) was removed from component hierarchy (so it's likely that the component will be released completely and garbage-collected).
Such component will no longer be returned from componentList() or lastFocusedComponent().
The PropertyChangeEvent.getOldValue() will be the removed last focused component and the PropertyChangeEvent.getNewValue() will be the component that would currently be returned from lastFocusedComponent().
If PropertyChangeEvent.getNewValue() returns null then there are no longer any registered components (componentList() would return empty list). If the client holds per-last-focused-component data it should clear them.

See Also:
Constant Field Values
Method Detail

lastFocusedComponent

public static JTextComponent lastFocusedComponent()
Return last focused text component (from the ones included in the registry).
It may or may not currently have a focus.

Returns:
last focused text component or null if no text components were registered yet or all the registered components were closed.

focusedComponent

public static JTextComponent focusedComponent()
Return the last focused component if it currently has a focus or return null if none of the registered components currently have the focus.

Returns:
focused component or null if none of the registered components is currently focused.

componentList

public static List<? extends JTextComponent> componentList()
Get list of all components present in the registry starting with the most active and ending with least active component.
The list is a snapshot of the current state and it may be modified by the caller if desired.

Returns:
non-null list containing all the registered components in MRU order.

addPropertyChangeListener

public static void addPropertyChangeListener(PropertyChangeListener l)
Add a property change listener for either of the following properties: .
All the firing should occur in AWT thread only (assuming the JTextComponent.setDocument() is done properly in AWT).

Parameters:
l - non-null listener to add.

removePropertyChangeListener

public static void removePropertyChangeListener(PropertyChangeListener l)

org.netbeans.modules.editor.lib2/1 1.43.1 10

Built on December 5 2011.  |  Portions Copyright 1997-2011 Sun Microsystems, Inc. All rights reserved.