From a slightly modified Chris Lombardi's patch "XUI update to x3.2rc2b" (see comments in https://issues.apache.org/jira/browse/OFBIZ-1580) - OFBIZ-1580
I will remove the old XUI jar later git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@615262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+2
-1
@@ -48,7 +48,8 @@
|
||||
<classpathentry kind="lib" path="framework/jetty/lib/org.mortbay.jetty.jar"/>
|
||||
<classpathentry kind="lib" path="framework/jetty/lib/jasper-runtime.jar"/>
|
||||
<classpathentry kind="lib" path="framework/jetty/lib/jasper-compiler.jar"/>
|
||||
<classpathentry kind="lib" path="framework/guiapp/lib/XuiCoreSwing_v2_0_6_jdk1_5.jar"/>
|
||||
<classpathentry kind="lib" path="framework/guiapp/lib/XuiCoreSwing-v3.2rc2b.jar"/>
|
||||
<classpathentry kind="lib" path="framework/guiapp/lib/XuiOptional-v3.2rc2b.jar"/>
|
||||
<classpathentry kind="lib" path="applications/content/lib/poi.jar"/>
|
||||
<classpathentry kind="lib" path="applications/content/lib/lucene-2.2.0.jar"/>
|
||||
<classpathentry kind="lib" path="framework/catalina/lib/tomcat-util.jar"/>
|
||||
|
||||
@@ -44,8 +44,9 @@ under the License.
|
||||
|
||||
<!-- load the POS GUI -->
|
||||
<container name="pos-container" class="org.ofbiz.pos.container.PosContainer">
|
||||
<property name="startup-directory" value="/specialpurpose/pos/config/"/>
|
||||
<property name="startup-directory" value="specialpurpose/pos/config/"/>
|
||||
<property name="startup-file" value="xpos.properties"/>
|
||||
<property name="class-package-name " value="net.xoetrope.swing"/>
|
||||
<property name="dispatcher-name" value="POSDispatcher"/>
|
||||
<property name="delegator-name" value="default"/>
|
||||
<property name="xui-session-id" value="pos-1"/>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -31,16 +31,13 @@ import org.ofbiz.base.container.ContainerException;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
import org.ofbiz.entity.GenericDelegator;
|
||||
import org.ofbiz.service.GenericDispatcher;
|
||||
import org.ofbiz.service.GenericServiceException;
|
||||
import org.ofbiz.service.LocalDispatcher;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
|
||||
public abstract class XuiContainer implements Container {
|
||||
|
||||
public static final String module = XuiContainer.class.getName();
|
||||
protected static XuiSession session = null;
|
||||
|
||||
protected XuiScreen initialScreen = null;
|
||||
protected static XuiSession xuiSession = null;
|
||||
|
||||
protected String startupDir = null;
|
||||
protected String startupFile = null;
|
||||
@@ -85,19 +82,24 @@ public abstract class XuiContainer implements Container {
|
||||
}
|
||||
|
||||
// create and cache the session
|
||||
session = new XuiSession(xuiSessionId, delegator, dispatcher, this);
|
||||
|
||||
xuiSession = new XuiSession(xuiSessionId, delegator, dispatcher, this);
|
||||
|
||||
// configure the rest of the container
|
||||
this.configure(cc);
|
||||
|
||||
// load the XUI and render the initial screen
|
||||
if (this.startupFile == null) {
|
||||
this.startupDir = ContainerConfig.getPropertyValue(cc, "startup-directory", "/specialpurpose/pos/config/");
|
||||
this.startupDir = ContainerConfig.getPropertyValue(cc, "startup-directory", "specialpurpose/pos/config/");
|
||||
this.startupFile = ContainerConfig.getPropertyValue(cc, "startup-file", "xpos.properties");
|
||||
}
|
||||
this.initialScreen = new XuiScreen();
|
||||
this.initialScreen.setup(this.startupDir, this.startupFile);
|
||||
|
||||
String classPackageName = ContainerConfig.getPropertyValue(cc, "class-package-name", "net.xoetrope.swing");
|
||||
|
||||
JFrame jframe = new JFrame();
|
||||
jframe.setUndecorated(true);
|
||||
new XuiScreen(
|
||||
new String[] { this.startupDir + this.startupFile,
|
||||
classPackageName}, jframe);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,25 +126,30 @@ public abstract class XuiContainer implements Container {
|
||||
public abstract void configure(ContainerConfig.Container cc) throws ContainerException;
|
||||
|
||||
public static XuiSession getSession() {
|
||||
return session;
|
||||
return xuiSession;
|
||||
}
|
||||
|
||||
class XuiScreen extends XApplet {
|
||||
|
||||
public void setup(String startupDir, String startupFile) {
|
||||
String xuiProps = System.getProperty("ofbiz.home") + startupDir + startupFile;
|
||||
protected String startupProperties = "";
|
||||
|
||||
public XuiScreen(String[] args, JFrame frame) {
|
||||
super(args, frame);
|
||||
if(args.length > 0) {
|
||||
startupProperties = args[0];
|
||||
}
|
||||
String suffix = Locale.getDefault().getLanguage();
|
||||
if ("en".equals(suffix)) {
|
||||
suffix = "";
|
||||
} else {
|
||||
suffix = "_" + suffix;
|
||||
}
|
||||
UtilProperties.setPropertyValue(xuiProps, "Language", "XuiLabels" + suffix);
|
||||
JFrame frame = new JFrame();
|
||||
frame.setUndecorated(true);
|
||||
frame.setVisible(false);
|
||||
frame.getContentPane().add(this);
|
||||
super.setup(frame, new String[] { startupFile });
|
||||
}
|
||||
String language = UtilProperties.getPropertyValue(startupProperties, "Language");
|
||||
if(language.compareTo("XuiLabels" + suffix ) != 0){
|
||||
UtilProperties.setPropertyValue(startupProperties, "Language", "XuiLabels" + suffix);
|
||||
}
|
||||
frame.setVisible(true);
|
||||
frame.getContentPane().add(this);
|
||||
frame.validate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,3 +28,5 @@ UseWindow=true
|
||||
UseFrames=false
|
||||
StartPackage=org.ofbiz.pos
|
||||
LogLevel=0
|
||||
StartClass=specialpurpose/pos/screens/default/pospanel
|
||||
StartPackage=org.ofbiz.pos
|
||||
|
||||
@@ -865,7 +865,7 @@ public class PosTransaction implements Serializable {
|
||||
double subTotal = unitPrice * quantity;
|
||||
double adjustment = item.getOtherAdjustments();
|
||||
|
||||
XModel line = Journal.appendNode(model, "tr", "", "");
|
||||
XModel line = Journal.appendNode(model, "tr", ""+cart.getItemIndex(item), "");
|
||||
Journal.appendNode(line, "td", "sku", item.getProductId());
|
||||
Journal.appendNode(line, "td", "desc", item.getName());
|
||||
Journal.appendNode(line, "td", "qty", UtilFormatOut.formatQuantity(quantity));
|
||||
@@ -880,10 +880,10 @@ public class PosTransaction implements Serializable {
|
||||
pcw = item.getConfigWrapper();
|
||||
List selected = pcw.getSelectedOptions();
|
||||
Iterator iter = selected.iterator();
|
||||
while(iter.hasNext()){
|
||||
while(iter.hasNext()){
|
||||
ConfigOption configoption = (ConfigOption)iter.next();
|
||||
if (configoption.isSelected()){
|
||||
XModel option = Journal.appendNode(model, "tr", "", "");
|
||||
XModel option = Journal.appendNode(model, "tr", ""+cart.getItemIndex(item), "");
|
||||
Journal.appendNode(option, "td", "sku", "");
|
||||
Journal.appendNode(option, "td", "desc", configoption.getDescription());
|
||||
Journal.appendNode(option, "td", "qty", "");
|
||||
@@ -895,7 +895,7 @@ public class PosTransaction implements Serializable {
|
||||
|
||||
if (adjustment != 0) {
|
||||
// append the promo info
|
||||
XModel promo = Journal.appendNode(model, "tr", "", "");
|
||||
XModel promo = Journal.appendNode(model, "tr", "itemadjustment", "");
|
||||
Journal.appendNode(promo, "td", "sku", "");
|
||||
Journal.appendNode(promo, "td", "desc", UtilProperties.getMessage("pos","(ItemDiscount)",defaultLocale));
|
||||
Journal.appendNode(promo, "td", "qty", "");
|
||||
@@ -915,28 +915,31 @@ public class PosTransaction implements Serializable {
|
||||
Iterator iter = adjustments.iterator();
|
||||
while(iter.hasNext()){
|
||||
GenericValue orderAdjustment = (GenericValue) iter.next();
|
||||
XModel adjustmentLine = Journal.appendNode(model, "tr", "", "");
|
||||
XModel adjustmentLine = Journal.appendNode(model, "tr", "adjustment", "");
|
||||
Journal.appendNode(adjustmentLine, "td", "sku", "");
|
||||
Journal.appendNode(adjustmentLine, "td", "desc",
|
||||
UtilProperties.getMessage("pos", "(SalesDiscount)",defaultLocale));
|
||||
Journal.appendNode(adjustmentLine, "td", "qty", "");
|
||||
Journal.appendNode(adjustmentLine, "td", "price",
|
||||
UtilFormatOut.formatPrice(orderAdjustment.getDouble("amount")));
|
||||
Journal.appendNode(adjustmentLine, "td", "index", "-1");
|
||||
}
|
||||
}
|
||||
|
||||
XModel taxLine = Journal.appendNode(model, "tr", "", "");
|
||||
XModel taxLine = Journal.appendNode(model, "tr", "tax", "");
|
||||
Journal.appendNode(taxLine, "td", "sku", "");
|
||||
|
||||
Journal.appendNode(taxLine, "td", "desc", UtilProperties.getMessage("pos","Sales_Tax",defaultLocale));
|
||||
Journal.appendNode(taxLine, "td", "qty", "");
|
||||
Journal.appendNode(taxLine, "td", "price", UtilFormatOut.formatPrice(taxAmount));
|
||||
|
||||
XModel totalLine = Journal.appendNode(model, "tr", "", "");
|
||||
Journal.appendNode(taxLine, "td", "index", "-1");
|
||||
|
||||
XModel totalLine = Journal.appendNode(model, "tr", "total", "");
|
||||
Journal.appendNode(totalLine, "td", "sku", "");
|
||||
Journal.appendNode(totalLine, "td", "desc", UtilProperties.getMessage("pos","Grand_Total",defaultLocale));
|
||||
Journal.appendNode(totalLine, "td", "qty", "");
|
||||
Journal.appendNode(totalLine, "td", "price", UtilFormatOut.formatPrice(total));
|
||||
Journal.appendNode(totalLine, "td", "index", "-1");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,23 +18,31 @@
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.pos.component;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import net.xoetrope.data.XDataSource;
|
||||
import net.xoetrope.swing.XTable;
|
||||
import net.xoetrope.swing.XScrollPane;
|
||||
import net.xoetrope.xui.XProject;
|
||||
import net.xoetrope.xui.XProjectManager;
|
||||
import net.xoetrope.xui.data.XModel;
|
||||
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
import org.ofbiz.pos.screen.PosScreen;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
|
||||
public class Journal {
|
||||
|
||||
public static final String module = Journal.class.getName();
|
||||
|
||||
private static String[] field = { "sku", "desc", "qty", "price", "index" };
|
||||
private static String[] name = { "SKU", "ITEM", "QTY", "AMT", "" };
|
||||
private static int[] width = { 100, 170, 60, 80, 0};
|
||||
protected XProject currentProject = (XProject)XProjectManager.getCurrentProject();
|
||||
|
||||
private static String[] field = { "sku", "desc", "qty", "price" };
|
||||
private static String[] name = { "SKU", "ITEM", "QTY", "AMT" };
|
||||
private static int[] width = { 100, 170, 50, 90};
|
||||
private Locale defaultLocale = Locale.getDefault();
|
||||
|
||||
protected XScrollPane jpanel = null;
|
||||
@@ -45,12 +53,17 @@ public class Journal {
|
||||
//The vertical bar is always visible to allow access to horizontal bar without shrink the journal panel
|
||||
this.jpanel = (XScrollPane) page.findComponent("journal_panel");
|
||||
this.jpanel.setVisible(false);
|
||||
this.jpanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
this.jpanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
this.jtable = (XTable) page.findComponent("jtable");
|
||||
|
||||
|
||||
// set the table as selectable
|
||||
jtable.setInteractiveTable(true);
|
||||
jtable.setFocusable(false);
|
||||
jtable.setDragEnabled(false);
|
||||
jtable.setColumnSelectionAllowed(false);
|
||||
jtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
|
||||
// set the styles
|
||||
jtable.setBorderStyle("journalBorder");
|
||||
@@ -65,6 +78,7 @@ public class Journal {
|
||||
jtable.setModel(jmodel);
|
||||
|
||||
for (int i = 0; i < width.length; i++) {
|
||||
//causes infinite loop
|
||||
jtable.setColWidth(i, width[i]);
|
||||
}
|
||||
}
|
||||
@@ -72,15 +86,15 @@ public class Journal {
|
||||
}
|
||||
|
||||
public String getSelectedSku() {
|
||||
XModel jmodel = (XModel) XModel.getInstance().get("journal/items");
|
||||
XModel jmodel = jtable.getXModel();
|
||||
XModel model = jmodel.get(jtable.getSelectedRow() + 1);
|
||||
return model.getValueAsString("sku");
|
||||
}
|
||||
|
||||
public String getSelectedIdx() {
|
||||
XModel jmodel = (XModel) XModel.getInstance().get("journal/items");
|
||||
XModel jmodel = jtable.getXModel();
|
||||
XModel model = jmodel.get(jtable.getSelectedRow() + 1);
|
||||
return model.getValueAsString("index");
|
||||
return model.getId();
|
||||
}
|
||||
|
||||
public void selectNext() {
|
||||
@@ -102,12 +116,13 @@ public class Journal {
|
||||
jtable.setFocusable(!lock);
|
||||
jtable.setVisible(!lock);
|
||||
jtable.setEnabled(!lock);
|
||||
this.jpanel.setVisible(!lock);
|
||||
if (!lock) {
|
||||
this.jpanel.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh(PosScreen pos) {
|
||||
public synchronized void refresh(PosScreen pos) {
|
||||
if (!jtable.isEnabled()) {
|
||||
// no point in refreshing when we are locked;
|
||||
// we will auto-refresh when unlocked
|
||||
@@ -133,27 +148,26 @@ public class Journal {
|
||||
|
||||
// make sure we are at the last item in the journal
|
||||
jtable.setSelectedRow(0);
|
||||
|
||||
|
||||
try {
|
||||
jtable.repaint();
|
||||
jtable.update();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// bug in XUI causes this; ignore for now
|
||||
// it has been reported and will be fixed soon
|
||||
Debug.logError(e, "Unable to repaint the Journal", module);
|
||||
}
|
||||
//Debug.logInfo(getModelText(jmodel), module);
|
||||
}
|
||||
|
||||
private XModel createModel() {
|
||||
XModel jmodel = (XModel) XModel.getInstance().get("journal/items");
|
||||
|
||||
XModel jmodel = (XModel)currentProject.getModel().get("table/items");
|
||||
// clear the list
|
||||
jmodel.clear();
|
||||
|
||||
|
||||
if (field.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
jmodel.setTagName("table");
|
||||
// create the header
|
||||
XModel headerNode = appendNode(jmodel, "th", "", "");
|
||||
XModel headerNode = appendNode(jmodel, "th", "header", "");
|
||||
for (int i = 0 ; i < field.length; i++) {
|
||||
appendNode(headerNode, "td", field[i],UtilProperties.getMessage("pos",name[i],defaultLocale));
|
||||
}
|
||||
@@ -162,7 +176,7 @@ public class Journal {
|
||||
}
|
||||
|
||||
private void appendEmpty(XModel jmodel) {
|
||||
XModel headerNode = appendNode(jmodel, "tr", "", "");
|
||||
XModel headerNode = appendNode(jmodel, "tr", "emptyrow", "");
|
||||
for (int i = 0 ; i < field.length; i++) {
|
||||
appendNode(headerNode, "td", field[i], "");
|
||||
}
|
||||
@@ -173,7 +187,14 @@ public class Journal {
|
||||
newNode.setTagName(tag);
|
||||
if (value != null) {
|
||||
newNode.set(value);
|
||||
}
|
||||
}
|
||||
return newNode;
|
||||
}
|
||||
}
|
||||
|
||||
private String getModelText(XModel model)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
XDataSource.outputModel( sw, model );
|
||||
return "<Datasets>" + sw.toString() + "</Datasets>";
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,8 @@ import java.util.Map;
|
||||
|
||||
import net.xoetrope.swing.XButton;
|
||||
import net.xoetrope.xui.helper.SwingWorker;
|
||||
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.config.GenericConfigException;
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilValidate;
|
||||
@@ -62,7 +63,7 @@ public class PosButton {
|
||||
if (UtilValidate.isEmpty(buttonName)) {
|
||||
wrapper.setEnabled(false);
|
||||
} else {
|
||||
pos.addActionHandler(button, PosScreen.BUTTON_ACTION_METHOD);
|
||||
XEventHelper.addActionHandler(pos, button, PosScreen.BUTTON_ACTION_METHOD);
|
||||
loadedXButtons.put(button.getName(), wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.swing.XList;
|
||||
import net.xoetrope.swing.XScrollPane;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
@@ -81,7 +82,6 @@ public class ConfigureItem extends XPage {
|
||||
// cache must be set to false because there's no method to remove actionhandlers
|
||||
m_dialog = (XDialog) pageMgr.loadPage(
|
||||
m_pos.getScreenLocation() + "/dialog/ConfigureItem", false);
|
||||
//TODO: change caption
|
||||
m_dialog.setCaption(UtilProperties.getMessage("pos", "ConfigureItem", Locale.getDefault()));
|
||||
|
||||
m_optionListPane = (XScrollPane) m_dialog.findComponent("optionListPane");
|
||||
@@ -90,8 +90,8 @@ public class ConfigureItem extends XPage {
|
||||
m_ok = (XButton) m_dialog.findComponent("BtnOk");
|
||||
m_reset = (XButton) m_dialog.findComponent("BtnReset");
|
||||
|
||||
addMouseHandler(m_ok, "ok");
|
||||
addMouseHandler(m_reset, "reset");
|
||||
XEventHelper.addMouseHandler(this, m_ok, "ok");
|
||||
XEventHelper.addMouseHandler(this, m_reset, "reset");
|
||||
|
||||
getButtons();
|
||||
//debugQuestions();
|
||||
@@ -119,13 +119,15 @@ public class ConfigureItem extends XPage {
|
||||
}
|
||||
|
||||
public synchronized void buttonPressed() {
|
||||
EventObject eo = getCurrentEvent();
|
||||
XButton button = (XButton) eo.getSource();
|
||||
Question question = (Question)questionHashMap.get(button.getName());
|
||||
question.buttonClicked();
|
||||
showItem();
|
||||
m_dialog.repaint();
|
||||
return;
|
||||
if (wasMouseClicked()) {
|
||||
EventObject eo = getCurrentEvent();
|
||||
XButton button = (XButton) eo.getSource();
|
||||
Question question = (Question)questionHashMap.get(button.getName());
|
||||
question.buttonClicked();
|
||||
showItem();
|
||||
m_dialog.repaint();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void listPressed() {
|
||||
@@ -193,7 +195,7 @@ public class ConfigureItem extends XPage {
|
||||
if(buttonQuestion instanceof ListQuestion){
|
||||
((ListQuestion)buttonQuestion).setupListPane(m_optionListPane);
|
||||
}
|
||||
addActionHandler(button, "buttonPressed");
|
||||
XEventHelper.addMouseHandler(this, button, "buttonPressed");
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1,244 +1,245 @@
|
||||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.pos.screen;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import net.xoetrope.swing.XButton;
|
||||
import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.swing.XList;
|
||||
import net.xoetrope.xui.XPage;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
|
||||
|
||||
public class LoadSale extends XPage {
|
||||
|
||||
/**
|
||||
* To load a sale from a shopping list. 2 modes : add to or replace the current sale. Also a button to delete a sale (aka shopping list)
|
||||
*/
|
||||
public static final String module = LoadSale.class.getName();
|
||||
protected static PosScreen m_pos = null;
|
||||
protected XDialog m_dialog = null;
|
||||
static protected Hashtable m_saleMap = new Hashtable();
|
||||
protected XList m_salesList = null;
|
||||
protected XButton m_cancel = null;
|
||||
protected XButton m_add = null;
|
||||
protected XButton m_replace = null;
|
||||
protected XButton m_delete = null;
|
||||
protected XButton m_replaceAndDelete = null;
|
||||
protected DefaultListModel m_listModel = null;
|
||||
protected static PosTransaction m_trans = null;
|
||||
|
||||
//TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
|
||||
|
||||
public LoadSale(Hashtable saleMap, PosTransaction trans, PosScreen page) {
|
||||
m_saleMap.putAll(saleMap);
|
||||
m_trans = trans;
|
||||
m_pos = page;
|
||||
}
|
||||
|
||||
public void openDlg() {
|
||||
m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/loadsale");
|
||||
m_dialog.setCaption(UtilProperties.getMessage("pos", "LoadASale", Locale.getDefault()));
|
||||
m_salesList = (XList) m_dialog.findComponent("salesList");
|
||||
addMouseHandler(m_salesList, "saleDoubleClick");
|
||||
|
||||
m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
|
||||
m_add = (XButton) m_dialog.findComponent("BtnAdd");
|
||||
m_replace = (XButton) m_dialog.findComponent("BtnReplace");
|
||||
m_delete = (XButton) m_dialog.findComponent("BtnDelete");
|
||||
m_replaceAndDelete = (XButton) m_dialog.findComponent("BtnReplaceAndDelete");
|
||||
addMouseHandler(m_cancel, "cancel");
|
||||
addMouseHandler(m_add, "addSale");
|
||||
addMouseHandler(m_replace, "replaceSale");
|
||||
addMouseHandler(m_delete, "deleteShoppingList");
|
||||
addMouseHandler(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);
|
||||
}
|
||||
m_salesList.setModel(m_listModel);
|
||||
m_salesList.setVisibleRowCount(-1);
|
||||
m_salesList.ensureIndexIsVisible(m_salesList.getItemCount());
|
||||
m_salesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
m_salesList.setToolTipText(UtilProperties.getMessage("pos", "LoadSaleListDblClickTip", Locale.getDefault()));
|
||||
|
||||
m_dialog.pack();
|
||||
m_salesList.requestFocusInWindow();
|
||||
m_dialog.showDialog(this);
|
||||
}
|
||||
|
||||
public synchronized void saleDoubleClick() {
|
||||
if (wasMouseDoubleClicked()) {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
replaceSaleAndDeleteShoppingList_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void cancel() {
|
||||
if (wasMouseClicked()) {
|
||||
closeDlg();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addSale() {
|
||||
if (wasMouseClicked()) {
|
||||
addSale_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void addSale_() {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
addListToCart(sale, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSale() {
|
||||
if (wasMouseClicked()) {
|
||||
replaceSale_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void replaceSale_() {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
addListToCart(sale, false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deleteShoppingList() {
|
||||
if (wasMouseClicked()) {
|
||||
deleteShoppingList_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void deleteShoppingList_() {
|
||||
String sale= (String) m_salesList.getSelectedValue();
|
||||
if (null != sale) {
|
||||
String shoppingListId = selectedSale();
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
if (m_trans.clearList(shoppingListId, m_pos)) {
|
||||
int index = m_salesList.getSelectedIndex();
|
||||
m_saleMap.remove(shoppingListId);
|
||||
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);
|
||||
}
|
||||
m_salesList.setModel(m_listModel);
|
||||
int size = m_listModel.getSize();
|
||||
if (size == 0) { //Nobody's left, nothing to do here
|
||||
closeDlg();
|
||||
} else { //Select an index.
|
||||
if (index == size) {
|
||||
//removed item in last position
|
||||
index--;
|
||||
}
|
||||
}
|
||||
m_salesList.setSelectedIndex(index);
|
||||
m_salesList.ensureIndexIsVisible(index);
|
||||
m_salesList.repaint();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSaleAndDeleteShoppingList() {
|
||||
if (wasMouseClicked()) {
|
||||
replaceSaleAndDeleteShoppingList_();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSaleAndDeleteShoppingList_() {
|
||||
replaceSale_();
|
||||
deleteShoppingList_();
|
||||
}
|
||||
|
||||
private String selectedSale() {
|
||||
String saleSelected = null;
|
||||
if (null != m_salesList.getSelectedValue()) {
|
||||
String sale = (String) m_salesList.getSelectedValue();
|
||||
Iterator i = m_saleMap.entrySet().iterator();
|
||||
while(i.hasNext()) {
|
||||
Object o = i.next();
|
||||
Map.Entry entry = (Map.Entry)o;
|
||||
String val = entry.getValue().toString();
|
||||
if (val.equals(sale)) {
|
||||
saleSelected = entry.getKey().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return saleSelected;
|
||||
}
|
||||
|
||||
private void addListToCart(String sale, boolean addToCart) {
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
if (!m_trans.addListToCart(sale, m_pos, addToCart)) {
|
||||
Debug.logError("Error while loading cart from shopping list : " + sale, module);
|
||||
}
|
||||
else {
|
||||
m_trans.calcTax();
|
||||
m_pos.refresh();
|
||||
}
|
||||
closeDlg();
|
||||
}
|
||||
|
||||
private ClassLoader getClassLoader(PosScreen pos) {
|
||||
ClassLoader cl = pos.getClassLoader();
|
||||
if (cl == null) {
|
||||
try {
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (cl == null) {
|
||||
Debug.log("No context classloader available; using class classloader", module);
|
||||
try {
|
||||
cl = this.getClass().getClassLoader();
|
||||
} catch (Throwable t) {
|
||||
Debug.logError(t, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
private void closeDlg() {
|
||||
m_dialog.closeDlg();
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.pos.screen;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.DefaultListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
|
||||
import net.xoetrope.swing.XButton;
|
||||
import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.swing.XList;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
|
||||
|
||||
public class LoadSale extends XPage {
|
||||
|
||||
/**
|
||||
* To load a sale from a shopping list. 2 modes : add to or replace the current sale. Also a button to delete a sale (aka shopping list)
|
||||
*/
|
||||
public static final String module = LoadSale.class.getName();
|
||||
protected static PosScreen m_pos = null;
|
||||
protected XDialog m_dialog = null;
|
||||
static protected Hashtable m_saleMap = new Hashtable();
|
||||
protected XList m_salesList = null;
|
||||
protected XButton m_cancel = null;
|
||||
protected XButton m_add = null;
|
||||
protected XButton m_replace = null;
|
||||
protected XButton m_delete = null;
|
||||
protected XButton m_replaceAndDelete = null;
|
||||
protected DefaultListModel m_listModel = null;
|
||||
protected static PosTransaction m_trans = null;
|
||||
|
||||
//TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
|
||||
|
||||
public LoadSale(Hashtable saleMap, PosTransaction trans, PosScreen page) {
|
||||
m_saleMap.putAll(saleMap);
|
||||
m_trans = trans;
|
||||
m_pos = page;
|
||||
}
|
||||
|
||||
public void openDlg() {
|
||||
m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/loadsale");
|
||||
m_dialog.setCaption(UtilProperties.getMessage("pos", "LoadASale", Locale.getDefault()));
|
||||
m_salesList = (XList) m_dialog.findComponent("salesList");
|
||||
XEventHelper.addMouseHandler(this, m_salesList, "saleDoubleClick");
|
||||
|
||||
m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
|
||||
m_add = (XButton) m_dialog.findComponent("BtnAdd");
|
||||
m_replace = (XButton) m_dialog.findComponent("BtnReplace");
|
||||
m_delete = (XButton) m_dialog.findComponent("BtnDelete");
|
||||
m_replaceAndDelete = (XButton) m_dialog.findComponent("BtnReplaceAndDelete");
|
||||
XEventHelper.addMouseHandler(this, m_cancel, "cancel");
|
||||
XEventHelper.addMouseHandler(this, m_replace, "replaceSale");
|
||||
XEventHelper.addMouseHandler(this, m_add, "addSale");
|
||||
XEventHelper.addMouseHandler(this, m_delete, "deleteShoppingList");
|
||||
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);
|
||||
}
|
||||
m_salesList.setModel(m_listModel);
|
||||
m_salesList.setVisibleRowCount(-1);
|
||||
m_salesList.ensureIndexIsVisible(m_salesList.getItemCount());
|
||||
m_salesList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
m_salesList.setToolTipText(UtilProperties.getMessage("pos", "LoadSaleListDblClickTip", Locale.getDefault()));
|
||||
|
||||
m_dialog.pack();
|
||||
m_salesList.requestFocusInWindow();
|
||||
m_dialog.showDialog(this);
|
||||
}
|
||||
|
||||
public synchronized void saleDoubleClick() {
|
||||
if (wasMouseDoubleClicked()) {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
replaceSaleAndDeleteShoppingList_();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void cancel() {
|
||||
if (wasMouseClicked()) {
|
||||
closeDlg();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void addSale() {
|
||||
if (wasMouseClicked()) {
|
||||
addSale_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void addSale_() {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
addListToCart(sale, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSale() {
|
||||
if (wasMouseClicked()) {
|
||||
replaceSale_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void replaceSale_() {
|
||||
String sale = selectedSale();
|
||||
if (null != sale) {
|
||||
addListToCart(sale, false);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void deleteShoppingList() {
|
||||
if (wasMouseClicked()) {
|
||||
deleteShoppingList_();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void deleteShoppingList_() {
|
||||
String sale= (String) m_salesList.getSelectedValue();
|
||||
if (null != sale) {
|
||||
String shoppingListId = selectedSale();
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
if (m_trans.clearList(shoppingListId, m_pos)) {
|
||||
int index = m_salesList.getSelectedIndex();
|
||||
m_saleMap.remove(shoppingListId);
|
||||
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);
|
||||
}
|
||||
m_salesList.setModel(m_listModel);
|
||||
int size = m_listModel.getSize();
|
||||
if (size == 0) { //Nobody's left, nothing to do here
|
||||
closeDlg();
|
||||
} else { //Select an index.
|
||||
if (index == size) {
|
||||
//removed item in last position
|
||||
index--;
|
||||
}
|
||||
}
|
||||
m_salesList.setSelectedIndex(index);
|
||||
m_salesList.ensureIndexIsVisible(index);
|
||||
m_salesList.repaint();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSaleAndDeleteShoppingList() {
|
||||
if (wasMouseClicked()) {
|
||||
replaceSaleAndDeleteShoppingList_();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void replaceSaleAndDeleteShoppingList_() {
|
||||
replaceSale_();
|
||||
deleteShoppingList_();
|
||||
}
|
||||
|
||||
private String selectedSale() {
|
||||
String saleSelected = null;
|
||||
if (null != m_salesList.getSelectedValue()) {
|
||||
String sale = (String) m_salesList.getSelectedValue();
|
||||
Iterator i = m_saleMap.entrySet().iterator();
|
||||
while(i.hasNext()) {
|
||||
Object o = i.next();
|
||||
Map.Entry entry = (Map.Entry)o;
|
||||
String val = entry.getValue().toString();
|
||||
if (val.equals(sale)) {
|
||||
saleSelected = entry.getKey().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return saleSelected;
|
||||
}
|
||||
|
||||
private void addListToCart(String sale, boolean addToCart) {
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
if (!m_trans.addListToCart(sale, m_pos, addToCart)) {
|
||||
Debug.logError("Error while loading cart from shopping list : " + sale, module);
|
||||
}
|
||||
else {
|
||||
m_trans.calcTax();
|
||||
m_pos.refresh();
|
||||
}
|
||||
closeDlg();
|
||||
}
|
||||
|
||||
private ClassLoader getClassLoader(PosScreen pos) {
|
||||
ClassLoader cl = pos.getClassLoader();
|
||||
if (cl == null) {
|
||||
try {
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (cl == null) {
|
||||
Debug.log("No context classloader available; using class classloader", module);
|
||||
try {
|
||||
cl = this.getClass().getClassLoader();
|
||||
} catch (Throwable t) {
|
||||
Debug.logError(t, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
private void closeDlg() {
|
||||
m_dialog.closeDlg();
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import net.xoetrope.swing.XEdit;
|
||||
import net.xoetrope.swing.XLabel;
|
||||
import net.xoetrope.swing.XComboBox;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.util.UtilMisc;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
@@ -76,8 +77,9 @@ public class PaidInOut extends XPage {
|
||||
m_ok = (XButton) m_dialog.findComponent("BtnOk");
|
||||
m_amoutLabel = (XLabel) m_dialog.findComponent("amoutLabel");
|
||||
m_reasonLabel = (XLabel) m_dialog.findComponent("reasonLabel");
|
||||
addMouseHandler(m_cancel, "cancel");
|
||||
addMouseHandler(m_ok, "verify");
|
||||
|
||||
XEventHelper.addMouseHandler(this, m_cancel, "cancel");
|
||||
XEventHelper.addMouseHandler(this, m_ok, "verify");
|
||||
|
||||
m_comboModel = new DefaultComboBoxModel();
|
||||
ResourceBundle reasons = null;
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.*;
|
||||
|
||||
import net.xoetrope.builder.NavigationHelper;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.XProject;
|
||||
import net.xoetrope.xui.XProjectManager;
|
||||
|
||||
import org.ofbiz.base.splash.SplashLoader;
|
||||
@@ -55,6 +56,7 @@ public class PosScreen extends NavigationHelper implements Runnable, DialogCallb
|
||||
public static final long MAX_INACTIVITY = 1800000;
|
||||
public static PosScreen currentScreen;
|
||||
|
||||
protected XProject currentProject = (XProject)XProjectManager.getCurrentProject();
|
||||
protected static boolean monitorRunning = false;
|
||||
protected static boolean firstInit = false;
|
||||
protected static long lastActivity = 0;
|
||||
@@ -98,9 +100,10 @@ public class PosScreen extends NavigationHelper implements Runnable, DialogCallb
|
||||
firstInit = true;
|
||||
|
||||
// pre-load a few screens
|
||||
XProjectManager.getPageManager().loadPage(this.getScreenLocation() + "/paypanel");
|
||||
XProjectManager.getPageManager().loadPage(this.getScreenLocation() + "/mgrpanel");
|
||||
XProjectManager.getPageManager().loadPage(this.getScreenLocation() + "/promopanel");
|
||||
|
||||
currentProject.getPageManager().loadPage(this.getScreenLocation() + "/paypanel");
|
||||
currentProject.getPageManager().loadPage(this.getScreenLocation() + "/mgrpanel");
|
||||
currentProject.getPageManager().loadPage(this.getScreenLocation() + "/promopanel");
|
||||
|
||||
// start the shared monitor thread
|
||||
if (activityMonitor == null) {
|
||||
@@ -300,7 +303,7 @@ public class PosScreen extends NavigationHelper implements Runnable, DialogCallb
|
||||
if (pageName.startsWith("/")) {
|
||||
pageName = pageName.substring(1);
|
||||
}
|
||||
XPage newPage = (XPage)XProjectManager.getPageManager().showPage(this.getScreenLocation() + "/" + pageName);
|
||||
XPage newPage = (XPage)currentProject.getPageManager().showPage(this.getScreenLocation() + "/" + pageName);
|
||||
if (newPage instanceof PosScreen) {
|
||||
if (refresh) ((PosScreen) newPage).refresh();
|
||||
return (PosScreen) newPage;
|
||||
@@ -336,7 +339,7 @@ public class PosScreen extends NavigationHelper implements Runnable, DialogCallb
|
||||
if (pageName.startsWith("/")) {
|
||||
pageName = pageName.substring(1);
|
||||
}
|
||||
XPage dialogPage = (XPage)XProjectManager.getPageManager().loadPage(this.getScreenLocation() + "/" + pageName);
|
||||
XPage dialogPage = (XPage)currentProject.getPageManager().loadPage(this.getScreenLocation() + "/" + pageName);
|
||||
PosDialog dialog = PosDialog.getInstance(dialogPage, true, 0);
|
||||
dialog.showDialog(this, cb, text);
|
||||
return dialog;
|
||||
@@ -383,7 +386,7 @@ public class PosScreen extends NavigationHelper implements Runnable, DialogCallb
|
||||
if (this.scrLocation == null) {
|
||||
String xuiProps = this.getSession().getContainer().getXuiPropertiesName();
|
||||
String startClass = UtilProperties.getPropertyValue(xuiProps, "StartClass", "default/pospanel");
|
||||
this.scrLocation = startClass.substring(0, startClass.indexOf("/"));
|
||||
this.scrLocation = startClass.substring(0, startClass.lastIndexOf("/"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +1,131 @@
|
||||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.pos.screen;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.xoetrope.swing.XButton;
|
||||
//import org.ofbiz.pos.screen.XFocusDialog;
|
||||
import net.xoetrope.swing.XEdit;
|
||||
import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.xui.XPage;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
|
||||
|
||||
public class SaveSale extends XPage {
|
||||
|
||||
/**
|
||||
* To save a sale. 2 modes : save and keep the current sale or save and clear the current sale.
|
||||
*/
|
||||
public static final String module = SaveSale.class.getName();
|
||||
protected static PosScreen m_pos = null;
|
||||
protected XDialog m_dialog = null;
|
||||
protected XEdit m_saleName = null;
|
||||
protected XButton m_cancel = null;
|
||||
protected XButton m_save = null;
|
||||
protected XButton m_saveAndClear = null;
|
||||
protected static PosTransaction m_trans = null;
|
||||
public static SimpleDateFormat sdf = new SimpleDateFormat(UtilProperties.getMessage("pos","DateTimeFormat",Locale.getDefault()));
|
||||
|
||||
//TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
|
||||
|
||||
public SaveSale(PosTransaction trans, PosScreen page) {
|
||||
m_trans = trans;
|
||||
m_pos = page;
|
||||
}
|
||||
|
||||
public void openDlg() {
|
||||
m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/savesale");
|
||||
m_saleName = (XEdit) m_dialog.findComponent("saleName");
|
||||
//m_dialog.setM_focused(m_saleName);
|
||||
m_saleName.setText(m_pos.session.getUserId() + " " + sdf.format(new Date()));
|
||||
m_dialog.setCaption(UtilProperties.getMessage("pos", "SaveASale", Locale.getDefault()));
|
||||
|
||||
m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
|
||||
m_save = (XButton) m_dialog.findComponent("BtnSave");
|
||||
m_saveAndClear = (XButton) m_dialog.findComponent("BtnSaveAndClear");
|
||||
|
||||
addMouseHandler(m_cancel, "cancel");
|
||||
addMouseHandler(m_save, "save");
|
||||
addMouseHandler(m_saveAndClear, "saveAndClear");
|
||||
|
||||
m_dialog.pack();
|
||||
m_dialog.showDialog(this);
|
||||
}
|
||||
|
||||
public synchronized void cancel()
|
||||
{
|
||||
if (wasMouseClicked()) {
|
||||
this.m_dialog.closeDlg();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void save() {
|
||||
if (wasMouseClicked()) {
|
||||
String sale = m_saleName.getText();
|
||||
if (null != sale) {
|
||||
saveSale(sale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void saveAndClear() {
|
||||
if (wasMouseClicked()) {
|
||||
String sale = m_saleName.getText();
|
||||
if (null != sale) {
|
||||
saveSale(sale);
|
||||
m_trans.voidSale();
|
||||
m_pos.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSale(String sale) {
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
m_trans.saveSale(sale, m_pos);
|
||||
this.m_dialog.closeDlg();
|
||||
}
|
||||
|
||||
private ClassLoader getClassLoader(PosScreen pos) {
|
||||
ClassLoader cl = pos.getClassLoader();
|
||||
if (cl == null) {
|
||||
try {
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (cl == null) {
|
||||
Debug.log("No context classloader available; using class classloader", module);
|
||||
try {
|
||||
cl = this.getClass().getClassLoader();
|
||||
} catch (Throwable t) {
|
||||
Debug.logError(t, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*******************************************************************************/
|
||||
package org.ofbiz.pos.screen;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.xoetrope.swing.XButton;
|
||||
//import org.ofbiz.pos.screen.XFocusDialog;
|
||||
import net.xoetrope.swing.XEdit;
|
||||
import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.util.Debug;
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
|
||||
|
||||
public class SaveSale extends XPage {
|
||||
|
||||
/**
|
||||
* To save a sale. 2 modes : save and keep the current sale or save and clear the current sale.
|
||||
*/
|
||||
public static final String module = SaveSale.class.getName();
|
||||
protected static PosScreen m_pos = null;
|
||||
protected XDialog m_dialog = null;
|
||||
protected XEdit m_saleName = null;
|
||||
protected XButton m_cancel = null;
|
||||
protected XButton m_save = null;
|
||||
protected XButton m_saveAndClear = null;
|
||||
protected static PosTransaction m_trans = null;
|
||||
public static SimpleDateFormat sdf = new SimpleDateFormat(UtilProperties.getMessage("pos","DateTimeFormat",Locale.getDefault()));
|
||||
|
||||
//TODO : make getter and setter for members (ie m_*) if needed (extern calls). For that in Eclipse use Source/Generate Getters and setters
|
||||
|
||||
public SaveSale(PosTransaction trans, PosScreen page) {
|
||||
m_trans = trans;
|
||||
m_pos = page;
|
||||
}
|
||||
|
||||
public void openDlg() {
|
||||
m_dialog = (XDialog) pageMgr.loadPage(m_pos.getScreenLocation() + "/dialog/savesale");
|
||||
m_saleName = (XEdit) m_dialog.findComponent("saleName");
|
||||
//m_dialog.setM_focused(m_saleName);
|
||||
m_saleName.setText(m_pos.session.getUserId() + " " + sdf.format(new Date()));
|
||||
m_dialog.setCaption(UtilProperties.getMessage("pos", "SaveASale", Locale.getDefault()));
|
||||
|
||||
m_cancel = (XButton) m_dialog.findComponent("BtnCancel");
|
||||
m_save = (XButton) m_dialog.findComponent("BtnSave");
|
||||
m_saveAndClear = (XButton) m_dialog.findComponent("BtnSaveAndClear");
|
||||
|
||||
|
||||
XEventHelper.addMouseHandler(this, m_cancel, "cancel");
|
||||
XEventHelper.addMouseHandler(this, m_save, "save");
|
||||
XEventHelper.addMouseHandler(this, m_saveAndClear, "saveAndClear");
|
||||
|
||||
m_dialog.pack();
|
||||
m_dialog.showDialog(this);
|
||||
}
|
||||
|
||||
public synchronized void cancel()
|
||||
{
|
||||
if (wasMouseClicked()) {
|
||||
this.m_dialog.closeDlg();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void save() {
|
||||
if (wasMouseClicked()) {
|
||||
String sale = m_saleName.getText();
|
||||
if (null != sale) {
|
||||
saveSale(sale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void saveAndClear() {
|
||||
if (wasMouseClicked()) {
|
||||
String sale = m_saleName.getText();
|
||||
if (null != sale) {
|
||||
saveSale(sale);
|
||||
m_trans.voidSale();
|
||||
m_pos.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveSale(String sale) {
|
||||
final ClassLoader cl = this.getClassLoader(m_pos);
|
||||
Thread.currentThread().setContextClassLoader(cl);
|
||||
m_trans.saveSale(sale, m_pos);
|
||||
this.m_dialog.closeDlg();
|
||||
}
|
||||
|
||||
private ClassLoader getClassLoader(PosScreen pos) {
|
||||
ClassLoader cl = pos.getClassLoader();
|
||||
if (cl == null) {
|
||||
try {
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
} catch (Throwable t) {
|
||||
}
|
||||
if (cl == null) {
|
||||
Debug.log("No context classloader available; using class classloader", module);
|
||||
try {
|
||||
cl = this.getClass().getClassLoader();
|
||||
} catch (Throwable t) {
|
||||
Debug.logError(t, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import net.xoetrope.swing.XButton;
|
||||
import net.xoetrope.swing.XDialog;
|
||||
import net.xoetrope.swing.XList;
|
||||
import net.xoetrope.xui.XPage;
|
||||
import net.xoetrope.xui.events.XEventHelper;
|
||||
|
||||
import org.ofbiz.base.util.UtilProperties;
|
||||
import org.ofbiz.pos.PosTransaction;
|
||||
@@ -65,12 +66,13 @@ public class SelectProduct extends XPage {
|
||||
dlg.setCaption(UtilProperties.getMessage("pos", "SelectAProduct", Locale.getDefault()));
|
||||
//dlg.setModal(true);
|
||||
m_productsList = (XList) dlg.findComponent("productsList");
|
||||
addMouseHandler(m_productsList, "DoubleClick");
|
||||
XEventHelper.addMouseHandler(this, m_productsList, "DoubleClick");
|
||||
|
||||
m_cancel = (XButton) dlg.findComponent("BtnCancel");
|
||||
m_select = (XButton) dlg.findComponent("BtnSelect");
|
||||
addMouseHandler(m_cancel, "cancel");
|
||||
addMouseHandler(m_select, "selectProduct");
|
||||
|
||||
XEventHelper.addMouseHandler(this, m_cancel, "cancel");
|
||||
XEventHelper.addMouseHandler(this, m_select, "selectProduct");
|
||||
|
||||
m_listModel = new DefaultListModel();
|
||||
for (Iterator i = m_productsMap.entrySet().iterator(); i.hasNext();) {
|
||||
|
||||
Reference in New Issue
Block a user