org.progeeks.util.swing
Class AbstractFocusedContextAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by org.progeeks.util.swing.AbstractContextAction
          extended by org.progeeks.util.swing.AbstractFocusedContextAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action, ViewContextAware

public abstract class AbstractFocusedContextAction
extends AbstractContextAction

Specialization of the AbstractContextAction that provides automatic focus watching when the context is a focused context. An abstract focusChanged() method is called whenever the context or focus of a FocusedContext has changed.

Version:
$Revision: 1.4 $
Author:
Paul Speed
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
protected AbstractFocusedContextAction()
           
protected AbstractFocusedContextAction(java.lang.String name)
           
protected AbstractFocusedContextAction(java.lang.String name, javax.swing.Icon icon)
           
 
Method Summary
protected  java.lang.Object clone()
          Make sure to clean-up some local references that shouldn't be cloned.
protected abstract  void focusChanged()
          Called when the context or the focus of a reference FocusedContext changes.
protected  java.lang.Object getFocus()
          Returns the current focus object if the attached context is a FocusedContext.
protected  java.util.List getFocusedObjects()
          Returns the current list of focused objects it the attached context is a MultiFocusedContext.
 void setViewContext(ViewContext context)
          Overridden to setup listeners on FocusedContexts that we're attached to.
 
Methods inherited from class org.progeeks.util.swing.AbstractContextAction
findViewContext, getViewContext
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Constructor Detail

AbstractFocusedContextAction

protected AbstractFocusedContextAction()

AbstractFocusedContextAction

protected AbstractFocusedContextAction(java.lang.String name)

AbstractFocusedContextAction

protected AbstractFocusedContextAction(java.lang.String name,
                                       javax.swing.Icon icon)
Method Detail

focusChanged

protected abstract void focusChanged()
Called when the context or the focus of a reference FocusedContext changes. It is up to the subclass to decide whether or not to enabled themselves, or change the name, etc. based on the context or the focus.


getFocus

protected java.lang.Object getFocus()
Returns the current focus object if the attached context is a FocusedContext. Otherwise, this method returns null.


getFocusedObjects

protected java.util.List getFocusedObjects()
Returns the current list of focused objects it the attached context is a MultiFocusedContext. Otherwise, this method returns a list with just the result of getFocus() in it if getFocus() is non-null or an empty list of no objects have the focus.


clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Make sure to clean-up some local references that shouldn't be cloned.

Overrides:
clone in class AbstractContextAction
Throws:
java.lang.CloneNotSupportedException

setViewContext

public void setViewContext(ViewContext context)
Overridden to setup listeners on FocusedContexts that we're attached to.

Specified by:
setViewContext in interface ViewContextAware
Overrides:
setViewContext in class AbstractContextAction


Copyright © 2002-2003 Paul Speed. All Rights Reserved.