Author: jleroux
Date: Sun Nov 1 20:04:17 2009 New Revision: 831753 URL: http://svn.apache.org/viewvc?rev=831753&view=rev Log: Handle several promo codes in the Promo status bar and canceling them, with the customer selected as well + some better French labels + some generics + a MaxInactivity parameter has been introduced (was harcoded) Added: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/PromoStatusBar.java - copied, changed from r831524, ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/StatusBar.java Removed: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/StatusBar.java Modified: ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosScreen.java ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java Modified: ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml (original) +++ ofbiz/trunk/specialpurpose/pos/config/PosUiLabels.xml Sun Nov 1 20:04:17 2009 @@ -373,8 +373,8 @@ <value xml:lang="zh">å¤çæ¯ä»...</value> </property> <property key="PosPromoCode"> - <value xml:lang="en">Promo code:</value> - <value xml:lang="fr">Code de promotion :</value> + <value xml:lang="en">Promo code(s):</value> + <value xml:lang="fr">Code(s) de promotion :</value> <value xml:lang="zh">ä¼æ å¸ä»£ç :</value> </property> <property key="PosQty"> Modified: ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties (original) +++ ofbiz/trunk/specialpurpose/pos/config/XuiLabels_fr.properties Sun Nov 1 20:04:17 2009 @@ -77,7 +77,7 @@ ReplaceAndDelete=<html><center>Remplacer et<br>supprimer SALE_DISC=Remise sur la vente SALE_VOIDED=Vente annul\u00e9e -SET_REF\#=n\u00b0 ? +SET_REF\#=Ref. de transaction SIGN_OUT=Sortir SKU=Code SWAP_KEYBOARD=Clavier virtuel @@ -88,7 +88,7 @@ TERMINAL_IS_CLOSED=Le terminal est ferm\u00e9 TEST_ALERT=Alerte (test) TEST_ALERT_BOX=Test de l'impl\u00e9mentation des alertes -TEST_MSR=Test MSR +TEST_MSR=Test lect. de carte TOTALS=Totals TRANS_RET=Recharger une vente TRANS_SAVE=Sauver la vente Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/PosTransaction.java Sun Nov 1 20:04:17 2009 @@ -631,7 +631,7 @@ } } - public void voidSale() { + public void voidSale(PosScreen pos) { trace("void sale"); txLog.set("statusId", "POSTX_VOIDED"); txLog.set("itemCount", new Long(cart.size())); @@ -642,6 +642,7 @@ Debug.logError(e, "Unable to store TX log - not fatal", module); } cart.clear(); + pos.getPromoStatusBar().clear(); currentTx = null; } Copied: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/PromoStatusBar.java (from r831524, ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/StatusBar.java) URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/PromoStatusBar.java?p2=ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/PromoStatusBar.java&p1=ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/StatusBar.java&r1=831524&r2=831753&rev=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/StatusBar.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/component/PromoStatusBar.java Sun Nov 1 20:04:17 2009 @@ -23,40 +23,59 @@ import net.xoetrope.swing.XEdit; import org.ofbiz.base.util.UtilProperties; +import org.ofbiz.base.util.UtilValidate; import org.ofbiz.pos.PosTransaction; import org.ofbiz.pos.screen.PosScreen; -public class StatusBar { - +public class PromoStatusBar { + protected static PosScreen m_pos = null; protected XEdit statusbarPromoCode = null; protected XEdit statusbarClient = null; private String customer = (UtilProperties.getMessage(PosTransaction.resource, "PosCustomer", Locale.getDefault())); private String promoCode = (UtilProperties.getMessage(PosTransaction.resource, "PosPromoCode", Locale.getDefault())); - public StatusBar(PosScreen page) { + public PromoStatusBar(PosScreen page) { + m_pos = page; statusbarClient = (XEdit) page.findComponent("statusbarClient"); statusbarClient.setFocusable(false); statusbarPromoCode = (XEdit) page.findComponent("statusbarPromoCode"); statusbarPromoCode.setFocusable(false); - clearClient(); - clearPromoCode(); } - public void printPromoCode(String message) { - statusbarPromoCode.setText(promoCode + " " + message); + public void addPromoCode(String message) { + String promoCodes = statusbarPromoCode.getText(); + if (UtilValidate.isNotEmpty(promoCodes)) { + statusbarPromoCode.setText(promoCodes + ", " + message); + } else { + statusbarPromoCode.setText(promoCode + " " + message); + } } - public void printClient(String message) { - statusbarClient.setText(customer + " " + - message); + public void displayClient(String message) { + statusbarClient.setText(customer + " " + message); } - public void clearPromoCode() { - statusbarPromoCode.setText(""); + public void clear() { + if (UtilValidate.isEmpty(statusbarPromoCode.getText())) { // to handle when on another screen + PosScreen newPos = m_pos.showPage("promopanel"); + PromoStatusBar promoStatusBar = newPos.getPromoStatusBar(); + XEdit statusbarPromoCode = promoStatusBar.getStatusbarPromoCode(); + statusbarPromoCode.setText(""); + XEdit statusbarClient = promoStatusBar.getStatusbarClient(); + statusbarClient.setText(""); + } else { + statusbarPromoCode.setText(""); + statusbarClient.setText(""); + } } - - public void clearClient() { - statusbarClient.setText(""); + + private XEdit getStatusbarPromoCode() { + return statusbarPromoCode; + } + + private XEdit getStatusbarClient() { + return statusbarClient; } } + \ No newline at end of file Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/config/ButtonEventConfig.java Sun Nov 1 20:04:17 2009 @@ -38,11 +38,12 @@ import org.w3c.dom.Element; +@SuppressWarnings("serial") public class ButtonEventConfig implements java.io.Serializable { public static final String module = ButtonEventConfig.class.getName(); public static final String BUTTON_EVENT_CONFIG = "buttonevents.xml"; - private static transient UtilCache buttonConfig = new UtilCache("pos.ButtonEvent", 0, 0, 0, false, true); + private static transient UtilCache<String, ButtonEventConfig> buttonConfig = new UtilCache<String, ButtonEventConfig>("pos.ButtonEvent", 0, 0, 0, false, true); protected String buttonName = null; protected String className = null; @@ -52,9 +53,9 @@ public static void loadButtonConfig() throws GenericConfigException { Element root = ResourceLoader.getXmlRootElement(ButtonEventConfig.BUTTON_EVENT_CONFIG); - List buttonEvents = UtilXml.childElementList(root, "event"); + List<?> buttonEvents = UtilXml.childElementList(root, "event"); if (!UtilValidate.isEmpty(buttonEvents)) { - Iterator i = buttonEvents.iterator(); + Iterator<?> i = buttonEvents.iterator(); while (i.hasNext()) { Element e = (Element) i.next(); ButtonEventConfig bef = new ButtonEventConfig(e); @@ -64,16 +65,16 @@ } public static boolean isLockable(String buttonName) { - ButtonEventConfig bef = (ButtonEventConfig) buttonConfig.get(buttonName); + ButtonEventConfig bef = buttonConfig.get(buttonName); if (bef == null) { return true; } return bef.isLockable(); } - public static void invokeButtonEvents(List buttonNames, PosScreen pos) throws ButtonEventNotFound, ButtonEventException { + public static void invokeButtonEvents(List<?> buttonNames, PosScreen pos) throws ButtonEventNotFound, ButtonEventException { if (buttonNames != null) { - Iterator i = buttonNames.iterator(); + Iterator<?> i = buttonNames.iterator(); while (i.hasNext()) { invokeButtonEvent(((String) i.next()), pos, null); } @@ -98,18 +99,18 @@ } // invoke the button event - ButtonEventConfig bef = (ButtonEventConfig) buttonConfig.get(buttonName); + ButtonEventConfig bef = buttonConfig.get(buttonName); if (bef == null) { throw new ButtonEventNotFound("No button definition found for button - " + buttonName); } bef.invoke(pos, event); } - public static List findButtonKeyAssign(int keyCode) { - List buttonAssignments = new ArrayList(); - Iterator i = buttonConfig.values().iterator(); + public static List<String> findButtonKeyAssign(int keyCode) { + List<String> buttonAssignments = new ArrayList<String>(); + Iterator<ButtonEventConfig> i = buttonConfig.values().iterator(); while (i.hasNext()) { - ButtonEventConfig bef = (ButtonEventConfig) i.next(); + ButtonEventConfig bef = i.next(); if (bef.getKeyCode() == keyCode) { buttonAssignments.add(bef.getName()); } @@ -175,7 +176,7 @@ Object[] params2 = new Object[] { pos }; // load the class - Class buttonClass = null; + Class<?> buttonClass = null; try { buttonClass = cl.loadClass(this.className); } catch (ClassNotFoundException e) { Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/MenuEvents.java Sun Nov 1 20:04:17 2009 @@ -168,16 +168,16 @@ // locate the product ID String productId = null; try { - List items = trans.lookupItem(value); + List<GenericValue> items = trans.lookupItem(value); if (items != null) { - ListIterator it = items.listIterator(); + ListIterator<GenericValue> it = items.listIterator(); if (it.hasNext()) { - GenericValue product = (GenericValue) it.next(); + GenericValue product = it.next(); productId = product.getString("productId"); - Hashtable productsMap = new Hashtable(); + Hashtable<String, Object> productsMap = new Hashtable<String, Object>(); productsMap.put(product.getString("productId"), product.get("internalName")); while (it.hasNext()) { - product = (GenericValue) it.next(); + product = it.next(); if (!productId.equals(product.getString("productId"))) { productsMap.put(product.getString("productId"), product.get("internalName")); } @@ -404,7 +404,7 @@ public static synchronized void voidAll(PosScreen pos) { PosTransaction trans = PosTransaction.getCurrentTx(pos.getSession()); - trans.voidSale(); + trans.voidSale(pos); NavagationEvents.showPosScreen(pos); pos.refresh(); } Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/event/PromoEvents.java Sun Nov 1 20:04:17 2009 @@ -25,7 +25,6 @@ import org.ofbiz.pos.PosTransaction; import org.ofbiz.pos.component.Input; import org.ofbiz.pos.component.Output; -import org.ofbiz.pos.component.StatusBar; import org.ofbiz.pos.screen.PosScreen; public class PromoEvents { @@ -48,15 +47,13 @@ } else if ("PROMOCODE".equals(lastFunc[0])) { String promoCode = input.value(); if (UtilValidate.isNotEmpty(promoCode)) { - StatusBar statusbar = new StatusBar(pos); - statusbar.clearPromoCode(); String result = trans.addProductPromoCode(promoCode); if (result != null) { pos.showDialog("dialog/error/exception", result); input.clearFunction("PROMOCODE"); } else { input.clearFunction("PROMOCODE"); - statusbar.printPromoCode(promoCode); + pos.getPromoStatusBar().addPromoCode(promoCode); NavagationEvents.showPosScreen(pos); pos.refresh(); } Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/ClientProfile.java Sun Nov 1 20:04:17 2009 @@ -43,7 +43,6 @@ import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.pos.PosTransaction; -import org.ofbiz.pos.component.StatusBar; @SuppressWarnings("serial") @@ -84,7 +83,6 @@ private static final String END_SENTINEL = UtilProperties.getPropertyValue("parameters", "EndSentinel", "?"); private static Locale locale = Locale.getDefault(); private String m_partyId = null; - protected StatusBar statusbar = null; //TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters @@ -152,10 +150,9 @@ String cardId = person.getString("cardId"); if (UtilValidate.isNotEmpty(cardId)) { String result = m_trans.addProductPromoCode(cardId); - statusbar = new StatusBar(m_pos); if (UtilValidate.isEmpty(result)) { - statusbar.printClient(person.getString("lastName")); - statusbar.printPromoCode(cardId); + m_pos.getPromoStatusBar().displayClient(person.getString("lastName")); + m_pos.getPromoStatusBar().addPromoCode(cardId); } else { m_pos.showDialog("dialog/error/exception", result); } Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/LoadSale.java Sun Nov 1 20:04:17 2009 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.pos.screen; -import java.util.Hashtable; import java.util.Iterator; import java.util.Locale; import java.util.Map; @@ -27,7 +26,6 @@ import javax.swing.ListSelectionModel; import javolution.util.FastMap; - import net.xoetrope.swing.XButton; import net.xoetrope.swing.XDialog; import net.xoetrope.swing.XList; @@ -39,6 +37,7 @@ import org.ofbiz.pos.PosTransaction; +@SuppressWarnings("serial") public class LoadSale extends XPage { /** @@ -84,11 +83,8 @@ XEventHelper.addMouseHandler(this, m_replaceAndDelete, "replaceSaleAndDeleteShoppingList"); m_listModel = new DefaultListModel(); - for (Iterator i = m_saleMap.entrySet().iterator(); i.hasNext();) { - Object o = i.next(); - Map.Entry entry = (Map.Entry)o; - String val = entry.getValue().toString(); - m_listModel.addElement(val); + for (Map.Entry<String, String> o : m_saleMap.entrySet()) { + m_listModel.addElement(o.getValue().toString()); } m_salesList.setModel(m_listModel); m_salesList.setVisibleRowCount(-1); @@ -158,9 +154,9 @@ int index = m_salesList.getSelectedIndex(); m_saleMap.remove(shoppingListId); m_listModel = new DefaultListModel(); - for (Iterator i = m_saleMap.entrySet().iterator(); i.hasNext();) { + for (Iterator<?> i = m_saleMap.entrySet().iterator(); i.hasNext();) { Object o = i.next(); - Map.Entry entry = (Map.Entry)o; + Map.Entry<?, ?> entry = (Map.Entry<?, ?>)o; String val = entry.getValue().toString(); m_listModel.addElement(val); } @@ -197,10 +193,10 @@ String saleSelected = null; if (null != m_salesList.getSelectedValue()) { String sale = (String) m_salesList.getSelectedValue(); - Iterator i = m_saleMap.entrySet().iterator(); + Iterator<?> i = m_saleMap.entrySet().iterator(); while (i.hasNext()) { Object o = i.next(); - Map.Entry entry = (Map.Entry)o; + Map.Entry<?, ?> entry = (Map.Entry<?, ?>)o; String val = entry.getValue().toString(); if (val.equals(sale)) { saleSelected = entry.getKey().toString(); Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosScreen.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosScreen.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosScreen.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/PosScreen.java Sun Nov 1 20:04:17 2009 @@ -24,9 +24,8 @@ import java.awt.Window; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; - import java.math.BigDecimal; -import java.util.*; +import java.util.Locale; import net.xoetrope.xui.XPage; import net.xoetrope.xui.XProject; @@ -45,7 +44,7 @@ import org.ofbiz.pos.component.Operator; import org.ofbiz.pos.component.Output; import org.ofbiz.pos.component.PosButton; -import org.ofbiz.pos.component.StatusBar; +import org.ofbiz.pos.component.PromoStatusBar; import org.ofbiz.pos.device.DeviceLoader; @SuppressWarnings("serial") @@ -56,7 +55,7 @@ public static final Frame appFrame = XProjectManager.getCurrentProject().getAppFrame(); public static final Window appWin = XProjectManager.getCurrentProject().getAppWindow(); public static final String BUTTON_ACTION_METHOD = "buttonPressed"; - public static final long MAX_INACTIVITY = 1800000; + public static final long MAX_INACTIVITY = Long.valueOf(UtilProperties.getPropertyValue(PosTransaction.resource, "MaxInactivity", "1800000")); public static PosScreen currentScreen; protected XProject currentProject = (XProject)XProjectManager.getCurrentProject(); @@ -75,7 +74,7 @@ protected String scrLocation = null; protected boolean isLocked = false; protected boolean inDialog = false; - protected StatusBar statusBar = null; + protected PromoStatusBar promoStatusBar = null; private Locale defaultLocale = Locale.getDefault(); @@ -99,7 +98,7 @@ this.input = new InputWithPassword(this); this.journal = new Journal(this); this.operator = new Operator(this); - this.statusBar = new StatusBar(this); + this.promoStatusBar = new PromoStatusBar(this); this.setLastActivity(System.currentTimeMillis()); if (!firstInit) { @@ -238,6 +237,8 @@ output.print(UtilProperties.getMessage(PosTransaction.resource,"PosIsClosed",defaultLocale)); } } + } else { + promoStatusBar.clear(); } //journal.focus(); } else { @@ -286,6 +287,10 @@ return this.buttons; } + public PromoStatusBar getPromoStatusBar() { + return this.promoStatusBar; + } + public void setLastActivity(long l) { lastActivity = l; } Modified: ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java?rev=831753&r1=831752&r2=831753&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java (original) +++ ofbiz/trunk/specialpurpose/pos/src/org/ofbiz/pos/screen/SaveSale.java Sun Nov 1 20:04:17 2009 @@ -106,7 +106,7 @@ String sale = m_saleName.getText(); if (null != sale) { saveSale(sale); - m_trans.voidSale(); + m_trans.voidSale(m_pos); m_pos.refresh(); } } @@ -120,7 +120,7 @@ saveSale(sale); //DO PRINT HERE DeviceLoader.receipt.printReceipt(m_trans, true); - m_trans.voidSale(); + m_trans.voidSale(m_pos); m_pos.refresh(); } } |
Free forum by Nabble | Edit this page |