org.salespointframework.desktop.strategies
Class AbstractAddCatalogItemStrategy

java.lang.Object
  extended by org.salespointframework.desktop.strategies.FormSheetStrategy
      extended by org.salespointframework.desktop.strategies.EditButtonStrategy
          extended by org.salespointframework.desktop.strategies.AbstractAddCatalogItemStrategy
All Implemented Interfaces:
ProcessErrorCodes

public abstract class AbstractAddCatalogItemStrategy
extends EditButtonStrategy

A strategy that can be attached to the "Add" button of a SingleTableFormSheet that displays a Catalog's contents.

This strategy is abstract since the creation of the CatalogItem is application specific. It must be defined by overriding createCatalogItem(java.lang.String).

Since:
v2.0
Version:
2.0 20/08/1999
Author:
Steffen Zschaler

Nested Class Summary
 
Nested classes/interfaces inherited from class org.salespointframework.desktop.strategies.FormSheetStrategy
FormSheetStrategy.ErrorHandler
 
Field Summary
static java.lang.String KEY_LABEL
          The resource bundle key of the label to be shown in the "Define Key" FormSheet.
protected  Catalog<CatalogItem> m_cCatalog
          The Catalog to be edited.
 
Fields inherited from class org.salespointframework.desktop.strategies.FormSheetStrategy
DEFAULT_ERROR_HANDLER, m_ehErrHandler, MSG_POPUP_ERROR_HANDLER
 
Fields inherited from interface org.salespointframework.core.exceptions.ProcessErrorCodes
DATABASKET_CONFLICT_ERROR, DUPLICATE_KEY_EXCEPTION, ERR_FORCED_SHUTDOWN, ERR_INTERNAL, ERR_LOWERBOUND, ERR_NOERROR, ERR_UPPERBOUND, NOT_ENOUGH_ELEMENTS_ERROR, REMOVE_VETO_EXCEPTION
 
Constructor Summary
AbstractAddCatalogItemStrategy(Catalog<CatalogItem> c)
          Create a new AbstractAddCatalogItemStrategy.
 
Method Summary
protected  void addToCatalog(SaleProcess p, CatalogItem ci)
          Add the specified CatalogItem to the Catalog.
protected abstract  CatalogItem createCatalogItem(java.lang.String sKey)
          Create a new CatalogItem of the given key.
protected  Gate getCreateCIGate(SingleTableFormSheet stfs)
          Get the first Gate in the sub-process.
protected  Gate getEditCIGate(CatalogItem ci, SingleTableFormSheet stfs, Transition tOk)
          Get a Gate at which a newly created CatalogItem can be edited by the user.
 Transition getEditProcess(SingleTableFormSheet stfs, SaleProcess p, SalesPoint sp)
          Get the first transition of the process that will perform the editing.
protected  java.lang.String getNewKey(SingleTableFormSheet stfs, SaleProcess p)
          Get the key of the new item.
protected  java.lang.String getResourceString(java.lang.String sKey)
          Get the resource String for the specified key.
 
Methods inherited from class org.salespointframework.desktop.strategies.FormSheetStrategy
error, setErrorHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_LABEL

public static final java.lang.String KEY_LABEL
The resource bundle key of the label to be shown in the "Define Key" FormSheet.

See Also:
Constant Field Values

m_cCatalog

protected Catalog<CatalogItem> m_cCatalog
The Catalog to be edited.

Constructor Detail

AbstractAddCatalogItemStrategy

public AbstractAddCatalogItemStrategy(Catalog<CatalogItem> c)
Create a new AbstractAddCatalogItemStrategy.

Parameters:
c - the Catalog to be edited. Must be the same that is displayed in the SingleTableFormSheet.
Method Detail

getEditProcess

public Transition getEditProcess(SingleTableFormSheet stfs,
                                 SaleProcess p,
                                 SalesPoint sp)
Description copied from class: EditButtonStrategy
Get the first transition of the process that will perform the editing. The process can have any number of Gates and Transitions and display any number of Form- and MenuSheets. Normally, the sub-process should end at the gate at which the SingleTableFormSheet is being displayed, which can be obtained by SingleTableFormSheet.getGate().

Specified by:
getEditProcess in class EditButtonStrategy
Parameters:
stfs - the SingleTableFormSheet that triggers the sub-process.
p - the process into which the sub-process will be implanted.
sp - the SalesPoint at which the FormSheet is displayed, if any.

getCreateCIGate

protected Gate getCreateCIGate(SingleTableFormSheet stfs)
Get the first Gate in the sub-process. This Gate asks the user for the key of the new item, creates it in a new Transition and after editing the new item adds it to the Catalog.

Parameters:
stfs - the FormSheet that triggered the sub-process.

getNewKey

protected java.lang.String getNewKey(SingleTableFormSheet stfs,
                                     SaleProcess p)
                              throws java.lang.InterruptedException
Get the key of the new item. Can assume that at a Gate.

Parameters:
stfs - the FormSheet that triggered the sub-process.
p - the process into which the sub-process was embedded.
Throws:
java.lang.InterruptedException

createCatalogItem

protected abstract CatalogItem createCatalogItem(java.lang.String sKey)
Create a new CatalogItem of the given key.

Parameters:
sKey - the key for which to create a new CatalogItem.
Returns:
the new CatalogItem.

getEditCIGate

protected Gate getEditCIGate(CatalogItem ci,
                             SingleTableFormSheet stfs,
                             Transition tOk)
Get a Gate at which a newly created CatalogItem can be edited by the user.

Parameters:
ci - the CatalogItem to be edited.
stfs - the FormSheet that triggered the sub-process. A transition to this FormSheet's gate must be leaving the Gate if the user cancels the operation.
tOk - the Transition that must be leaving the Gate if the user finished editing and did not cancel the operation or enter invalid data.

addToCatalog

protected void addToCatalog(SaleProcess p,
                            CatalogItem ci)
Add the specified CatalogItem to the Catalog.

Any error condition should be passed on to FormSheetStrategy.error(org.salespointframework.core.SaleProcess, int) in FormSheetStrategy.

Parameters:
p - the process into which the sub-process was embedded.
ci - the CatalogItem to be added to the Catalog.

getResourceString

protected java.lang.String getResourceString(java.lang.String sKey)
Get the resource String for the specified key.