SalesPoint v3.3 API

users
Class ActionCapability

java.lang.Object
  extended by users.AbstractCapability
      extended by users.ActionCapability
All Implemented Interfaces:
Serializable, Action, Capability

public class ActionCapability
extends AbstractCapability
implements Action

A special capability guarding an action object.

The ActionCapability is itself an Action again, so that you can write code like this:

   public class S extends SalesPoint {

   ...

     public MenuSheet getDefaultMenuSheet() {

       MenuSheet ms = new MenuSheet();

       ms.addItem ("Capability Test",
         (Action) getUser().getCapability("CapTest"));
 
       return ms;
     }

   ...

   }

 

Assuming that the CapTest capability is represented by an ActionCapability wrapping some other Action.

Since:
v2.0
Author:
Steffen Zschaler
See Also:
SalesPoint, MenuSheet, UserManager, User, Serialized Form

Constructor Summary
ActionCapability(String sName, Action aToDo)
          Create a granted capability.
ActionCapability(String sName, String sOnDeny, Action aToDo, boolean fGranted)
          Create a new ActionCapability.
 
Method Summary
 void doAction(SaleProcess p, SalesPoint sp)
          If the capability is granting rights, perform the guarded action; otherwise, print a message to the user that he/she is not granted the right to perform this action.
 Capability getToggled()
          Get the ActionCapability that is the inverse to this one.
 boolean isGranted()
          Return true if this capability is granting rights.
 
Methods inherited from class users.AbstractCapability
getDisplayName, getDisplayName, getName, setDisplayNameResourceBundleName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActionCapability

public ActionCapability(String sName,
                        Action aToDo)
Create a granted capability.

Parameters:
sName - the name of the capability.
aToDo - the Action to be guarded.

ActionCapability

public ActionCapability(String sName,
                        String sOnDeny,
                        Action aToDo,
                        boolean fGranted)
Create a new ActionCapability.

Parameters:
sName - the name of the capability.
sOnDeny - a message to be popped up on denial.
aToDo - the Action to be guarded.
fGranted - true if this capability is to grant rights.
Method Detail

getToggled

public Capability getToggled()
Get the ActionCapability that is the inverse to this one. I.e. if this capability grants the right to execute a given action, the returned capability will deny this right and vice versa.

Specified by:
getToggled in interface Capability
Specified by:
getToggled in class AbstractCapability
Returns:
the ActionCapability that is the inverse to this one.
Override:
Never

isGranted

public boolean isGranted()
Return true if this capability is granting rights.

Specified by:
isGranted in interface Capability
Specified by:
isGranted in class AbstractCapability
Returns:
true if this capability is granting rights.
Override:
Never

doAction

public void doAction(SaleProcess p,
                     SalesPoint sp)
              throws Throwable
If the capability is granting rights, perform the guarded action; otherwise, print a message to the user that he/she is not granted the right to perform this action.

Specified by:
doAction in interface Action
Parameters:
p - the process in which to perform the action
sp - the SalesPoint on which to perform the action.
Throws:
Throwable - on any error that shall be reported and lead to cancellation of the action.
Override:
Never

SalesPoint v3.3 API