com.swfm.mica.core
Interface MiiAction

All Superinterfaces:
MiiActionTypes
All Known Implementing Classes:
MiAction

public interface MiiAction
extends MiiActionTypes

This interface describes a Mica Action. An action is generated by a graphics MiPart (often in response to Events generated by users). Usually this occurs when the MiPart changes in some way, either geometrically (it moved or changed size), visibly (changed color, became visible, etc.) or state (it was selected, deselected).

MiiActions are designed so that usually it itself contains a reference to the action handler (observer) it will be dispatched to. In this way, actions are not constructed and destroyed when they are dispatched, they just have their context dependent data modified and are sent on to the handler.

Version:
%I% %G%
Author:
Michael L. Davis
See Also:
MiiActionHandler, MiiActionTypes, MiPart.appendActionHandler(com.swfm.mica.core.MiiAction, com.swfm.mica.events.MiEvent)

Field Summary
   
Method Summary
 MiiActionHandler getActionHandler()
          Gets the action handler this action will be dispatched to.
 MiPart getActionSource()
          Gets the MiPart that originally generated the action.
 java.lang.Object getActionSystemInfo()
          Gets the system information field of this action.
 int getActionType()
          Gets the actual type of this dispatched action.
 java.lang.Object getActionUserInfo()
          Gets the user information field of this action.
 MiPart getObservedObject()
          Gets the MiPart that dispatched the action to the MiiActionHandler.
 int getPhase()
          Gets the phase of this dispatched action.
 java.lang.Object getResource(java.lang.String name)
          Gets the value of the given named resource.
 java.lang.String getValidActionsString()
          For debug, gets a text string describing the action types that this action is watching for/handling.
 boolean hasActionType(int actionType)
          Gets whether the actual type of this dispatched action is the same as the given type.
 boolean isInterestedInActionsOfPartsOfObserved()
          Gets whether this action is interested in actions of the parts of the MiPart this action is assigned to.
 boolean isPhase(int phase)
          Gets whether the given phase is the phase of this dispatched action.
 boolean isValidActionType(int actionType)
          Gets whether given action type is an action type for which this action will be dispatched to it's action handler.
 boolean isVetoed()
          Gets whether this action, in the request phase, is saying no to the request.
 void setActionHandler(MiiActionHandler handler)
          Sets the action handler this action will be dispatched to.
 void setActionSource(MiPart source)
          Sets the MiPart that originally generated the action.
 void setActionSystemInfo(java.lang.Object info)
          Sets the system information field of this action.
 void setActionType(int actionType)
          Sets the actual type of this dispatched action.
 void setActionUserInfo(java.lang.Object info)
          Sets the user information field of this action.
 void setObservedObject(MiPart source)
          Sets the MiPart that dispatched the action to the MiiActionHandler.
 void setResource(java.lang.String name, java.lang.Object value)
          Adds (if necessary) and sets the given named resource to the given value.
 void setVetoed(boolean flag)
          Sets whether this action, in the request phase, is saying no to the request.
 void veto()
          Specifies that this action, in the request phase, is saying no to the request.
 

Method Detail

setActionSource

public void setActionSource(MiPart source)
Sets the MiPart that originally generated the action. This is set automatically by Mica whenever the action is dispatched.

Parameters:
source - the part that generated the action

getActionSource

public MiPart getActionSource()
Gets the MiPart that originally generated the action.

Returns:
the part that generated the action

setObservedObject

public void setObservedObject(MiPart source)
Sets the MiPart that dispatched the action to the MiiActionHandler. This is set automatically by Mica whenever the action is dispatched.

Parameters:
source - the part that dispatched the action

getObservedObject

public MiPart getObservedObject()
Gets the MiPart that dispatched the action to the MiiActionHandler.

Returns:
the part that dispatched the action

setActionHandler

public void setActionHandler(MiiActionHandler handler)
Sets the action handler this action will be dispatched to.

Parameters:
handler - the action handler to send this action to

getActionHandler

public MiiActionHandler getActionHandler()
Gets the action handler this action will be dispatched to.

Returns:
the action handler to send this action to

setActionType

public void setActionType(int actionType)
Sets the actual type of this dispatched action. This type is one of the valid types of this action. MiiActionHandler. This is set automatically by Mica whenever the action is dispatched.

Returns:
the part that dispatched the action
See Also:
isValidActionType(int)

getActionType

public int getActionType()
Gets the actual type of this dispatched action. Includes action and phase information.

Returns:
the action type of this action
See Also:
isValidActionType(int)

hasActionType

public boolean hasActionType(int actionType)
Gets whether the actual type of this dispatched action is the same as the given type. Includes action and phase information.

Returns:
true if the given action type is the same action type this action has.
See Also:
getActionType(), isValidActionType(int)

isValidActionType

public boolean isValidActionType(int actionType)
Gets whether given action type is an action type for which this action will be dispatched to it's action handler.

Returns:
true if the given action type is a valid action type or this action
See Also:
isValidActionType(int)

setActionUserInfo

public void setActionUserInfo(java.lang.Object info)
Sets the user information field of this action.

Parameters:
info - the information supplied by the programmer.
See Also:
getActionUserInfo()

getActionUserInfo

public java.lang.Object getActionUserInfo()
Gets the user information field of this action.

Returns:
the information supplied by the programmer.
See Also:
setActionUserInfo(java.lang.Object)

setActionSystemInfo

public void setActionSystemInfo(java.lang.Object info)
Sets the system information field of this action. This used when the MiPart that generated the action thinks additional information is required to completely describe the action. For example the Mi_COPY_ACTION action is generated by a MiPart that is being copied and has system info equal to the new MiPart copy. This is set automatically by Mica whenever the action is dispatched, if the specific action need it.

Parameters:
info - the information supplied by the generator of the action or null.
See Also:
setActionUserInfo(java.lang.Object), getActionSystemInfo()

getActionSystemInfo

public java.lang.Object getActionSystemInfo()
Gets the system information field of this action. This used when the MiPart that generated the action thinks additional information is required to completely describe the action. For example the Mi_COPY_ACTION action is generated by a MiPart that is being copied and has system info equal to the new MiPart copy.

Returns:
the information supplied by the generator of the action or null.
See Also:
getActionUserInfo(), setActionSystemInfo(java.lang.Object)

setResource

public void setResource(java.lang.String name,
                        java.lang.Object value)
Adds (if necessary) and sets the given named resource to the given value. Every action can have an unlimited number of programmer-specified resources.

Parameters:
name - the resource name
value - the resource value (non-null)
See Also:
getResource(java.lang.String)

getResource

public java.lang.Object getResource(java.lang.String name)
Gets the value of the given named resource. If to the given value. Every action can have an unlimited number of programmer-specified resources.

Parameters:
name - the resource name
See Also:
setResource(java.lang.String, java.lang.Object)

isPhase

public boolean isPhase(int phase)
Gets whether the given phase is the phase of this dispatched action. Possible values are: Mi_REQUEST_ACTION_PHASE Mi_CANCEL_ACTION_PHASE Mi_COMMIT_ACTION_PHASE Mi_CANCEL_ACTION_PHASE

Parameters:
phase - the possible phase of this action
Returns:
true if the given phase equals the current phase of this action

getPhase

public int getPhase()
Gets the phase of this dispatched action. Possible values are: Mi_REQUEST_ACTION_PHASE Mi_CANCEL_ACTION_PHASE Mi_COMMIT_ACTION_PHASE Mi_CANCEL_ACTION_PHASE Use getActionType() & ~getPhase() to get pure action type

Returns:
phase the phase of this action

isInterestedInActionsOfPartsOfObserved

public boolean isInterestedInActionsOfPartsOfObserved()
Gets whether this action is interested in actions of the parts of the MiPart this action is assigned to. Use Mi_ACTIONS_OF_PARTS_OF_OBSERVED when specifying valid actions if this behavior is desired.

Returns:
true if interested

veto

public void veto()
Specifies that this action, in the request phase, is saying no to the request.


isVetoed

public boolean isVetoed()
Gets whether this action, in the request phase, is saying no to the request.

Returns:
true if vetoed

setVetoed

public void setVetoed(boolean flag)
Sets whether this action, in the request phase, is saying no to the request.

Parameters:
flag - true if vetoed

getValidActionsString

public java.lang.String getValidActionsString()
For debug, gets a text string describing the action types that this action is watching for/handling. The toString() method returns a string describing the current action type.

Returns:
a text string describing the valid action types for this action