001 package market.swing; 002 003 import sale.SaleProcess; 004 import sale.SalesPoint; 005 import data.Catalog; 006 import data.CatalogItem; 007 import data.CountingStock; 008 import data.DataBasket; 009 import data.NotEnoughElementsException; 010 import data.stdforms.twotableformsheet.CCSStrategy; 011 012 /** 013 * Defines the behaviour of the shifting buttons in the manager's Purchase-TwoTableFormSheet 014 */ 015 public class CCSStrategyMarket extends CCSStrategy { 016 017 public CCSStrategyMarket() { 018 super(); 019 } 020 021 /** 022 * Removes at most as much items as are left in the stock. 023 * @param p the current SaleProcess. 024 * @param sp the SalesPoint on which the TTFS is displayed. 025 * @param cSource the source Catalog. 026 * @param csDest the destination CountingStock. 027 * @param db the transaction's DataBasket. 028 * @param ci the affected CatalogItem 029 * @param nCount the amount of Items to be shifted. 030 */ 031 protected void moveToSource (SaleProcess p, SalesPoint sp, Catalog cSource, 032 CountingStock csDest, DataBasket db, CatalogItem ci, int nCount) { 033 int count = csDest.countItems(ci.getName(),db); 034 count = Math.min(count, nCount); 035 try { 036 csDest.remove (ci.getName(), count, db); 037 } 038 catch (NotEnoughElementsException nee) { 039 error (p, NOT_ENOUGH_ELEMENTS_ERROR); 040 } 041 catch (data.events.VetoException ve) { 042 error (p, REMOVE_VETO_EXCEPTION); 043 } 044 catch (Exception e) { 045 System.out.println(e); 046 } 047 } 048 }