SalesPoint Framework v3.1

data.stdforms.singletableformsheet
Class AbstractAddCatalogItemStrategy

java.lang.Object
  extended bysale.stdforms.FormSheetStrategy
      extended bydata.stdforms.singletableformsheet.EditButtonStrategy
          extended bydata.stdforms.singletableformsheet.AbstractAddCatalogItemStrategy
All Implemented Interfaces:
ProcessErrorCodes, Serializable

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
Author:
Steffen Zschaler
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class sale.stdforms.FormSheetStrategy
FormSheetStrategy.ErrorHandler
 
Field Summary
static String KEY_LABEL
          The resource bundle key of the label to be shown in the "Define Key" FormSheet.
protected  Catalog m_cCatalog
          The Catalog to be edited.
 
Fields inherited from class sale.stdforms.FormSheetStrategy
DEFAULT_ERROR_HANDLER, m_ehErrHandler, MSG_POPUP_ERROR_HANDLER
 
Fields inherited from interface sale.ProcessErrorCodes
DATABASKET_CONFLICT_ERROR, DUPLICATE_KEY_EXCEPTION, ERR_INTERNAL, ERR_LOWERBOUND, ERR_NOERROR, ERR_UPPERBOUND, NOT_ENOUGH_ELEMENTS_ERROR, REMOVE_VETO_EXCEPTION
 
Constructor Summary
AbstractAddCatalogItemStrategy(Catalog 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(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  String getNewKey(SingleTableFormSheet stfs, SaleProcess p)
          Get the key of the new item.
protected  String getResourceString(String sKey)
          Get the resource String for the specified key.
 
Methods inherited from class sale.stdforms.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 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 m_cCatalog
The Catalog to be edited.

Constructor Detail

AbstractAddCatalogItemStrategy

public AbstractAddCatalogItemStrategy(Catalog 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.
Override:
Never

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.
Override:
Never Instead, override getNewKey(data.stdforms.SingleTableFormSheet, sale.SaleProcess), createCatalogItem(java.lang.String), getEditCIGate(data.CatalogItem, data.stdforms.SingleTableFormSheet, sale.Transition) and/or addToCatalog(sale.SaleProcess, data.CatalogItem).

getNewKey

protected String getNewKey(SingleTableFormSheet stfs,
                           SaleProcess p)
                    throws 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:
InterruptedException
Override:
Sometimes The default implementation pops up a FormSheet where the user can enter a new key.

createCatalogItem

protected abstract CatalogItem createCatalogItem(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.
Override:
Always The contents of this method is application specific.

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.
Override:
Sometimes The default implementation simply continues with tOk.

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(sale.SaleProcess, int) in FormSheetStrategy.

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

getResourceString

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

Override:
Sometimes The default implementation returns ""Please specify the CatalogItem's key:"" if asked for KEY_LABEL.

SalesPoint Framework v3.1