org.salespointframework.core
Class Shop

java.lang.Object
  extended by org.salespointframework.core.Shop
All Implemented Interfaces:
java.util.EventListener

public class Shop
extends java.lang.Object
implements java.util.EventListener

The central class in a SalesPoint application, responsible for central management tasks and for persistence.

There is only one instance of the Shop class per application, and you can obtain, or change this central, singleton instance through calls to getTheShop() or setTheShop(org.salespointframework.core.Shop), resp.

The Shop will manage the application's display, creating and removing additional SalesPoints' displays as necessary. Also, the Shop will offer a central MenuSheet, from which the user can select certain central, administrative actions, like shutdown, loadup, creating and removing SalesPoints, etc. This MenuSheet can, of course, be adapted. See createShopMenuSheet(), if you're interested in this.

The Shop can make persistent the entire current state of the application by calling just one method: #makePersistent.

The Shop serves as a ProcessContext for remote and background processes, which will be equipped with a NullDisplay. To find out about running processes at the Shop, see runProcess(org.salespointframework.core.SaleProcess, org.salespointframework.core.Display, org.salespointframework.core.users.User, org.salespointframework.core.data.interfaces.DataBasket) and runBackgroundProcess(org.salespointframework.core.SaleProcess, org.salespointframework.core.users.User, org.salespointframework.core.data.interfaces.DataBasket).

Since:
v2.0
Version:
2.0 28/05/1999
Author:
Steffen Zschaler

Nested Class Summary
protected static class Shop.ProcessHandle
          A ProcessContext for one remote or background process.
 
Field Summary
static java.lang.String DBM_TAG
          MenuSheetObject tag marking the "Database Manager" item.
static int DEAD
          Constant marking the Shop's state.
private static javax.swing.ImageIcon LOAD_ICON
          Icon MenuItem "Load".
static java.lang.String LOAD_TAG
          MenuSheetObject tag marking the "Load...
protected  javax.swing.JFrame m_jfShopFrame
          The Shop's frame.
protected  java.util.List<Shop.ProcessHandle> m_lphProcesses
          All remote or background processes currently running on this Shop, represented by their process handles.
protected  java.util.List<SalesPoint> m_lspSalesPoints
          The SalesPoints that belong to the system.
private  java.util.Map<java.lang.String,Catalog<?>> m_mpCatalogs
          The global catalogs.
private  java.util.Map<java.lang.String,Stock> m_mpStocks
          The global Stocks.
private  MenuSheet m_msMultiWindowMenu
          Temporary helper variable to be able to insert the MultiWindow MenuSheet into the Shop's menu.
private  NameContext m_ncCatalogContext
          The global Catalogs' name context.
private  NameContext m_ncStockContext
          The global Stocks' name context.
private  int m_nCurrentSalesPointIsAdjusting
          Flag indicating whether calls to setCurrentSalesPoint(org.salespointframework.core.SalesPoint) are to have an effect or not.
private  int m_nShopState
          The current state of the Shop.
private  java.lang.Object m_oCatalogsLock
          The monitor synchronizing access to the Catalogs.
private  java.lang.Object m_oProcessesLock
          The monitor synchronizing access to the list of processes.
private  java.lang.Object m_oSalesPointsLock
          The monitor synchronizing access to the list of SalesPoints.
private  java.lang.Object m_oStateLock
          The monitor synchronizing access to the Shop's state.
private  java.lang.Object m_oStocksLock
          The monitor synchronizing access to the Stocks.
protected  java.util.Map<java.lang.String,java.lang.Object> m_pContext
          ProcessContext data.
protected  java.awt.Rectangle m_rShopFrameBounds
          The ShopFrames bounds.
private  SalesPoint m_spCurrent
          The current SalesPoint.
protected  java.lang.String m_sShopFrameTitle
          The title of the Shop's frame.
protected  Timer m_trTimer
          The Timer used by this Shop for managing the simulation time.
private  WindowRepaintListener m_wrlWindowRepaintListener
          Current WindowRepaintListener
private static java.lang.String PREFERENCE_SHOP_HEIGHT
          Shop frames height
private static java.lang.String PREFERENCE_SHOP_VIEWMODE
          Shop frames viewmode
private static java.lang.String PREFERENCE_SHOP_WIDTH
          Shop frames width
private static java.lang.String PREFERENCE_SHOP_X
          Shop frames x-position
private static java.lang.String PREFERENCE_SHOP_Y
          Shop frames y-position
private static PreferenceStorage preferenceStorage
          Shop's preference storage
static java.lang.String QUIT_SHOP_TAG
          MenuSheetObject tag marking the "Quit" item.
static int RUNNING
          Constant marking the Shop's state.
private static java.lang.Object s_oShopLock
          The monitor used to synchronized access to the singleton.
private static Shop s_shTheShop
          The singleton instance of the Shop, that is used throughout the entire application.
static java.lang.String SALESPOINT_FULL_NAME
           
static java.lang.String SALESPOINT_MAJOR_VERSION
           
static java.lang.String SALESPOINT_MINOR_VERSION
           
static java.lang.String SALESPOINT_NAME
           
static java.lang.String SALESPOINT_VERSION_CODENAME
           
private static javax.swing.ImageIcon SAVE_ICON
          Icon MenuItem "Save".
static java.lang.String SAVE_TAG
          MenuSheetObject tag marking the "Save...
static java.lang.String SEPARATOR_ONE_TAG
          MenuSheetObject tag marking the first separator.
static java.lang.String SEPARATOR_TWO_TAG
          MenuSheetObject tag marking the second separator.
static java.lang.String SET_CURRENT_SP_TAG
          MenuSheetObject tag marking the "Set Current SalesPoint" item.
static java.lang.String SHOP_MENU_TAG
          MenuSheetObject tag marking the entire Shop MenuSheet.
static int SUSPENDED
          Constant marking the Shop's state.
 
Constructor Summary
protected Shop()
          Sole constructor to enforce singleton pattern.
 
Method Summary
 void addCatalog(Catalog<?> c)
          Add a Catalog to the global table of Catalogs.
 void addSalesPoint(SalesPoint sp)
          Add a SalesPoint to the Shop.
 void addStock(Stock<?,?> st)
          Add a Stock to the global list of Stocks.
protected  boolean canShutdown()
          Check whether shutdown can be permitted in the current state of the system.
 boolean checkForRunningProcessesAndUser()
          checks for running processes and or logged on users on this shop
protected  void clearInternalStructures()
          Clear the internal structures maintained by the Shop, thus finishing off shutdown.
protected  MultiWindow createShopFrame()
          Creates and returns a new MultiWindow with window view mode set.
protected  MenuSheet createShopMenuSheet()
          Create and return the Shop's main MenuSheet.
 void forceGlobalProcessTermination()
          This method kills all processes on all SalesPoints
<T extends CatalogItem>
Catalog<T>
getCatalog(CatalogIdentifier<T> ciId)
          Get a Catalog from the global list of Catalogs.
 Catalog<?> getCatalog(java.lang.String sName)
          Get a Catalog from the global list of Catalogs.
private  java.lang.Object getCatalogsLock()
          Return the monitor synchronizing access to the Catalogs.
private  javax.swing.JFileChooser getChooser()
          Helper method creating the dialog in which the user can select the persistence file.
 SalesPoint getCurrentSalesPoint()
          Returns the currently active SalesPoint of the Shop.
private  java.awt.Rectangle getDefaultShopFrameBounds()
          Calculates the default Shop frame position
static Shop getInstance()
          Get the current instance
static PreferenceStorage getPreferenceStorage()
          get the currently active preference storage
protected  java.lang.Object getProcessesLock()
          Return the monitor synchronizing access to the list of processes.
 SalesPoint getSalesPoint(int id)
          get SalesPoint by id ( SalesPoint.getID() )
 java.util.List<SalesPoint> getSalesPoints()
          Get a list of all SalesPoints in the Shop.
protected  java.lang.Object getSalesPointsLock()
          Return the monitor synchronizing access to the list of SalesPoints.
 javax.swing.JFrame getShopFrame()
          Gets the Shop's main frame.
 java.awt.Rectangle getShopFrameBounds()
          Returns the Framebounds of the Shops assoziated JFrame.
 java.lang.String getShopFrameTitle()
          get m_sShopFrameTitle
 int getShopState()
          Return the Shop's state, being one of DEAD, RUNNING or SUSPENDED.
private  java.lang.Object getStateLock()
          Return the monitor synchronizing access to the Shop's state.
<T extends StockItem,CT extends CatalogItem>
Stock<T,CT>
getStock(StockIdentifier<T,CT> ciId)
          Look up a Stock in the global Stock list.
 Stock getStock(java.lang.String sName)
          Look up a Stock in the global Stock list.
private  java.lang.Object getStocksLock()
          Return the monitor synchronizing access to the Stocks.
static Shop getTheShop()
          Get the global, singleton Shop instance.
 Timer getTimer()
          Get the Shop's timer.
 WindowRepaintListener getWindowRepaintListener()
          get m_wrlWindowRepaintListener
 void initializeData()
          Called, when the PersistenceManager asks the Shop to initialize it's data
 boolean isCurrentSalesPointAdjusting()
          Return whether or not calls to setCurrentSalesPoint(org.salespointframework.core.SalesPoint) have any effect.
 void log(Loggable la)
          Log a piece of information to the global log file.
protected  void onSalesPointAdded(SalesPoint sp)
          Hook method performing additional work when a SalesPoint was added.
protected  void onSalesPointRemoved(SalesPoint sp)
          Hook method called when a SalesPoint was removed from the Shop.
 void quit()
          Close the Shop and quit the application.
 Catalog<?> removeCatalog(java.lang.String sName)
          Remove a catalog from the global table of Catalogs.
 void removeSalesPoint(SalesPoint sp)
          Remove a SalesPoint from the Shop.
protected  void removeStatusDisplay(Display d)
          Close a status display.
 Stock removeStock(java.lang.String sName)
          Remove a Stock from the global list of Stocks.
 void resetCurrentSalesPointIsAdjusting()
          Reset a flag that can be used to optimize setCurrentSalesPoint calls.
 void resume()
          Resume a suspended Shop.
 void runBackgroundProcess(SaleProcess p, User usr, DataBasket db)
          Run a background process on the Shop.
 void runProcess(SaleProcess p, Display d, User usr, DataBasket db)
          Run a process on the Shop.
private  void SaveShopState()
          save window position and view mode to PreferenceStorage
 void setCurrentSalesPoint(SalesPoint sp)
          Makes a SalesPoint the current SalesPoint.
 void setCurrentSalesPointIsAdjusting()
          Sets a flag that can be used to optimize setCurrentSalesPoint calls.
static void setPreferenceStorage(PreferenceStorage ps)
          Replace the preference storage Should be done before calling #start()
private  void setSavedShopFrameBounds()
          Loads the Shop frame bounds from PreferenceStorage
 void setShopFrameBounds(java.awt.Rectangle r)
          Sets the Framebounds of the Shops assoziated JFrame.
 void setShopFrameTitle(java.lang.String sTitle)
          Set the Shop frame's title.
static void setTheShop(Shop shTheShop)
          Set the global, singleton Shop instance.
 void setTimer(Timer trTimer)
          Set the Shop's Timer.
 void setViewMode(int viewMode)
          Sets the view mode for the Shop.
 void setWindowRepaintListener(WindowRepaintListener wrl)
          Sets the callback for replacing the default SalesPoint background render in the shop window
protected  void showShutdownPreventedHint(MultiWindow mw)
          Shows a hint if the shop shutdown was prevented by something.
 boolean shutdown()
          Close the Shop.
 void start()
          Start the Shop.
 void suspend()
          Suspend a running Shop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SALESPOINT_NAME

public static final java.lang.String SALESPOINT_NAME
See Also:
Constant Field Values

SALESPOINT_MAJOR_VERSION

public static final java.lang.String SALESPOINT_MAJOR_VERSION
See Also:
Constant Field Values

SALESPOINT_MINOR_VERSION

public static final java.lang.String SALESPOINT_MINOR_VERSION
See Also:
Constant Field Values

SALESPOINT_VERSION_CODENAME

public static final java.lang.String SALESPOINT_VERSION_CODENAME

SALESPOINT_FULL_NAME

public static final java.lang.String SALESPOINT_FULL_NAME

preferenceStorage

private static PreferenceStorage preferenceStorage
Shop's preference storage


m_wrlWindowRepaintListener

private WindowRepaintListener m_wrlWindowRepaintListener
Current WindowRepaintListener


m_pContext

protected java.util.Map<java.lang.String,java.lang.Object> m_pContext
ProcessContext data.


m_lspSalesPoints

protected java.util.List<SalesPoint> m_lspSalesPoints
The SalesPoints that belong to the system.


m_oSalesPointsLock

private transient java.lang.Object m_oSalesPointsLock
The monitor synchronizing access to the list of SalesPoints.


m_spCurrent

private SalesPoint m_spCurrent
The current SalesPoint.


m_nCurrentSalesPointIsAdjusting

private int m_nCurrentSalesPointIsAdjusting
Flag indicating whether calls to setCurrentSalesPoint(org.salespointframework.core.SalesPoint) are to have an effect or not. Used for optimization reasons.


m_rShopFrameBounds

protected java.awt.Rectangle m_rShopFrameBounds
The ShopFrames bounds.


m_lphProcesses

protected java.util.List<Shop.ProcessHandle> m_lphProcesses
All remote or background processes currently running on this Shop, represented by their process handles.


m_oProcessesLock

private transient java.lang.Object m_oProcessesLock
The monitor synchronizing access to the list of processes.


m_mpCatalogs

private java.util.Map<java.lang.String,Catalog<?>> m_mpCatalogs
The global catalogs.


m_oCatalogsLock

private transient java.lang.Object m_oCatalogsLock
The monitor synchronizing access to the Catalogs.


m_ncCatalogContext

private final NameContext m_ncCatalogContext
The global Catalogs' name context. ATTENTION: Currently rollback and/or commit of Catalog name changes are not supported.


m_mpStocks

private java.util.Map<java.lang.String,Stock> m_mpStocks
The global Stocks.


m_oStocksLock

private transient java.lang.Object m_oStocksLock
The monitor synchronizing access to the Stocks.


m_ncStockContext

private final NameContext m_ncStockContext
The global Stocks' name context. ATTENTION: Currently rollback and/or commit of Stock name changes are not supported.


m_nShopState

private int m_nShopState
The current state of the Shop. One of DEAD, RUNNING or SUSPENDED.


m_oStateLock

private transient java.lang.Object m_oStateLock
The monitor synchronizing access to the Shop's state.


m_jfShopFrame

protected transient javax.swing.JFrame m_jfShopFrame
The Shop's frame.


m_sShopFrameTitle

protected java.lang.String m_sShopFrameTitle
The title of the Shop's frame.


m_msMultiWindowMenu

private transient MenuSheet m_msMultiWindowMenu
Temporary helper variable to be able to insert the MultiWindow MenuSheet into the Shop's menu.


m_trTimer

protected Timer m_trTimer
The Timer used by this Shop for managing the simulation time.


PREFERENCE_SHOP_X

private static final java.lang.String PREFERENCE_SHOP_X
Shop frames x-position

See Also:
Constant Field Values

PREFERENCE_SHOP_Y

private static final java.lang.String PREFERENCE_SHOP_Y
Shop frames y-position

See Also:
Constant Field Values

PREFERENCE_SHOP_WIDTH

private static final java.lang.String PREFERENCE_SHOP_WIDTH
Shop frames width

See Also:
Constant Field Values

PREFERENCE_SHOP_HEIGHT

private static final java.lang.String PREFERENCE_SHOP_HEIGHT
Shop frames height

See Also:
Constant Field Values

PREFERENCE_SHOP_VIEWMODE

private static final java.lang.String PREFERENCE_SHOP_VIEWMODE
Shop frames viewmode

See Also:
Constant Field Values

DEAD

public static final int DEAD
Constant marking the Shop's state. DEAD means the Shop was either shut down or not started yet.

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
Constant marking the Shop's state. RUNNING means the Shop was started and neither suspended nor shutdown.

See Also:
Constant Field Values

SUSPENDED

public static final int SUSPENDED
Constant marking the Shop's state. SUSPENDED means the Shop was suspended.

See Also:
Constant Field Values

SHOP_MENU_TAG

public static final java.lang.String SHOP_MENU_TAG
MenuSheetObject tag marking the entire Shop MenuSheet.

See Also:
Constant Field Values

SET_CURRENT_SP_TAG

public static final java.lang.String SET_CURRENT_SP_TAG
MenuSheetObject tag marking the "Set Current SalesPoint" item.

See Also:
Constant Field Values

SEPARATOR_ONE_TAG

public static final java.lang.String SEPARATOR_ONE_TAG
MenuSheetObject tag marking the first separator.

See Also:
Constant Field Values

LOAD_TAG

public static final java.lang.String LOAD_TAG
MenuSheetObject tag marking the "Load..." item.

See Also:
Constant Field Values

SAVE_TAG

public static final java.lang.String SAVE_TAG
MenuSheetObject tag marking the "Save..." item.

See Also:
Constant Field Values

DBM_TAG

public static final java.lang.String DBM_TAG
MenuSheetObject tag marking the "Database Manager" item.

See Also:
Constant Field Values

SEPARATOR_TWO_TAG

public static final java.lang.String SEPARATOR_TWO_TAG
MenuSheetObject tag marking the second separator.

See Also:
Constant Field Values

QUIT_SHOP_TAG

public static final java.lang.String QUIT_SHOP_TAG
MenuSheetObject tag marking the "Quit" item.

See Also:
Constant Field Values

LOAD_ICON

private static final javax.swing.ImageIcon LOAD_ICON
Icon MenuItem "Load".


SAVE_ICON

private static final javax.swing.ImageIcon SAVE_ICON
Icon MenuItem "Save".


s_shTheShop

private static Shop s_shTheShop
The singleton instance of the Shop, that is used throughout the entire application.


s_oShopLock

private static java.lang.Object s_oShopLock
The monitor used to synchronized access to the singleton.

Constructor Detail

Shop

protected Shop()
Sole constructor to enforce singleton pattern.

Method Detail

getSalesPointsLock

protected final java.lang.Object getSalesPointsLock()
Return the monitor synchronizing access to the list of SalesPoints.


getProcessesLock

protected final java.lang.Object getProcessesLock()
Return the monitor synchronizing access to the list of processes.


getCatalogsLock

private final java.lang.Object getCatalogsLock()
Return the monitor synchronizing access to the Catalogs.


getStocksLock

private final java.lang.Object getStocksLock()
Return the monitor synchronizing access to the Stocks.


getStateLock

private final java.lang.Object getStateLock()
Return the monitor synchronizing access to the Shop's state.


addSalesPoint

public void addSalesPoint(SalesPoint sp)
Add a SalesPoint to the Shop.

Parameters:
sp - the SalesPoint to be added.

setViewMode

public void setViewMode(int viewMode)
Sets the view mode for the Shop.

Parameters:
viewMode - can be MultiWindow.WINDOW_VIEW, MultiWindow.TABBED_VIEW, MultiWindow.DESKTOP_VIEW

onSalesPointAdded

protected void onSalesPointAdded(SalesPoint sp)
Hook method performing additional work when a SalesPoint was added.

Parameters:
sp - the SalesPoint that was removed from the Shop.

removeSalesPoint

public void removeSalesPoint(SalesPoint sp)
Remove a SalesPoint from the Shop.

Prior to being removed from the Shop, the SalesPoint will be suspended.

Parameters:
sp - the SalesPoint to be removed

onSalesPointRemoved

protected void onSalesPointRemoved(SalesPoint sp)
Hook method called when a SalesPoint was removed from the Shop.

Parameters:
sp - the SalesPoint that was removed from the Shop.

removeStatusDisplay

protected void removeStatusDisplay(Display d)
Close a status display.

Parameters:
d - the status display to be closed.

setPreferenceStorage

public static void setPreferenceStorage(PreferenceStorage ps)
Replace the preference storage Should be done before calling #start()

Parameters:
ps - the new PreferenceStorage

getPreferenceStorage

public static PreferenceStorage getPreferenceStorage()
get the currently active preference storage

Returns:

getSalesPoints

public java.util.List<SalesPoint> getSalesPoints()
Get a list of all SalesPoints in the Shop.

The list is backed by the SalesPoint's queue, but is immutable.


getSalesPoint

public SalesPoint getSalesPoint(int id)
get SalesPoint by id ( SalesPoint.getID() )

Parameters:
id -
Returns:

setWindowRepaintListener

public void setWindowRepaintListener(WindowRepaintListener wrl)
Sets the callback for replacing the default SalesPoint background render in the shop window

Parameters:
wrl - the new WindowRepaintListener

getWindowRepaintListener

public WindowRepaintListener getWindowRepaintListener()
get m_wrlWindowRepaintListener

Returns:

setCurrentSalesPoint

public void setCurrentSalesPoint(SalesPoint sp)
Makes a SalesPoint the current SalesPoint.

This will bring the specified SalesPoint's window to the front.

Parameters:
sp - the SalesPoint to be the current SalesPoint from now on.

setCurrentSalesPointIsAdjusting

public void setCurrentSalesPointIsAdjusting()
Sets a flag that can be used to optimize setCurrentSalesPoint calls. As long as this flag is set, i.e. isCurrentSalesPointAdjusting() returns true, calls to setCurrentSalesPoint(org.salespointframework.core.SalesPoint) will have no effect. You can reset the flag by calling resetCurrentSalesPointIsAdjusting().


resetCurrentSalesPointIsAdjusting

public void resetCurrentSalesPointIsAdjusting()
Reset a flag that can be used to optimize setCurrentSalesPoint calls. There must be one call to resetCurrentSalesPointIsAdjusting for each call to setCurrentSalesPointIsAdjusting(). Calls to this function must be followed by an explicit call to setCurrentSalesPoint(org.salespointframework.core.SalesPoint).


isCurrentSalesPointAdjusting

public boolean isCurrentSalesPointAdjusting()
Return whether or not calls to setCurrentSalesPoint(org.salespointframework.core.SalesPoint) have any effect.


getCurrentSalesPoint

public SalesPoint getCurrentSalesPoint()
Returns the currently active SalesPoint of the Shop.


runProcess

public void runProcess(SaleProcess p,
                       Display d,
                       User usr,
                       DataBasket db)
Run a process on the Shop.

Parameters:
p - the process to be run.
d - the display to be used by the Shop. This can be null, then, a NullDisplay will be used.
usr - the user to be the current user for the process.
db - the DataBasket to be used by the process.

runBackgroundProcess

public void runBackgroundProcess(SaleProcess p,
                                 User usr,
                                 DataBasket db)
Run a background process on the Shop. A background process does not have a display. You can use background processes to perform tasks that do not need user communication.

Parameters:
p - the process to be run.
usr - the user to be the current user for the process.
db - the DataBasket to be used by the process.

SaveShopState

private void SaveShopState()
save window position and view mode to PreferenceStorage


setSavedShopFrameBounds

private void setSavedShopFrameBounds()
Loads the Shop frame bounds from PreferenceStorage


getDefaultShopFrameBounds

private java.awt.Rectangle getDefaultShopFrameBounds()
Calculates the default Shop frame position

Returns:

start

public void start()
Start the Shop.

This method must not be called after load up.


setShopFrameBounds

public void setShopFrameBounds(java.awt.Rectangle r)
Sets the Framebounds of the Shops assoziated JFrame.

Example:

Shop.getTheShop().setShopFrameBounds (new Rectangle (10,10,200,200)); This moves the JFrame to Position (10,10) with a size of (200,200).


getShopFrameBounds

public java.awt.Rectangle getShopFrameBounds()
Returns the Framebounds of the Shops assoziated JFrame.


suspend

public void suspend()
Suspend a running Shop. Suspending the Shop includes suspending all SalesPoints currently in the Shop.


resume

public void resume()
Resume a suspended Shop. Resuming includes resuming all SalesPoints currently in the Shop.


quit

public final void quit()
Close the Shop and quit the application.

This method is linked to the "Quit" item in the Shop's MenuSheet as well as to the close window gesture for the Shop frame.


checkForRunningProcessesAndUser

public final boolean checkForRunningProcessesAndUser()
checks for running processes and or logged on users on this shop

Returns:

forceGlobalProcessTermination

public final void forceGlobalProcessTermination()
This method kills all processes on all SalesPoints


shutdown

public boolean shutdown()
Close the Shop.

Calling this method will stop any processes currently running on any SalesPoints in the Shop after calling canShutdown() to check whether shutdown is permitted at the moment. The method must therefore not be called from within a process !

Returns:
true if the shutdown was successful.

showShutdownPreventedHint

protected void showShutdownPreventedHint(MultiWindow mw)
Shows a hint if the shop shutdown was prevented by something. the recommended way is to show the hint on the mw.getPopupLayer()

Parameters:
mw - Shops MultiWindow, obtained by getShopFrame()

canShutdown

protected boolean canShutdown()
Check whether shutdown can be permitted in the current state of the system.

In this method you can assume that you are the owner of getSalesPointsLock() and getProcessesLock(), so that you can access the list of SalesPoints and the list of processes without extra synchronization.

The default implementation will first suspend() the Shop, should its state be RUNNING. It will then check all processes running on the Shop. If no such processes exist or if all of them confirm that shut down is possible, it will call the SalesPoint.canQuit(boolean) method of any SalesPoint in the system, passing !fPersistify as the parameter. If all SalesPoints return true, the Shop stays suspended and canShutdown returns true. In any other case, the Shop will be resumed again, and false will be returned.

This method is usually not called directly, but if you do, make sure to call it with synchronization on getSalesPointsLock() and getProcessesLock().

Returns:
true to indicate shutdown is OK; false otherwise.

getShopState

public int getShopState()
Return the Shop's state, being one of DEAD, RUNNING or SUSPENDED.


getChooser

private javax.swing.JFileChooser getChooser()
Helper method creating the dialog in which the user can select the persistence file.


clearInternalStructures

protected void clearInternalStructures()
Clear the internal structures maintained by the Shop, thus finishing off shutdown.


setShopFrameTitle

public void setShopFrameTitle(java.lang.String sTitle)
Set the Shop frame's title. Initially, this is "Shop".

Parameters:
sTitle - the new title.

getShopFrameTitle

public java.lang.String getShopFrameTitle()
get m_sShopFrameTitle

Returns:

getShopFrame

public javax.swing.JFrame getShopFrame()
Gets the Shop's main frame.

The main Shop frame will be the frame in which the Shop's menu gets displayed.

By default this creates a MultiWindow with the title that you specified in a call to setShopFrameTitle(java.lang.String).


createShopFrame

protected MultiWindow createShopFrame()
Creates and returns a new MultiWindow with window view mode set.


createShopMenuSheet

protected MenuSheet createShopMenuSheet()
Create and return the Shop's main MenuSheet.

The default implementation will provide two MenuSheets in the Shop's MenuSheet:

MenuSheet (name/tag) Item text Item tag Item action Comments
Shop SHOP_MENU_TAG Set current SalesPoint SET_CURRENT_SP_TAG setCurrentSalesPoint(). This is a Sub-MenuSheet that shows all the SalesPoints in the Shop. The user can click the one he or she wants to select. As long as this MenuSheet is found in the Shop's MenuSheet, it will be updated by calls to addSalesPoint(org.salespointframework.core.SalesPoint) and removeSalesPoint(org.salespointframework.core.SalesPoint).
Separator SEPARATOR_ONE_TAG
Load... LOAD_TAG Load a persistent Shop image.
Save... SAVE_TAG Save current Shop state to create a persistant Shop image.
Separator SEPARATOR_TWO_TAG
Quit QUIT_SHOP_TAG quit().
MultiWindow MultiWindow.MULTIWINDOW_MENU_TAG see MultiWindow.getMultiWindowMenuSheet()


getTimer

public Timer getTimer()
Get the Shop's timer. If no timer has been set using setTimer(org.salespointframework.core.Timer), the default timer will be a StepTimer with a Step time.

Returns:
the Shop's Timer

setTimer

public void setTimer(Timer trTimer)
Set the Shop's Timer.

Parameters:
trTimer - the Timer to be used from now on

log

public void log(Loggable la)
         throws java.io.IOException
Log a piece of information to the global log file.

Parameters:
la - the information to be logged.
Throws:
java.io.IOException - on any error while logging.

addStock

public void addStock(Stock<?,?> st)
              throws DuplicateKeyException
Add a Stock to the global list of Stocks. The Stock can later be identified by its name.

Parameters:
st - the Stock to be added to the global list of Stocks.
Throws:
DuplicateKeyException - if a Stock of the same name already exists in the global list of Stocks.

removeStock

public Stock removeStock(java.lang.String sName)
Remove a Stock from the global list of Stocks.

Parameters:
sName - the name of the Stock to be removed.
Returns:
the removed Stock, if any.

getStock

public Stock getStock(java.lang.String sName)
Look up a Stock in the global Stock list.

Parameters:
sName - the name of the Stock to be looked up.
Returns:
the Stock, if any.

getStock

public <T extends StockItem,CT extends CatalogItem> Stock<T,CT> getStock(StockIdentifier<T,CT> ciId)
Look up a Stock in the global Stock list. This is the generic version of getStock(String). It returns the correctly parametrized stock. However, this does only work if the Stock in question and it's identifier are parametrized equally.

Parameters:
ciId - the id of the Stock to be looked up.
Returns:
the Stock, if any.

addCatalog

public void addCatalog(Catalog<?> c)
                throws DuplicateKeyException
Add a Catalog to the global table of Catalogs. The Catalog will be identifiable by its name.

Parameters:
c - the Catalog to be added to the global list of Catalogs
Throws:
DuplicateKeyException - if a Catalog of the same name already existed in the global list of Catalogs.

initializeData

public void initializeData()
Called, when the PersistenceManager asks the Shop to initialize it's data


removeCatalog

public Catalog<?> removeCatalog(java.lang.String sName)
Remove a catalog from the global table of Catalogs.

Parameters:
sName - the name of the Catalog to be removed.
Returns:
the Catalog that was removed, if any.

getCatalog

public Catalog<?> getCatalog(java.lang.String sName)
Get a Catalog from the global list of Catalogs.

Parameters:
sName - the name of the Catalog to be returned.
Returns:
the associated Catalog, if any.

getCatalog

public <T extends CatalogItem> Catalog<T> getCatalog(CatalogIdentifier<T> ciId)
Get a Catalog from the global list of Catalogs. This is the generic version of getCatalog(String). It returns the correctly parametrized catalog. However, this does only work if the Catalog in question and it's identifier are parametrized equally.

Parameters:
ciId - the Identifier of the Catalog to be returned.
Returns:
the associated Catalog, if any.

getTheShop

public static Shop getTheShop()
Get the global, singleton Shop instance.


getInstance

public static Shop getInstance()
Get the current instance

Returns:
Shop

setTheShop

public static void setTheShop(Shop shTheShop)
Set the global, singleton Shop instance.

This method will only have an effect the next time, getTheShop() gets called. So to avoid inconsistency, use this method only in the beginning of your program, to install an instance of a subclass of Shop as the global, singleton Shop instance.

Parameters:
shTheShop - the new global, singleton Shop instance