org.fopps.ui.actions
Class ActionHandler

java.lang.Object
  |
  +--org.fopps.ui.actions.ActionHandler
All Implemented Interfaces:
java.util.EventListener, java.awt.event.FocusListener, java.awt.event.ItemListener, ViewActionReceiver

public class ActionHandler
extends java.lang.Object
implements java.awt.event.ItemListener, ViewActionReceiver, java.awt.event.FocusListener

ActionHandler is the mediator between data model and UI actions. All views shold register themselves to an instance of action handler. Each action knows its handler, so that they can react properly on selections.

The ActionHandler knows also the data container and the application instance to realize actions that affects all data or even the whole application.


Nested Class Summary
 class ActionHandler.DummyApplication
          'Null' application
 
Field Summary
static java.lang.Class[] ACTIONS
           
 
Constructor Summary
ActionHandler(ActionHandler pOldHandler)
          Copy constructor for ActionHandler.
ActionHandler(ProjectContainer pContainer, Application pApp)
          Constructor for ActionHandler.
 
Method Summary
 boolean allowMultipleSelection()
          Returns true if view allows multiple selection.
 boolean canZoom()
          Returns true if view can be zoomed
 void clearSelection()
          Clear selection and refresh all actions
 void exportActions()
          For validation purpose only (makes nothing until fopps.debug is set)
 void focusGained(java.awt.event.FocusEvent e)
          Invoked when a component gains the keyboard focus.
 void focusLost(java.awt.event.FocusEvent e)
          Invoked when a component loses the keyboard focus.
 BaseAction getActionByName(java.lang.String pName)
          Returns the action with the given name or null, if action not exist
 java.util.Collection getActionNames()
          Returns a list containing all action names
 java.util.List getActions()
          Returns a list containing all actions.
 java.util.List getActionsForGroup(java.lang.String pGroupName)
          Returns all actions for a given group.
 java.util.Map getAllGroups()
          Returns the map with all groups and their actions
 Application getApp()
          Returns the app.
 javax.swing.AbstractButton getComponentForAction(java.lang.String pName)
          Returns the corresponding component for an action.
 ProjectContainer getContainer()
          Returns the container.
 java.util.Set getGroupNames()
          Return the set with all group names
 javax.swing.JMenuItem getMenuComponentForAction(java.lang.String pName)
          Returns the corresponding menu component for an action.
 java.util.List getPossibleActionsForSelection()
          Returns a list with all actions which accepts the current selection
 ViewActionReceiver getViewActionReceiver()
          Returns the view which will receive the view actions
 void invertSelection()
          Inverts current selection
 void itemStateChanged(java.awt.event.ItemEvent e)
           
 void narrow()
          Narrows current view, if applicable
 void register(java.lang.Object pComponent)
          Registers a component.
 void registerAction(BaseAction pAction)
          Registers an action.
 void registerContainerComponent(ContainerSelectable pItem)
           
protected  void registerController(Controller pItem)
           
 void selectAll()
          Selects all items in a view
 void selectItem(java.lang.Object pObject)
          Select an object in the view
 void setContainer(ProjectContainer container)
          Sets the container and passes the new container to all registered components
 void setViewActionReceiver(ViewActionReceiver pReceiver)
          Sets the view which will receive all following view actions.
 void unselectAll()
          Unselects all items in a view
 void widen()
          Widens current view, if applicable
 void zoomIn()
          Zooms current view, if applicable
 void zoomOut()
          Unzooms current view, if applicable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIONS

public static final java.lang.Class[] ACTIONS
Constructor Detail

ActionHandler

public ActionHandler(ProjectContainer pContainer,
                     Application pApp)
Constructor for ActionHandler.


ActionHandler

public ActionHandler(ActionHandler pOldHandler)
Copy constructor for ActionHandler.

Method Detail

getActionsForGroup

public java.util.List getActionsForGroup(java.lang.String pGroupName)
Returns all actions for a given group.

Parameters:
pGroupName - Name of group
Returns:
List with actions belonging to given group or an empty list, if group not exists

getAllGroups

public java.util.Map getAllGroups()
Returns the map with all groups and their actions


getGroupNames

public java.util.Set getGroupNames()
Return the set with all group names


getActionByName

public BaseAction getActionByName(java.lang.String pName)
Returns the action with the given name or null, if action not exist


getActionNames

public java.util.Collection getActionNames()
Returns a list containing all action names


registerAction

public void registerAction(BaseAction pAction)
Registers an action. All registered actions will be notified on selection changes, so they are able to enable/disable them appropiatly.

Parameters:
pAction - Action to register

clearSelection

public void clearSelection()
Clear selection and refresh all actions


focusGained

public void focusGained(java.awt.event.FocusEvent e)
Invoked when a component gains the keyboard focus.

Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Invoked when a component loses the keyboard focus.

Specified by:
focusLost in interface java.awt.event.FocusListener

register

public void register(java.lang.Object pComponent)
Registers a component. Instances of ContainerSelectable will be notified on container changes (e. g. loading a new file), ViewActionReceiver will receive action events.

See Also:
ViewActionReceiver, ContainerSelectable, ItemSelectable

registerContainerComponent

public void registerContainerComponent(ContainerSelectable pItem)

registerController

protected void registerController(Controller pItem)

setViewActionReceiver

public void setViewActionReceiver(ViewActionReceiver pReceiver)
Sets the view which will receive all following view actions.

If the view instance changes, the existing selection will be dropped


itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener
See Also:
ItemListener.itemStateChanged(ItemEvent)

getViewActionReceiver

public ViewActionReceiver getViewActionReceiver()
Returns the view which will receive the view actions

Returns:
Current view or null, if no view has focus

getActions

public java.util.List getActions()
Returns a list containing all actions.

Returns:
List

getApp

public Application getApp()
Returns the app.

Returns:
Application

getContainer

public ProjectContainer getContainer()
Returns the container.

Returns:
ProjectContainer

setContainer

public void setContainer(ProjectContainer container)
Sets the container and passes the new container to all registered components

Parameters:
container - The container to set

selectAll

public void selectAll()
Selects all items in a view

Specified by:
selectAll in interface ViewActionReceiver

unselectAll

public void unselectAll()
Unselects all items in a view

Specified by:
unselectAll in interface ViewActionReceiver

invertSelection

public void invertSelection()
Inverts current selection

Specified by:
invertSelection in interface ViewActionReceiver

selectItem

public void selectItem(java.lang.Object pObject)
Select an object in the view

Specified by:
selectItem in interface ViewActionReceiver
Parameters:
pObject - Object to select in view

zoomIn

public void zoomIn()
Zooms current view, if applicable

Specified by:
zoomIn in interface ViewActionReceiver

zoomOut

public void zoomOut()
Unzooms current view, if applicable

Specified by:
zoomOut in interface ViewActionReceiver

narrow

public void narrow()
Narrows current view, if applicable

Specified by:
narrow in interface ViewActionReceiver

widen

public void widen()
Widens current view, if applicable

Specified by:
widen in interface ViewActionReceiver

canZoom

public boolean canZoom()
Returns true if view can be zoomed

Specified by:
canZoom in interface ViewActionReceiver

allowMultipleSelection

public boolean allowMultipleSelection()
Returns true if view allows multiple selection. If false, (un)selectAll and invertSelection actions are disabled

Specified by:
allowMultipleSelection in interface ViewActionReceiver

getComponentForAction

public javax.swing.AbstractButton getComponentForAction(java.lang.String pName)
Returns the corresponding component for an action. Normally this is an instance of JButton. If the action is a two-state action, a JToggleButton is returned. The action is connected to the component automatically.

Parameters:
pName - name of the action

getMenuComponentForAction

public javax.swing.JMenuItem getMenuComponentForAction(java.lang.String pName)
Returns the corresponding menu component for an action. Normally this is an instance of JMenuItem. If the action is a two-state action, a JCheckBoxMenuItem is returned. The action is connected to the component automatically.

Parameters:
pName - name of the action

exportActions

public void exportActions()
For validation purpose only (makes nothing until fopps.debug is set)


getPossibleActionsForSelection

public java.util.List getPossibleActionsForSelection()
Returns a list with all actions which accepts the current selection



Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.