org.openbp.jaspira.gui.plugin
Class PluginFocusMgr

java.lang.Object
  extended by java.awt.KeyboardFocusManager
      extended by java.awt.DefaultKeyboardFocusManager
          extended by javax.swing.FocusManager
              extended by javax.swing.DefaultFocusManager
                  extended by org.openbp.jaspira.gui.plugin.PluginFocusMgr
All Implemented Interfaces:
java.awt.KeyEventDispatcher, java.awt.KeyEventPostProcessor

public final class PluginFocusMgr
extends javax.swing.DefaultFocusManager

Focus manager which manages the focusation of plugins. This class is a singleton.

Author:
Jens Ferchland

Field Summary
protected  java.lang.ref.WeakReference lastPluginRef
          Plugin that had the focus last (contains a VisiblePlugin).
 
Fields inherited from class javax.swing.FocusManager
FOCUS_MANAGER_CLASS_PROPERTY
 
Fields inherited from class java.awt.KeyboardFocusManager
BACKWARD_TRAVERSAL_KEYS, DOWN_CYCLE_TRAVERSAL_KEYS, FORWARD_TRAVERSAL_KEYS, UP_CYCLE_TRAVERSAL_KEYS
 
Method Summary
 void changeFocus(VisiblePlugin plugin)
          Changes the focus from the currently focused plugin to the given plugin.
 boolean dispatchEvent(java.awt.AWTEvent e)
           
 VisiblePlugin getFocusedPlugin()
          Returns the currently focused plugin.
static PluginFocusMgr getInstance()
          Returns the current focus manager if it is a PluginFocusMgr or some subclass of it or otherwise the only instance of this class.
 void resetFocusCache()
          Resets the focus cache of the plugin focus manager.
 
Methods inherited from class javax.swing.DefaultFocusManager
compareTabOrder, getComponentAfter, getComponentBefore, getFirstComponent, getLastComponent
 
Methods inherited from class javax.swing.FocusManager
disableSwingFocusManager, getCurrentManager, isFocusManagerEnabled, setCurrentManager
 
Methods inherited from class java.awt.DefaultKeyboardFocusManager
dequeueKeyEvents, discardKeyEvents, dispatchKeyEvent, downFocusCycle, enqueueKeyEvents, focusNextComponent, focusPreviousComponent, postProcessKeyEvent, processKeyEvent, upFocusCycle
 
Methods inherited from class java.awt.KeyboardFocusManager
addKeyEventDispatcher, addKeyEventPostProcessor, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clearGlobalFocusOwner, downFocusCycle, firePropertyChange, fireVetoableChange, focusNextComponent, focusPreviousComponent, getActiveWindow, getCurrentFocusCycleRoot, getCurrentKeyboardFocusManager, getDefaultFocusTraversalKeys, getDefaultFocusTraversalPolicy, getFocusedWindow, getFocusOwner, getGlobalActiveWindow, getGlobalCurrentFocusCycleRoot, getGlobalFocusedWindow, getGlobalFocusOwner, getGlobalPermanentFocusOwner, getKeyEventDispatchers, getKeyEventPostProcessors, getPermanentFocusOwner, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, redispatchEvent, removeKeyEventDispatcher, removeKeyEventPostProcessor, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setCurrentKeyboardFocusManager, setDefaultFocusTraversalKeys, setDefaultFocusTraversalPolicy, setGlobalActiveWindow, setGlobalCurrentFocusCycleRoot, setGlobalFocusedWindow, setGlobalFocusOwner, setGlobalPermanentFocusOwner, upFocusCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastPluginRef

protected java.lang.ref.WeakReference lastPluginRef
Plugin that had the focus last (contains a VisiblePlugin). This is a temporary variable only, so we use weak references here in order to prevent memory leaks.

Method Detail

getInstance

public static PluginFocusMgr getInstance()
Returns the current focus manager if it is a PluginFocusMgr or some subclass of it or otherwise the only instance of this class.

Returns:
The plugin focus manager

dispatchEvent

public boolean dispatchEvent(java.awt.AWTEvent e)
Overrides:
dispatchEvent in class java.awt.DefaultKeyboardFocusManager
See Also:
DefaultKeyboardFocusManager.dispatchEvent(AWTEvent)

changeFocus

public void changeFocus(VisiblePlugin plugin)
Changes the focus from the currently focused plugin to the given plugin. If the plugin already has the focus, nothing will happen.

Parameters:
plugin - Plugin to receive the focus

getFocusedPlugin

public VisiblePlugin getFocusedPlugin()
Returns the currently focused plugin. If the currently focused plugin has been garbage-collected, the method will try a fallback to the active plugin of the currenly focused frame.

Returns:
The focused plugin or null if no plugin is focused

resetFocusCache

public void resetFocusCache()
Resets the focus cache of the plugin focus manager. Call this method if you want a plugin that already has the focus to be focused explicitely again if its VisiblePlugin.focusPlugin() method is being called. This is used e. g. if a plugin is dragged to another container to repaint the plugin panel title.



Copyright © 2011. All Rights Reserved.