de.kleopatra.view.presentation
Class ActionFactory

java.lang.Object
  extended byde.kleopatra.view.presentation.ActionFactory

public class ActionFactory
extends java.lang.Object

Creates, "registers" and wires actions to resourceIDs and eventHandlers.

The actions are identifiable by a actionID/resourceID pair. ActionIDs should be unique per resourceID, resourceIDs should be unique per application (nothing done yet to enforce it). Generally, there is one eventHandler per resourceID. It's possible to replace the handler of a subset of a resourceID, though.

PENDING: unique actionID per listID - who is responsible for checking?

Version:
$Revision: 1.2 $ - $Date: 2004/09/29 14:40:19 $
Author:
(C) 2003, 2004 Jeanette Winzenburg, Berlin

Constructor Summary
protected ActionFactory()
           
 
Method Summary
 void addToActionList(java.util.List actionIDs, java.lang.Object resourceID, java.lang.Object handler)
          creates and registers actions for all actionIDs to resource and binds them to handler.
 void clear()
          removes all action/resourceID mappings.
protected  DelegateAction createDelegateAction(java.lang.Object actionID)
          creates and returns a DelegateAction with name and actionCommand set to actionID's String-rep.
protected  java.awt.event.ActionListener createEventHandlerProxy(java.lang.Object handler, java.lang.String methodName)
           
protected  java.util.List createList()
           
protected  java.util.Map createMap()
           
protected  java.util.List ensureActionList(java.lang.Object resourceID)
           
 javax.swing.Action getAction(java.lang.Object actionID, java.lang.Object resourceID)
          returns an action with the id actionID which is registered for resourceID listID.
protected  java.util.Map getActionLists()
           
 java.util.List getActions(java.lang.Object resourceID)
          returns a list of all actions registered for resourceID.
static ActionFactory getInstance()
           
 boolean isUniqueListID(java.lang.Object resourceID)
          Deprecated.  
 void moveActions(java.lang.Object fromResourceID, java.lang.Object targetResourceID)
          moves all actions registered in fromResourceID to targetResourceID.
 javax.swing.Action registerAction(java.lang.Object actionID, java.lang.Object resourceID)
          registers and returns the action with actionID in list resourceID.
 javax.swing.Action registerActionAsHandler(java.lang.Object actionID, java.lang.Object resourceID, javax.swing.Action handler)
          registers an Action as handler.
 java.util.List registerHandler(java.util.List actionIDs, java.lang.Object resourceID, java.lang.Object handler)
          returns a list of all actions registered for the resourceID.
 javax.swing.Action registerHandler(java.lang.Object actionID, java.lang.Object resourceID, java.lang.Object handler)
           
 void reset()
          used for unittesting only: to get a new singleton.
 java.util.List setActionList(java.util.List actionIDs, java.lang.Object resourceID, java.lang.Object handler)
          Deprecated. use registerActionsAndHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActionFactory

protected ActionFactory()
Method Detail

getInstance

public static ActionFactory getInstance()

reset

public void reset()
used for unittesting only: to get a new singleton.


clear

public void clear()
removes all action/resourceID mappings.


isUniqueListID

public boolean isUniqueListID(java.lang.Object resourceID)
Deprecated.  

not used and wrong name: should be hasResourceID(...).


setActionList

public java.util.List setActionList(java.util.List actionIDs,
                                    java.lang.Object resourceID,
                                    java.lang.Object handler)
Deprecated. use registerActionsAndHandler

registers action with given ids to resource and wires them to given eventhandler.

creates an action if there is no action with the id in the resource map. if there already is an action in the resource map with the id, its eventhandler is replaced by the new one.


registerHandler

public java.util.List registerHandler(java.util.List actionIDs,
                                      java.lang.Object resourceID,
                                      java.lang.Object handler)
returns a list of all actions registered for the resourceID.

Guarantees a Action for each element in actionIDs. Creates an Action if there is none with the id in the resource map. If there already is an action in the resource map with the id, its eventhandler is replaced by the new one.

PRE: resourceID != null, actionIDs != null, handler != null


registerHandler

public javax.swing.Action registerHandler(java.lang.Object actionID,
                                          java.lang.Object resourceID,
                                          java.lang.Object handler)

addToActionList

public void addToActionList(java.util.List actionIDs,
                            java.lang.Object resourceID,
                            java.lang.Object handler)
creates and registers actions for all actionIDs to resource and binds them to handler.


moveActions

public void moveActions(java.lang.Object fromResourceID,
                        java.lang.Object targetResourceID)
moves all actions registered in fromResourceID to targetResourceID.

quick hack to enable correct finding of actions in placeholders. PENDING: really support nested actions/containers! POST: list with targetListID added might be empty if sourceListID empty or not found


registerAction

public final javax.swing.Action registerAction(java.lang.Object actionID,
                                               java.lang.Object resourceID)
registers and returns the action with actionID in list resourceID. Creates an action if none is found in the list with resourceID. Creates a new list for resourceID if none is available yet. Registers the action with resource "default" if resourceID == null;

PRE: actionID != null.


registerActionAsHandler

public javax.swing.Action registerActionAsHandler(java.lang.Object actionID,
                                                  java.lang.Object resourceID,
                                                  javax.swing.Action handler)
registers an Action as handler.

The returned delegate carries the presentation values, delegates the performed(..) to the handler and synchronizes its enabled/disabled state with the handler.

Parameters:
actionID -
resourceID -
handler - the action to perform
Returns:
the delegate action for use in ui components

getActions

public java.util.List getActions(java.lang.Object resourceID)
returns a list of all actions registered for resourceID.


getAction

public javax.swing.Action getAction(java.lang.Object actionID,
                                    java.lang.Object resourceID)
returns an action with the id actionID which is registered for resourceID listID.


ensureActionList

protected java.util.List ensureActionList(java.lang.Object resourceID)

createEventHandlerProxy

protected java.awt.event.ActionListener createEventHandlerProxy(java.lang.Object handler,
                                                                java.lang.String methodName)

createDelegateAction

protected DelegateAction createDelegateAction(java.lang.Object actionID)
creates and returns a DelegateAction with name and actionCommand set to actionID's String-rep. PRE: actionID != null.


getActionLists

protected java.util.Map getActionLists()

createMap

protected java.util.Map createMap()

createList

protected java.util.List createList()


Copyright © 2003, 2004 SwingEmpire Jeanette Winzenburg. All Rights Reserved.