From 8885aa8bb7d3238531636aa4e75a619529000d83 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 23 Aug 2008 04:06:26 +0000 Subject: [PATCH] Merge 6183-6210 from branches/adempiere341 --- .../src/org/adempiere/webui/Desktop.java | 19 +- .../webui/ServerContextCallback.java | 35 + .../adempiere/webui/TimelineEventFeed.java | 6 +- .../org/adempiere/webui/ValuePreference.java | 2 +- .../src/org/adempiere/webui/WRequest.java | 2 +- .../adempiere/webui/ZkContextProvider.java | 34 +- .../org/adempiere/webui/acct/WAcctViewer.java | 12 +- .../src/org/adempiere/webui/apps/AEnv.java | 200 +- .../adempiere/webui/apps/ProcessDialog.java | 4 +- .../webui/apps/ProcessParameterPanel.java | 12 +- .../webui/apps/form/WAllocation.java | 3375 ++++++----------- .../webui/apps/form/WArchiveViewer.java | 27 +- .../webui/apps/form/WAttributeGrid.java | 16 +- .../adempiere/webui/apps/form/WBOMDrop.java | 11 +- .../adempiere/webui/apps/form/WCharge.java | 21 +- .../webui/apps/form/WCreateFrom.java | 15 +- .../webui/apps/form/WCreateFromInvoice.java | 2 +- .../webui/apps/form/WCreateFromShipment.java | 2 +- .../webui/apps/form/WCreateFromStatement.java | 2 +- .../webui/apps/form/WFileImport.java | 8 +- .../adempiere/webui/apps/form/WInOutGen.java | 20 +- .../webui/apps/form/WInvoiceGen.java | 20 +- .../org/adempiere/webui/apps/form/WMatch.java | 18 +- .../org/adempiere/webui/apps/form/WMerge.java | 37 +- .../adempiere/webui/apps/form/WPayPrint.java | 16 +- .../adempiere/webui/apps/form/WPaySelect.java | 15 +- .../adempiere/webui/apps/form/WPayment.java | 4 +- .../webui/apps/form/WSQLProcess.java | 11 +- .../webui/apps/form/WTrxMaterial.java | 19 +- .../apps/graph/WPerformanceIndicator.java | 2 +- .../adempiere/webui/apps/wf/WWFActivity.java | 16 +- .../webui/component/ADButtonTabList.java | 12 + .../webui/component/ADTabListModel.java | 12 + .../webui/component/ButtonFactory.java | 22 - .../webui/component/CWindowToolbar.java | 50 +- .../webui/component/Combinationbox.java | 10 +- .../webui/component/ConfirmPanel.java | 57 +- .../webui/component/DesktopTabpanel.java | 29 + .../webui/component/GridFactory.java | 21 + .../adempiere/webui/component/GridPanel.java | 5 + .../org/adempiere/webui/component/Label.java | 4 +- .../webui/component/ListboxFactory.java | 25 + .../adempiere/webui/component/Messagebox.java | 10 +- .../adempiere/webui/component/NumberBox.java | 2 +- .../webui/component/ToolBarButton.java | 5 + .../webui/component/WAppsAction.java | 83 +- .../webui/component/WConfirmPanel.java | 652 ---- .../adempiere/webui/component/WStatusBar.java | 1 - .../webui/editor/WAccountEditor.java | 2 +- .../webui/editor/WAssignmentEditor.java | 2 +- .../adempiere/webui/editor/WButtonEditor.java | 10 +- .../org/adempiere/webui/editor/WEditor.java | 64 +- .../webui/editor/WEditorPopupMenu.java | 8 +- .../webui/editor/WFilenameEditor.java | 2 +- .../webui/editor/WLocationEditor.java | 2 +- .../webui/editor/WLocatorEditor.java | 2 +- .../webui/editor/WPAttributeEditor.java | 2 +- .../adempiere/webui/editor/WSearchEditor.java | 6 +- .../adempiere/webui/editor/WUrlEditor.java | 2 +- .../org/adempiere/webui/grid/WBPartner.java | 2 +- .../src/org/adempiere/webui/panel/ADForm.java | 12 +- .../org/adempiere/webui/panel/ADSortTab.java | 8 +- .../org/adempiere/webui/panel/ADTabpanel.java | 8 +- .../adempiere/webui/panel/InfoAssetPanel.java | 4 +- .../webui/panel/InfoAssignmentPanel.java | 2 +- .../webui/panel/InfoCashLinePanel.java | 6 +- .../adempiere/webui/panel/InfoInOutPanel.java | 2 +- .../webui/panel/InfoInvoicePanel.java | 4 +- .../adempiere/webui/panel/InfoOrderPanel.java | 2 +- .../webui/panel/InfoPaymentPanel.java | 2 +- .../webui/panel/InfoProductPanel.java | 2 +- .../org/adempiere/webui/panel/LoginPanel.java | 63 +- .../org/adempiere/webui/panel/MenuPanel.java | 8 +- .../org/adempiere/webui/panel/RolePanel.java | 64 +- .../adempiere/webui/panel/WAttachment.java | 12 +- .../webui/panel/WDocActionPanel.java | 16 +- .../adempiere/webui/part/WindowContainer.java | 14 +- .../{WebContext.java => ServerContext.java} | 45 +- .../webui/session/SessionContextListener.java | 35 +- .../adempiere/webui/session/WebUIServlet.java | 2 +- .../adempiere/webui/window/AboutWindow.java | 2 +- .../adempiere/webui/window/FindWindow.java | 18 +- .../adempiere/webui/window/InfoSchedule.java | 2 +- .../webui/window/WAccountDialog.java | 8 +- .../adempiere/webui/window/WEMailDialog.java | 18 +- .../webui/window/WLocationDialog.java | 4 +- .../webui/window/WLocatorDialog.java | 4 +- .../adempiere/webui/window/WMediaDialog.java | 10 +- .../webui/window/WPAttributeDialog.java | 4 +- .../adempiere/webui/window/WRecordInfo.java | 2 +- .../adempiere/webui/window/ZkJRViewer.java | 2 +- .../webui/window/ZkReportViewer.java | 26 +- zkwebui/css/default.css.dsp | 9 + 93 files changed, 1929 insertions(+), 3578 deletions(-) create mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/ServerContextCallback.java delete mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/component/ButtonFactory.java create mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/component/DesktopTabpanel.java delete mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/component/WConfirmPanel.java rename zkwebui/WEB-INF/src/org/adempiere/webui/session/{WebContext.java => ServerContext.java} (64%) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java index 6969cee283..2c39fd0d0d 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java @@ -29,6 +29,7 @@ import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.ProcessDialog; import org.adempiere.webui.apps.graph.WPAPanel; import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.DesktopTabpanel; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.Window; @@ -173,7 +174,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl vbCol1.appendChild(gbxFav); Caption caption = new Caption("Favourites"); // Elaine 2008/07/24 - Image img = new Image("/images/Delete24.gif"); + Image img = new Image("/images/Delete24.png"); caption.appendChild(img); img.setAlign("right"); img.setDroppable("deleteFav"); @@ -285,7 +286,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl vbox.appendChild(btnNotice); btnNotice.setLabel("Notice : 0"); btnNotice.setTooltiptext("Notice"); - btnNotice.setImage("/images/GetMail16.gif"); + btnNotice.setImage("/images/GetMail16.png"); int AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Notice' AND IsSummary = 'N'"); btnNotice.setName(String.valueOf(AD_Menu_ID)); btnNotice.addEventListener(Events.ON_CLICK, this); @@ -294,7 +295,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl vbox.appendChild(btnRequest); btnRequest.setLabel("Request : 0"); btnRequest.setTooltiptext("Request"); - btnRequest.setImage("/images/Request16.gif"); + btnRequest.setImage("/images/Request16.png"); AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Request' AND IsSummary = 'N'"); btnRequest.setName(String.valueOf(AD_Menu_ID)); btnRequest.addEventListener(Events.ON_CLICK, this); @@ -303,7 +304,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl vbox.appendChild(btnWorkflow); btnWorkflow.setLabel("Workflow Activities : 0"); btnWorkflow.setTooltiptext("Workflow Activities"); - btnWorkflow.setImage("/images/Assignment16.gif"); + btnWorkflow.setImage("/images/Assignment16.png"); AD_Menu_ID = DB.getSQLValue(null, "SELECT AD_Menu_ID FROM AD_Menu WHERE Name = 'Workflow Activities' AND IsSummary = 'N'"); btnWorkflow.setName(String.valueOf(AD_Menu_ID)); btnWorkflow.addEventListener(Events.ON_CLICK, this); @@ -522,7 +523,9 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl { Tabpanel tabPanel = new Tabpanel(); window.setParent(tabPanel); - windowContainer.addWindow(tabPanel, window.getTitle(), true); + String title = window.getTitle(); + window.setTitle(null); + windowContainer.addWindow(tabPanel, title, true); } public void onEvent(Event event) @@ -719,7 +722,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl { ADWindow adWindow = new ADWindow(Env.getCtx(), menu.getAD_Window_ID()); - Tabpanel tabPanel = new Tabpanel(); + DesktopTabpanel tabPanel = new DesktopTabpanel(); adWindow.createPart(tabPanel); windowContainer.addWindow(tabPanel, adWindow.getTitle(), true); } @@ -741,7 +744,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl { ADForm form = ADForm.openForm(menu.getAD_Form_ID()); - Tabpanel tabPanel = new Tabpanel(); + DesktopTabpanel tabPanel = new DesktopTabpanel(); form.setParent(tabPanel); //do not show window title when open as tab form.setTitle(null); @@ -796,7 +799,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl { ADWindow wnd = new ADWindow(Env.getCtx(), AD_Window_ID, query); - Tabpanel tabPanel = new Tabpanel(); + DesktopTabpanel tabPanel = new DesktopTabpanel(); wnd.createPart(tabPanel); windowContainer.addWindow(tabPanel, wnd.getTitle(), true); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/ServerContextCallback.java b/zkwebui/WEB-INF/src/org/adempiere/webui/ServerContextCallback.java new file mode 100644 index 0000000000..4605a5819f --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/ServerContextCallback.java @@ -0,0 +1,35 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.webui; + +import java.lang.reflect.Method; + +import org.adempiere.webui.session.ServerContext; + +import net.sf.cglib.proxy.InvocationHandler; + +/** + * Intercaptor for Server context properties that delegate to the threadlocal instance + * @author Low Heng Sin + * + */ +public class ServerContextCallback implements InvocationHandler { + + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + ServerContext context = ServerContext.getCurrentInstance(); + Method m = context.getClass().getMethod(method.getName(), method.getParameterTypes()); + return m.invoke(context, args); + } + +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/TimelineEventFeed.java b/zkwebui/WEB-INF/src/org/adempiere/webui/TimelineEventFeed.java index 29c7cf4378..719373aad3 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/TimelineEventFeed.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/TimelineEventFeed.java @@ -17,7 +17,7 @@ import javax.servlet.http.HttpServletResponse; import org.adempiere.webui.component.ZkCssHelper; import org.adempiere.webui.session.SessionContextListener; -import org.adempiere.webui.session.WebContext; +import org.adempiere.webui.session.ServerContext; import org.compiere.model.MAssignmentSlot; import org.compiere.model.ScheduleUtil; import org.compiere.util.Env; @@ -31,11 +31,11 @@ public class TimelineEventFeed extends HttpServlet { protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - WebContext ctx = (WebContext)req.getSession().getAttribute(SessionContextListener.SESSION_CTX); + ServerContext ctx = (ServerContext)req.getSession().getAttribute(SessionContextListener.SESSION_CTX); if (ctx == null) { return; } else { - WebContext.setCurrentInstance(ctx); + ServerContext.setCurrentInstance(ctx); } int resourceId = 0; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/ValuePreference.java b/zkwebui/WEB-INF/src/org/adempiere/webui/ValuePreference.java index 10a8a963fe..38876a6060 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/ValuePreference.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/ValuePreference.java @@ -142,7 +142,7 @@ public class ValuePreference extends Window implements EventListener /** The Name of the Editor */ public static final String NAME = "ValuePreference"; /** The Menu Icon */ - private static String ICON_URL = "images/VPreference16.gif"; + private static String ICON_URL = "images/VPreference16.png"; /** Logger */ private static CLogger log = CLogger.getCLogger(ValuePreference.class); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/WRequest.java b/zkwebui/WEB-INF/src/org/adempiere/webui/WRequest.java index 0c8e06c990..2e2dd83640 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/WRequest.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/WRequest.java @@ -83,7 +83,7 @@ public class WRequest implements EventListener private void getRequests (Component invoker) { m_new = new Menuitem(Msg.getMsg(Env.getCtx(), "RequestNew")); - m_new.setImage("/images/New16.gif"); + m_new.setImage("/images/New16.png"); m_new.addEventListener(Events.ON_CLICK, this); m_popup.appendChild(m_new); // diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/ZkContextProvider.java b/zkwebui/WEB-INF/src/org/adempiere/webui/ZkContextProvider.java index 136c4e1f0a..39cbe21099 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/ZkContextProvider.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/ZkContextProvider.java @@ -16,13 +16,10 @@ *****************************************************************************/ package org.adempiere.webui; -import java.awt.Image; import java.util.Properties; - -import javax.swing.ImageIcon; +import net.sf.cglib.proxy.Enhancer; import org.adempiere.webui.session.SessionManager; -import org.adempiere.webui.session.WebContext; import org.compiere.util.ContextProvider; /** @@ -32,27 +29,20 @@ import org.compiere.util.ContextProvider; */ public class ZkContextProvider implements ContextProvider { + private final ServerContextCallback callback = new ServerContextCallback(); + private final Properties context = (Properties) Enhancer.create(Properties.class, callback); + + /** + * Get server context proxy + */ public Properties getContext() { - return WebContext.getCurrentInstance(); + return context; } + /** + * Show url at zk desktop + */ public void showURL(String url) { SessionManager.getAppDesktop().showURL(url,true); - } - - public Image getImage (String fileNameInImageDir) - { - return null; - } - - public ImageIcon getImageIcon (String fileNameInImageDir) - { - return null; - } - - public ImageIcon getImageIcon2 (String fileName) - { - return null; - } - + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java index b404ca6d30..943655970b 100755 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java @@ -449,7 +449,7 @@ public class WAcctViewer extends Window implements EventListener displayPanel.appendChild(boxSort3); displayPanel.appendChild(boxSort4); - //"images/InfoAccount16.gif" + //"images/InfoAccount16.png" Groupbox groupDisplay = new Groupbox(); Caption capDisplay = new Caption("Display"); @@ -483,11 +483,11 @@ public class WAcctViewer extends Window implements EventListener forcePost.setTooltiptext(Msg.getMsg(Env.getCtx(), "ForceInfo")); forcePost.setVisible(false); - bQuery.setImage("/images/Refresh16.gif"); + bQuery.setImage("/images/Refresh16.png"); bQuery.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh")); bQuery.addEventListener(Events.ON_CLICK, this); - bPrint.setImage("/images/Print16.gif"); + bPrint.setImage("/images/Print16.png"); bPrint.setTooltiptext(Msg.getMsg(Env.getCtx(), "Print")); bPrint.addEventListener(Events.ON_CLICK, this); @@ -600,7 +600,7 @@ public class WAcctViewer extends Window implements EventListener m_data.fillTable(selTable); selTable.addEventListener(Events.ON_SELECT, this); - selRecord.setImage("/images/Find16.gif"); + selRecord.setImage("/images/Find16.png"); selRecord.addEventListener(Events.ON_CLICK, this); selRecord.setLabel(""); @@ -613,7 +613,7 @@ public class WAcctViewer extends Window implements EventListener selAcct.setName("Account_ID"); selAcct.addEventListener(Events.ON_CLICK, this); selAcct.setLabel(""); - selAcct.setImage("/images/Find16.gif"); + selAcct.setImage("/images/Find16.png"); statusLine.setValue(" " + Msg.getMsg(Env.getCtx(), "ViewerOptions")); @@ -807,7 +807,7 @@ public class WAcctViewer extends Window implements EventListener labels[selectionIndex].setVisible(true); buttons[selectionIndex].setName(columnName); // actionCommand buttons[selectionIndex].addEventListener(Events.ON_CLICK, this); - buttons[selectionIndex].setImage("/images/Find16.gif"); + buttons[selectionIndex].setImage("/images/Find16.png"); buttons[selectionIndex].setLabel(""); buttons[selectionIndex].setVisible(true); selectionIndex++; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 70d7848764..5ad99dd567 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -21,7 +21,6 @@ import java.io.InvalidClassException; import java.io.NotSerializableException; import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.rmi.RemoteException; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -32,7 +31,6 @@ import java.util.logging.Level; import org.adempiere.webui.component.Window; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.window.FDialog; -import org.compiere.Adempiere; import org.compiere.apps.ALogin; import org.compiere.db.CConnection; import org.compiere.interfaces.Server; @@ -73,21 +71,18 @@ public final class AEnv */ public static void positionCenterScreen(Window window) { - // positionScreen (window, SwingConstants.CENTER); + showCenterScreen(window); } // positionCenterScreen /** * Show in the center of the screen. * (pack, set location and set visibility) * @param window Window to position - * @param position SwingConstants + * @param position */ - public static void showScreen(Window window, int position) + public static void showScreen(Window window, String position) { - /* positionScreen(window, position); - window.setVisible(true); - window.toFront(); - */ + SessionManager.getAppDesktop().showWindow(window, position); } // showScreen /** @@ -98,154 +93,10 @@ public final class AEnv */ public static void showCenterWindow(Window parent, Window window) { - /* - positionCenterWindow(parent, window); - window.setVisible(true); - window.toFront(); - */ + parent.appendChild(window); + showScreen(window, "parent,center"); } // showCenterWindow - /** - * Perform action command for common menu items. - * Created in AMenu.createMenu(), APanel.createMenu(), FormFrame.createMenu() - * @param actionCommand known action command - * @param WindowNo window no - * @param c Container parent - * @return true if actionCommand was found and performed - */ - /* public static boolean actionPerformed (String actionCommand, int WindowNo, Container c) - { - - MRole role = MRole.getDefault(); - // File Menu ------------------------ - if (actionCommand.equals("PrintScreen")) - { - PrintScreenPainter.printScreen (Env.getFrame(c)); - } - else if (actionCommand.equals("ScreenShot")) - { - ScreenShot.createJPEG(Env.getFrame(c), null); - } - // else if (actionCommand.equals("Report")) - // { - // AEnv.showCenterScreen (new ProcessStart()); - // } - else if (actionCommand.equals("Exit")) - { - if (ADialog.ask(WindowNo, c, "ExitApplication?")) - Env.exitEnv(0); - } - else if (actionCommand.equals("Logout")) - { - AMenu aMenu = (AMenu)Env.getWindow(0); - aMenu.logout(); - } - - // View Menu ------------------------ - else if (actionCommand.equals("InfoProduct") && AEnv.canAccessInfo("PRODUCT")) - { - org.compiere.apps.search.Info.showProduct (Env.getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoBPartner") && AEnv.canAccessInfo("BPARTNER")) - { - org.compiere.apps.search.Info.showBPartner (Env.getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoAsset") && AEnv.canAccessInfo("ASSET")) - { - org.compiere.apps.search.Info.showAsset (Env.getFrame(c), WindowNo); - } - else if (actionCommand.equals("InfoAccount") && - MRole.getDefault().isShowAcct() && - AEnv.canAccessInfo("ACCOUNT")) - { - new org.compiere.acct.AcctViewer(); - } - else if (actionCommand.equals("InfoSchedule") && AEnv.canAccessInfo("SCHEDULE")) - { - new org.compiere.apps.search.InfoSchedule (Env.getFrame(c), null, false); - } - else if (actionCommand.equals("InfoOrder") && AEnv.canAccessInfo("ORDER")) - { - org.compiere.apps.search.Info.showOrder (Env.getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoInvoice") && AEnv.canAccessInfo("INVOICE")) - { - org.compiere.apps.search.Info.showInvoice (Env.getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoInOut") && AEnv.canAccessInfo("INOUT")) - { - org.compiere.apps.search.Info.showInOut (Env.getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoPayment") && AEnv.canAccessInfo("PAYMENT")) - { - org.compiere.apps.search.Info.showPayment (Env.getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoCashLine") && AEnv.canAccessInfo("CASHJOURNAL")) - { - org.compiere.apps.search.Info.showCashLine (Env.getFrame(c), WindowNo, ""); - } - else if (actionCommand.equals("InfoAssignment") && AEnv.canAccessInfo("RESOURCE")) - { - org.compiere.apps.search.Info.showAssignment (Env.getFrame(c), WindowNo, ""); - } - - // Go Menu ------------------------ - else if (actionCommand.equals("WorkFlow")) - { - startWorkflowProcess(0,0); - } - else if (actionCommand.equals("Home")) - { - Env.getWindow(0).toFront(); - } - - // Tools Menu ------------------------ - else if (actionCommand.equals("Calculator")) - { - Calculator calc = new org.compiere.grid.ed.Calculator(Env.getFrame(c)); - calc.setDisposeOnEqual(false); - AEnv.showCenterScreen (calc); - } - else if (actionCommand.equals("Calendar")) - { - AEnv.showCenterScreen (new org.compiere.grid.ed.Calendar(Env.getFrame(c))); - } - else if (actionCommand.equals("Editor")) - { - AEnv.showCenterScreen (new org.compiere.grid.ed.Editor(Env.getFrame(c))); - } - else if (actionCommand.equals("Script")) - { - new ScriptEditor(); - } - else if (actionCommand.equals("Preference")) - { - if (role.isShowPreference()) { - AEnv.showCenterScreen(new Preference (Env.getFrame(c), WindowNo)); - } - } - - // Help Menu ------------------------ - else if (actionCommand.equals("Online")) - { - Env.startBrowser(org.compiere.Adempiere.getOnlineHelpURL()); - } - else if (actionCommand.equals("EMailSupport")) - { - ADialog.createSupportEMail(Env.getFrame(c), Env.getFrame(c).getTitle(), "\n\n"); - } - else if (actionCommand.equals("About")) - { - AEnv.showCenterScreen(new AboutBox(Env.getFrame(c))); - } - else - return false; - // - return true; - - } // actionPerformed -*/ - /** * Get Mnemonic character from text. * @param text text with '&' @@ -551,7 +402,7 @@ public final class AEnv { // Remote Context is called by value, not reference // Add Window properties to context - Enumeration keyEnum = mWindowVO.ctx.keys(); + Enumeration keyEnum = mWindowVO.ctx.keys(); while (keyEnum.hasMoreElements()) { String key = (String)keyEnum.nextElement(); @@ -823,7 +674,7 @@ public final class AEnv /** * Get ImageIcon. * - * @param fileNameInImageDir full file name in imgaes folder (e.g. Bean16.gif) + * @param fileNameInImageDir full file name in imgaes folder (e.g. Bean16.png) * @return image */ public static URI getImage(String fileNameInImageDir) @@ -840,39 +691,4 @@ public final class AEnv } return uri; } // getImageIcon - - /** - * Get ImageIcon. This method different from getImageIcon - * where the fileName parameter is without extension. The - * method will first try .gif and then .png if .gif does not - * exists. - * - * @param fileName file name in imgaes folder without the extension(e.g. Bean16) - * @return image - */ - public static URI getImage2 (String fileName) - { - String relativePath; - URI uri = null; - URL absoluteUrl = null; - final String imageDir = "images/"; - - relativePath = imageDir + fileName + ".png"; - uri = URI.create("/" + relativePath); - absoluteUrl = Adempiere.class.getResource(relativePath); - if (absoluteUrl == null) - { - relativePath = imageDir + fileName + ".gif"; - uri = URI.create("/" + relativePath); - absoluteUrl = Adempiere.class.getResource(relativePath); - if (absoluteUrl == null) - { - log.log(Level.WARNING, "GIF/PNG Not found: " + fileName); - return null; - } - } - - return uri; - } // getImageIcon2 - } // AEnv diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index d836ffa8b2..328af59faf 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -106,14 +106,14 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce Hbox hbox = new Hbox(); String label = Msg.getMsg(Env.getCtx(), "Ok"); bOK = new Button(label.replaceAll("&", "")); - bOK.setImage("/images/Ok16.gif"); + bOK.setImage("/images/Ok16.png"); bOK.setName("ok"); bOK.addEventListener(Events.ON_CLICK, this); hbox.appendChild(bOK); label = Msg.getMsg(Env.getCtx(), "Cancel"); Button btn = new Button(label.replaceAll("&", "")); - btn.setImage("/images/Cancel16.gif"); + btn.setImage("/images/Cancel16.png"); btn.setName("cancel"); btn.addEventListener(Events.ON_CLICK, this); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java index ae22096f22..0710e6d04b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/ProcessParameterPanel.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.logging.Level; import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; @@ -72,7 +73,7 @@ implements ValueChangeListener, IProcessParameter } // ProcessParameterPanel private void initComponent() { - centerPanel = new Grid(); + centerPanel = GridFactory.newGridLayout(); this.appendChild(centerPanel); } @@ -233,7 +234,7 @@ implements ValueChangeListener, IProcessParameter // The Editor WEditor wEditor = WebEditorFactory.getEditor(mField, false); - wEditor.addValueChangeListner(this); + wEditor.addValueChangeListener(this); // MField => VEditor - New Field value to be updated to editor mField.addPropertyChangeListener(wEditor); // Set Default @@ -422,13 +423,6 @@ implements ValueChangeListener, IProcessParameter public void valueChange(ValueChangeEvent evt) { String value = evt.getNewValue() == null ? "" : evt.getNewValue().toString(); - - if (evt.getSource() instanceof WEditor) - { - WEditor comp = (WEditor)(evt.getSource()); - comp.setValue(value); - - } Env.setContext(Env.getCtx(), m_WindowNo, evt.getPropertyName(), value); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java index abf9dd04e9..9d2b46f2b6 100755 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAllocation.java @@ -1,2162 +1,1213 @@ -/****************************************************************************** - * Product: Adempiere ERP & CRM Smart Business Solution * - * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * - * or via info@compiere.org or http://www.compiere.org/license.html * - *****************************************************************************/ - -/** - * 2007, Modified by Posterita Ltd. - */ - -package org.adempiere.webui.apps.form; - -import java.math.BigDecimal; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Vector; -import java.util.logging.Level; - -import org.adempiere.webui.LayoutUtils; -import org.adempiere.webui.component.Button; -import org.adempiere.webui.component.Checkbox; -import org.adempiere.webui.component.Grid; -import org.adempiere.webui.component.Label; -import org.adempiere.webui.component.ListModelTable; -import org.adempiere.webui.component.Panel; -import org.adempiere.webui.component.Row; -import org.adempiere.webui.component.Rows; -import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.WListbox; -import org.adempiere.webui.component.WStatusBar; -import org.adempiere.webui.editor.WDateEditor; -import org.adempiere.webui.editor.WEditor; -import org.adempiere.webui.editor.WSearchEditor; -import org.adempiere.webui.editor.WTableDirEditor; -import org.adempiere.webui.event.ValueChangeEvent; -import org.adempiere.webui.event.ValueChangeListener; -import org.adempiere.webui.event.WTableModelEvent; -import org.adempiere.webui.event.WTableModelListener; -import org.adempiere.webui.panel.ADForm; -import org.adempiere.webui.window.FDialog; -import org.compiere.model.MAllocationHdr; -import org.compiere.model.MAllocationLine; -import org.compiere.model.MInvoice; -import org.compiere.model.MLookup; -import org.compiere.model.MLookupFactory; -import org.compiere.model.MPayment; -import org.compiere.process.DocAction; -import org.compiere.util.DB; -import org.compiere.util.DisplayType; -import org.compiere.util.Env; -import org.compiere.util.KeyNamePair; -import org.compiere.util.Msg; -import org.compiere.util.TimeUtil; -import org.compiere.util.Trx; -import org.compiere.util.Util; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; -import org.zkoss.zkex.zul.Borderlayout; -import org.zkoss.zkex.zul.Center; -import org.zkoss.zkex.zul.North; -import org.zkoss.zkex.zul.South; -import org.zkoss.zul.Div; -import org.zkoss.zul.Hbox; -import org.zkoss.zul.Separator; -import org.zkoss.zul.Space; -import org.zkoss.zul.event.ListDataEvent; - - -/** - * Allocation panel. Panel for selecting sets of invoices and payments to - * process. The panel contains a set of paramater components that select and - * filter the invoices and payments, a panel for displaying and selecting - * invoices, a panel for selecting and displaying payments, and a panel for - * allocating payments. - * - * - * @author Andrew Kimball - * - */ -public class WAllocation extends ADForm implements EventListener, - ValueChangeListener, WTableModelListener -{ - /* - * TODO A lot of the code here replicates code in the rich client version of - * VAllocation. Creating a common superclass would remove a lot of this - * duplication. - */ - - /** Unique identifier. */ - private static final long serialVersionUID = 1L; - - /** */ - //private Panel m_pnlMain = new Panel(); - private Borderlayout m_pnlMain = new Borderlayout(); - - /** Parameter panel. */ - private Panel m_pnlParameter = new Panel(); - /** Parameter grid. */ - private Grid m_grdParameter = new Grid(); - /** Business Partner label. */ - private Label m_lblBusinessPartner = new Label(); - /** Business Partner search editor. */ - private WEditor m_wedBusinessPartnerSearch = null; - /** Currency label. */ - private Label m_lblCurrency = new Label(); - /** Currency pick editor. */ - private WEditor m_wedCurrencyPick = null; - /** Date label. */ - private Label m_lblDate = new Label(); - /** Date Field editor. */ - private WDateEditor m_wdeDateField = new WDateEditor(); - /** Multi Currency checkbox. */ - private Checkbox m_chbMultiCurrency = new Checkbox(); - - /** Payment panel. */ - private Panel m_pnlPayment = new Panel(); - /** Payment Panel label. */ - private Label m_lblPayment = new Label(); - /** Payment Info label. */ - private Label m_lblPaymentInfo = new Label(); - /** Payment Info table. */ - private WListbox m_lsbPayments = new WListbox(); - - /** Invoice panel. */ - private Panel m_pnlInvoice = new Panel(); - /** Invoice Panel label. */ - private Label m_lblInvoice = new Label(); - /** Invoice Info label. */ - private Label m_lblInvoiceInfo = new Label(); - /** Invoice Info table. */ - private WListbox m_lsbInvoices = new WListbox(); - - /** Panel to group Invoice and Payment panels. */ - private Panel m_pnlInfo = new Panel(); - - /** Allocation panel. */ - private Panel m_pnlAllocate = new Panel(); - /** Difference label. */ - private Label m_lblDifference = new Label(); - /** Difference field. */ - private Textbox m_txbDifferenceField = new Textbox(); - /** Allocation button. */ - private Button m_btnAllocate = new Button(); - /** Allocation Currency label. */ - private Label m_lblAllocCurrency = new Label(); - /** Automatic write-off checkbox. */ - private Checkbox m_chbAutoWriteOff = new Checkbox(); - - /** Status Bar. */ - private WStatusBar m_statusBar = new WStatusBar(); - - /** true if a calculation is currentl being performed. */ - private boolean m_isCalculating = false; - - /** index of selected currency. */ - private int m_currencyId = 0; - - /** index of selected business partner. */ - private int m_businessPartnerId = 0; - - /** number of affected invoices. */ - private int m_noSelectedInvoices = 0; - - /** number of affected payments. */ - private int m_noSelectedPayments = 0; - - /** the index of the last row containing an invoice. */ - private int m_rowLastInvoice = 0; - - private ArrayList m_bPartnerCheck = new ArrayList(); - - /** index of the selected column. */ - static final private int ms_selectedColIndex = 0; - - /** index of the date column. */ - static final private int ms_dateColIndex = 1; - - /** index of the value column. */ - static final private int ms_valueColIndex = 2; - - // Index changed if multi-currency (either 5 or 7) - /** index of the payment column. */ - private int m_paymentColIndex = 7; - - /** index of the open column. */ - private int m_openColIndex = 6; - - /** index of the discount column. */ - private int m_discountColIndex = 7; - - /** index of the write-off column. */ - private int m_writeOffColIndex = 8; - - /** index of the applied column. */ - private int m_appliedColIndex = 9; - - /** value of total payments */ - private BigDecimal m_totalPayment = new BigDecimal(0.0); - - /** value of total invoice */ - private BigDecimal m_totalInvoiced = new BigDecimal(0.0); - - /** value of total credit */ - private BigDecimal m_totalCredit = new BigDecimal(0.0); - - /** enumeration of the possible types of allocation */ - private enum EIndicator - { - /** No allocation. */ - NONE, - /** Total payment = Total invoiced. */ - TOTAL_PAY, - /** - * Subpayment - *

- * issotrx=y - */ - SUBPAYMENT_SO, - /** - * Total payment > Total invoiced. - *

- * issotrx=y - */ - GREATER_PAYMENT_SO, - /** Subpayment with credit note. */ - CREDIT_MEMO, - /** - * Total payment > Total invoiced - *

- * issotrx=n - */ - GREATER_PAYMENT_PO, - /** - * Total payment < Total invoiced - *

- * issotrx=n - */ - GREATER_INVOICED_PO, - /** Credit emo > Invoiced. */ - GREATER_CREDIT - } - - /** Indicator for the type of allocation being made. */ - private EIndicator m_eIndicator = EIndicator.NONE; - - /** column index for Invoice. */ - private int m_invoiceIndex = 0; - - /** column index for credit. */ - private int m_creditIndex = 0; - - /** - * Default constructor. - */ - public WAllocation() - { - super(); - } - - /** - * Create a panel containing details of payments. - * - * @see #createInfoPanel() - * @see #createInvoicePanel() - */ - private void createPaymentPanel() - { - Div div = new Div(); - - // Put the table label at the top of this panel - m_lblPayment.setValue(Msg.translate(Env.getCtx(), "C_Payment_ID")); - div.setStyle("text-align:left"); - div.appendChild(m_lblPayment); - m_pnlPayment.appendChild(div); - - // Add the payment details table - m_lsbPayments.setVflex(true); - m_lsbPayments.setHeight("80%"); - m_lsbPayments.setWidth("99%"); - m_pnlPayment.appendChild(m_lsbPayments); - - // Put the selected payment information just below the table and - // right-align it - div = new Div(); - div.setWidth("99%"); - m_lblPaymentInfo.setValue("."); - div.setStyle("text-align:right"); - div.appendChild(m_lblPaymentInfo); - m_pnlPayment.appendChild(div); - - - return; - } - - /** - * Create a panel containing details of invoices - * - * @see #createInfoPanel() - * @see #createPaymentPanel() - */ - private void createInvoicePanel() - { - Div div = new Div(); - - // Put the table label at the top of this panel - m_lblInvoice.setValue(Msg.translate(Env.getCtx(), "C_Invoice_ID")); - div.setStyle("text-align:left"); - div.appendChild(m_lblInvoice); - m_pnlInvoice.appendChild(div); - - // Add the invoice details table - m_lsbInvoices.setHeight("80%"); - m_lsbInvoices.setWidth("99%"); - m_lsbInvoices.setVflex(true); - m_pnlInvoice.appendChild(m_lsbInvoices); - - // Put the selected invoice information just below the table and - // right-align it - div = new Div(); - div.setWidth("99%"); - m_lblInvoiceInfo.setValue("."); - div.setStyle("text-align:right"); - div.appendChild(m_lblInvoiceInfo); - m_pnlInvoice.appendChild(div); - - return; - } - - /** - * Create a panel containing details of payments and invoices. - * - * @see #createInvoicePanel() - * @see #createPaymentPanel() - */ - private void createInfoPanel() - { - - createPaymentPanel(); - m_pnlPayment.setHeight("49%"); - m_pnlPayment.setWidth("100%"); - m_pnlInfo.appendChild(m_pnlPayment); - - createInvoicePanel(); - m_pnlInvoice.setHeight("49%"); - m_pnlInvoice.setWidth("100%"); - m_pnlInfo.appendChild(m_pnlInvoice); - - return; - } - - /** - * Create a panel containing components to enable allocations of payments to - * invoices. - */ - private void createAllocationPanel() - { - Hbox box = new Hbox(); - - // align the components - box.setValign("center"); - - // First add the difference label - m_lblDifference.setValue(Msg.getMsg(Env.getCtx(), "Difference")); - box.appendChild(m_lblDifference); - - // Then put a label showing the currency - m_lblAllocCurrency.setValue("."); - box.appendChild(m_lblAllocCurrency); - - // Then add the label showing the difference between the selected - // payment and invoice - // amounts - m_txbDifferenceField.setReadonly(true); - m_txbDifferenceField.setText("0"); - m_txbDifferenceField.setCols(8); - m_txbDifferenceField.setStyle("text-align:right"); - box.appendChild(m_txbDifferenceField); - - // Then add the auto write-off checkbox - m_chbAutoWriteOff.setChecked(false); - m_chbAutoWriteOff.setLabel(Msg.getMsg(Env.getCtx(), "AutoWriteOff", true)); - m_chbAutoWriteOff.setTooltiptext(Msg.getMsg(Env.getCtx(), "AutoWriteOff", - false)); - box.appendChild(m_chbAutoWriteOff); - - // Finally add the allocate button - m_btnAllocate.setLabel(Msg.getMsg(Env.getCtx(), "Process")); - box.appendChild(m_btnAllocate); - m_btnAllocate.addEventListener(Events.ON_CLICK, this); - - // Add the complete box to the panel - m_pnlAllocate.appendChild(box); - - return; - } - - /** - * Create the panel containing the business partner, currency and date - * parameters. - * - * These parameters are used for filtering and displaying - * invoices and payments. - */ - private void createParameterPanel() - { - m_grdParameter.makeNoStrip(); - - Rows rows = new Rows(); - Row rowTop = new Row(); - Row rowBottom = new Row(); - - // set the labels - m_lblDate.setValue(Msg.getMsg(Env.getCtx(), "Date")); - m_lblCurrency.setValue(Msg.translate(Env.getCtx(), "C_Currency_ID")); - m_lblBusinessPartner.setValue(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - m_chbMultiCurrency.setLabel(Msg.getMsg(Env.getCtx(), "MultiCurrency")); - m_chbMultiCurrency.addEventListener(Events.ON_CHECK, this); - - // add the business partner search box to the top row - rowTop.appendChild(LayoutUtils.makeRightAlign(m_lblBusinessPartner)); - rowTop.appendChild(m_wedBusinessPartnerSearch.getComponent()); - - // add the date box to the top row - rowTop.appendChild(LayoutUtils.makeRightAlign(m_lblDate)); - rowTop.appendChild(m_wdeDateField.getComponent()); - - rows.appendChild(rowTop); - - // add the currency search box to the bottom row - rowBottom.appendChild(LayoutUtils.makeRightAlign(m_lblCurrency)); - rowBottom.appendChild(m_wedCurrencyPick.getComponent()); - - // add the mult-currency check-box to the bottom row - rowBottom.appendChild(new Space()); - rowBottom.appendChild(m_chbMultiCurrency); - - // put it all together - rows.appendChild(rowBottom); - - m_grdParameter.setWidth("600px"); - m_grdParameter.appendChild(rows); - - m_pnlParameter.appendChild(m_grdParameter); - - return; - } - - /** - * Initialise the panel. - * - * @param adFormId - * The Adempiere identifier for the form - * @param name - * The name of the form - */ - public void init(int adFormId, String name) - { - super.init(adFormId, name); - - m_currencyId = Env.getContextAsInt(Env.getCtx(), "$C_Currency_ID"); // default - logger.info("Currency=" + m_currencyId); - - dynamicInitialise(); - - createParameterPanel(); - North north = new North(); - north.appendChild(m_pnlParameter); - - createInfoPanel(); - Center center = new Center(); - center.appendChild(m_pnlInfo); - m_pnlInfo.setWidth("100%"); - m_pnlInfo.setHeight("100%"); - center.setFlex(true); - center.setAutoscroll(true); - - createAllocationPanel(); - South south = new South(); - Div div = new Div(); - div.appendChild(m_pnlAllocate); - div.appendChild(new Separator("vertical")); - div.appendChild(m_statusBar); - div.setHeight("100%"); - south.appendChild(div); - - this.appendChild(m_pnlMain); - - m_pnlMain.appendChild(north); - m_pnlMain.appendChild(center); - m_pnlMain.appendChild(south); - - m_pnlMain.setWidth("99%"); - m_pnlMain.setHeight("100%"); - - calculate(); - - return; - } - - /** - * Create the components of the panel which have dynamic content. - * - */ - private void dynamicInitialise() - { - // these magic numbers are copied from VAllocation - final int adCurrencyId = 3505; // C_Invoice.C_Currency_ID - final int adBPartnerId = 3499; // C_Invoice.C_BPartner_ID - - // status bar - m_statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "AllocateStatus")); - m_statusBar.setStatusDB(""); - - // date field - m_wdeDateField.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); - m_wdeDateField.addValueChangeListner(this); - - // business partner search edit box - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, - 0, adBPartnerId, DisplayType.Search); - m_wedBusinessPartnerSearch = new WSearchEditor(lookupBP, Msg.translate( - Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - m_wedBusinessPartnerSearch.addValueChangeListner(this); - - // currency pick search box - MLookup lookupCur = MLookupFactory.get(Env.getCtx(), super.m_windowNo, - 0, adCurrencyId, DisplayType.TableDir); - m_wedCurrencyPick = new WTableDirEditor(lookupCur, Msg.translate(Env - .getCtx(), "C_Currency_ID"), "", true, false, true); - m_wedCurrencyPick.addValueChangeListner(this); - m_wedCurrencyPick.setValue(new Integer(m_currencyId)); - - return; - } - - /** - * Retrieve unallocated payments from the database and store them in the - * payments table. - */ - private void loadUnallocatedPayments() - { - /* - * Load unallocated Payments 1-TrxDate, 2-DocumentNo, (3-Currency, - * 4-PayAmt,) 5-ConvAmt, 6-ConvOpen, 7-Allocated - */ - Vector data = null; - // Header Info - Vector columnNames = getPaymentColumnNames(); - - data = getPaymentData(); - - // Set Model - ListModelTable model = new ListModelTable(data); - model.addTableModelListener(this); - m_lsbPayments.setData(model, columnNames); - // - setPaymentColumnClasses(); - - // removed terniary operator for clarity - if (m_chbMultiCurrency.isChecked()) - { - m_paymentColIndex = 7; - } - else - { - m_paymentColIndex = 5; - } - - // Table UI - // paymentTable.autoSize(); - - return; - } - - /** - * Get the payment data. - * - * @return A vector containing the payment data - */ - private Vector getPaymentData() - { - Vector data = new Vector(); - ResultSet rs = null; - PreparedStatement pstmt = null; - - try - { - pstmt = preparePaymentStatement(); - rs = pstmt.executeQuery(); - - while (rs.next()) - { - Vector line = new Vector(); - line.add(new Boolean(false)); // 0-Selection - line.add(rs.getTimestamp(1)); // 1-TrxDate - KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(2)); - line.add(pp); // 2-DocumentNo - if (m_chbMultiCurrency.isChecked()) - { - line.add(rs.getString(4)); // 3-Currency - line.add(rs.getBigDecimal(5)); // 4-PayAmt - } - line.add(rs.getBigDecimal(6)); // 3/5-ConvAmt - BigDecimal available = rs.getBigDecimal(7); - if (available == null || available.signum() == 0) // nothing - // available - { - continue; - } - line.add(available); // 4/6-ConvOpen/Available - line.add(Env.ZERO); // 5/7-Payment - // - data.add(line); - } - rs.close(); - pstmt.close(); - } - catch (SQLException exception) - { - // TODO what to report here if don't have access to SQL statement - logger.log(Level.SEVERE, getPaymentSql(), exception); - } - - return data; - } - - /** - * Prepare the SQL statement for obtaining the unallocated payments. - * - * @return the precompiled SQL statement - * @throws SQLException - */ - private PreparedStatement preparePaymentStatement() throws SQLException - { - String sql = getPaymentSql(); - PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); - pstmt.setInt(1, m_currencyId); - pstmt.setInt(2, m_currencyId); - pstmt.setInt(3, m_businessPartnerId); - - if (!m_chbMultiCurrency.isChecked()) - { - pstmt.setInt(4, m_currencyId); - } - return pstmt; - } - - /** - * Create the SQL statement for obtaining unallocated payments. - * - * @return the SQL statement for obtaining unallocated payments - */ - private String getPaymentSql() - { - // Create SELECT statement - StringBuffer sql = new StringBuffer("SELECT p.DateTrx, " - + "p.DocumentNo, " - + "p.C_Payment_ID," // 1..3 - + "c.ISO_Code, " - + "p.PayAmt," // 4..5 - + "currencyConvert(p.PayAmt," + "p.C_Currency_ID," - + "?," - + "p.DateTrx," - + "p.C_ConversionType_ID," - + "p.AD_Client_ID," - + "p.AD_Org_ID),"// 6 #1 - + "currencyConvert(paymentAvailable(C_Payment_ID)," - + "p.C_Currency_ID," + "?," + "p.DateTrx," - + "p.C_ConversionType_ID," + "p.AD_Client_ID," - + "p.AD_Org_ID)," // 7 #2 - + "p.MultiplierAP "); - - // Append FROM clause - sql - .append("FROM C_Payment_v p" // Corrected for AP/AR - + " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) "); - - // Append WHERE clause - sql.append("WHERE p.IsAllocated='N' AND p.Processed='Y'" - + " AND p.C_Charge_ID IS NULL" // Prepayments OK - + " AND p.C_BPartner_ID=?"); // #3 - - if (!m_chbMultiCurrency.isChecked()) - { - sql.append(" AND p.C_Currency_ID=?"); // #4 - } - sql.append(" ORDER BY p.DateTrx,p.DocumentNo"); - - logger.fine("PaySQL=" + sql.toString()); - - return sql.toString(); - } - - /** - * Set the classes and read-only property for all payment table columns. - */ - private void setPaymentColumnClasses() - { - int columnIndex = 0; - m_lsbPayments.setColumnClass(columnIndex++, Boolean.class, false); // 0-Selection - m_lsbPayments.setColumnClass(columnIndex++, Timestamp.class, true); // 1-TrxDate - m_lsbPayments.setColumnClass(columnIndex++, String.class, true); // 2-Value - if (m_chbMultiCurrency.isChecked()) - { - m_lsbPayments.setColumnClass(columnIndex++, String.class, true); // 3-Currency - m_lsbPayments.setColumnClass(columnIndex++, BigDecimal.class, true); // 4-PayAmt - } - m_lsbPayments.setColumnClass(columnIndex++, BigDecimal.class, true); // 5-ConvAmt - m_lsbPayments.setColumnClass(columnIndex++, BigDecimal.class, true); // 6-ConvOpen - m_lsbPayments.setColumnClass(columnIndex++, BigDecimal.class, false); // 7-Allocated - - return; - } - - /** - * Get a all of the columnn names. - * - * @return vector containing all of the column names - */ - private Vector getPaymentColumnNames() - { - Vector columnNames = new Vector(); - columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); - columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Util - .cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); - if (m_chbMultiCurrency.isChecked()) - { - columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); - columnNames.add(Msg.translate(Env.getCtx(), "Amount")); - } - columnNames.add(Msg.getMsg(Env.getCtx(), "ConvertedAmount")); - columnNames.add(Msg.getMsg(Env.getCtx(), "OpenAmt")); - columnNames.add(Msg.getMsg(Env.getCtx(), "AppliedAmt")); - return columnNames; - } - - /** - * - * - */ - private void loadUnpaidInvoices() - { - /* - * Load unpaid Invoices 1-TrxDate, 2-Value, (3-Currency, 4-InvAmt,) - * 5-ConvAmt, 6-ConvOpen, 7-ConvDisc, 8-WriteOff, 9-Applied - * - * SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID,c.ISO_Code, - * i.GrandTotal*i.MultiplierAP "GrandTotal", - * currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) - * "GrandTotal $", invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID) - * "Open", - * currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP - * "Open $", - * invoiceDiscount(i.C_Invoice_ID,SysDate,C_InvoicePaySchedule_ID) - * "Discount", - * currencyConvert(invoiceDiscount(i.C_Invoice_ID,SysDate,C_InvoicePaySchedule_ID),i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP - * "Discount $", i.MultiplierAP, i.Multiplier FROM C_Invoice_v i INNER - * JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) WHERE -- - * i.IsPaid='N' AND i.Processed='Y' AND i.C_BPartner_ID=1000001 - */ - Vector data = new Vector(); - // Header Info - Vector columnNames = getInvoiceColumnNames(); - ResultSet rs = null; - PreparedStatement pstmt = null; - - try - { - pstmt = prepareInvoiceStatement(); - rs = pstmt.executeQuery(); - - while (rs.next()) - { - Vector line = new Vector(); - line.add(new Boolean(false)); // 0-Selection - line.add(rs.getTimestamp(1)); // 1-TrxDate - KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(2)); - line.add(pp); // 2-Value - if (m_chbMultiCurrency.isChecked()) - { - line.add(rs.getString(4)); // 3-Currency - line.add(rs.getBigDecimal(5)); // 4-Orig Amount - } - line.add(rs.getBigDecimal(6)); // 3/5-ConvAmt - BigDecimal open = rs.getBigDecimal(7); - if (open == null) // no conversion rate - { - open = Env.ZERO; - } - line.add(open); // 4/6-ConvOpen - BigDecimal discount = rs.getBigDecimal(8); - if (discount == null) // no conversion rate - { - discount = Env.ZERO; - } - line.add(discount); // 5/7-ConvAllowedDisc - line.add(Env.ZERO); // 6/8-WriteOff - line.add(Env.ZERO); // 7/9-Applied - - // Add when open <> 0 (i.e. not if no conversion rate) - if (Env.ZERO.compareTo(open) != 0) - { - data.add(line); - } - } - rs.close(); - pstmt.close(); - } - catch (SQLException exception) - { - logger.log(Level.SEVERE, getInvoiceSql(), exception); - } - - // Remove previous listeners - // TODO - // invoiceTable.getModel().removeTableModelListener(this); - - ListModelTable model = new ListModelTable(data); - model.addTableModelListener(this); - m_lsbInvoices.setData(model, columnNames); - - // set column data - setInvoiceColumnClasses(); - - // TODO Table UI - // invoiceTable.autoSize(); - - return; - } - - /** - * Prepare the SQL statement for obtaining the unallocated invoices. - * - * @return the precompiled SQL statement - * @throws SQLException - */ - private PreparedStatement prepareInvoiceStatement() throws SQLException - { - String sql = getInvoiceSql(); - PreparedStatement pstmt = DB.prepareStatement(sql, null); - - pstmt.setInt(1, m_currencyId); - pstmt.setInt(2, m_currencyId); - pstmt.setTimestamp(3, (Timestamp) m_wdeDateField.getValue()); - pstmt.setInt(4, m_currencyId); - pstmt.setInt(5, m_businessPartnerId); - - if (!m_chbMultiCurrency.isChecked()) - { - pstmt.setInt(6, m_currencyId); - } - - return pstmt; - } - - /** - * Get all of the columnn names for the invoice table. - * - * @return vector containing all of the column names - */ - private Vector getInvoiceColumnNames() - { - Vector columnNames = new Vector(); - - columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); - columnNames.add(Msg.translate(Env.getCtx(), "Date")); - columnNames.add(Util - .cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); - if (m_chbMultiCurrency.isChecked()) - { - columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); - columnNames.add(Msg.translate(Env.getCtx(), "Amount")); - } - columnNames.add(Msg.getMsg(Env.getCtx(), "ConvertedAmount")); - columnNames.add(Msg.getMsg(Env.getCtx(), "OpenAmt")); - columnNames.add(Msg.getMsg(Env.getCtx(), "Discount")); - columnNames.add(Msg.getMsg(Env.getCtx(), "WriteOff")); - columnNames.add(Msg.getMsg(Env.getCtx(), "AppliedAmt")); - - return columnNames; - } - - /** - * Set the classes and read-only property for all invoice table columns. - */ - private void setInvoiceColumnClasses() - { - int columnIndex = 0; - m_lsbInvoices.setColumnClass(columnIndex++, Boolean.class, false); // 0-Selection - m_lsbInvoices.setColumnClass(columnIndex++, Timestamp.class, true); // 1-TrxDate - m_lsbInvoices.setColumnClass(columnIndex++, String.class, true); // 2-Value - if (m_chbMultiCurrency.isChecked()) - { - m_lsbInvoices.setColumnClass(columnIndex++, String.class, true); // 3-Currency - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, true); // 4-Amt - } - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, true); // 5-ConvAmt - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, true); // 6-ConvAmt - // Open - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, false); // 7-Conv - // Discount - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, false); // 8-Conv - // WriteOff - m_lsbInvoices.setColumnClass(columnIndex++, BigDecimal.class, false); // 9-Conv - // Applied - } - - /** - * Create the SQL statement for obtaining unallocated invoices. - * - * @return the SQL statement for obtaining unallocated invoices - */ - private String getInvoiceSql() - { - StringBuffer sql = new StringBuffer( - "SELECT i.DateInvoiced, " - + "i.DocumentNo, " - + "i.C_Invoice_ID," // 1..3 - + "c.ISO_Code, " - + "i.GrandTotal * i.MultiplierAP, " // 4..5 - // Orig - // Currency - + "currencyConvert(i.GrandTotal * i.MultiplierAP, " - + "i.C_Currency_ID, " - + "?, " - + "i.DateInvoiced, " - + "i.C_ConversionType_ID, " - + "i.AD_Client_ID, " - + "i.AD_Org_ID), " // 6 #1 Converted - + "currencyConvert(invoiceOpen(C_Invoice_ID, C_InvoicePaySchedule_ID), " - + "i.C_Currency_ID, " - + "?, " - + "i.DateInvoiced, " - + "i.C_ConversionType_ID, " - + "i.AD_Client_ID, " - + "i.AD_Org_ID) * i.MultiplierAP, " // 7 #2 Converted - // Open - + "currencyConvert(invoiceDiscount(i.C_Invoice_ID, " - + "?, " - + "C_InvoicePaySchedule_ID), " // 8 AllowedDiscount - + "i.C_Currency_ID, " + "?, " + "i.DateInvoiced, " - + "i.C_ConversionType_ID, " + "i.AD_Client_ID, " - + "i.AD_Org_ID) * i.Multiplier * i.MultiplierAP, " // #3, - // #4 - + "i.MultiplierAP"); - - // FROM - sql - .append(" FROM C_Invoice_v i" // corrected for CM/Split - + " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) "); - - // WHERE - sql.append(" WHERE i.IsPaid='N' AND i.Processed='Y'" - + " AND i.C_BPartner_ID=?"); // #5 - - // additional WHERE - if (!m_chbMultiCurrency.isChecked()) - { - sql.append(" AND i.C_Currency_ID=?"); // #6 - } - - // ORDER BY - sql.append(" ORDER BY i.DateInvoiced, i.DocumentNo"); - - logger.fine("InvSQL=" + sql.toString()); - - return sql.toString(); - } - - /** - * Load Business Partner Info - Payments - Invoices. - */ - private void loadBPartner() - { - Integer key = null; - Thread thread; - - logger.config("BPartner=" + m_businessPartnerId + ", Cur=" - + m_currencyId); - - // Need to have both values - if ((m_businessPartnerId == 0) || (m_currencyId == 0)) - { - return; - } - - // Async BPartner Test - key = new Integer(m_businessPartnerId); - if (!m_bPartnerCheck.contains(key)) - { - thread = new Thread() - { - public void run() - { - MPayment.setIsAllocated(Env.getCtx(), m_businessPartnerId, - null); - MInvoice.setIsPaid(Env.getCtx(), m_businessPartnerId, null); - } - }; - thread.start(); - m_bPartnerCheck.add(key); - } - - loadUnallocatedPayments(); - - loadUnpaidInvoices(); - - setColumnIndices(); - - // Calculate Totals - calculate(); - - return; - } // loadBPartner - - /** - * Set the column indices, depending on whether multi-currency is checked. - */ - private void setColumnIndices() - { - final int defaultOpenColIndex = 4; - final int defaultDiscountColIndex = 5; - final int defaultWriteOffColIndex = 6; - final int defaultAppliedColIndex = 7; - int colOffset = 0; - - // removed use of tertiary operator to aid readability - if (m_chbMultiCurrency.isChecked()) - { - colOffset = 2; - } - // set column indices - m_openColIndex = defaultOpenColIndex + colOffset; // 4 or 6 - m_discountColIndex = defaultDiscountColIndex + colOffset; // 5 or 7 - m_writeOffColIndex = defaultWriteOffColIndex + colOffset; // 6 or 8 - m_appliedColIndex = defaultAppliedColIndex + colOffset; // 7 or 9 - - return; - } - - /* - * (non-Javadoc) - * - * @see org.adempiere.webui.panel.ADForm#onEvent(org.zkoss.zk.ui.event.Event) - */ - public void onEvent(Event event) throws Exception - { - if (event == null) - { - return; - } - - logger.config(""); - - if (event.getTarget().equals(m_chbMultiCurrency)) - { - loadBPartner(); - } - else if (event.getTarget().equals(m_btnAllocate)) - { - m_btnAllocate.setEnabled(false); - saveData(); - loadBPartner(); - m_btnAllocate.setEnabled(true); - } - - return; - } - - /** - * Calculate Allocation info. - */ - private void calculate() - { - // TODO refactor this. Function is too long to maintain easily - DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount); - Timestamp allocDate = null; - boolean isPaymentSelected = false; - boolean isInvoiceSelected = false; - - logger.config(""); - - // Payment - BigDecimal totalPayment = new BigDecimal(0.0); - int rows = m_lsbPayments.getRowCount(); - m_noSelectedPayments = 0; - - for (int rowIndex = 0; rowIndex < rows; rowIndex++) - { - isPaymentSelected = isRowSelected(m_lsbPayments, rowIndex); - if (isPaymentSelected) - { - // TODO remove magic number - Timestamp ts = (Timestamp) m_lsbPayments.getValueAt(rowIndex, - ms_dateColIndex); - allocDate = TimeUtil.max(allocDate, ts); - BigDecimal bd = (BigDecimal) m_lsbPayments.getValueAt(rowIndex, - m_paymentColIndex); - totalPayment = totalPayment.add(bd); // Applied Pay - m_noSelectedPayments++; - - logger.fine("Payment_" + rowIndex + " = " + bd - + " - Total=" + totalPayment); - } - } - - m_lblPaymentInfo.setValue(String.valueOf(m_noSelectedPayments) + " - " - + Msg.getMsg(Env.getCtx(), "Sum") + " " - + format.format(totalPayment) + " "); - - // Invoices - BigDecimal totalInvoice = new BigDecimal(0.0); - rows = m_lsbInvoices.getRowCount(); - m_noSelectedInvoices = 0; - - for (int rowIndex = 0; rowIndex < rows; rowIndex++) - { - isInvoiceSelected = isRowSelected(m_lsbInvoices, rowIndex); - if (isInvoiceSelected) - { - Timestamp ts = (Timestamp) m_lsbInvoices.getValueAt(rowIndex, - ms_dateColIndex); - allocDate = TimeUtil.max(allocDate, ts); - BigDecimal bd = (BigDecimal) m_lsbInvoices.getValueAt(rowIndex, - m_appliedColIndex); - totalInvoice = totalInvoice.add(bd); // Applied Inv - m_noSelectedInvoices++; - - logger.fine("Invoice_" + rowIndex + " = " + bd + " - Total=" - + totalPayment); - } - } - m_lblInvoiceInfo.setValue(String.valueOf(m_noSelectedInvoices) + " - " - + Msg.getMsg(Env.getCtx(), "Sum") + " " - + format.format(totalInvoice) + " "); - - // Set AllocationDate - if (allocDate != null) - { - m_wdeDateField.setValue(allocDate); - } - // Set Allocation Currency - m_lblAllocCurrency.setValue(m_wedCurrencyPick.getDisplay()); - - // TODO extract method - - // modification fabian-subpayments 040506 - int noInvoices = m_noSelectedInvoices; - int noPayments = m_noSelectedPayments; - logger.config("Npayments:" + noPayments + " Ninvoice:" + noInvoices); - m_totalPayment = totalPayment; - m_totalInvoiced = totalInvoice; - - // Difference - BigDecimal difference = m_totalPayment.subtract(m_totalInvoiced); - m_txbDifferenceField.setText(format.format(difference)); - - logger.info("Total-Pay:" + m_totalPayment + " TotalInv: " - + m_totalInvoiced + " Diference: " + difference + " npayments=" - + noPayments + " ninvoices=" + noInvoices); - - m_totalCredit = new BigDecimal("0"); - - boolean enableAllocButton = false; - m_eIndicator = EIndicator.NONE; - - // isTotalPay - if (difference.compareTo(new BigDecimal(0.0)) == 0 && noPayments == 1) - {// ---------------------------------- - m_eIndicator = EIndicator.TOTAL_PAY; // totalpay=totalinvoiced - enableAllocButton = true; - } - // isSubPayment - else if (difference.compareTo(new BigDecimal(0.0)) < 0 - && noPayments == 1 && noInvoices == 1 - && m_totalPayment.compareTo(new BigDecimal(0.0)) > 0 - && m_totalInvoiced.compareTo(new BigDecimal(0.0)) > 0) - { - m_eIndicator = EIndicator.SUBPAYMENT_SO; // subpayment issotrx=y - enableAllocButton = true; - } - // isGreaterPaymentSO - else if (difference.compareTo(new BigDecimal(0.0)) > 0 - && noPayments == 1 && noInvoices == 1 - && m_totalPayment.compareTo(new BigDecimal(0.0)) > 0 - && m_totalInvoiced.compareTo(new BigDecimal(0.0)) > 0) - { - m_eIndicator = EIndicator.GREATER_PAYMENT_SO; // totalpay>totalinvoiced - // issotrx=y - enableAllocButton = true; - } - // isCreditMemo - else if (difference.compareTo(new BigDecimal(0.0)) <= 0 - && noPayments == 0 && noInvoices > 0) - { - m_eIndicator = EIndicator.CREDIT_MEMO; // Credit Memo - if (revisionSubcredit()) - { - enableAllocButton = true; - } - } - // isGreaterPaymentPO - else if (difference.compareTo(new BigDecimal(0.0)) < 0 - && noPayments == 1 && noInvoices == 1 - && m_totalPayment.compareTo(new BigDecimal(0.0)) < 0 - && m_totalInvoiced.compareTo(new BigDecimal(0.0)) < 0) - { - m_eIndicator = EIndicator.GREATER_PAYMENT_PO; // totalpay>totalinvoiced - // issotrx=n - enableAllocButton = true; - } - // special case vendor subpayments - else if (difference.compareTo(new BigDecimal(0.0)) > 0 - && noPayments == 1 && noInvoices == 1 - && m_totalPayment.compareTo(new BigDecimal(0.0)) < 0 - && m_totalInvoiced.compareTo(new BigDecimal(0.0)) < 0) - { - m_eIndicator = EIndicator.GREATER_INVOICED_PO; // totalpay 0 - && noPayments == 0 && noInvoices > 0) - { - m_eIndicator = EIndicator.GREATER_CREDIT; - if (revisionSubcredit()) // creditmemo > invoiced - { - enableAllocButton = true; - } - } - - logger.info("Enable Allocate Button=" + enableAllocButton - + " Indicator=" + m_eIndicator); - - m_btnAllocate.setEnabled(enableAllocButton); - - return; - } // calculate - - /** - * Query whether the specified row of the specified - * table is selected. - * - * @param table The table to query - * @param row The row to query - * @return true if the row is selected, false otherwise - */ - private boolean isRowSelected(WListbox table, int row) - { - return ((Boolean) table.getValueAt(row, ms_selectedColIndex)) - .booleanValue(); - } - - /** - * Queries whether the alocation is a subcredit. - * - * @return true if the selected allocation represent a subcredit. False otherwise. - */ - private boolean revisionSubcredit() - { - int noCredits = 0; - - logger.fine("Recalculating grid"); - - // TODO factor out - calculatePayments(); - - // TODO factor out - // Invoices - noCredits = calculateInvoices(); - - if (m_noSelectedInvoices == 1 - && m_noSelectedPayments == 0 - && noCredits == 1 - && m_totalInvoiced.subtract(m_totalCredit).compareTo(Env.ZERO) >= 0) - { - logger.info("return true"); - return true; - } - return false; - } - - /** - * Calculate the number of selected payments and the total payment amount. - * - * @return the number of credits - */ - private int calculateInvoices() - { - BigDecimal totalInvoice = Env.ZERO; - BigDecimal totalCredit = Env.ZERO; - int noInvoices = m_lsbInvoices.getRowCount(); - int noCredits = 0; - BigDecimal openAmount = null; - - m_noSelectedInvoices = 0; - m_totalCredit = Env.ZERO; - - for (int rowIndex = 0; rowIndex < noInvoices; rowIndex++) - { - if (isRowSelected(m_lsbInvoices, rowIndex)) - { - openAmount = (BigDecimal) m_lsbInvoices.getValueAt(rowIndex, - m_openColIndex); - - logger.info("*Value:" + openAmount); - - if (isNegative(openAmount)) - { - noCredits++; - totalCredit = totalCredit.add(openAmount); - m_creditIndex = rowIndex; - } - else - { - m_noSelectedInvoices++; - totalInvoice = totalInvoice.add(openAmount); // Applied - // Inv - m_invoiceIndex = rowIndex; - } - - logger.info("Invoice_" + rowIndex + " = " + openAmount - + " - Total=" + totalInvoice); - } - } - m_totalInvoiced = totalInvoice; - m_totalCredit = totalCredit; - - logger.info("totalInvoiced= " + m_totalInvoiced - + "--totalcredit= " + m_totalCredit); - - logger.info("inv-cr: " + m_totalInvoiced.subtract(m_totalCredit)); - - return noCredits; - } - - /** - * Calculate the number of selected payments and the total payment amount. - */ - private void calculatePayments() - { - BigDecimal totalPayment = Env.ZERO; - int noPayments = m_lsbPayments.getRowCount(); - - m_noSelectedPayments = 0; - for (int paymentIndex = 0; paymentIndex < noPayments; paymentIndex++) - { - if (isRowSelected(m_lsbPayments, paymentIndex)) - { - BigDecimal bd = (BigDecimal) m_lsbPayments.getValueAt( - paymentIndex, m_paymentColIndex); - totalPayment = totalPayment.add(bd); // Applied Pay - m_noSelectedPayments++; - - logger.info("Payment_" + paymentIndex + " = " + bd - + " - Total=" + totalPayment); - } - } - m_totalPayment = totalPayment; - - return; - } - - /* - * (non-Javadoc) - * - * @see org.adempiere.webui.event.ValueChangeListener#valueChange(org.adempiere.webui.event.ValueChangeEvent) - */ - public void valueChange(ValueChangeEvent event) - { - String name = event.getPropertyName(); - Object value = event.getNewValue(); - - logger.config(name + "=" + value); - - if (value == null) - { - return; - } - - // BPartner - if (name.equals("C_BPartner_ID")) - { - m_wedBusinessPartnerSearch.setValue(value); - m_businessPartnerId = ((Integer) value).intValue(); - loadBPartner(); - } - // Currency - else if (name.equals("C_Currency_ID")) - { - m_currencyId = ((Integer) value).intValue(); - loadBPartner(); - } - // Date for Multi-Currency - else if (name.equals("Date") && m_chbMultiCurrency.isChecked()) - { - loadBPartner(); - } - - return; - } - - /* - * (non-Javadoc) - * - * @see org.adempiere.webui.event.WTableModelListener#tableChanged(org.adempiere.webui.event.WTableModelEvent) - */ - public void tableChanged(WTableModelEvent event) - { - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - boolean isUpdate = (event.getType() == ListDataEvent.CONTENTS_CHANGED); - boolean isPayment = false; - - // Not a table update - if (!isUpdate) - { - calculate(); - return; - } - - if (m_isCalculating) // Avoid recursive calls - { - return; - } - m_isCalculating = true; - - isPayment = (event.getModel().equals(m_lsbPayments.getModel())); - - logger.config("Row=" + event.getFirstRow() + ", Col=" - + event.getColumn() + ", InvoiceTable=" + isPayment); - - // Payments - if (isPayment) - { - paymentTableChanged(event); - } - else - { - invoiceTableChanged(event); - } - - m_isCalculating = false; - calculate(); - - return; - } - - /** - * Respond to an event on the invoice table. - * - * @param event The event to consider - */ - private void invoiceTableChanged(WTableModelEvent event) - { - boolean isSubPayment = false; - int row = event.getFirstRow(); - int col = event.getColumn(); - final double thirtyPercent = 0.30; - - // Invoice Selection - if (col == ms_selectedColIndex) - { - // TableModel invoice = invoiceTable.getModel(); - // selected - set applied amount - if (isRowSelected(m_lsbInvoices, row)) - { - BigDecimal amount = (BigDecimal) m_lsbInvoices.getValueAt(row, - m_openColIndex); // Open Amount - amount = amount.subtract((BigDecimal) m_lsbInvoices.getValueAt( - row, m_discountColIndex)); - m_lsbInvoices.setValueAt(Env.ZERO, row, m_writeOffColIndex); // to - // be - // sure - m_lsbInvoices.setValueAt(amount, row, m_appliedColIndex); - - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - isSubPayment = revisionSubpayment(); - - logger.fine("Invoice-issubpayment: " + isSubPayment); - - m_rowLastInvoice = row; - if (isSubPayment) - { - logger.fine("End Process SubPayment"); - // TODO factor out to isNegative - if (isNegative(amount.subtract(m_totalPayment))) - { - m_lsbInvoices.setValueAt(amount, row, m_appliedColIndex); - } - else - { - m_lsbInvoices.setValueAt(m_totalPayment, row, - m_appliedColIndex); - } - } - // ---END---------- - } - else - // de-selected - { - m_lsbInvoices.setValueAt(Env.ZERO, row, m_writeOffColIndex); - m_lsbInvoices.setValueAt(Env.ZERO, row, m_appliedColIndex); - } - m_lsbInvoices.repaint(); // update r/o - } - - // Invoice - Try to balance entry - else if (m_chbAutoWriteOff.isChecked()) - { - // TableModel invoice = invoiceTable.getModel(); - // if applied entered, adjust writeOff - if (col == m_appliedColIndex) - { - BigDecimal openAmount = (BigDecimal) m_lsbInvoices.getValueAt( - row, m_openColIndex); // Open Amount - BigDecimal amount = openAmount - .subtract((BigDecimal) m_lsbInvoices.getValueAt(row, - m_discountColIndex)); - amount = amount.subtract((BigDecimal) m_lsbInvoices.getValueAt( - row, m_appliedColIndex)); - m_lsbInvoices.setValueAt(amount, row, m_writeOffColIndex); - - // Warning if > 30% - if (amount.doubleValue() / openAmount.doubleValue() > thirtyPercent) - { - FDialog.warn(m_windowNo, "AllocationWriteOffWarn"); - } - } - else - // adjust applied - { - BigDecimal amount = (BigDecimal) m_lsbInvoices.getValueAt(row, - m_openColIndex); // Open Amount - amount = amount.subtract((BigDecimal) m_lsbInvoices.getValueAt( - row, m_discountColIndex)); - amount = amount.subtract((BigDecimal) m_lsbInvoices.getValueAt( - row, m_writeOffColIndex)); - m_lsbInvoices.setValueAt(amount, row, m_appliedColIndex); - } - } - - return; - } - - /** - * Respond to an event on the payment table. - * - * @param event the event to respond to - */ - private void paymentTableChanged(WTableModelEvent event) - { - boolean isSubPayment; - int row = event.getFirstRow(); - int col = event.getColumn(); - - if (col == ms_selectedColIndex) - { - // selected - set payment amount - if (isRowSelected(m_lsbPayments, row)) - { - BigDecimal amount = (BigDecimal) m_lsbPayments.getValueAt(row, - m_openColIndex); // Open Amount - m_lsbPayments.setValueAt(amount, row, m_paymentColIndex); - - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - isSubPayment = revisionSubpayment(); - - logger.fine("Payment-issubpayment: " + isSubPayment); - - if (isSubPayment) - { - m_rowLastInvoice = getRowInvoice(); - - if (m_rowLastInvoice > -1) - { - if (isNegative(m_totalInvoiced.subtract(m_totalPayment))) - { - m_lsbInvoices.setValueAt(m_totalInvoiced, - m_rowLastInvoice, m_appliedColIndex); - } - else - { - m_lsbInvoices.setValueAt(m_totalPayment, - m_rowLastInvoice, m_appliedColIndex); - } - } - } - else if (m_totalPayment == m_totalInvoiced) - { - m_lsbInvoices.setValueAt((BigDecimal) m_lsbInvoices.getValueAt(m_rowLastInvoice, - m_openColIndex), m_rowLastInvoice, m_appliedColIndex); - } - // -End------------- - } - else - // de-selected - { - m_lsbPayments.setValueAt(Env.ZERO, row, m_paymentColIndex); - } - m_lsbPayments.repaint(); // update r/o - } - } - - /** - * Find the index of the row containing the last invoice. - * - * @return index of the row containing the last invoice. - */ - private int getRowInvoice() - { - // Invoices - // TableModel invoice = invoiceTable.getModel(); - BigDecimal totalInvoice = Env.ZERO; - BigDecimal totalCredit = Env.ZERO; - int noInvoices = m_lsbInvoices.getRowCount(); - int noCredits = 0; - int rowInvoice = -1; - BigDecimal openAmount = null; - - logger.fine("Finding row"); - - m_noSelectedInvoices = 0; - m_totalCredit = Env.ZERO; - - for (int invoiceIndex = 0; invoiceIndex < noInvoices; invoiceIndex++) - { - if (isRowSelected(m_lsbInvoices, invoiceIndex)) - { - openAmount = (BigDecimal) m_lsbInvoices.getValueAt(invoiceIndex, - m_openColIndex); - - if (isNegative(openAmount)) - { - noCredits++; - totalCredit = totalCredit.add(openAmount); - } - else - { - m_noSelectedInvoices++; - totalInvoice = totalInvoice.add(openAmount); // Applied - // Inv - rowInvoice = invoiceIndex; - } - } - } - - logger.fine("totalInvoiced= " + totalInvoice + "--totalcredit= " - + totalCredit); - - return rowInvoice; - } - - /** - * Performs subpayment revision. - */ - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - private boolean revisionSubpayment() - { - logger.fine("Recalculating grid"); - - // Payment - // TableModel payment = paymentTable.getModel(); - BigDecimal totalPayment = Env.ZERO; - int rows = m_lsbPayments.getRowCount(); - - m_noSelectedPayments = 0; - for (int rowIndex = 0; rowIndex < rows; rowIndex++) - { - if (isRowSelected(m_lsbPayments, rowIndex)) - { - BigDecimal bd = (BigDecimal) m_lsbPayments.getValueAt(rowIndex, - m_paymentColIndex); - totalPayment = totalPayment.add(bd); // Applied Pay - m_noSelectedPayments++; - - logger.fine("Payment_" + rowIndex + " = " + bd + " - Total=" - + totalPayment); - } - } - - // Invoices - // TableModel invoice = invoiceTable.getModel(); - BigDecimal totalInvoice = Env.ZERO; - rows = m_lsbInvoices.getRowCount(); - m_noSelectedInvoices = 0; - - for (int rowIndex = 0; rowIndex < rows; rowIndex++) - { - if (isRowSelected(m_lsbInvoices, rowIndex)) - { - BigDecimal bd = (BigDecimal) m_lsbInvoices.getValueAt(rowIndex, - m_openColIndex); - totalInvoice = totalInvoice.add(bd); // Applied Inv - m_noSelectedInvoices++; - - logger.fine("Invoice_" + rowIndex + " = " + bd + " - Total=" - + totalPayment); - } - } - m_totalPayment = totalPayment; - m_totalInvoiced = totalInvoice; - - logger.fine("**totalPayment: " + m_totalPayment + " totalInvoiced: " - + m_totalInvoiced); - - if ((m_noSelectedInvoices == 1) && (m_noSelectedPayments == 1)) - { - BigDecimal difference = totalPayment.subtract(totalInvoice); - if (isNegative(difference)) - { - return true; - } - } - return false; - } - - /** - * Query whether the specified value is negative. - * - * @param value - * the value to test for sign - * @return true if the value is negative, false otherwise - */ - public static boolean isNegative(BigDecimal value) - { - return (value.signum() == -1); - } - - /** - * Query whether the specified value is positive. - * - * @param value - * the value to test for sign - * @return true if the value is positive, false otherwise - */ - public static boolean isPositive(BigDecimal value) - { - return (value.signum() == 1); - } - - /** - * Query whether the specified value is non-zero. - * - * @param value - * the value to test for sign - * @return true if the value is non-zero, false otherwise - */ - public static boolean isNonZero(BigDecimal value) - { - return (value.signum() != 0); - } - - /** - * Query whether the specified value is zero. - * - * @param value - * the value to test for sign - * @return true if the value is zero, false otherwise - */ - public static boolean isZero(BigDecimal value) - { - return (value.signum() == 0); - } - - /** - * Save Data. - */ - private void saveData() - { - // TODO refactor this - // fixed fields - final int AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_windowNo, - "AD_Client_ID"); - final int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), m_windowNo, - "AD_Org_ID"); - final int C_BPartner_ID = m_businessPartnerId; - final int C_Currency_ID = m_currencyId; // the allocation currency - final int C_Order_ID = 0; - final int C_CashLine_ID = 0; - final Timestamp DateTrx = (Timestamp) m_wdeDateField.getValue(); - - if (m_noSelectedInvoices + m_noSelectedPayments == 0) - { - return; - } - // - if (AD_Org_ID == 0) - { - FDialog.error(m_windowNo, "Org0NotAllowed"); - return; - } - // - logger.config("Client=" + AD_Client_ID + ", Org=" + AD_Org_ID - + ", BPartner=" + C_BPartner_ID + ", Date=" + DateTrx); - - Trx trx = Trx.get(Trx.createTrxName("AL"), true); - - /** - * Generation of allocations: amount/discount/writeOff - if there is one - * payment -- one line per invoice is generated with both the Invoice - * and Payment reference Pay=80 Inv=100 Disc=10 WOff=10 => 80/10/10 - * Pay#1 Inv#1 or Pay=160 Inv=100 Disc=10 WOff=10 => 80/10/10 Pay#1 - * Inv#1 Pay=160 Inv=100 Disc=10 WOff=10 => 80/10/10 Pay#1 Inv#2 - if - * there are multiple payment lines -- the amounts are allocated - * starting with the first payment and payment Pay=60 Inv=100 Disc=10 - * WOff=10 => 60/10/10 Pay#1 Inv#1 Pay=100 Inv=100 Disc=10 WOff=10 => - * 20/0/0 Pay#2 Inv#1 Pay=100 Inv=100 Disc=10 WOff=10 => 80/10/10 Pay#2 - * Inv#2 - if you apply a credit memo to an invoice Inv=10 Disc=0 WOff=0 => - * 10/0/0 Inv#1 Inv=-10 Disc=0 WOff=0 => -10/0/0 Inv#2 - if you want to - * write off a (partial) invoice without applying, enter zero in applied - * Inv=10 Disc=1 WOff=9 => 0/1/9 Inv#1 Issues - you cannot write-off a - * payment - */ - - // Payment - Loop and add them to paymentList/amountList - int paymentRows = m_lsbPayments.getRowCount(); - ArrayList paymentList = new ArrayList(paymentRows); - ArrayList amountList = new ArrayList( - paymentRows); - - BigDecimal paymentAppliedAmt = Env.ZERO; - - for (int rowIndex = 0; rowIndex < paymentRows; rowIndex++) - { - // Payment line is selected - if (isRowSelected(m_lsbPayments, rowIndex)) - { - KeyNamePair pp = (KeyNamePair) m_lsbPayments.getValueAt( - rowIndex, ms_valueColIndex); // Value - // Payment variables - int C_Payment_ID = pp.getKey(); - paymentList.add(new Integer(C_Payment_ID)); - // - BigDecimal PaymentAmt = (BigDecimal) m_lsbPayments.getValueAt( - rowIndex, m_paymentColIndex); // Applied Payment - amountList.add(PaymentAmt); - // - paymentAppliedAmt = paymentAppliedAmt.add(PaymentAmt); - // - logger.fine("C_Payment_ID=" + C_Payment_ID + " - PaymentAmt=" - + PaymentAmt); // + " * " + Multiplier + " = " + - // PaymentAmtAbs); - } - } - - logger.config("Number of Payments=" + paymentList.size() + " - Total=" - + paymentAppliedAmt); - - // Invoices - Loop and generate alloctions - int invoiceRows = m_lsbInvoices.getRowCount(); - BigDecimal totalAppliedAmt = Env.ZERO; - - // Create Allocation - but don't save yet - MAllocationHdr alloc = new MAllocationHdr(Env.getCtx(), true, DateTrx, - C_Currency_ID, Env.getContext(Env.getCtx(), "#AD_User_Name"), - trx.getTrxName()); // manual - alloc.setAD_Org_ID(AD_Org_ID); - - // For all invoices - int invoiceLines = 0; - for (int rowIndex = 0; rowIndex < invoiceRows; rowIndex++) - { - // Invoice line is selected - if (isRowSelected(m_lsbInvoices, rowIndex)) - { - invoiceLines++; - KeyNamePair pp = (KeyNamePair) m_lsbInvoices.getValueAt( - rowIndex, ms_valueColIndex); // Value - // Invoice variables - int C_Invoice_ID = pp.getKey(); - BigDecimal AppliedAmt = (BigDecimal) m_lsbInvoices.getValueAt( - rowIndex, m_appliedColIndex); - // semi-fixed fields (reset after first invoice) - BigDecimal DiscountAmt = (BigDecimal) m_lsbInvoices.getValueAt( - rowIndex, m_discountColIndex); - BigDecimal WriteOffAmt = (BigDecimal) m_lsbInvoices.getValueAt( - rowIndex, m_writeOffColIndex); - // OverUnderAmt needs to be in Allocation Currency - BigDecimal OverUnderAmt = ((BigDecimal) m_lsbInvoices - .getValueAt(rowIndex, m_openColIndex)).subtract( - AppliedAmt).subtract(DiscountAmt).subtract(WriteOffAmt); - - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - if (m_eIndicator == EIndicator.SUBPAYMENT_SO) - { - OverUnderAmt = ((BigDecimal) m_lsbInvoices.getValueAt( - rowIndex, m_openColIndex)).subtract(m_totalPayment); - AppliedAmt = m_totalPayment; - } - else if (m_eIndicator == EIndicator.GREATER_INVOICED_PO) - { - OverUnderAmt = m_totalInvoiced.subtract(m_totalPayment); - AppliedAmt = m_totalPayment; - } - else if (m_eIndicator == EIndicator.GREATER_PAYMENT_PO) - { - OverUnderAmt = new BigDecimal("0"); - AppliedAmt = m_totalInvoiced; - } - else if (m_eIndicator == EIndicator.GREATER_CREDIT) - { - OverUnderAmt = new BigDecimal("0"); - AppliedAmt = m_totalInvoiced; - } - else if (m_eIndicator == EIndicator.CREDIT_MEMO) // subpayment - // with - // credit - // note - { - logger.fine("**AppliedAmt: " + AppliedAmt); - if (isPositive(AppliedAmt)) - { - OverUnderAmt = AppliedAmt.add(m_totalCredit); - AppliedAmt = m_totalCredit.abs(); - } - } - // ------END--------------------------- - - logger.config("Invoice #" + rowIndex + " - AppliedAmt=" - + AppliedAmt);// + " -> " + AppliedAbs); - - // loop through all payments until invoice applied - int noPayments = 0; - for (int paymentIndex = 0; (paymentIndex < paymentList.size()) - && (isNonZero(AppliedAmt)); paymentIndex++) - { - int C_Payment_ID = ((Integer) paymentList.get(paymentIndex)) - .intValue(); - BigDecimal PaymentAmt = (BigDecimal) amountList - .get(paymentIndex); - if (isNonZero(PaymentAmt)) - { - logger.config(".. with payment #" + paymentIndex - + ", Amt=" + PaymentAmt); - - noPayments++; - // use Invoice Applied Amt - BigDecimal amount = AppliedAmt; - logger.fine("C_Payment_ID=" + C_Payment_ID - + ", C_Invoice_ID=" + C_Invoice_ID - + ", Amount=" + amount + ", Discount=" - + DiscountAmt + ", WriteOff=" + WriteOffAmt); - - // Allocation Header - if ((alloc.get_ID() == 0) && !alloc.save()) - { - logger.log(Level.SEVERE, "Allocation not created"); - return; - } - // Allocation Line - MAllocationLine aLine = new MAllocationLine(alloc, - amount, DiscountAmt, WriteOffAmt, OverUnderAmt); - aLine.setDocInfo(C_BPartner_ID, C_Order_ID, - C_Invoice_ID); - aLine.setPaymentInfo(C_Payment_ID, C_CashLine_ID); - - if (!aLine.save()) - { - logger.log(Level.SEVERE, - "Allocation Line not written - Invoice=" - + C_Invoice_ID); - } - - // Apply Discounts and WriteOff only first time - DiscountAmt = Env.ZERO; - WriteOffAmt = Env.ZERO; - // subtract amount from Payment/Invoice - AppliedAmt = AppliedAmt.subtract(amount); - PaymentAmt = PaymentAmt.subtract(amount); - - logger.fine("Allocation Amount=" + amount - + " - Remaining Applied=" + AppliedAmt - + ", Payment=" + PaymentAmt); - - amountList.set(paymentIndex, PaymentAmt); // update - } // for all applied amounts - } // noop through payments for invoice - - // No Payments allocated and none existing (e.g. Inv/CM) - if ((noPayments == 0) && (paymentList.size() == 0)) - { - int C_Payment_ID = 0; - - logger.config(" ... no payment - TotalApplied=" - + totalAppliedAmt); - - // Begin Enable MultiAllocation Fabian Aguilar OFBConsulting - if (m_eIndicator == EIndicator.GREATER_CREDIT) - { - if (rowIndex == m_creditIndex) - { - AppliedAmt = AppliedAmt.negate(); - } - } - // --------END------------------------ - - // Create Allocation - - logger.fine("C_Payment_ID=" + C_Payment_ID - + ", C_Invoice_ID=" + C_Invoice_ID + ", Amount=" - + AppliedAmt + ", Discount=" + DiscountAmt - + ", WriteOff=" + WriteOffAmt); - - // Allocation Header - if ((alloc.get_ID() == 0) && !alloc.save()) - { - logger.log(Level.SEVERE, "Allocation not created"); - return; - } - // Allocation Line - MAllocationLine aLine = new MAllocationLine(alloc, - AppliedAmt, DiscountAmt, WriteOffAmt, OverUnderAmt); - aLine.setDocInfo(C_BPartner_ID, C_Order_ID, C_Invoice_ID); - aLine.setPaymentInfo(C_Payment_ID, C_CashLine_ID); - if (!aLine.save(trx.getTrxName())) - { - logger.log(Level.SEVERE, - "Allocation Line not written - Invoice=" - + C_Invoice_ID); - } - - logger.fine("Allocation Amount=" + AppliedAmt); - } - totalAppliedAmt = totalAppliedAmt.add(AppliedAmt); - logger.config("TotalRemaining=" + totalAppliedAmt); - } // invoice selected - } // invoice loop - - // Only Payments and total of 0 (e.g. Payment/Reversal) - if ((invoiceLines == 0) && (paymentList.size() > 0) - && (isZero(paymentAppliedAmt))) - { - for (int paymentIndex = 0; paymentIndex < paymentList.size(); paymentIndex++) - { - int C_Payment_ID = ((Integer) paymentList.get(paymentIndex)) - .intValue(); - BigDecimal paymentAmt = (BigDecimal) amountList.get(paymentIndex); - - logger.fine("Payment=" + C_Payment_ID + ", Amount=" - + paymentAmt); // + ", Abs=" + PaymentAbs); - - // Allocation Header - if ((alloc.get_ID() == 0) && !alloc.save()) - { - logger.log(Level.SEVERE, "Allocation not created"); - return; - } - - // Allocation Line - MAllocationLine aLine = new MAllocationLine(alloc, paymentAmt, - Env.ZERO, Env.ZERO, Env.ZERO); - aLine.setDocInfo(C_BPartner_ID, 0, 0); - aLine.setPaymentInfo(C_Payment_ID, 0); - - if (!aLine.save(trx.getTrxName())) - { - logger.log(Level.SEVERE, - "Allocation Line not saved - Payment=" - + C_Payment_ID); - } - } - } // onlyPayments - - if (isNonZero(totalAppliedAmt)) - { - logger.log(Level.SEVERE, "Remaining TotalAppliedAmt=" - + totalAppliedAmt); - } - - // Should start WF - if (alloc.get_ID() != 0) - { - alloc.processIt(DocAction.ACTION_Complete); - alloc.save(); - } - - // Test/Set IsPaid for Invoice - requires that allocation is posted - for (int rowIndex = 0; rowIndex < invoiceRows; rowIndex++) - { - // Invoice line is selected - if (isRowSelected(m_lsbInvoices, rowIndex)) - { - KeyNamePair pp = (KeyNamePair) m_lsbInvoices.getValueAt( - rowIndex, 2); // Value - // Invoice variables - int C_Invoice_ID = pp.getKey(); - String sql = "SELECT invoiceOpen(C_Invoice_ID, 0) " - + "FROM C_Invoice " + "WHERE C_Invoice_ID=?"; - - BigDecimal open = DB.getSQLValueBD(trx.getTrxName(), sql, - C_Invoice_ID); - - // Enable MultiAllocation Fabian Aguilar OFBConsulting - if ((open != null) - && (isZero(open)) - && (m_eIndicator != EIndicator.SUBPAYMENT_SO) - && (m_eIndicator != EIndicator.GREATER_INVOICED_PO) - && ((m_eIndicator != EIndicator.CREDIT_MEMO) - && (getRowInvoice() != rowIndex))) - { - sql = "UPDATE C_Invoice " + "SET IsPaid='Y' " - + "WHERE C_Invoice_ID=" + C_Invoice_ID; - - int noAffectedRows = DB.executeUpdate(sql, trx.getTrxName()); - - logger.config("Invoice #" + rowIndex - + " is paid - updated=" + noAffectedRows); - } - else - { - logger.config("Invoice #" + rowIndex + " is not paid - " - + open); - } - } - } - - // Test/Set Payment is fully allocated - for (int paymentIndex = 0; paymentIndex < paymentList.size(); paymentIndex++) - { - int C_Payment_ID = ((Integer) paymentList.get(paymentIndex)).intValue(); - MPayment pay = new MPayment(Env.getCtx(), C_Payment_ID, trx.getTrxName()); - - // Enable MultiAllocation Fabian Aguilar OFBConsulting - if ((pay.testAllocation() || (m_eIndicator == EIndicator.SUBPAYMENT_SO)) - && (m_eIndicator != EIndicator.GREATER_PAYMENT_SO) - && (m_eIndicator != EIndicator.GREATER_PAYMENT_PO)) - { - pay.save(); - } - - logger - .config("Payment #" + paymentIndex - + (pay.isAllocated() ? " not" : " is") - + " fully allocated"); - } - - paymentList.clear(); - amountList.clear(); - trx.commit(); - trx.close(); - - return; - } // saveData - -} // WAllocation +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + *****************************************************************************/ +package org.adempiere.webui.apps.form; + +import java.math.*; +import java.sql.*; +import java.text.*; +import java.util.*; +import java.util.logging.*; + +import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Checkbox; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.ListModelTable; +import org.adempiere.webui.component.ListboxFactory; +import org.adempiere.webui.component.Panel; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.Textbox; +import org.adempiere.webui.component.WListbox; +import org.adempiere.webui.component.WStatusBar; +import org.adempiere.webui.editor.WDateEditor; +import org.adempiere.webui.editor.WSearchEditor; +import org.adempiere.webui.editor.WTableDirEditor; +import org.adempiere.webui.event.ValueChangeEvent; +import org.adempiere.webui.event.ValueChangeListener; +import org.adempiere.webui.event.WTableModelEvent; +import org.adempiere.webui.event.WTableModelListener; +import org.adempiere.webui.panel.ADForm; +import org.adempiere.webui.window.FDialog; +import org.compiere.model.*; +import org.compiere.process.*; +import org.compiere.util.*; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zkex.zul.Borderlayout; +import org.zkoss.zkex.zul.Center; +import org.zkoss.zkex.zul.North; +import org.zkoss.zkex.zul.South; +import org.zkoss.zul.Separator; +import org.zkoss.zul.Space; + +/** + * Allocation Form + * + * @author Jorg Janke + * @version $Id: VAllocation.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ + * + * Contributor : Fabian Aguilar - OFBConsulting - Multiallocation + */ +public class WAllocation extends ADForm + implements EventListener, WTableModelListener, ValueChangeListener +{ + + /** + * Initialize Panel + * @param WindowNo window + * @param frame frame + */ + protected void initForm() + { + Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", "Y"); // defaults to no + m_C_Currency_ID = Env.getContextAsInt(Env.getCtx(), "$C_Currency_ID"); // default + // + log.info("Currency=" + m_C_Currency_ID); + try + { + dynInit(); + zkInit(); + calculate(); + southPanel.appendChild(new Separator()); + southPanel.appendChild(statusBar); + statusBar.setWidth("100%"); + } + catch(Exception e) + { + log.log(Level.SEVERE, "", e); + } + } // init + + /** Logger */ + private static CLogger log = CLogger.getCLogger(WAllocation.class); + + private boolean m_calculating = false; + private int m_C_Currency_ID = 0; + private int m_C_BPartner_ID = 0; + private int m_noInvoices = 0; + private int m_noPayments = 0; + private BigDecimal totalInv = new BigDecimal(0.0); + private BigDecimal totalPay = new BigDecimal(0.0); + private BigDecimal totalDiff = new BigDecimal(0.0); + + // Index changed if multi-currency + private int i_payment = 7; + // + private int i_open = 6; + private int i_discount = 7; + private int i_writeOff = 8; + private int i_overUnder = 9; + private int i_applied = 10; +// private int i_multiplier = 10; + // + private Borderlayout mainLayout = new Borderlayout(); + private Panel parameterPanel = new Panel(); + private Panel allocationPanel = new Panel(); + private Grid parameterLayout = GridFactory.newGridLayout(); + private Label bpartnerLabel = new Label(); + private WSearchEditor bpartnerSearch = null; + private WListbox invoiceTable = ListboxFactory.newDataTable(); + private WListbox paymentTable = ListboxFactory.newDataTable(); + private Borderlayout infoPanel = new Borderlayout(); + private Panel paymentPanel = new Panel(); + private Panel invoicePanel = new Panel(); + private Label paymentLabel = new Label(); + private Label invoiceLabel = new Label(); + private Borderlayout paymentLayout = new Borderlayout(); + private Borderlayout invoiceLayout = new Borderlayout(); + private Label paymentInfo = new Label(); + private Label invoiceInfo = new Label(); + private Grid allocationLayout = GridFactory.newGridLayout(); + private Label differenceLabel = new Label(); + private Textbox differenceField = new Textbox(); + private Button allocateButton = new Button(); + private Label currencyLabel = new Label(); + private WTableDirEditor currencyPick = null; + private Checkbox multiCurrency = new Checkbox(); + private Label allocCurrencyLabel = new Label(); + private WStatusBar statusBar = new WStatusBar(); + private Label dateLabel = new Label(); + private WDateEditor dateField = new WDateEditor(); + private Checkbox autoWriteOff = new Checkbox(); + + private ArrayList m_bpartnerCheck = new ArrayList(); + + private Panel southPanel = new Panel(); + + /** + * Static Init + * @throws Exception + */ + private void zkInit() throws Exception + { + // + this.appendChild(mainLayout); + mainLayout.setWidth("99%"); + mainLayout.setHeight("100%"); + dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date")); + autoWriteOff.setSelected(false); + autoWriteOff.setText(Msg.getMsg(Env.getCtx(), "AutoWriteOff", true)); + autoWriteOff.setTooltiptext(Msg.getMsg(Env.getCtx(), "AutoWriteOff", false)); + // + parameterPanel.appendChild(parameterLayout); + allocationPanel.appendChild(allocationLayout); + bpartnerLabel.setText(Msg.translate(Env.getCtx(), "C_BPartner_ID")); + paymentLabel.setText(" " + Msg.translate(Env.getCtx(), "C_Payment_ID")); + invoiceLabel.setText(" " + Msg.translate(Env.getCtx(), "C_Invoice_ID")); + paymentPanel.appendChild(paymentLayout); + invoicePanel.appendChild(invoiceLayout); + invoiceInfo.setText("."); + paymentInfo.setText("."); + differenceLabel.setText(Msg.getMsg(Env.getCtx(), "Difference")); + differenceField.setText("0"); + allocateButton.setLabel(Msg.getMsg(Env.getCtx(), "Process")); + allocateButton.addActionListener(this); + currencyLabel.setText(Msg.translate(Env.getCtx(), "C_Currency_ID")); + multiCurrency.setText(Msg.getMsg(Env.getCtx(), "MultiCurrency")); + multiCurrency.addActionListener(this); + allocCurrencyLabel.setText("."); + + North north = new North(); + north.setStyle("border: none"); + mainLayout.appendChild(north); + north.appendChild(parameterPanel); + + Rows rows = null; + Row row = null; + + parameterLayout.setWidth("600px"); + rows = parameterLayout.newRows(); + row = rows.newRow(); + row.appendChild(bpartnerLabel.rightAlign()); + row.appendChild(bpartnerSearch.getComponent()); + row.appendChild(dateLabel.rightAlign()); + row.appendChild(dateField.getComponent()); + + row = rows.newRow(); + row.appendChild(currencyLabel.rightAlign()); + row.appendChild(currencyPick.getComponent()); + row.appendChild(multiCurrency); + row.setSpans("1,1,2"); + + row = rows.newRow(); + row.appendChild(new Space()); + row.appendChild(autoWriteOff); + row.appendChild(new Space()); + row.appendChild(new Space()); + + South south = new South(); + south.setStyle("border: none"); + mainLayout.appendChild(south); + south.appendChild(southPanel); + southPanel.appendChild(allocationPanel); + allocationPanel.appendChild(allocationLayout); + allocationLayout.setWidth("400px"); + rows = allocationLayout.newRows(); + row = rows.newRow(); + row.appendChild(differenceLabel.rightAlign()); + row.appendChild(allocCurrencyLabel.rightAlign()); + row.appendChild(differenceField); + row.appendChild(new Space()); + row.appendChild(allocateButton); + + paymentPanel.appendChild(paymentLayout); + paymentPanel.setWidth("100%"); + paymentPanel.setHeight("100%"); + paymentLayout.setWidth("100%"); + paymentLayout.setHeight("100%"); + paymentLayout.setStyle("border: none"); + + invoicePanel.appendChild(invoiceLayout); + invoicePanel.setWidth("100%"); + invoicePanel.setHeight("100%"); + invoiceLayout.setWidth("100%"); + invoiceLayout.setHeight("100%"); + invoiceLayout.setStyle("border: none"); + + north = new North(); + north.setStyle("border: none"); + paymentLayout.appendChild(north); + north.appendChild(paymentLabel); + south = new South(); + south.setStyle("border: none"); + paymentLayout.appendChild(south); + south.appendChild(paymentInfo.rightAlign()); + Center center = new Center(); + paymentLayout.appendChild(center); + center.appendChild(paymentTable); + paymentTable.setWidth("99%"); + paymentTable.setHeight("99%"); + center.setStyle("border: none"); + + north = new North(); + north.setStyle("border: none"); + invoiceLayout.appendChild(north); + north.appendChild(invoiceLabel); + south = new South(); + south.setStyle("border: none"); + invoiceLayout.appendChild(south); + south.appendChild(invoiceInfo.rightAlign()); + center = new Center(); + invoiceLayout.appendChild(center); + center.appendChild(invoiceTable); + invoiceTable.setWidth("99%"); + invoiceTable.setHeight("99%"); + center.setStyle("border: none"); + // + center = new Center(); + center.setFlex(true); + mainLayout.appendChild(center); + center.appendChild(infoPanel); + + infoPanel.setStyle("border: none"); + infoPanel.setWidth("100%"); + infoPanel.setHeight("100%"); + + north = new North(); + north.setStyle("border: none"); + north.setHeight("49%"); + infoPanel.appendChild(north); + north.appendChild(paymentPanel); + north.setSplittable(true); + center = new Center(); + center.setStyle("border: none"); + center.setFlex(true); + infoPanel.appendChild(center); + center.appendChild(invoicePanel); + } // jbInit + + /** + * Dynamic Init (prepare dynamic fields) + * @throws Exception if Lookups cannot be initialized + */ + private void dynInit() throws Exception + { + // Currency + int AD_Column_ID = 3505; // C_Invoice.C_Currency_ID + MLookup lookupCur = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); + currencyPick = new WTableDirEditor("C_Currency_ID", true, false, true, lookupCur); + currencyPick.setValue(new Integer(m_C_Currency_ID)); + currencyPick.addValueChangeListener(this); + + // BPartner + AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID + MLookup lookupBP = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); + bpartnerSearch = new WSearchEditor("C_BPartner_ID", true, false, true, lookupBP); + bpartnerSearch.addValueChangeListener(this); + + // Translation + statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "AllocateStatus")); + statusBar.setStatusDB(""); + + // Date set to Login Date + dateField.setValue(Env.getContextAsDate(Env.getCtx(), "#Date")); + dateField.addValueChangeListener(this); + } // dynInit + + /** + * Load Business Partner Info + * - Payments + * - Invoices + */ + private void loadBPartner () + { + log.config("BPartner=" + m_C_BPartner_ID + ", Cur=" + m_C_Currency_ID); + // Need to have both values + if (m_C_BPartner_ID == 0 || m_C_Currency_ID == 0) + return; + + // Async BPartner Test + Integer key = new Integer(m_C_BPartner_ID); + if (!m_bpartnerCheck.contains(key)) + { + new Thread() + { + public void run() + { + MPayment.setIsAllocated (Env.getCtx(), m_C_BPartner_ID, null); + MInvoice.setIsPaid (Env.getCtx(), m_C_BPartner_ID, null); + } + }.start(); + m_bpartnerCheck.add(key); + } + + /******************************** + * Load unallocated Payments + * 1-TrxDate, 2-DocumentNo, (3-Currency, 4-PayAmt,) + * 5-ConvAmt, 6-ConvOpen, 7-Allocated + */ + Vector> data = new Vector>(); + StringBuffer sql = new StringBuffer("SELECT p.DateTrx,p.DocumentNo,p.C_Payment_ID," // 1..3 + + "c.ISO_Code,p.PayAmt," // 4..5 + + "currencyConvert(p.PayAmt,p.C_Currency_ID,?,p.DateTrx,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID),"// 6 #1 + + "currencyConvert(paymentAvailable(C_Payment_ID),p.C_Currency_ID,?,p.DateTrx,p.C_ConversionType_ID,p.AD_Client_ID,p.AD_Org_ID)," // 7 #2 + + "p.MultiplierAP " + + "FROM C_Payment_v p" // Corrected for AP/AR + + " INNER JOIN C_Currency c ON (p.C_Currency_ID=c.C_Currency_ID) " + + "WHERE p.IsAllocated='N' AND p.Processed='Y'" + + " AND p.C_Charge_ID IS NULL" // Prepayments OK + + " AND p.C_BPartner_ID=?"); // #3 + if (!multiCurrency.isSelected()) + sql.append(" AND p.C_Currency_ID=?"); // #4 + sql.append(" ORDER BY p.DateTrx,p.DocumentNo"); + log.fine("PaySQL=" + sql.toString()); + try + { + PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); + pstmt.setInt(1, m_C_Currency_ID); + pstmt.setInt(2, m_C_Currency_ID); + pstmt.setInt(3, m_C_BPartner_ID); + if (!multiCurrency.isSelected()) + pstmt.setInt(4, m_C_Currency_ID); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + { + Vector line = new Vector(); + line.add(new Boolean(false)); // 0-Selection + line.add(rs.getTimestamp(1)); // 1-TrxDate + KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(2)); + line.add(pp); // 2-DocumentNo + if (multiCurrency.isSelected()) + { + line.add(rs.getString(4)); // 3-Currency + line.add(rs.getBigDecimal(5)); // 4-PayAmt + } + line.add(rs.getBigDecimal(6)); // 3/5-ConvAmt + BigDecimal available = rs.getBigDecimal(7); + if (available == null || available.signum() == 0) // nothing available + continue; + line.add(available); // 4/6-ConvOpen/Available + line.add(Env.ZERO); // 5/7-Payment +// line.add(rs.getBigDecimal(8)); // 6/8-Multiplier + // + data.add(line); + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql.toString(), e); + } + // Remove previous listeners + paymentTable.getModel().removeTableModelListener(this); + // Header Info + Vector columnNames = new Vector(); + columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); + columnNames.add(Msg.translate(Env.getCtx(), "Date")); + columnNames.add(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); + if (multiCurrency.isSelected()) + { + columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); + columnNames.add(Msg.translate(Env.getCtx(), "Amount")); + } + columnNames.add(Msg.getMsg(Env.getCtx(), "ConvertedAmount")); + columnNames.add(Msg.getMsg(Env.getCtx(), "OpenAmt")); + columnNames.add(Msg.getMsg(Env.getCtx(), "AppliedAmt")); +// columnNames.add(" "); // Multiplier + + // Set Model + ListModelTable modelP = new ListModelTable(data); + modelP.addTableModelListener(this); + paymentTable.setData(modelP, columnNames); + // + int i = 0; + paymentTable.setColumnClass(i++, Boolean.class, false); // 0-Selection + paymentTable.setColumnClass(i++, Timestamp.class, true); // 1-TrxDate + paymentTable.setColumnClass(i++, String.class, true); // 2-Value + if (multiCurrency.isSelected()) + { + paymentTable.setColumnClass(i++, String.class, true); // 3-Currency + paymentTable.setColumnClass(i++, BigDecimal.class, true); // 4-PayAmt + } + paymentTable.setColumnClass(i++, BigDecimal.class, true); // 5-ConvAmt + paymentTable.setColumnClass(i++, BigDecimal.class, true); // 6-ConvOpen + paymentTable.setColumnClass(i++, BigDecimal.class, false); // 7-Allocated +// paymentTable.setColumnClass(i++, BigDecimal.class, true); // 8-Multiplier + + // + i_payment = multiCurrency.isSelected() ? 7 : 5; + + + // Table UI + paymentTable.autoSize(); + + + /******************************** + * Load unpaid Invoices + * 1-TrxDate, 2-Value, (3-Currency, 4-InvAmt,) + * 5-ConvAmt, 6-ConvOpen, 7-ConvDisc, 8-WriteOff, 9-Applied + * + SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID,c.ISO_Code, + i.GrandTotal*i.MultiplierAP "GrandTotal", + currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID) "GrandTotal $", + invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID) "Open", + currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP "Open $", + invoiceDiscount(i.C_Invoice_ID,SysDate,C_InvoicePaySchedule_ID) "Discount", + currencyConvert(invoiceDiscount(i.C_Invoice_ID,SysDate,C_InvoicePaySchedule_ID),i.C_Currency_ID,i.C_Currency_ID,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP "Discount $", + i.MultiplierAP, i.Multiplier + FROM C_Invoice_v i INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) + WHERE -- i.IsPaid='N' AND i.Processed='Y' AND i.C_BPartner_ID=1000001 + */ + data = new Vector>(); + sql = new StringBuffer("SELECT i.DateInvoiced,i.DocumentNo,i.C_Invoice_ID," // 1..3 + + "c.ISO_Code,i.GrandTotal*i.MultiplierAP, " // 4..5 Orig Currency + + "currencyConvert(i.GrandTotal*i.MultiplierAP,i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID), " // 6 #1 Converted + + "currencyConvert(invoiceOpen(C_Invoice_ID,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.MultiplierAP, " // 7 #2 Converted Open + + "currencyConvert(invoiceDiscount" // 8 AllowedDiscount + + "(i.C_Invoice_ID,?,C_InvoicePaySchedule_ID),i.C_Currency_ID,?,i.DateInvoiced,i.C_ConversionType_ID,i.AD_Client_ID,i.AD_Org_ID)*i.Multiplier*i.MultiplierAP," // #3, #4 + + "i.MultiplierAP " + + "FROM C_Invoice_v i" // corrected for CM/Split + + " INNER JOIN C_Currency c ON (i.C_Currency_ID=c.C_Currency_ID) " + + "WHERE i.IsPaid='N' AND i.Processed='Y'" + + " AND i.C_BPartner_ID=?"); // #5 + if (!multiCurrency.isSelected()) + sql.append(" AND i.C_Currency_ID=?"); // #6 + sql.append(" ORDER BY i.DateInvoiced, i.DocumentNo"); + log.fine("InvSQL=" + sql.toString()); + try + { + PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null); + pstmt.setInt(1, m_C_Currency_ID); + pstmt.setInt(2, m_C_Currency_ID); + pstmt.setTimestamp(3, (Timestamp)dateField.getValue()); + pstmt.setInt(4, m_C_Currency_ID); + pstmt.setInt(5, m_C_BPartner_ID); + if (!multiCurrency.isSelected()) + pstmt.setInt(6, m_C_Currency_ID); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + { + Vector line = new Vector(); + line.add(new Boolean(false)); // 0-Selection + line.add(rs.getTimestamp(1)); // 1-TrxDate + KeyNamePair pp = new KeyNamePair(rs.getInt(3), rs.getString(2)); + line.add(pp); // 2-Value + if (multiCurrency.isSelected()) + { + line.add(rs.getString(4)); // 3-Currency + line.add(rs.getBigDecimal(5)); // 4-Orig Amount + } + line.add(rs.getBigDecimal(6)); // 3/5-ConvAmt + BigDecimal open = rs.getBigDecimal(7); + if (open == null) // no conversion rate + open = Env.ZERO; + line.add(open); // 4/6-ConvOpen + BigDecimal discount = rs.getBigDecimal(8); + if (discount == null) // no concersion rate + discount = Env.ZERO; + line.add(discount); // 5/7-ConvAllowedDisc + line.add(Env.ZERO); // 6/8-WriteOff + line.add(Env.ZERO); // 7/9-OverUnder + line.add(Env.ZERO); // 8/10-Applied +// line.add(rs.getBigDecimal(9)); // 8/10-Multiplier + // Add when open <> 0 (i.e. not if no conversion rate) + if (Env.ZERO.compareTo(open) != 0) + data.add(line); + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql.toString(), e); + } + + // Remove previous listeners + invoiceTable.getModel().removeTableModelListener(this); + // Header Info + columnNames = new Vector(); + columnNames.add(Msg.getMsg(Env.getCtx(), "Select")); + columnNames.add(Msg.translate(Env.getCtx(), "Date")); + columnNames.add(Util.cleanAmp(Msg.translate(Env.getCtx(), "DocumentNo"))); + if (multiCurrency.isSelected()) + { + columnNames.add(Msg.getMsg(Env.getCtx(), "TrxCurrency")); + columnNames.add(Msg.translate(Env.getCtx(), "Amount")); + } + columnNames.add(Msg.getMsg(Env.getCtx(), "ConvertedAmount")); + columnNames.add(Msg.getMsg(Env.getCtx(), "OpenAmt")); + columnNames.add(Msg.getMsg(Env.getCtx(), "Discount")); + columnNames.add(Msg.getMsg(Env.getCtx(), "WriteOff")); + columnNames.add(Msg.getMsg(Env.getCtx(), "OverUnderAmt")); + columnNames.add(Msg.getMsg(Env.getCtx(), "AppliedAmt")); +// columnNames.add(" "); // Multiplier + + // Set Model + ListModelTable modelI = new ListModelTable(data); + modelI.addTableModelListener(this); + invoiceTable.setData(modelI, columnNames); + // + i = 0; + invoiceTable.setColumnClass(i++, Boolean.class, false); // 0-Selection + invoiceTable.setColumnClass(i++, Timestamp.class, true); // 1-TrxDate + invoiceTable.setColumnClass(i++, String.class, true); // 2-Value + if (multiCurrency.isSelected()) + { + invoiceTable.setColumnClass(i++, String.class, true); // 3-Currency + invoiceTable.setColumnClass(i++, BigDecimal.class, true); // 4-Amt + } + invoiceTable.setColumnClass(i++, BigDecimal.class, true); // 5-ConvAmt + invoiceTable.setColumnClass(i++, BigDecimal.class, true); // 6-ConvAmt Open + invoiceTable.setColumnClass(i++, BigDecimal.class, false); // 7-Conv Discount + invoiceTable.setColumnClass(i++, BigDecimal.class, false); // 8-Conv WriteOff + invoiceTable.setColumnClass(i++, BigDecimal.class, false); // 9-Conv OverUnder + invoiceTable.setColumnClass(i++, BigDecimal.class, false); // 10-Conv Applied +// invoiceTable.setColumnClass(i++, BigDecimal.class, true); // 10-Multiplier + // Table UI + invoiceTable.autoSize(); + + i_open = multiCurrency.isSelected() ? 6 : 4; + i_discount = multiCurrency.isSelected() ? 7 : 5; + i_writeOff = multiCurrency.isSelected() ? 8 : 6; + i_overUnder = multiCurrency.isSelected() ? 9 : 7; + i_applied = multiCurrency.isSelected() ? 10 : 8; +// i_multiplier = multiCurrency.isSelected() ? 10 : 8; + + // Calculate Totals + calculate(); + } // loadBPartner + + + + /************************************************************************** + * Action Listener. + * - MultiCurrency + * - Allocate + * @param e event + */ + public void onEvent(Event e) + { + log.config(""); + if (e.getTarget().equals(multiCurrency)) + loadBPartner(); + // Allocate + else if (e.getTarget().equals(allocateButton)) + { + allocateButton.setEnabled(false); + saveData(); + loadBPartner(); + allocateButton.setEnabled(true); + } + } // actionPerformed + + /** + * Table Model Listener. + * - Recalculate Totals + * @param e event + */ + public void tableChanged(WTableModelEvent e) + { + boolean isUpdate = (e.getType() == WTableModelEvent.CONTENTS_CHANGED); + // Not a table update + if (!isUpdate) + { + calculate(); + return; + } + + + /** + * Setting defaults + */ + if (m_calculating) // Avoid recursive calls + return; + m_calculating = true; + int row = e.getFirstRow(); + int col = e.getColumn(); + boolean isInvoice = (e.getModel().equals(invoiceTable.getModel())); + log.config("Row=" + row + + ", Col=" + col + ", InvoiceTable=" + isInvoice); + + // Payments + if (!isInvoice) + { + ListModelTable payment = paymentTable.getModel(); + + BigDecimal open = (BigDecimal)payment.getValueAt(row, i_open); + BigDecimal applied = (BigDecimal)payment.getValueAt(row, i_payment); + + if (col == 0) + { + // selection of payment row + if (((Boolean)payment.getValueAt(row, 0)).booleanValue()) + { + applied = open; // Open Amount + if (totalDiff.abs().compareTo(applied.abs()) < 0 // where less is available to allocate than open + && totalDiff.signum() == -applied.signum() ) // and the available amount has the opposite sign + applied = totalDiff.negate(); // reduce the amount applied to what's available + + } + else // de-selected + applied = Env.ZERO; + } + + + if (col == i_payment) + { + if ( applied.signum() == -open.signum() ) + applied = applied.negate(); + if ( open.abs().compareTo( applied.abs() ) < 0 ) + applied = open; + } + + payment.setValueAt(applied, row, i_payment); + } + + // Invoice + else + { + ListModelTable invoice = invoiceTable.getModel(); + boolean selected = ((Boolean) invoice.getValueAt(row, 0)).booleanValue(); + BigDecimal open = (BigDecimal)invoice.getValueAt(row, i_open); + BigDecimal discount = (BigDecimal)invoice.getValueAt(row, i_discount); + BigDecimal applied = (BigDecimal)invoice.getValueAt(row, i_applied); + BigDecimal writeOff = (BigDecimal) invoice.getValueAt(row, i_writeOff); + BigDecimal overUnder = (BigDecimal) invoice.getValueAt(row, i_overUnder); + int openSign = open.signum(); + + if (col == 0) //selection + { + // selected - set applied amount + if ( selected ) + { + applied = open; // Open Amount + applied = applied.subtract(discount); + writeOff = Env.ZERO; // to be sure + overUnder = Env.ZERO; + + if (totalDiff.abs().compareTo(applied.abs()) < 0 // where less is available to allocate than open + && totalDiff.signum() == applied.signum() ) // and the available amount has the same sign + applied = totalDiff; // reduce the amount applied to what's available + + if ( autoWriteOff.isSelected() ) + writeOff = open.subtract(applied.add(discount)); + else + overUnder = open.subtract(applied.add(discount)); + } + else // de-selected + { + writeOff = Env.ZERO; + applied = Env.ZERO; + overUnder = Env.ZERO; + } + } + + // check entered values are sensible and possibly auto write-off + if ( selected && col != 0 ) + { + + // values should have same sign as open except over/under + if ( discount.signum() == -openSign ) + discount = discount.negate(); + if ( writeOff.signum() == -openSign) + writeOff = writeOff.negate(); + if ( applied.signum() == -openSign ) + applied = applied.negate(); + + // discount and write-off must be less than open amount + if ( discount.abs().compareTo(open.abs()) > 0) + discount = open; + if ( writeOff.abs().compareTo(open.abs()) > 0) + writeOff = open; + + // if overUnder has same sign as open it is an under payment -> less than open + if ( overUnder.signum() == openSign && overUnder.abs().compareTo(open.abs()) > 0) + overUnder = open; + + /* + * Three rules to maintain: + * 1) |overUnder + writeOff + discount| < open + * 2) |writeOff + discount| < open ( in case overUnder is 'negative') + * 3) discount + writeOff + overUnder + applied = 0 + * + * As only one column is edited at a time and the initial position was one of compliance + * with the rules, we only need to redistribute the increase/decrease in the edited column to + * the others. + */ + + // comply with rules 1 or 2 + BigDecimal amtOver; + if ( overUnder.signum() == -openSign ) + amtOver = (discount.add(writeOff)).subtract(open); + else + amtOver = (discount.add(writeOff.add(overUnder))).subtract(open); + + if ( amtOver.signum() == openSign ) + { + BigDecimal temp = Env.ZERO; + if ( col != i_overUnder && overUnder.signum() == openSign ) + { + temp = overUnder.subtract(amtOver); + if ( temp.signum() == -openSign ) + { + overUnder = Env.ZERO; + amtOver = temp.negate(); + } + else + { + overUnder = temp; + amtOver = Env.ZERO; + } + } + + if ( col != i_writeOff ) + { + temp = writeOff.subtract(amtOver); + if ( temp.signum() == -openSign ) + { + writeOff = Env.ZERO; + amtOver = temp.negate(); + } + else + { + writeOff = temp; + amtOver = Env.ZERO; + } + } + + if ( col != i_discount ) + { + temp = discount.subtract(amtOver); + if ( temp.signum() == -openSign ) + { + discount = Env.ZERO; + amtOver = temp.negate(); + } + else + { + discount = temp; + amtOver = Env.ZERO; + } + } + } + + + // make everything balance to open + BigDecimal remainder = open.subtract(discount.add(writeOff.add(overUnder.add(applied)))); + + // need to increase something + if ( remainder.signum() == openSign ) + { + BigDecimal temp = Env.ZERO; + BigDecimal amtUnder = amtOver.negate(); + + if ( autoWriteOff.isSelected() && col != i_writeOff ) + { + temp = writeOff.add(remainder); + + if ( temp.abs().compareTo(amtUnder.abs()) > 0 ) + { + writeOff = amtUnder; + remainder = temp.subtract(amtUnder); + } + else + { + writeOff = temp; + remainder = Env.ZERO; + } + } + + if ( col != i_overUnder ) + { + temp = overUnder.add(remainder); + if ( temp.abs().compareTo(amtUnder.abs()) > 0 ) + { + overUnder = amtUnder; + remainder = temp.subtract(amtUnder); + } + else + { + overUnder = temp; + remainder = Env.ZERO; + } + } + + if ( col != i_applied && remainder.signum() != 0 ) + { + applied = applied.add(remainder); + remainder = Env.ZERO; + } + } + + // need to decrease some amount/s + if ( remainder.signum() == -openSign ) + { + BigDecimal temp = Env.ZERO; + + + if ( autoWriteOff.isSelected() && col != i_writeOff ) + { + temp = writeOff.add(remainder); + + if ( temp.signum() == -openSign ) + { + writeOff = Env.ZERO; + remainder = temp; + } + else + { + writeOff = temp; + remainder = Env.ZERO; + } + } + + + + if ( col != i_overUnder && remainder.signum() != 0 ) + { + overUnder = overUnder.add(remainder); + remainder = Env.ZERO; + } + } + + } + + // Warning if write Off > 30% + if (autoWriteOff.isSelected() && writeOff.doubleValue()/open.doubleValue() > .30) + FDialog.warn(m_WindowNo, "AllocationWriteOffWarn"); + + + invoice.setValueAt(discount, row, i_discount); + invoice.setValueAt(applied, row, i_applied); + invoice.setValueAt(writeOff, row, i_writeOff); + invoice.setValueAt(overUnder, row, i_overUnder); + + invoiceTable.repaint(); // update r/o + + + + } + + m_calculating = false; + calculate(); + } // tableChanged + + /** + * Calculate Allocation info + */ + private void calculate () + { + log.config(""); + // + DecimalFormat format = DisplayType.getNumberFormat(DisplayType.Amount); + Timestamp allocDate = null; + + // Payment + ListModelTable payment = paymentTable.getModel(); + totalPay = new BigDecimal(0.0); + int rows = payment.getRowCount(); + m_noPayments = 0; + for (int i = 0; i < rows; i++) + { + if (((Boolean)payment.getValueAt(i, 0)).booleanValue()) + { + Timestamp ts = (Timestamp)payment.getValueAt(i, 1); + allocDate = TimeUtil.max(allocDate, ts); + BigDecimal bd = (BigDecimal)payment.getValueAt(i, i_payment); + totalPay = totalPay.add(bd); // Applied Pay + m_noPayments++; + log.fine("Payment_" + i + " = " + bd + " - Total=" + totalPay); + } + } + paymentInfo.setText(String.valueOf(m_noPayments) + " - " + + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(totalPay) + " "); + + // Invoices + ListModelTable invoice = invoiceTable.getModel(); + totalInv = new BigDecimal(0.0); + rows = invoice.getRowCount(); + m_noInvoices = 0; + + for (int i = 0; i < rows; i++) + { + if (((Boolean)invoice.getValueAt(i, 0)).booleanValue()) + { + Timestamp ts = (Timestamp)invoice.getValueAt(i, 1); + allocDate = TimeUtil.max(allocDate, ts); + BigDecimal bd = (BigDecimal)invoice.getValueAt(i, i_applied); + totalInv = totalInv.add(bd); // Applied Inv + m_noInvoices++; + log.fine("Invoice_" + i + " = " + bd + " - Total=" + totalPay); + } + } + invoiceInfo.setText(String.valueOf(m_noInvoices) + " - " + + Msg.getMsg(Env.getCtx(), "Sum") + " " + format.format(totalInv) + " "); + + // Set AllocationDate + if (allocDate != null) + dateField.setValue(allocDate); + // Set Allocation Currency + allocCurrencyLabel.setText(currencyPick.getDisplay()); + // Difference + totalDiff = totalPay.subtract(totalInv); + differenceField.setText(format.format(totalDiff)); + + if (totalDiff.compareTo(new BigDecimal(0.0)) == 0) + allocateButton.setEnabled(true); + else + allocateButton.setEnabled(false); + + } // calculate + + /** + * Vetoable Change Listener. + * - Business Partner + * - Currency + * - Date + * @param e event + */ + public void valueChange (ValueChangeEvent e) + { + String name = e.getPropertyName(); + Object value = e.getNewValue(); + log.config(name + "=" + value); + if (value == null) + return; + + // BPartner + if (name.equals("C_BPartner_ID")) + { + bpartnerSearch.setValue(value); + m_C_BPartner_ID = ((Integer)value).intValue(); + loadBPartner(); + } + // Currency + else if (name.equals("C_Currency_ID")) + { + m_C_Currency_ID = ((Integer)value).intValue(); + loadBPartner(); + } + // Date for Multi-Currency + else if (name.equals("Date") && multiCurrency.isSelected()) + loadBPartner(); + } // vetoableChange + + + /************************************************************************** + * Save Data + */ + private void saveData() + { + if (m_noInvoices + m_noPayments == 0) + return; + + // fixed fields + int AD_Client_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Client_ID"); + int AD_Org_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "AD_Org_ID"); + int C_BPartner_ID = m_C_BPartner_ID; + int C_Order_ID = 0; + int C_CashLine_ID = 0; + Timestamp DateTrx = (Timestamp)dateField.getValue(); + int C_Currency_ID = m_C_Currency_ID; // the allocation currency + // + if (AD_Org_ID == 0) + { + FDialog.error(m_WindowNo, "Org0NotAllowed", null); + return; + } + // + log.config("Client=" + AD_Client_ID + ", Org=" + AD_Org_ID + + ", BPartner=" + C_BPartner_ID + ", Date=" + DateTrx); + + Trx trx = Trx.get(Trx.createTrxName("AL"), true); + + // Payment - Loop and add them to paymentList/amountList + int pRows = paymentTable.getRowCount(); + ListModelTable payment = paymentTable.getModel(); + ArrayList paymentList = new ArrayList(pRows); + ArrayList amountList = new ArrayList(pRows); + BigDecimal paymentAppliedAmt = Env.ZERO; + for (int i = 0; i < pRows; i++) + { + // Payment line is selected + if (((Boolean)payment.getValueAt(i, 0)).booleanValue()) + { + KeyNamePair pp = (KeyNamePair)payment.getValueAt(i, 2); // Value + // Payment variables + int C_Payment_ID = pp.getKey(); + paymentList.add(new Integer(C_Payment_ID)); + // + BigDecimal PaymentAmt = (BigDecimal)payment.getValueAt(i, i_payment); // Applied Payment + amountList.add(PaymentAmt); + // + paymentAppliedAmt = paymentAppliedAmt.add(PaymentAmt); + // + log.fine("C_Payment_ID=" + C_Payment_ID + + " - PaymentAmt=" + PaymentAmt); // + " * " + Multiplier + " = " + PaymentAmtAbs); + } + } + log.config("Number of Payments=" + paymentList.size() + " - Total=" + paymentAppliedAmt); + + // Invoices - Loop and generate allocations + int iRows = invoiceTable.getRowCount(); + ListModelTable invoice = invoiceTable.getModel(); + + // Create Allocation + MAllocationHdr alloc = new MAllocationHdr (Env.getCtx(), true, // manual + DateTrx, C_Currency_ID, Env.getContext(Env.getCtx(), "#AD_User_Name"), trx.getTrxName()); + alloc.setAD_Org_ID(AD_Org_ID); + if (!alloc.save()) + { + log.log(Level.SEVERE, "Allocation not created"); + return; + } + + // For all invoices + int invoiceLines = 0; + BigDecimal unmatchedApplied = Env.ZERO; + for (int i = 0; i < iRows; i++) + { + // Invoice line is selected + if (((Boolean)invoice.getValueAt(i, 0)).booleanValue()) + { + invoiceLines++; + KeyNamePair pp = (KeyNamePair)invoice.getValueAt(i, 2); // Value + // Invoice variables + int C_Invoice_ID = pp.getKey(); + BigDecimal AppliedAmt = (BigDecimal)invoice.getValueAt(i, i_applied); + // semi-fixed fields (reset after first invoice) + BigDecimal DiscountAmt = (BigDecimal)invoice.getValueAt(i, i_discount); + BigDecimal WriteOffAmt = (BigDecimal)invoice.getValueAt(i, i_writeOff); + // OverUnderAmt needs to be in Allocation Currency + BigDecimal OverUnderAmt = ((BigDecimal)invoice.getValueAt(i, i_open)) + .subtract(AppliedAmt).subtract(DiscountAmt).subtract(WriteOffAmt); + + log.config("Invoice #" + i + " - AppliedAmt=" + AppliedAmt);// + " -> " + AppliedAbs); + // loop through all payments until invoice applied + + for (int j = 0; j < paymentList.size() && AppliedAmt.signum() != 0; j++) + { + int C_Payment_ID = ((Integer)paymentList.get(j)).intValue(); + BigDecimal PaymentAmt = (BigDecimal)amountList.get(j); + if (PaymentAmt.signum() == AppliedAmt.signum()) // only match same sign (otherwise appliedAmt increases) + { // and not zero (appliedAmt was checked earlier) + log.config(".. with payment #" + j + ", Amt=" + PaymentAmt); + + BigDecimal amount = AppliedAmt; + if (amount.abs().compareTo(PaymentAmt.abs()) > 0) // if there's more open on the invoice + amount = PaymentAmt; // than left in the payment + + // Allocation Line + MAllocationLine aLine = new MAllocationLine (alloc, amount, + DiscountAmt, WriteOffAmt, OverUnderAmt); + aLine.setDocInfo(C_BPartner_ID, C_Order_ID, C_Invoice_ID); + aLine.setPaymentInfo(C_Payment_ID, C_CashLine_ID); + if (!aLine.save()) + log.log(Level.SEVERE, "Allocation Line not written - Invoice=" + C_Invoice_ID); + + // Apply Discounts and WriteOff only first time + DiscountAmt = Env.ZERO; + WriteOffAmt = Env.ZERO; + // subtract amount from Payment/Invoice + AppliedAmt = AppliedAmt.subtract(amount); + PaymentAmt = PaymentAmt.subtract(amount); + log.fine("Allocation Amount=" + amount + " - Remaining Applied=" + AppliedAmt + ", Payment=" + PaymentAmt); + amountList.set(j, PaymentAmt); // update + } // for all applied amounts + } // loop through payments for invoice + + if ( AppliedAmt.signum() == 0 && DiscountAmt.signum() == 0 && WriteOffAmt.signum() == 0) + continue; + else { // remainder will need to match against other invoices + int C_Payment_ID = 0; + + // Allocation Line + MAllocationLine aLine = new MAllocationLine (alloc, AppliedAmt, + DiscountAmt, WriteOffAmt, OverUnderAmt); + aLine.setDocInfo(C_BPartner_ID, C_Order_ID, C_Invoice_ID); + aLine.setPaymentInfo(C_Payment_ID, C_CashLine_ID); + if (!aLine.save(trx.getTrxName())) + log.log(Level.SEVERE, "Allocation Line not written - Invoice=" + C_Invoice_ID); + + log.fine("Allocation Amount=" + AppliedAmt); + unmatchedApplied = unmatchedApplied.add(AppliedAmt); + } + } // invoice selected + } // invoice loop + + // check for unapplied payment amounts (eg from payment reversals) + for (int i = 0; i < paymentList.size(); i++) { + BigDecimal payAmt = (BigDecimal) amountList.get(i); + if ( payAmt.signum() == 0 ) + continue; + int C_Payment_ID = ((Integer)paymentList.get(i)).intValue(); + log.fine("Payment=" + C_Payment_ID + + ", Amount=" + payAmt); + + // Allocation Line + MAllocationLine aLine = new MAllocationLine (alloc, payAmt, + Env.ZERO, Env.ZERO, Env.ZERO); + aLine.setDocInfo(C_BPartner_ID, 0, 0); + aLine.setPaymentInfo(C_Payment_ID, 0); + if (!aLine.save(trx.getTrxName())) + log.log(Level.SEVERE, "Allocation Line not saved - Payment=" + C_Payment_ID); + unmatchedApplied = unmatchedApplied.subtract(payAmt); + } + + if ( unmatchedApplied.signum() != 0 ) + log.log(Level.SEVERE, "Allocation not balanced -- out by " + unmatchedApplied ); + + // Should start WF + if (alloc.get_ID() != 0) + { + alloc.processIt(DocAction.ACTION_Complete); + alloc.save(); + } + + // Test/Set IsPaid for Invoice - requires that allocation is posted + for (int i = 0; i < iRows; i++) + { + // Invoice line is selected + if (((Boolean)invoice.getValueAt(i, 0)).booleanValue()) + { + KeyNamePair pp = (KeyNamePair)invoice.getValueAt(i, 2); // Value + // Invoice variables + int C_Invoice_ID = pp.getKey(); + String sql = "SELECT invoiceOpen(C_Invoice_ID, 0) " + + "FROM C_Invoice WHERE C_Invoice_ID=?"; + BigDecimal open = DB.getSQLValueBD(trx.getTrxName(), sql, C_Invoice_ID); + if (open != null && open.signum() == 0) { + sql = "UPDATE C_Invoice SET IsPaid='Y' " + + "WHERE C_Invoice_ID=" + C_Invoice_ID; + int no = DB.executeUpdate(sql, trx.getTrxName()); + log.config("Invoice #" + i + " is paid - updated=" + no); + } else + log.config("Invoice #" + i + " is not paid - " + open); + } + } + // Test/Set Payment is fully allocated + for (int i = 0; i < paymentList.size(); i++) + { + int C_Payment_ID = ((Integer)paymentList.get(i)).intValue(); + MPayment pay = new MPayment (Env.getCtx(), C_Payment_ID, trx.getTrxName()); + if (pay.testAllocation()) + pay.save(); + log.config("Payment #" + i + (pay.isAllocated() ? " not" : " is") + + " fully allocated"); + } + paymentList.clear(); + amountList.clear(); + trx.commit(); + trx.close(); + + statusBar.setStatusLine(alloc.getDocumentNo()); + } // saveData + + +} // VAllocation diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java index fff7c7c736..a216d52293 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java @@ -28,6 +28,7 @@ import java.util.logging.Level; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Checkbox; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Datebox; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Label; @@ -41,7 +42,6 @@ import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.WConfirmPanel; import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; @@ -78,9 +78,6 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange { private static final long serialVersionUID = 1L; - /** Window No */ - private int m_WindowNo = 0; - /** The Archives */ private MArchive[] m_archives = new MArchive[0]; @@ -131,7 +128,7 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private Textbox descriptionField = new Textbox(); private Label helpLabel = new Label(Msg.translate(Env.getCtx(), "Help")); private Textbox helpField = new Textbox(); - private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private ConfirmPanel confirmPanel = new ConfirmPanel(true); private Button updateArchive = new Button(); private Tabbox tabbox = new Tabbox(); @@ -143,7 +140,6 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange public WArchiveViewer() { - init(super.m_windowNo); } /** @@ -151,10 +147,9 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange * @param WindowNo window */ - public void init (int WindowNo) + protected void initForm() { log.info(""); - m_WindowNo = WindowNo; try { @@ -236,7 +231,7 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange bPartnerField = new WSearchEditor(lookup, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - bPartnerField.addValueChangeListner(this); + bPartnerField.addValueChangeListener(this); } // dynInit private void reportViewer(byte[] data) @@ -268,19 +263,19 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange createdByQField.setMold("select"); createdByQField.setRows(1); - updateArchive.setImage("/images/Ok24.gif"); + updateArchive.setImage("/images/Ok24.png"); updateArchive.setTooltiptext("Save Archive"); updateArchive.addEventListener(Events.ON_CLICK, this); - bRefresh.setImage("/images/Refresh24.gif"); + bRefresh.setImage("/images/Refresh24.png"); bRefresh.setTooltiptext("Refresh"); bRefresh.addEventListener(Events.ON_CLICK, this); - bBack.setImage("/images/Parent24.gif"); + bBack.setImage("/images/Parent24.png"); bBack.setTooltiptext("Back"); bBack.addEventListener(Events.ON_CLICK, this); - bNext.setImage("/images/Detail24.gif"); + bNext.setImage("/images/Detail24.png"); bNext.setTooltiptext("Next"); bNext.addEventListener(Events.ON_CLICK, this); @@ -506,7 +501,7 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange tabs.appendChild(tabView); tabpanels.appendChild(tabViewPanel); - confirmPanel.addEventListener(this); + confirmPanel.addActionListener(this); updateQDisplay(); iframe.setId("reportFrame"); @@ -528,9 +523,9 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange if (e.getTarget() == updateArchive) cmd_updateArchive(); - else if (e.getName().equals(WConfirmPanel.A_CANCEL)) + else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) SessionManager.getAppDesktop().removeWindow(); - else if (e.getName().equals(WConfirmPanel.A_OK)) + else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) { if (tabbox.getSelectedIndex() == 1) SessionManager.getAppDesktop().removeWindow(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAttributeGrid.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAttributeGrid.java index 4d0df89b00..c0e810c4a8 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAttributeGrid.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WAttributeGrid.java @@ -35,7 +35,7 @@ import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.window.FDialog; import org.compiere.model.MAttribute; @@ -73,10 +73,8 @@ public class WAttributeGrid extends ADForm implements EventListener * @param WindowNo * @param frame */ - public void init(int adFormId, String name) + protected void initForm() { - super.init(adFormId, name); - m_attributes = MAttribute.getOfClient(Env.getCtx(), true, true); KeyNamePair[] vector = new KeyNamePair[m_attributes.length+1]; vector[0] = new KeyNamePair(0, ""); @@ -192,7 +190,7 @@ public class WAttributeGrid extends ADForm implements EventListener this.appendChild(tabbox); tabbox.addEventListener(Events.ON_SELECT, this); this.appendChild(confirmPanel); - confirmPanel.addEventListener(this); + confirmPanel.addActionListener(this); } // init /** Window No */ @@ -236,7 +234,7 @@ public class WAttributeGrid extends ADForm implements EventListener private Listbox pickPriceList = new Listbox(); private Label labelWarehouse = new Label(Msg.getElement(Env.getCtx(), "M_Warehouse_ID")); private Listbox pickWarehouse = new Listbox(); - private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private ConfirmPanel confirmPanel = new ConfirmPanel(true); // private Grid gridView = new Grid(); // private CPanel gridPanel = new CPanel(new BorderLayout()); @@ -316,14 +314,14 @@ public class WAttributeGrid extends ADForm implements EventListener } else if(e.getTarget() == modeCombo) createGrid(); - else if (e.getName().equals(WConfirmPanel.A_OK)) + else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) { if (tabbox.getSelectedIndex() == 0) createGrid(); else gridOK(); } - else if (e.getName().equals(WConfirmPanel.A_CANCEL)) + else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) onClose(); } // actionPerformed @@ -370,7 +368,7 @@ public class WAttributeGrid extends ADForm implements EventListener if (attr1.equals(attr2)) { - FDialog.warn(m_windowNo, "Same Attribute Selected", getTitle()); + FDialog.warn(m_WindowNo, "Same Attribute Selected", getTitle()); log.warning("Same Attribute Selected"); tabbox.setSelectedIndex(0); return; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java index 61c6b3ff37..f3e0914c81 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WBOMDrop.java @@ -67,9 +67,6 @@ public class WBOMDrop extends ADForm implements EventListener { private static final long serialVersionUID = 1L; - /** Window No */ - private int m_WindowNo = 0; - /** Product to create BOMs from */ private MProduct m_product; @@ -109,20 +106,16 @@ public class WBOMDrop extends ADForm implements EventListener private Groupbox grpSelectProd = new Groupbox(); public WBOMDrop() - { - init(super.m_windowNo); - } + {} /** * Initialize Panel * @param WindowNo window * @param frame parent frame */ - - public void init (int WindowNo) + protected void initForm() { log.info(""); - m_WindowNo = WindowNo; try { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java index 8a41936e2d..af15c14776 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCharge.java @@ -38,7 +38,7 @@ import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.WListbox; import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.session.SessionManager; @@ -121,7 +121,7 @@ public class WCharge extends ADForm implements EventListener private WListbox m_tblData = new WListbox(); /** confirmation panel. */ - private WConfirmPanel m_pnlConfirm = new WConfirmPanel(); + private ConfirmPanel m_pnlConfirm = new ConfirmPanel(); /** Confirmation Grid. */ private Grid m_grdConfirm = new Grid(); @@ -201,9 +201,8 @@ public class WCharge extends ADForm implements EventListener * @param adFormId The Adempiere identifier for the form * @param name The name of the form */ - public void init(int adFormId, String name) + protected void initForm() { - super.init(adFormId, name); log.info(""); try { @@ -508,7 +507,7 @@ public class WCharge extends ADForm implements EventListener { log.info(event.getName()); // - if (event.getName().equals(WConfirmPanel.A_OK) || m_elementId == 0) + if (event.getTarget().getId().equals(ConfirmPanel.A_OK) || m_elementId == 0) { close(); } @@ -556,17 +555,17 @@ public class WCharge extends ADForm implements EventListener int elementValueId = createElementValue (value, name, m_chbIsExpense.isChecked()); if (elementValueId == 0) { - FDialog.error(m_windowNo, this, "ChargeNotCreated", name); + FDialog.error(m_WindowNo, this, "ChargeNotCreated", name); return; } // Create Charge int chargeId = createCharge(name, elementValueId); if (chargeId == 0) { - FDialog.error(m_windowNo, this, "ChargeNotCreated", name); + FDialog.error(m_WindowNo, this, "ChargeNotCreated", name); return; } - FDialog.info(m_windowNo, this, "ChargeCreated", name); + FDialog.info(m_WindowNo, this, "ChargeCreated", name); } // createNew @@ -787,11 +786,11 @@ public class WCharge extends ADForm implements EventListener } if (listCreated.length() > 0) { - FDialog.info(m_windowNo, this, "ChargeCreated", listCreated.toString()); + FDialog.info(m_WindowNo, this, "ChargeCreated", listCreated.toString()); } if (listRejected.length() > 0) { - FDialog.error(m_windowNo, this, "ChargeNotCreated", listRejected.toString()); + FDialog.error(m_WindowNo, this, "ChargeNotCreated", listRejected.toString()); } return; @@ -887,7 +886,7 @@ public class WCharge extends ADForm implements EventListener { Rows rows = new Rows(); Row row = new Row(); - m_pnlConfirm.addEventListener(this); + m_pnlConfirm.addActionListener(this); row.appendChild(m_pnlConfirm); rows.appendChild(row); m_grdConfirm.appendChild(rows); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFrom.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFrom.java index 273ae49953..4511dd8c9c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFrom.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFrom.java @@ -23,7 +23,6 @@ import java.math.*; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Button; -import org.adempiere.webui.component.ButtonFactory; import org.adempiere.webui.component.Checkbox; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Grid; @@ -35,6 +34,7 @@ import org.adempiere.webui.component.ListboxFactory; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.WAppsAction; import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.WStatusBar; import org.adempiere.webui.component.Window; @@ -42,7 +42,6 @@ import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WLocatorEditor; import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WStringEditor; -import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.event.WTableModelEvent; import org.adempiere.webui.event.WTableModelListener; import org.compiere.model.*; @@ -231,7 +230,7 @@ public abstract class WCreateFrom extends Window parameterLayout.appendChild(north); north.appendChild(parameterBankPanel); - parameterLayout.setHeight("100px"); + parameterLayout.setHeight("110px"); parameterLayout.setWidth("100%"); parameterBankPanel.appendChild(parameterBankLayout); @@ -282,13 +281,11 @@ public abstract class WCreateFrom extends Window // // // @Trifon -// AppsAction selectAllAction = new AppsAction (SELECT_ALL, KeyStroke.getKeyStroke(KeyEvent.VK_A, java.awt.event.InputEvent.ALT_MASK), null); + WAppsAction selectAllAction = new WAppsAction (SELECT_ALL, null, null); - Button selectAllButton = ButtonFactory.createButton(SELECT_ALL, null); + Button selectAllButton = selectAllAction.getButton(); confirmPanel.addComponentsLeft(selectAllButton); selectAllButton.addActionListener(this); -// selectAllButton.setToolTipText(Msg.getMsg(Env.getCtx(), SELECT_ALL_TOOLTIP)); - confirmPanel.addButton(selectAllButton); // South south = new South(); contentPane.appendChild(south); @@ -498,7 +495,7 @@ public abstract class WCreateFrom extends Window log.config("C_Order_ID=" + C_Order_ID); p_order = new MOrder (Env.getCtx(), C_Order_ID, null); // save - Vector data = new Vector(); + Vector> data = new Vector>(); StringBuffer sql = new StringBuffer("SELECT " + "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," // 1 + "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2 @@ -564,7 +561,7 @@ public abstract class WCreateFrom extends Window * Load Order/Invoice/Shipment data into Table * @param data data */ - protected void loadTableOIS (Vector data) + protected void loadTableOIS (Vector> data) { // Header Info Vector columnNames = new Vector(7); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromInvoice.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromInvoice.java index 3e1b17a896..6f06107322 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromInvoice.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromInvoice.java @@ -78,7 +78,7 @@ public class WCreateFromInvoice extends WCreateFrom implements ValueChangeListen } initBPartner(true); - bPartnerField.addValueChangeListner(this); + bPartnerField.addValueChangeListener(this); return true; } // dynInit diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromShipment.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromShipment.java index d790cf7d3c..6bca344010 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromShipment.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromShipment.java @@ -114,7 +114,7 @@ public class WCreateFromShipment extends WCreateFrom implements ValueChangeListe locatorField = new WLocatorEditor ("M_Locator_ID", true, false, true, locator, p_WindowNo); initBPartner(false); - bPartnerField.addValueChangeListner(this); + bPartnerField.addValueChangeListener(this); locatorLabel.setMandatory(true); return true; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromStatement.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromStatement.java index 2c3a2702e0..50f0606a3b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromStatement.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WCreateFromStatement.java @@ -78,7 +78,7 @@ public class WCreateFromStatement extends WCreateFrom implements ValueChangeList MLookup lookup = MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); WTableDirEditor editor = new WTableDirEditor ("C_BankAccount_ID", true, false, true, lookup); bankAccountField = editor.getComponent(); - editor.addValueChangeListner(this); + editor.addValueChangeListener(this); // Set Default int C_BankAccount_ID = Env.getContextAsInt(Env.getCtx(), p_WindowNo, "C_BankAccount_ID"); bankAccountField.setValue(new Integer(C_BankAccount_ID)); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java index 38293dbefa..3746574e8c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WFileImport.java @@ -76,9 +76,6 @@ public class WFileImport extends ADForm implements EventListener /** Logger */ private static CLogger log = CLogger.getCLogger(WFileImport.class); - /** Window No */ - private int m_WindowNo = 0; - private int m_record = -1; private Listbox pickFormat = new Listbox(); @@ -115,18 +112,15 @@ public class WFileImport extends ADForm implements EventListener public WFileImport() { - init(super.m_windowNo); } /** * Initialize Panel * @param WindowNo window */ - - public void init (int WindowNo) + protected void initForm() { log.info(""); - m_WindowNo = WindowNo; try { jbInit(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java index 7432bae45e..1500167b17 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInOutGen.java @@ -125,11 +125,9 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe public WInOutGen() { - init(); - initComponents(); } - private void init() + protected void initForm() { separator = new Separator(); separator.setHeight("5px"); @@ -159,11 +157,11 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe lstSelect.getModel().addTableModelListener(this); btnCancel = new Button(); - btnCancel.setImage("/images/Cancel24.gif"); + btnCancel.setImage("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); btnOk = new Button(); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); lblGenerate = new Label(); @@ -182,6 +180,8 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe populateWarehouse(); showBusinessPartner(); + + initComponents(); } private void initComponents() @@ -320,26 +320,26 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe { final int AD_Column_ID = 2223; - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupBP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); warehouseSearch = new WTableDirEditor(lookupBP, Msg.translate( Env.getCtx(), "M_Warehouse_ID"), "", true, false, true); - warehouseSearch.addValueChangeListner(this); + warehouseSearch.addValueChangeListener(this); } private void showBusinessPartner() { final int AD_BPartner_ID = 3499; - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupBP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_BPartner_ID, DisplayType.Search); bPartnerSearch = new WSearchEditor(lookupBP, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - bPartnerSearch.addValueChangeListner(this); + bPartnerSearch.addValueChangeListener(this); } @@ -565,7 +565,7 @@ public class WInOutGen extends ADForm implements EventListener, ValueChangeListe } // Execute Process - ProcessCtl worker = new ProcessCtl(null, super.m_windowNo, pi, trx); + ProcessCtl worker = new ProcessCtl(null, m_WindowNo, pi, trx); worker.start(); // complete tasks in unlockUI / generateShipments_complete lstSelect.clearTable(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInvoiceGen.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInvoiceGen.java index 9b7cf2f33a..49e64eac94 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInvoiceGen.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WInvoiceGen.java @@ -127,11 +127,9 @@ public class WInvoiceGen extends ADForm implements EventListener, ValueChangeLis public WInvoiceGen() { - init(); - initComponents(); } - private void init() + protected void initForm() { separator = new Separator(); separator.setHeight("5px"); @@ -161,11 +159,11 @@ public class WInvoiceGen extends ADForm implements EventListener, ValueChangeLis lstSelect.getModel().addTableModelListener(this); btnCancel = new Button(); - btnCancel.setImage("/images/Cancel24.gif"); + btnCancel.setImage("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); btnOk = new Button(); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); lblGenerate = new Label(); @@ -184,6 +182,8 @@ public class WInvoiceGen extends ADForm implements EventListener, ValueChangeLis populateOrganisation(); showBusinessPartner(); + + initComponents(); } private void initComponents() @@ -328,26 +328,26 @@ public class WInvoiceGen extends ADForm implements EventListener, ValueChangeLis { final int AD_Column_ID = 2163; - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupBP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.TableDir); organizationSearch = new WTableDirEditor(lookupBP, Msg.translate( Env.getCtx(), "AD_Org_ID"), "", true, false, true); - organizationSearch.addValueChangeListner(this); + organizationSearch.addValueChangeListener(this); } private void showBusinessPartner() { final int AD_Column_ID = 3499; - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupBP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); bPartnerSearch = new WSearchEditor(lookupBP, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - bPartnerSearch.addValueChangeListner(this); + bPartnerSearch.addValueChangeListener(this); } @@ -572,7 +572,7 @@ public class WInvoiceGen extends ADForm implements EventListener, ValueChangeLis // Execute Process - ProcessCtl worker = new ProcessCtl(null, super.m_windowNo, pi, trx); + ProcessCtl worker = new ProcessCtl(null, m_WindowNo, pi, trx); worker.start(); lstSelect.clearTable(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java index df68898616..33729e10ba 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMatch.java @@ -163,11 +163,9 @@ public class WMatch extends ADForm implements EventListener, ValueChangeListener public WMatch() { - init(); - initComponents(); } - private void init() + protected void initForm() { try { @@ -202,11 +200,11 @@ public class WMatch extends ADForm implements EventListener, ValueChangeListener lstReceipt.setWidth("700px"); cmdSearch = new Button(); - cmdSearch.setImage("/images/FindX24.gif"); + cmdSearch.setImage("/images/FindX24.png"); cmdSearch.addEventListener(Events.ON_CLICK, this); cmdProcess = new Button(); - cmdProcess.setImage("/images/Process24.gif"); + cmdProcess.setImage("/images/Process24.png"); cmdProcess.addEventListener(Events.ON_CLICK, this); dateFrom = new Datebox(); @@ -269,6 +267,8 @@ public class WMatch extends ADForm implements EventListener, ValueChangeListener xMatchedToTable.setHeight("150px"); xMatchedToTable.getModel().addTableModelListener(this); xMatchedToTable.addEventListener(Events.ON_SELECT, this); + + initComponents(); } private void initComponents() @@ -439,26 +439,26 @@ public class WMatch extends ADForm implements EventListener, ValueChangeListener { final int AD_Column_ID = 3499; - MLookup lookupBP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupBP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); bPartnerSearch = new WSearchEditor(lookupBP, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - bPartnerSearch.addValueChangeListner(this); + bPartnerSearch.addValueChangeListener(this); } private void showProduct() { final int AD_Column_ID = 3840; - MLookup lookupP = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookupP = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); productSearch = new WSearchEditor(lookupP, Msg.translate( Env.getCtx(), "M_Product_ID"), "", true, false, true); - productSearch.addValueChangeListner(this); + productSearch.addValueChangeListener(this); } private void prepareTable() diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMerge.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMerge.java index 69d3ff1bc6..51062cb810 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMerge.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WMerge.java @@ -28,7 +28,7 @@ import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WTableDirEditor; @@ -70,7 +70,7 @@ public class WMerge extends ADForm implements EventListener, ValueChangeListener private Row row; /** Confirmation panel containing Ok and Cancel button. */ - private WConfirmPanel m_pnlConfirm; + private ConfirmPanel m_pnlConfirm; private WEditor[] from = new WEditor[4]; private WEditor[] to = new WEditor[4]; @@ -113,26 +113,25 @@ public class WMerge extends ADForm implements EventListener, ValueChangeListener public WMerge() { - init(); - initComponents(); } - public void init() + protected void initForm() { grdAll = new Grid(); grdAll.setWidth("700px"); /*btnCancel = new Button(); - btnCancel.setImage("/images/Cancel24.gif"); + btnCancel.setImage("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); btnOk = new Button(); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this);*/ - m_pnlConfirm = new WConfirmPanel(true); - m_pnlConfirm.addEventListener(this); + m_pnlConfirm = new ConfirmPanel(true); + m_pnlConfirm.addActionListener(this); + initComponents(); } public void initComponents() @@ -169,36 +168,36 @@ public class WMerge extends ADForm implements EventListener, ValueChangeListener private void components() { - MLookup lookup = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID[0], DisplayType.TableDir); from[0] = new WTableDirEditor(lookup, Msg.translate( Env.getCtx(), text[0]), "from", true, false, true); - from[0].addValueChangeListner(this); + from[0].addValueChangeListener(this); to[0] = new WTableDirEditor(lookup, Msg.translate( Env.getCtx(), text[0]), "to", true, false, true); - to[0].addValueChangeListner(this); + to[0].addValueChangeListener(this); // Search Editors for (int i = 1; i < AD_Column_ID.length; i++) { - lookup = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID[i], DisplayType.Search); from[i] = new WSearchEditor(lookup, Msg.translate( Env.getCtx(), text[i]), "from", true, false, true); - from[i].addValueChangeListner(this); + from[i].addValueChangeListener(this); to[i] = new WSearchEditor(lookup, Msg.translate( Env.getCtx(), text[i]), "to", true, false, true); - to[i].addValueChangeListner(this); + to[i].addValueChangeListener(this); } } @@ -539,11 +538,11 @@ public class WMerge extends ADForm implements EventListener, ValueChangeListener if (success) { - FDialog.info (super.m_windowNo, this, msg); + FDialog.info (m_WindowNo, this, msg); } else { - FDialog.error(super.m_windowNo, this, "MergeError", m_errorLog.toString()); + FDialog.error(m_WindowNo, this, "MergeError", m_errorLog.toString()); return; } } @@ -558,12 +557,12 @@ public class WMerge extends ADForm implements EventListener, ValueChangeListener { if (event != null) { - if (event.getName().equals(WConfirmPanel.A_CANCEL)) + if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) { SessionManager.getAppDesktop().removeWindow(); return; } - else if (event.getName().equals(WConfirmPanel.A_OK)) + else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) { process(); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayPrint.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayPrint.java index 090d56b59a..cd5c0eb8a3 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayPrint.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayPrint.java @@ -60,8 +60,6 @@ import org.zkoss.zul.Hbox; public class WPayPrint extends ADForm implements EventListener { - /** Window No */ - private int m_WindowNo = 0; /** Used Bank Account */ private int m_C_BankAccount_ID = -1; @@ -100,13 +98,11 @@ public class WPayPrint extends ADForm implements EventListener public WPayPrint() { - init(super.m_windowNo); } - public void init (int WindowNo) + protected void initForm() { log.info(""); - m_WindowNo = WindowNo; try { @@ -137,9 +133,9 @@ public class WPayPrint extends ADForm implements EventListener fPaymentRule.setRows(1); fPaymentRule.setMold("select"); - bCancel.setImage("/images/Cancel24.gif"); - bPrint.setImage("/images/Print24.gif"); - bExport.setImage("/images/ExportX24.gif"); + bCancel.setImage("/images/Cancel24.png"); + bPrint.setImage("/images/Print24.png"); + bExport.setImage("/images/ExportX24.png"); bPrint.addEventListener(Events.ON_CLICK, this); bExport.addEventListener(Events.ON_CLICK, this); @@ -626,7 +622,7 @@ public class WPayPrint extends ADForm implements EventListener { MPaySelectionCheck check = m_checks[i]; // ReportCtrl will check BankAccountDoc for PrintFormat - boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, super.m_windowNo, directPrint); + boolean ok = ReportCtl.startDocumentPrint(ReportEngine.CHECK, check.get_ID(), null, m_WindowNo, directPrint); if (!somethingPrinted && ok) somethingPrinted = true; } @@ -650,7 +646,7 @@ public class WPayPrint extends ADForm implements EventListener for (int i = 0; i < m_checks.length; i++) { MPaySelectionCheck check = m_checks[i]; - ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, super.m_windowNo, directPrint); + ReportCtl.startDocumentPrint(ReportEngine.REMITTANCE, check.get_ID(), null, m_WindowNo, directPrint); } } // remittance diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPaySelect.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPaySelect.java index 0e311f8ef0..8e7397b77b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPaySelect.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPaySelect.java @@ -123,14 +123,13 @@ public class WPaySelect extends ADForm implements EventListener, WTableModelList */ public WPaySelect() { - init(); } /** * * */ - private void init() + protected void initForm() { dataTable = new WListbox(); dataTable.setWidth("700px"); @@ -181,11 +180,11 @@ public class WPaySelect extends ADForm implements EventListener, WTableModelList lstPaymentRule.addEventListener(Events.ON_SELECT, this); refresh = new Button(); - refresh.setImage("/images/Refresh24.gif"); + refresh.setImage("/images/Refresh24.png"); refresh.addEventListener(Events.ON_CLICK, this); btnProcess = new Button(); - btnProcess.setImage("/images/Process24.gif"); + btnProcess.setImage("/images/Process24.png"); btnProcess.setEnabled(false); btnProcess.addEventListener(Events.ON_CLICK, this); @@ -277,7 +276,7 @@ public class WPaySelect extends ADForm implements EventListener, WTableModelList if (!m_ps.save()) { - FDialog.error(super.m_windowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelection_ID")); + FDialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelection_ID")); m_ps = null; return; } @@ -315,7 +314,7 @@ public class WPaySelect extends ADForm implements EventListener, WTableModelList if (!psl.save(trxName)) { - FDialog.error(this.m_windowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID")); + FDialog.error(m_WindowNo, this, "SaveError", Msg.translate(Env.getCtx(), "C_PaySelectionLine_ID")); return; } log.fine("C_Invoice_ID=" + C_Invoice_ID @@ -325,13 +324,13 @@ public class WPaySelect extends ADForm implements EventListener, WTableModelList // Ask to Post it - if (!FDialog.ask(this.m_windowNo, this, "(" + m_ps.getName() + ")")) + if (!FDialog.ask(m_WindowNo, this, "(" + m_ps.getName() + ")")) { return; } ProcessModalDialog msg = new ProcessModalDialog( - this, "Payment Selection Manual", null, this.m_windowNo, adProcessId, + this, "Payment Selection Manual", null, m_WindowNo, adProcessId, X_C_PaySelection.Table_ID, m_ps.getC_PaySelection_ID(), true); if (msg.isValid()) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayment.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayment.java index 9a640a1e2b..ed85c62661 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayment.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WPayment.java @@ -535,9 +535,9 @@ public class WPayment extends Window implements EventListener Hbox boxButtons = new Hbox(); - btnCancel.setImage("/images/Cancel24.gif"); + btnCancel.setImage("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); boxButtons.appendChild(btnCancel); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WSQLProcess.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WSQLProcess.java index 004ed3c752..888581cb79 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WSQLProcess.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WSQLProcess.java @@ -73,11 +73,8 @@ public class WSQLProcess extends ADForm implements EventListener super(); } - /* - * (non-Javadoc) - * @see org.adempiere.webui.panel.ADForm#init(int, java.lang.String) - */ - public void init(int adFormId, String name) + @Override + protected void initForm() { Row rwTop = new Row(); Row rwBottom = new Row(); @@ -87,8 +84,6 @@ public class WSQLProcess extends ADForm implements EventListener final int noStatementRows = 3; final int noResultRows = 20; - super.init(adFormId, name); - m_grdMain.setWidth("80%"); // create the top row of components @@ -133,7 +128,7 @@ public class WSQLProcess extends ADForm implements EventListener { Button btnProcess = new Button(); - btnProcess.setImage("/images/Process24.gif"); + btnProcess.setImage("/images/Process24.png"); btnProcess.setName(Msg.getMsg(Env.getCtx(), "Process")); return btnProcess; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java index f8a016aff4..395df6da42 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WTrxMaterial.java @@ -77,9 +77,6 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi { private static final long serialVersionUID = 1L; - /** Window No */ - private int m_WindowNo = 0; - /** FormFrame */ //private FormFrame m_frame; @@ -119,7 +116,6 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi public WTrxMaterial() { - init(super.m_windowNo); } /** @@ -128,10 +124,9 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi * @param frame frame */ - public void init (int WindowNo) + protected void initForm() { log.info(""); - m_WindowNo = WindowNo; try { @@ -253,22 +248,22 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi MLookup orgLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3660, DisplayType.TableDir); orgField = new WTableDirEditor(orgLookup, "AD_Org_ID", "", false, false, true); - orgField.addValueChangeListner(this); + orgField.addValueChangeListener(this); // Locator MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo); - locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_windowNo); - locatorField.addValueChangeListner(this); + locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo); + locatorField.addValueChangeListener(this); // Product MLookup productLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3668, DisplayType.Search); productField = new WSearchEditor(productLookup, "M_Product_ID", "", false, false, true); - productField.addValueChangeListner(this); + productField.addValueChangeListener(this); // Movement Type MLookup mtypeLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3666, DisplayType.List); mtypeField = new WTableDirEditor(mtypeLookup, "MovementType", "", false, false, true); - mtypeField.addValueChangeListner(this); + mtypeField.addValueChangeListener(this); // Dates dateFField = new Datebox();//"DateFrom", false, false, true, DisplayType.Date, Msg.getMsg(Env.getCtx(), "DateFrom")); @@ -360,7 +355,7 @@ public class WTrxMaterial extends ADForm implements EventListener, ValueChangeLi { if (gridfields[j].isLookup()) { - MLookup lookup = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, gridfields[j].getAD_Column_ID(), gridfields[j].getDisplayType()); NamePair namepair = lookup.get(obj); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceIndicator.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceIndicator.java index 112dc0c510..b838507436 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceIndicator.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceIndicator.java @@ -75,7 +75,7 @@ public class WPerformanceIndicator extends Panel implements EventListener private static DecimalFormat s_format = DisplayType.getNumberFormat(DisplayType.Integer); Menupopup popupMenu = new Menupopup(); - private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), "/images/Refresh16.gif"); + private Menuitem mRefresh = new Menuitem(Msg.getMsg(Env.getCtx(), "Refresh"), "/images/Refresh16.png"); //Insert Pie Graph Kinamo (pelgrim) // private static Color colorOK = Color.magenta; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java index 05b166e2ca..975637e635 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java @@ -96,20 +96,18 @@ public class WWFActivity extends ADForm implements EventListener super(); } - public void init(int adFormId, String name) + protected void initForm() { - super.init(adFormId, name); - loadActivities(); fAnswerList.setMold("select"); - bPrevious.setImage("/images/Previous16.gif"); - bNext.setImage("/images/Next16.gif"); - bZoom.setImage("/images/Zoom16.gif"); - bOK.setImage("/images/Ok24.gif"); + bPrevious.setImage("/images/Previous16.png"); + bNext.setImage("/images/Next16.png"); + bZoom.setImage("/images/Zoom16.png"); + bOK.setImage("/images/Ok24.png"); - MLookup lookup = MLookupFactory.get(Env.getCtx(), super.m_windowNo, + MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 10443, DisplayType.Search); fForward = new WSearchEditor(lookup, Msg.translate( Env.getCtx(), "AD_User_ID"), "", true, false, true); @@ -388,7 +386,7 @@ public class WWFActivity extends ADForm implements EventListener fTextMsg.setValue (""); fAnswerText.setVisible(false); fAnswerList.setVisible(false); - fAnswerButton.setImage("/images/mWindow.gif"); + fAnswerButton.setImage("/images/mWindow.png"); fAnswerButton.setVisible(false); fTextMsg.setReadonly(m_activities.length == 0); // fTextMsg.setReadWrite(m_activities.length != 0); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java index b6acc28a7b..6b18d72fb4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADButtonTabList.java @@ -1,3 +1,15 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ package org.adempiere.webui.component; import java.util.ArrayList; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADTabListModel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADTabListModel.java index 33354cffcc..a8044162c1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADTabListModel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ADTabListModel.java @@ -1,3 +1,15 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ package org.adempiere.webui.component; import java.util.List; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ButtonFactory.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ButtonFactory.java deleted file mode 100644 index 4b2f52c92a..0000000000 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ButtonFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.adempiere.webui.component; - -import org.compiere.util.Env; -import org.compiere.util.Msg; - -public class ButtonFactory { - - public static Button createButton(String action, String label) { - Button button = new Button(); - button.setId(action); - button.setImage("images/" + action + "16.gif"); - if (label == null) { - label = Msg.getMsg(Env.getCtx(), action); - if (label != null && !label.equals(action)) { - label = label.replaceAll("[&]", ""); - button.setLabel(label); - } - } - - return button; - } -} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java index 94a74406d4..2d5c36d982 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java @@ -86,130 +86,130 @@ public class CWindowToolbar extends FToolbar implements EventListener btnIgnore = new ToolBarButton(); btnIgnore.setName("btnIgnore"); - btnIgnore.setImage("/images/Ignore16.gif"); + btnIgnore.setImage("/images/Ignore16.png"); btnIgnore.setTooltiptext(Msg.getMsg(Env.getCtx(),"Ignore")); // -- btnHelp = new ToolBarButton(""); btnHelp.setName("btnHelp"); - btnHelp.setImage("/images/Help24.gif"); + btnHelp.setImage("/images/Help24.png"); btnHelp.setTooltiptext(Msg.getMsg(Env.getCtx(),"Help")); btnNew = new ToolBarButton(""); btnNew.setName("btnNew"); - btnNew.setImage("/images/New24.gif"); + btnNew.setImage("/images/New24.png"); btnNew.setTooltiptext(Msg.getMsg(Env.getCtx(),"New")); btnDelete = new ToolBarButton(""); btnDelete.setName("btnDelete"); - btnDelete.setImage("/images/Delete24.gif"); + btnDelete.setImage("/images/Delete24.png"); btnDelete.setTooltiptext(Msg.getMsg(Env.getCtx(),"Delete")); btnSave = new ToolBarButton(""); btnSave.setName("btnSave"); - btnSave.setImage("/images/Save24.gif"); + btnSave.setImage("/images/Save24.png"); btnSave.setTooltiptext(Msg.getMsg(Env.getCtx(),"Save")); // -- btnRefresh = new ToolBarButton(""); btnRefresh.setName("btnRefresh"); - btnRefresh.setImage("/images/Refresh24.gif"); + btnRefresh.setImage("/images/Refresh24.png"); btnRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(),"Refresh")); btnFind = new ToolBarButton(""); btnFind.setName("btnFind"); - btnFind.setImage("/images/Find24.gif"); + btnFind.setImage("/images/Find24.png"); btnFind.setTooltiptext(Msg.getMsg(Env.getCtx(),"Find")); btnAttachment = new ToolBarButton(""); btnAttachment.setName("btnAttachment"); - btnAttachment.setImage("/images/Attachment24.gif"); + btnAttachment.setImage("/images/Attachment24.png"); btnAttachment.setTooltiptext(Msg.getMsg(Env.getCtx(),"Attachment")); // -- btnGridToggle = new ToolBarButton(""); btnGridToggle.setName("btnGridToggle"); - btnGridToggle.setImage("/images/Multi24.gif"); + btnGridToggle.setImage("/images/Multi24.png"); btnGridToggle.setTooltiptext(Msg.getMsg(Env.getCtx(),"Multi")); btnHistoryRecords = new ToolBarButton(""); btnHistoryRecords.setName("btnHistoryRecords"); - btnHistoryRecords.setImage("/images/HistoryX24.gif"); + btnHistoryRecords.setImage("/images/HistoryX24.png"); btnHistoryRecords.setTooltiptext(Msg.getMsg(Env.getCtx(),"History")); btnMenu = new ToolBarButton(""); btnMenu.setName("btnHome"); - btnMenu.setImage("/images/Home24.gif"); + btnMenu.setImage("/images/Home24.png"); btnMenu.setTooltiptext(Msg.getMsg(Env.getCtx(),"Home")); btnParentRecord = new ToolBarButton(""); btnParentRecord.setName("btnParentRecord"); - btnParentRecord.setImage("/images/Parent24.gif"); + btnParentRecord.setImage("/images/Parent24.png"); btnParentRecord.setTooltiptext(Msg.getMsg(Env.getCtx(),"Parent")); btnDetailRecord = new ToolBarButton(""); btnDetailRecord.setName("btnDetailRecord"); - btnDetailRecord.setImage("/images/Detail24.gif"); + btnDetailRecord.setImage("/images/Detail24.png"); btnDetailRecord.setTooltiptext(Msg.getMsg(Env.getCtx(),"Detail")); // -- btnFirst = new ToolBarButton(""); btnFirst.setName("btnFirst"); - btnFirst.setImage("/images/First24.gif"); + btnFirst.setImage("/images/First24.png"); btnFirst.setTooltiptext(Msg.getMsg(Env.getCtx(),"First")); btnPrevious = new ToolBarButton(""); btnPrevious.setName("btnPrevious"); - btnPrevious.setImage("/images/Previous24.gif"); + btnPrevious.setImage("/images/Previous24.png"); btnPrevious.setTooltiptext(Msg.getMsg(Env.getCtx(),"Previous")); btnNext = new ToolBarButton(""); btnNext.setName("btnNext"); - btnNext.setImage("/images/Next24.gif"); + btnNext.setImage("/images/Next24.png"); btnNext.setTooltiptext(Msg.getMsg(Env.getCtx(),"Next")); btnLast = new ToolBarButton(""); btnLast.setName("btnLast"); - btnLast.setImage("/images/Last24.gif"); + btnLast.setImage("/images/Last24.png"); btnLast.setTooltiptext(Msg.getMsg(Env.getCtx(),"Last")); // -- btnReport = new ToolBarButton(""); btnReport.setName("btnReport"); - btnReport.setImage("/images/Report24.gif"); + btnReport.setImage("/images/Report24.png"); btnReport.setTooltiptext(Msg.getMsg(Env.getCtx(),"Report")); btnArchive = new ToolBarButton(""); btnArchive.setName("btnArchive"); - btnArchive.setImage("/images/Archive24.gif"); + btnArchive.setImage("/images/Archive24.png"); btnArchive.setTooltiptext(Msg.getMsg(Env.getCtx(),"Archive")); btnPrint = new ToolBarButton(""); btnPrint.setName("btnPrint"); - btnPrint.setImage("/images/Print24.gif"); + btnPrint.setImage("/images/Print24.png"); btnPrint.setTooltiptext(Msg.getMsg(Env.getCtx(),"Print")); // -- btnZoomAcross = new ToolBarButton(""); btnZoomAcross.setName("btnZoomAcross"); - btnZoomAcross.setImage("/images/ZoomAcross24.gif"); + btnZoomAcross.setImage("/images/ZoomAcross24.png"); btnZoomAcross.setTooltiptext(Msg.getMsg(Env.getCtx(),"ZoomAcross")); btnActiveWorkflows = new ToolBarButton(""); btnActiveWorkflows.setName("btnActiveWorkflows"); - btnActiveWorkflows.setImage("/images/WorkFlow24.gif"); + btnActiveWorkflows.setImage("/images/WorkFlow24.png"); btnActiveWorkflows.setTooltiptext(Msg.getMsg(Env.getCtx(),"WorkFlow")); btnRequests = new ToolBarButton(""); btnRequests.setName("btnRequests"); - btnRequests.setImage("/images/Request24.gif"); + btnRequests.setImage("/images/Request24.png"); btnRequests.setTooltiptext(Msg.getMsg(Env.getCtx(),"Request")); btnProductInfo = new ToolBarButton(""); btnProductInfo.setName("btnProductInfo"); - btnProductInfo.setImage("/images/Product24.gif"); + btnProductInfo.setImage("/images/Product24.png"); btnProductInfo.setTooltiptext(Msg.getMsg(Env.getCtx(),"InfoProduct")); // btnExit = new ToolBarButton(""); // btnExit.setName("btnExit"); -// btnExit.setImage("/images/End24.gif"); +// btnExit.setImage("/images/End24.png"); this.appendChild(btnIgnore); addSeparator(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combinationbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combinationbox.java index e61f7f79ae..ecc1c31311 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combinationbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combinationbox.java @@ -1,6 +1,5 @@ /****************************************************************************** - * Product: Posterita Ajax UI * - * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * + * Copyright (C) 2008 Low Heng Sin * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * @@ -10,9 +9,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ package org.adempiere.webui.component; @@ -21,7 +17,9 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zul.Hbox; /** - * URL Box + * + * @author Low Heng Sin + * */ public class Combinationbox extends Hbox { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java index cfc32cec32..1ae259faf6 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ConfirmPanel.java @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import org.adempiere.webui.LayoutUtils; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Hbox; @@ -37,9 +38,35 @@ public final class ConfirmPanel extends Hbox private static final long serialVersionUID = 1L; - public static final String A_OK = "Ok"; + /** Action String OK. */ + public static final String A_OK = "Ok"; + /** Action String Cancel. */ + public static final String A_CANCEL = "Cancel"; + /** Action String Refresh. */ + public static final String A_REFRESH = "Refresh"; + /** Action String Reset. */ + public static final String A_RESET = "Reset"; + /** Action String Customize. */ + public static final String A_CUSTOMIZE = "Customize"; + /** Action String History. */ + public static final String A_HISTORY = "History"; + /** Action String Zoom. */ + public static final String A_ZOOM = "Zoom"; - public static final String A_CANCEL = "Cancel"; + /** Action String Process. */ + public static final String A_PROCESS = "Process"; + /** Action String Print. */ + public static final String A_PRINT = "Print"; + /** Action String Export. */ + public static final String A_EXPORT = "Export"; + /** Action String Help. */ + public static final String A_HELP = "Help"; + /** Action String Delete. */ + public static final String A_DELETE = "Delete"; + /** Action String PAttribute. */ + public static final String A_PATTRIBUTE = "PAttribute"; + /** Action String New. */ + public static final String A_NEW = "New"; private Map buttonMap = new HashMap(); @@ -71,7 +98,9 @@ public final class ConfirmPanel extends Hbox Button button = new Button(); button.setName("btn"+name); button.setId(name); - button.setSrc("images/"+name+"24.gif"); + button.setSrc("images/"+name+"24.png"); + + LayoutUtils.addSclass("action-button", button); buttonMap.put(name, button); @@ -96,29 +125,29 @@ public final class ConfirmPanel extends Hbox { init(); - setVisible("Cancel", withCancelButton); - addComponentsRight(createButton("Ok")); - addComponentsRight(createButton("Cancel")); + setVisible(A_CANCEL, withCancelButton); + addComponentsRight(createButton(A_OK)); + addComponentsRight(createButton(A_CANCEL)); if (withRefreshButton) { - addComponentsLeft(createButton("Refresh")); + addComponentsLeft(createButton(A_REFRESH)); } if (withResetButton) { - addComponentsLeft(createButton("Reset")); + addComponentsLeft(createButton(A_RESET)); } if (withCustomizeButton) { - addComponentsLeft(createButton("Customize")); + addComponentsLeft(createButton(A_CUSTOMIZE)); } if (withHistoryButton) { - addComponentsLeft(createButton("History")); + addComponentsLeft(createButton(A_HISTORY)); } if (withZoomButton) { - addComponentsLeft(createButton("Zoom")); + addComponentsLeft(createButton(A_ZOOM)); } } @@ -178,6 +207,8 @@ public final class ConfirmPanel extends Hbox */ public void addComponentsLeft(Button button) { + if (!buttonMap.containsKey(button.getId())) + buttonMap.put(button.getId(), button); pnlBtnLeft.appendChild(button); } @@ -187,6 +218,8 @@ public final class ConfirmPanel extends Hbox */ public void addComponentsRight(Button button) { + if (!buttonMap.containsKey(button.getId())) + buttonMap.put(button.getId(), button); pnlBtnRight.appendChild(button); } @@ -380,7 +413,7 @@ public final class ConfirmPanel extends Hbox * @return Button */ public Button getOKButton() { - return getButton("Ok"); + return getButton(A_OK); } } // ConfirmPanel diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/DesktopTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/DesktopTabpanel.java new file mode 100644 index 0000000000..4c7aedcb19 --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/DesktopTabpanel.java @@ -0,0 +1,29 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ +package org.adempiere.webui.component; + +import org.zkoss.zk.ui.IdSpace; + +/** + * Tabpanel use by desktop to host AD Window, implements IdSpace to avoid Id conflict + * @author Low Heng Sin + * + */ +public class DesktopTabpanel extends Tabpanel implements IdSpace { + + /** + * generated serail version id + */ + private static final long serialVersionUID = -7142048018260264752L; + +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridFactory.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridFactory.java index a9a494c5d9..b9cb29ecc0 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridFactory.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridFactory.java @@ -1,7 +1,28 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ package org.adempiere.webui.component; +/** + * + * @author Low Heng Sin + * + */ public class GridFactory { + /** + * New instance of grid for form layout + * @return Grid + */ public static Grid newGridLayout() { Grid grid = new Grid(); grid.makeNoStrip(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java index 54c46845b4..9985c2f6c6 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java @@ -37,6 +37,11 @@ import org.zkoss.zul.ListitemRenderer; import org.zkoss.zul.Paging; import org.zkoss.zul.event.ZulEvents; +/** + * + * @author Low Heng Sin + * + */ public class GridPanel extends Borderlayout implements EventListener { private static final int MIN_COLUMN_WIDTH = 100; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java index a8fc576b4c..0a5cca6cf2 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Label.java @@ -41,7 +41,7 @@ public class Label extends org.zkoss.zul.Label public Label(String value) { - super(value); + super(value != null ? value.replaceAll("[&]", "") : null); } public boolean isMandatory() { @@ -59,7 +59,7 @@ public class Label extends org.zkoss.zul.Label @Override public void setValue(String value) { - super.setValue(value); + super.setValue(value != null ? value.replaceAll("[&]", "") : null); setupMandatoryDecorator(); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ListboxFactory.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ListboxFactory.java index 7af4605504..493a194900 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ListboxFactory.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ListboxFactory.java @@ -1,13 +1,38 @@ +/****************************************************************************** + * Copyright (C) 2008 Low Heng Sin * + * This program is free software; you can redistribute it and/or modify it * + * under the terms version 2 of the GNU General Public License as published * + * by the Free Software Foundation. This program is distributed in the hope * + * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * + * See the GNU General Public License for more details. * + * You should have received a copy of the GNU General Public License along * + * with this program; if not, write to the Free Software Foundation, Inc., * + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * + *****************************************************************************/ package org.adempiere.webui.component; +/** + * + * @author Low Heng Sin + * + */ public class ListboxFactory { + /** + * Create new listbox instance that is in combo mode + * @return Listbox + */ public static Listbox newDropdownListbox() { Listbox listbox = new Listbox(); listbox.setMold("select"); return listbox; } + /** + * Create new data table instance for use in custom form. + * @return WListbox + */ public static WListbox newDataTable() { WListbox dataTable = new WListbox(); dataTable.setWidth("100%"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Messagebox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Messagebox.java index 6fde70cefd..2888c25362 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Messagebox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Messagebox.java @@ -101,19 +101,19 @@ public class Messagebox extends Window implements EventListener lblMsg.setValue(msg); btnOk.setLabel("OK"); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); btnCancel.setLabel("Cancel"); - btnCancel.setImage("/images/Cancel24.gif"); + btnCancel.setImage("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); btnYes.setLabel("Yes"); - btnYes.setImage("/images/Ok24.gif"); + btnYes.setImage("/images/Ok24.png"); btnYes.addEventListener(Events.ON_CLICK, this); btnNo.setLabel("No"); - btnNo.setImage("/images/Cancel24.gif"); + btnNo.setImage("/images/Cancel24.png"); btnNo.addEventListener(Events.ON_CLICK, this); btnAbort.setLabel("Abort"); @@ -125,7 +125,7 @@ public class Messagebox extends Window implements EventListener btnRetry.addEventListener(Events.ON_CLICK, this); btnIgnore.setLabel("Ignore"); - btnIgnore.setImage("/images/Ignore24.gif"); + btnIgnore.setImage("/images/Ignore24.png"); btnIgnore.addEventListener(Events.ON_CLICK, this); Panel pnlMessage = new Panel(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/NumberBox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/NumberBox.java index 8d8b5b6c1f..6ce1719493 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/NumberBox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/NumberBox.java @@ -50,7 +50,7 @@ public class NumberBox extends Bandbox private void init() { - this.setImage("/images/Calculator16.gif"); + this.setImage("/images/Calculator16.png"); this.setAction("onKeyPress : return calc.validate('" + this.getId() + "'," + integral + ", event);"); this.appendChild(getBandPopup()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java index 0bae06571a..1e3cf9eeba 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java @@ -52,4 +52,9 @@ public class ToolBarButton extends org.zkoss.zul.Toolbarbutton public void setName(String name) { this.name = name; } + + @Override + public void setTooltiptext(String tooltiptext) { + super.setTooltiptext(tooltiptext != null ? tooltiptext.replaceAll("[&]", "") : null); + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WAppsAction.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/WAppsAction.java index ddecd93d6b..b1f73eafa1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WAppsAction.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/WAppsAction.java @@ -17,28 +17,23 @@ package org.adempiere.webui.component; -import java.awt.Dimension; import java.io.IOException; import java.net.URI; +import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.apps.AEnv; import org.compiere.util.Env; import org.compiere.util.Msg; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; - - /** * Application Action. - * Creates Action with MenuItem and Button, delegate execution of action to an attached ActionListener instance + * Creates Action with Button * The ActionCommand is translated for display * If translated text contains &, the next character is the Mnemonic * * @author Andrew Kimball */ -public class WAppsAction implements EventListener +public class WAppsAction { /** * @@ -88,7 +83,6 @@ public class WAppsAction implements EventListener int pos = newToolTipText.indexOf('&'); if (pos != -1 && newToolTipText.length() > pos) // We have a nemonic - creates ALT-_ { - // TODO create mnemonic Character ch = new Character(newToolTipText.toLowerCase().charAt(pos + 1)); if (ch != ' ') { @@ -100,38 +94,31 @@ public class WAppsAction implements EventListener } } // - //Image small = getImage(action, true); URI large = getImage(action, false); - //Image largePressed = null; - - // Attributes - - m_button = new Button(); - - m_button.setTooltiptext(newToolTipText); // Display // Create Button - - m_button.setName(action); - // Correcting Action items + m_button = new Button(); + m_button.setTooltiptext(newToolTipText); // Display + m_button.setName("btn" + action); + m_button.setId(action); + + //Image only if image is available if (large != null) { m_button.setImage(large.getPath()); - //m_button.setImage("/images/Cancel16.gif"); m_button.setLabel(null); } - m_button.setWidth(Integer.toString(Double.valueOf(BUTTON_SIZE.getWidth()).intValue())); - m_button.setHeight(Integer.toString(Double.valueOf(BUTTON_SIZE.getHeight()).intValue())); + else + { + m_button.setLabel(newToolTipText); + } + LayoutUtils.addSclass("action-button", m_button); } // Action - - /** Button Size */ - public static final Dimension BUTTON_SIZE = new Dimension(28,28); - /** CButton or CToggelButton */ + private Button m_button; private String m_action = null; private String m_accelerator = null; - private EventListener m_delegate = null; /** * Get Icon with name action @@ -142,7 +129,7 @@ public class WAppsAction implements EventListener private URI getImage(String name, boolean small) throws IOException { String fullName = name + (small ? "16" : "24"); - URI uri = AEnv.getImage2(fullName); + URI uri = AEnv.getImage(fullName + ".png"); return uri; } // getIcon @@ -165,44 +152,6 @@ public class WAppsAction implements EventListener } // getButton - /** - * Set Delegate to receive the actionPerformed calls - * @param listener listener - * @throws IllegalArgumentException if the listener is not a window. This - * exception can be ignored as events will still be fired for button presses. - */ - public void setDelegate(EventListener listener) throws IllegalArgumentException - { - m_button.addEventListener(Events.ON_CLICK, this); - m_delegate = listener; - - if (listener instanceof Window) - { - ((Window) listener).setCtrlKeys(this.m_accelerator); - ((Window) listener).addEventListener(Events.ON_CTRL_KEY, this); - } - else - { - throw new IllegalArgumentException("Functionality has been restricted. " - + " as a result of the listener not being a Window. " - + "Consequently, it is unable to respond to keystrokes"); - } - - return; - } // setDelegate - - /* (non-Javadoc) - * @see org.zkoss.zk.ui.event.EventListener#onEvent(org.zkoss.zk.ui.event.Event) - */ - public void onEvent(Event event) throws Exception - { - // TODO Auto-generated method stub - Event newEvent = new Event(this.m_action, event.getTarget()); - m_delegate.onEvent(newEvent); - - return; - } - public String getCtrlKeys() { return this.m_accelerator; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WConfirmPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/WConfirmPanel.java deleted file mode 100644 index 7ea2961623..0000000000 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WConfirmPanel.java +++ /dev/null @@ -1,652 +0,0 @@ -/****************************************************************************** - * Product: Posterita Ajax UI * - * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * - *****************************************************************************/ - -package org.adempiere.webui.component; - -import java.io.IOException; -import java.util.logging.Level; - -import org.compiere.util.CLogger; -import org.compiere.util.Env; -import org.compiere.util.Msg; -import org.zkoss.zk.ui.event.Event; -import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zk.ui.event.Events; - -/** - * @author Andrew Kimball - * - */ -public class WConfirmPanel extends Panel implements EventListener -{ - /** Action String OK. */ - public static final String A_OK = "Ok"; - /** Action String Cancel. */ - public static final String A_CANCEL = "Cancel"; - /** Action String Refresh. */ - public static final String A_REFRESH = "Refresh"; - /** Action String Reset. */ - public static final String A_RESET = "Reset"; - /** Action String Customize. */ - public static final String A_CUSTOMIZE = "Customize"; - /** Action String History. */ - public static final String A_HISTORY = "History"; - /** Action String Zoom. */ - public static final String A_ZOOM = "Zoom"; - - /** Action String Process. */ - public static final String A_PROCESS = "Process"; - /** Action String Print. */ - public static final String A_PRINT = "Print"; - /** Action String Export. */ - public static final String A_EXPORT = "Export"; - /** Action String Help. */ - public static final String A_HELP = "Help"; - /** Action String Delete. */ - public static final String A_DELETE = "Delete"; - /** Action String PAttribute. */ - public static final String A_PATTRIBUTE = "PAttribute"; - /** Action String New. */ - public static final String A_NEW = "New"; - - /** Logger. */ - private static CLogger log = CLogger.getCLogger(WConfirmPanel.class); - - - /** Cancel action. */ - private WAppsAction m_actionCancel; - private WAppsAction m_actionOk; - - private WAppsAction m_actionRefresh; - private WAppsAction m_actionReset; - private WAppsAction m_actionCustomize; - private WAppsAction m_actionHistory; - private WAppsAction m_actionZoom; - - /** - * Create Confirmation Panel with OK Button. - */ - public WConfirmPanel() - { - this (false, false, false, false, false, false, true); - } // ConfirmPanel - - - /** - * Create Confirmation Panel with OK and Cancel Button. - * @param withCancelButton with cancel - */ - public WConfirmPanel(boolean withCancelButton) - { - this(withCancelButton, false, false, false, false, false, true); - } - - /** - * Create Confirmation Panel with different buttons. - * @param withCancelButton with cancel - * @param withRefreshButton with refresh - * @param withResetButton with reset - * @param withCustomizeButton with customize - * @param withHistoryButton with history - * @param withZoomButton with zoom - * @param withText with tool tip text - */ - public WConfirmPanel(boolean withCancelButton, - boolean withRefreshButton, - boolean withResetButton, - boolean withCustomizeButton, - boolean withHistoryButton, - boolean withZoomButton, - boolean withText) - { - Panel pnlOkCancel = new Panel(); - Button button; - - try - { - - this.setAlign("right"); - - // Cancel - m_actionCancel = createCancelButton(withText); - Button btnCancel = m_actionCancel.getButton(); - setCancelVisible(btnCancel, withCancelButton); - pnlOkCancel.appendChild(btnCancel); - - // OK - m_actionOk = createOKButton(withText); - Button btnOk = m_actionOk.getButton(); - pnlOkCancel.appendChild(btnOk); - - this.appendChild(pnlOkCancel); - - // - if (withRefreshButton) - { - m_actionRefresh = createRefreshButton(withText); - Button btnRefresh = m_actionRefresh.getButton(); - this.appendChild(btnRefresh); - } - if (withResetButton) - { - m_actionReset = createResetButton(withText); - Button btnReset = m_actionReset.getButton(); - this.appendChild(btnReset); - } - if (withCustomizeButton) - { - m_actionCustomize = createCustomizeButton(withText); - Button btnCustomize = m_actionCustomize.getButton(); - this.appendChild(btnCustomize); - } - if (withHistoryButton) - { - m_actionHistory = createHistoryButton(withText); - Button btnHistory = m_actionHistory.getButton(); - this.appendChild(btnHistory); - } - if (withZoomButton) - { - m_actionZoom = createZoomButton(withText); - Button btnZoom = m_actionZoom.getButton(); - this.appendChild(btnZoom); - } - } - catch(Exception exception) - { - log.log(Level.WARNING, "Failed to correctly create Confirmation Panel:" - + exception.getMessage()); - } - } // ConfirmPanel - - /** - * Create OK Button with Standard text. - * @param withText with text - * @return OK Button - */ - public static final WAppsAction createOKButton (boolean withText) throws IOException - { - if (withText) - { - return createOKButton(Msg.getMsg(Env.getCtx(), A_OK)); - } - return createOKButton(""); - } // createOKButton - - /** - * Create OK Button with label text and F4 Shortcut. - * @param text text - * @return OK Button - */ - public static final WAppsAction createOKButton (String text) throws IOException - { - final String specialKey = "#f2"; - WAppsAction aa = new WAppsAction(A_OK, specialKey, text); - return aa; - } // createOKButton - - /** - * Create Cancel Button wlth label text and register ESC as KeyStroke. - * @param text text - * @return Cancel Button - */ - public static final WAppsAction createCancelButton(String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_CANCEL, null, text); - return aa; - } // createCancelButton - - /** - * Create Cancel Button wlth Standard text. - * @param withText with text - * @return Button - */ - public static final WAppsAction createCancelButton(boolean withText) throws IOException - { - if (withText) - { - return createCancelButton(Msg.getMsg(Env.getCtx(), A_CANCEL)); - } - return createCancelButton(""); - } // createCancelButton - - - - /** - * Create Refresh Button wlth label text and F5. - * @param text text - * @return button - */ - public static final WAppsAction createRefreshButton (String text) throws IOException - { - final String specialKey = "#f5"; - - WAppsAction aa = new WAppsAction(A_REFRESH, specialKey, text); - - return aa; - } // createRefreshButton - - /** - * Create Refresh Button wlth Standard text. - * @param withText with text - * @return Button - */ - public static final WAppsAction createRefreshButton (boolean withText) throws IOException - { - if (withText) - { - return createRefreshButton(Msg.getMsg(Env.getCtx(), A_REFRESH)); - } - return createRefreshButton(""); - } // createRefreshButton - - - /** - * Create Reset Button wlth label text. - * @param text text - * @return button - */ - public static final WAppsAction createResetButton (String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_RESET, null, text); - - return aa; - } // createResetButton - - /** - * Create Reset Button wlth Standard text. - * @param withText with text - * @return Button - */ - public static final WAppsAction createResetButton (boolean withText) throws IOException - { - if (withText) - { - return createResetButton(Msg.getMsg(Env.getCtx(), A_RESET)); - } - return createResetButton(null); - } // createRefreshButton - - /** - * Create Customize Button wlth label text. - * @param text text - * @return button - */ - public static final WAppsAction createCustomizeButton (String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_CUSTOMIZE, null, text); - - return aa; - // Env.getImageIcon("Preference24.gif")); - } // createCustomizeButton - - /** - * Create Customize Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createCustomizeButton (boolean withText) throws IOException - { - if (withText) - { - return createCustomizeButton(Msg.getMsg(Env.getCtx(), A_CUSTOMIZE)); - } - return createCustomizeButton(null); - } // createCustomizeButton - - - /** - * Create History Button wlth label text. - * @param text text - * @return aa - */ - public static final WAppsAction createHistoryButton (String text) throws IOException - { - final String specialKey = "#f9"; - WAppsAction aa = new WAppsAction(A_HISTORY, specialKey, text); - - return aa; - } // createHistoryButton - - /** - * Create History Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createHistoryButton (boolean withText) throws IOException - { - if (withText) - { - return createHistoryButton(Msg.getMsg(Env.getCtx(), A_HISTORY)); - } - return createHistoryButton(null); - } // createHistoryButton - - - /** - * Create Zoom Button wlth label text. - * @param text text - * @return aa - */ - public static final WAppsAction createZoomButton (String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_ZOOM, null, text); - - return aa; - } // createZoomButton - - /** - * Create Zoom Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createZoomButton (boolean withText) throws IOException - { - if (withText) - { - return createZoomButton(Msg.getMsg(Env.getCtx(), A_ZOOM)); - } - return createZoomButton(null); - } // createZoomButton - - - /** - * Create Process Button wlth label text Shift-F4. - * @param text text - * @return aa - */ - public static final WAppsAction createProcessButton (String text) throws IOException - { - // Shift-F4 - final String specialKey = "$#f4"; - WAppsAction aa = new WAppsAction(A_PROCESS, specialKey, text); - - return aa; - } // createProcessButton - - /** - * Create Process Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createProcessButton (boolean withText) throws IOException - { - if (withText) - { - return createProcessButton(Msg.getMsg(Env.getCtx(), A_PROCESS)); - } - return createProcessButton(null); - } // createProcessButton - - - /** - * Create Print Button wlth label text. - * @param text text - * @return aa - */ - public static final WAppsAction createPrintButton (String text) throws IOException - { - final String specialKey = "#f12"; - WAppsAction aa = new WAppsAction(A_PRINT, specialKey, text); - - return aa; - } // createPrintButton - - /** - * Create Print Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createPrintButton (boolean withText) throws IOException - { - if (withText) - { - return createPrintButton(Msg.getMsg(Env.getCtx(), A_PRINT)); - } - return createPrintButton(null); - } // createPrintButton - - - /** - * Create Help Button wlth label text. - * @param text text - * @return aa - */ - public static final WAppsAction createHelpButton (String text) throws IOException - { - final String specialKey = "#f1"; - WAppsAction aa = new WAppsAction(A_HELP, specialKey, text); - - return aa; - } // createHelpButton - - /** - * Create Help Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createHelpButton (boolean withText) throws IOException - { - if (withText) - { - return createHelpButton(Msg.getMsg(Env.getCtx(), A_HELP)); - } - return createHelpButton(null); - } // createHelpButton - - - /** - * Create Export Button wlth label text. - * @param text text - * @return aa - */ - public static final WAppsAction createExportButton (String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_EXPORT, null, text); - - return aa; - } // createExportButton - - /** - * Create Export Button wlth Standard text. - * @param withText with text - * @return aa - */ - public static final WAppsAction createExportButton (boolean withText) throws IOException - { - if (withText) - { - return createExportButton(Msg.getMsg(Env.getCtx(), A_EXPORT)); - } - return createExportButton(null); - } // createExportButton - - - /************************ - * Create Delete Button with label text - F3. - * @param text text - * @return Delete Button - */ - public static final WAppsAction createDeleteButton (String text) throws IOException - { - final String specialKey = "#f3"; - WAppsAction aa = new WAppsAction(A_DELETE, specialKey, text); - - return aa; - } // createDeleteButton - - /** - * Create Delete Button with Standard text. - * @param withText with text - * @return Delete Button - */ - public static final WAppsAction createDeleteButton (boolean withText) throws IOException - { - if (withText) - { - return createDeleteButton(Msg.getMsg(Env.getCtx(), A_DELETE)); - } - return createDeleteButton(null); - } // createDeleteButton - - - /************************ - * Create Product Attribute Button with Standard text. - * @param withText with text - * @return Product Attribute Button - */ - public static final WAppsAction createPAttributeButton (boolean withText) throws IOException - { - if (withText) - { - return createPAttributeButton(Msg.getMsg(Env.getCtx(), A_PATTRIBUTE)); - } - return createPAttributeButton(null); - } // createPAttributeButton - - /** - * Create Product Attribute Button with label text. - * @param text text - * @return Product Attribute Button - */ - public static final WAppsAction createPAttributeButton (String text) throws IOException - { - WAppsAction aa = new WAppsAction(A_PATTRIBUTE, null, text); - - return aa; - } // createPAttributeButton - - - /** - * Create New Button with Standard text. - * @param withText with text - * @return New Button - */ - public static final WAppsAction createNewButton (boolean withText) throws IOException - { - if (withText) - { - return createNewButton(Msg.getMsg(Env.getCtx(), A_NEW)); - } - return createNewButton(null); - } // createNewButton - - /** - * Create New Button with label text - F2. - * @param text text - * @return Product Attribute Button - */ - public static final WAppsAction createNewButton (String text) throws IOException - { - final String specialKey = "#f2"; - WAppsAction aa = new WAppsAction(A_NEW, specialKey, text); - - return aa; - } // createNewButton - - /** - * Show Cancel button. - * @param value trie for visible - */ - public void setCancelVisible (Button button, boolean value) - { - button.setVisible(value); - button.setEnabled(value); - } - - /** - * Add Event Listener. - * - * if (e.getActionCommand().equals(ConfirmPanel.A_OK)) - * - * In order to respond to keystrokes, the EventListener - * should be a Window. If the listener is not a window - * the panel will only respond to onClick events. - * - * @param listener the event listener - */ - public void addEventListener(EventListener listener) - { - String ctrlKeys = ""; - try - { - m_actionOk.setDelegate(listener); - ctrlKeys += m_actionOk.getCtrlKeys(); - m_actionCancel.setDelegate(listener); - ctrlKeys += m_actionCancel.getCtrlKeys(); - // - if (m_actionRefresh != null) - { - m_actionRefresh.setDelegate(listener); - ctrlKeys += m_actionRefresh.getCtrlKeys(); - } - if (m_actionReset != null) - { - m_actionReset.setDelegate(listener); - ctrlKeys += m_actionReset.getCtrlKeys(); - } - if (m_actionCustomize != null) - { - m_actionCustomize.setDelegate(listener); - ctrlKeys += m_actionCustomize.getCtrlKeys(); - } - if (m_actionHistory != null) - { - m_actionHistory.setDelegate(listener); - ctrlKeys += m_actionHistory.getCtrlKeys(); - } - if (m_actionZoom != null) - { - m_actionZoom.setDelegate(listener); - ctrlKeys += m_actionZoom.getCtrlKeys(); - } - } - catch (IllegalArgumentException exception) - { - log.warning(exception.getMessage()); - } - - // Set OK as default Button - // and Cancel as cancel button - if (listener instanceof Window) - { - ((Window) listener).addEventListener(Events.ON_CANCEL, m_actionCancel); - ((Window) listener).addEventListener(Events.ON_OK, m_actionOk); - // TODO enable Ctrl Keys - //((Window) listener).setCtrlKeys(ctrlKeys); - //((Window) listener).addEventListener(Events.ON_CTRL_KEY, this); - } - else - { - log.warning("Functionality of the Confirmation Panel has been restricted. " - + " as a result of the specified listener not being a Window. " - + "Consequently, it is unable to respond to keystrokes"); - } - } // addActionListener - - /* (non-Javadoc) - * @see org.zkoss.zk.ui.event.EventListener#onEvent(org.zkoss.zk.ui.event.Event) - */ - public void onEvent(Event event) throws Exception - { - // TODO Auto-generated method stub - - } - - - -} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WStatusBar.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/WStatusBar.java index 6be26261ba..72eaa4903c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/WStatusBar.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/WStatusBar.java @@ -130,7 +130,6 @@ public class WStatusBar extends Grid implements EventListener */ } statusLine.setValue(mt_text); // - Thread.yield(); } // setStatusLine /** diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java index ee6db4d743..2288485b8e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAccountEditor.java @@ -48,7 +48,7 @@ public class WAccountEditor extends WEditor public WAccountEditor(GridField gridField) { super(new Combinationbox(), gridField); - getComponent().setButtonImage("/images/Account16.gif"); + getComponent().setButtonImage("/images/Account16.png"); m_mAccount = new MAccountLookup (gridField.getVO().ctx, gridField.getWindowNo()); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java index bc2ed9fa95..c9b4b9df5c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WAssignmentEditor.java @@ -38,7 +38,7 @@ public class WAssignmentEditor extends WEditor { private void initComponents() { getComponent().getTextBox().setReadonly(true); - getComponent().setButtonImage("images/Assignment10.gif"); + getComponent().setButtonImage("images/Assignment10.png"); getComponent().addEventListener(Events.ON_CLICK, this); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java index a4c538ffbc..395374cb10 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WButtonEditor.java @@ -107,28 +107,28 @@ public class WButtonEditor extends WEditor { readReference(195); // this.setForeground(Color.blue); - getComponent().setImage("/images/Payment16.gif"); // 29*14 + getComponent().setImage("/images/Payment16.png"); // 29*14 } else if (columnName.equals("DocAction")) { readReference(135); // this.setForeground(Color.blue); - getComponent().setImage("/images/Process16.gif"); // 16*16 + getComponent().setImage("/images/Process16.png"); // 16*16 } else if (columnName.equals("CreateFrom")) { - getComponent().setImage("/images/Copy16.gif"); // 16*16 + getComponent().setImage("/images/Copy16.png"); // 16*16 } else if (columnName.equals("Record_ID")) { - getComponent().setImage("/images/Zoom16.gif"); // 16*16 + getComponent().setImage("/images/Zoom16.png"); // 16*16 getComponent().setLabel(Msg.getMsg(Env.getCtx(), "ZoomDocument")); } else if (columnName.equals("Posted")) { readReference(234); // this.setForeground(Color.magenta); - getComponent().setImage("/images/InfoAccount16.gif"); // 16*16 + getComponent().setImage("/images/InfoAccount16.png"); // 16*16 } if (gridField.getColumnName().endsWith("_ID") && !gridField.getColumnName().equals("Record_ID")) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java index ad880ae52d..3a20dbed35 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditor.java @@ -65,6 +65,11 @@ public abstract class WEditor implements EventListener, PropertyChangeListener private String columnName; + /** + * + * @param comp + * @param gridField + */ public WEditor(Component comp, GridField gridField) { if (comp == null) @@ -246,16 +251,26 @@ public abstract class WEditor implements EventListener, PropertyChangeListener return component; } + /** + * @param gridTab + */ public void setGridTab(GridTab gridTab) { this.gridTab = gridTab; } + /** + * + * @return popup menu instance ( if available ) + */ public WEditorPopupMenu getPopupMenu() { return null; } + /** + * @param evt + */ public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(org.compiere.model.GridField.PROPERTY)) @@ -264,16 +279,19 @@ public abstract class WEditor implements EventListener, PropertyChangeListener } } - public void addValueChangeListner(ValueChangeListener listener) + /** + * @param listener + */ + public void addValueChangeListener(ValueChangeListener listener) { - if (listener == null) + if (listener == null) { return; } listeners.add(listener); } - + protected void fireValueChange(ValueChangeEvent event) { for (ValueChangeListener listener : listeners) @@ -282,21 +300,41 @@ public abstract class WEditor implements EventListener, PropertyChangeListener } } + /** + * + * @return Label + */ public Label getLabel() { return label; } + /** + * + * @param readWrite + */ public abstract void setReadWrite(boolean readWrite); + /** + * + * @return editable + */ public abstract boolean isReadWrite(); + /** + * + * @param visible + */ public void setVisible(boolean visible) { label.setVisible(visible); component.setVisible(visible); } + /** + * + * @return is visible + */ public boolean isVisible() { return component.isVisible(); @@ -322,12 +360,28 @@ public abstract class WEditor implements EventListener, PropertyChangeListener return sb.toString(); } + /** + * + * @param value + */ abstract public void setValue(Object value); + /** + * + * @return Object + */ abstract public Object getValue(); + /** + * + * @return display text + */ abstract public String getDisplay(); + /** + * + * @return list of events + */ public String[] getEvents() { return WEditor.lISTENER_EVENTS; @@ -344,6 +398,10 @@ public abstract class WEditor implements EventListener, PropertyChangeListener label.setMandatory(mandatory); } + /** + * + * @return boolean + */ public boolean isMandatory() { return this.mandatory; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java index e3b1b9e96c..835e5902c1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WEditorPopupMenu.java @@ -86,7 +86,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener zoomItem = new Menuitem(); zoomItem.setAttribute(EVENT_ATTRIBUTE, ZOOM_EVENT); zoomItem.setLabel("Zoom"); - zoomItem.setImage("/images/Zoom16.gif"); + zoomItem.setImage("/images/Zoom16.png"); zoomItem.addEventListener(Events.ON_CLICK, this); this.appendChild(zoomItem); @@ -97,7 +97,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener requeryItem = new Menuitem(); requeryItem.setAttribute(EVENT_ATTRIBUTE, REQUERY_EVENT); requeryItem.setLabel("ReQuery"); - requeryItem.setImage("/images/Refresh16.gif"); + requeryItem.setImage("/images/Refresh16.png"); requeryItem.addEventListener(Events.ON_CLICK, this); this.appendChild(requeryItem); } @@ -107,7 +107,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener prefItem = new Menuitem(); prefItem.setAttribute(EVENT_ATTRIBUTE, PREFERENCE_EVENT); prefItem.setLabel("Value Preference"); - prefItem.setImage("/images/VPreference16.gif"); + prefItem.setImage("/images/VPreference16.png"); prefItem.addEventListener(Events.ON_CLICK, this); this.appendChild(prefItem); } @@ -117,7 +117,7 @@ public class WEditorPopupMenu extends Menupopup implements EventListener newItem = new Menuitem(); newItem.setAttribute(EVENT_ATTRIBUTE, NEW_EVENT); newItem.setLabel("New Record"); - newItem.setImage("/images/New16.gif"); + newItem.setImage("/images/New16.png"); newItem.addEventListener(Events.ON_CLICK, this); this.appendChild(newItem); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java index d4c4e9185a..71a14d8979 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WFilenameEditor.java @@ -42,7 +42,7 @@ public class WFilenameEditor extends WEditor public WFilenameEditor(GridField gridField) { super(new FilenameBox(), gridField); - getComponent().setButtonImage("/images/Open16.gif"); + getComponent().setButtonImage("/images/Open16.png"); getComponent().addEventListener(Events.ON_CLICK, this); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java index 458f13683d..7e7083c7e8 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocationEditor.java @@ -63,7 +63,7 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC m_columnName = columnName; m_Location = mLocation; - getComponent().setButtonImage("/images/Location10.gif"); + getComponent().setButtonImage("/images/Location10.png"); } @Override diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java index 271fa60c4a..3016b3ecb7 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WLocatorEditor.java @@ -84,7 +84,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh m_columnName = columnName; m_mLocator = mLocator; - getComponent().setButtonImage("/images/Locator10.gif"); + getComponent().setButtonImage("/images/Locator10.png"); setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ] diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java index ab63f67031..90ad91aba2 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WPAttributeEditor.java @@ -65,7 +65,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener } private void initComponents() { - getComponent().setButtonImage("images/PAttribute10.gif"); + getComponent().setButtonImage("images/PAttribute10.png"); getComponent().addEventListener(Events.ON_CLICK, this); m_WindowNo = gridField.getWindowNo(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java index ca6499a428..099157557f 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java @@ -151,15 +151,15 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value if (columnName.equals("C_BPartner_ID")) { - getComponent().setButtonImage("/images/BPartner10.gif"); + getComponent().setButtonImage("/images/BPartner10.png"); } else if (columnName.equals("M_Product_ID")) { - getComponent().setButtonImage("/images/Product10.gif"); + getComponent().setButtonImage("/images/Product10.png"); } else { - getComponent().setButtonImage("/images/PickOpen10.gif"); + getComponent().setButtonImage("/images/PickOpen10.png"); } return; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java index fa7a38b14f..d9ccf0f174 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WUrlEditor.java @@ -34,7 +34,7 @@ public class WUrlEditor extends WEditor public WUrlEditor(GridField gridField) { super(new Urlbox(), gridField); - getComponent().setButtonImage("/images/Online16.gif"); + getComponent().setButtonImage("/images/Online16.png"); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/grid/WBPartner.java b/zkwebui/WEB-INF/src/org/adempiere/webui/grid/WBPartner.java index 63237aedbe..9fa63945b8 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/grid/WBPartner.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/grid/WBPartner.java @@ -204,7 +204,7 @@ public class WBPartner extends Window implements EventListener, ValueChangeListe fAddress = new WLocationEditor("C_Location_ID", false, ro, true, new MLocationLookup (Env.getCtx(), m_WindowNo)); - fAddress.addValueChangeListner(this); + fAddress.addValueChangeListener(this); fAddress.setValue (null); createLine (fAddress.getComponent(), "C_Location_ID", true)/*.setFontBold(true)*/; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADForm.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADForm.java index 27b891d54c..af7a18a7c1 100755 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADForm.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADForm.java @@ -52,7 +52,7 @@ public abstract class ADForm extends Window implements EventListener /** The unique identifier of the form type */ private int m_adFormId; /** The identifying number of the window in which the form is housed */ - protected int m_windowNo; + protected int m_WindowNo; private String m_name; @@ -65,7 +65,7 @@ public abstract class ADForm extends Window implements EventListener */ protected ADForm() { - m_windowNo = SessionManager.getAppDesktop().registerWindow(this); + m_WindowNo = SessionManager.getAppDesktop().registerWindow(this); this.setWidth("100%"); this.setHeight("95%"); @@ -75,7 +75,7 @@ public abstract class ADForm extends Window implements EventListener protected int getWindowNo() { - return m_windowNo; + return m_WindowNo; } protected int getAdFormId() @@ -102,10 +102,12 @@ public abstract class ADForm extends Window implements EventListener setTitle(name); m_name = name; - return; + initForm(); } - /** + abstract protected void initForm(); + + /** * @return form name */ public String getFormName() { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java index ebc49ac2c5..cb1e99159a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java @@ -273,10 +273,10 @@ public class ADSortTab extends Panel implements IADTabpanel yesList.setSeltype("multiple"); noList.setSeltype("multiple"); - bAdd.setImage("images/Detail24.gif"); + bAdd.setImage("images/Detail24.png"); bAdd.addEventListener(Events.ON_CLICK, actionListener); - bRemove.setImage("images/Parent24.gif"); + bRemove.setImage("images/Parent24.png"); bRemove.addEventListener(Events.ON_CLICK, actionListener); EventListener crossListMouseListener = new DragListener(); @@ -292,10 +292,10 @@ public class ADSortTab extends Panel implements IADTabpanel } }; - bUp.setImage("images/Previous24.gif"); + bUp.setImage("images/Previous24.png"); bUp.addEventListener(Events.ON_CLICK, actionListener); - bDown.setImage("images/Next24.gif"); + bDown.setImage("images/Next24.png"); bDown.addEventListener(Events.ON_CLICK, actionListener); EventListener yesListMouseMotionListener = new EventListener() diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index c7316aed3e..5eb8e1df85 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -279,7 +279,7 @@ DataStatusListener, ValueChangeListener, IADTabpanel else { ToolBar toolbar = new ToolBar(); - Toolbarbutton button = new Toolbarbutton(fieldGroup, "images/ns-collapse.gif"); + Toolbarbutton button = new Toolbarbutton(fieldGroup, "images/ns-collapse.png"); button.addEventListener(Events.ON_CLICK, this); button.setParent(toolbar); row.appendChild(toolbar); @@ -351,7 +351,7 @@ DataStatusListener, ValueChangeListener, IADTabpanel } else { - editor.addValueChangeListner(this); + editor.addValueChangeListener(this); } if (editor.getComponent() instanceof HtmlBasedComponent) { @@ -638,12 +638,12 @@ DataStatusListener, ValueChangeListener, IADTabpanel for (Row row : list) { row.setVisible(false); } - button.setImage("images/ns-expand.gif"); + button.setImage("images/ns-expand.png"); } else { for (Row row : list) { row.setVisible(true); } - button.setImage("images/ns-collapse.gif"); + button.setImage("images/ns-collapse.png"); } } else if (event.getTarget() instanceof Listbox) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssetPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssetPanel.java index 281c52ab95..eee273e0ef 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssetPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssetPanel.java @@ -150,7 +150,7 @@ public class InfoAssetPanel extends InfoPanel implements ValueChangeListener, Ev fBPartner_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 8065, DisplayType.Search), Msg.translate(Env.getCtx(), "C_BPartner_ID"), "", false, false, true); - fBPartner_ID.addValueChangeListner(this); + fBPartner_ID.addValueChangeListener(this); boxBPartner.setWidth("100%"); boxBPartner.setWidths("40%, "); @@ -164,7 +164,7 @@ public class InfoAssetPanel extends InfoPanel implements ValueChangeListener, Ev fProduct_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 8047, DisplayType.Search), Msg.translate(Env.getCtx(), "M_Product_ID"), "", false, false, true); - fProduct_ID.addValueChangeListner(this); + fProduct_ID.addValueChangeListener(this); boxProduct.appendChild(fProduct_ID.getLabel()); boxProduct.appendChild(fProduct_ID.getComponent()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java index e23001689b..62d8134397 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoAssignmentPanel.java @@ -150,7 +150,7 @@ public class InfoAssignmentPanel extends InfoPanel implements EventListener, Val return false; } - bNew.setImage("/images/New16.gif"); + bNew.setImage("/images/New16.png"); return true; } // initLookups diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java index 7960b8a9eb..a3ed44b4ea 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java @@ -187,7 +187,7 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, fCashBook_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5249, DisplayType.TableDir), Msg.translate(Env.getCtx(), "C_CashBook_ID"), "", false, false, true); - fCashBook_ID.addValueChangeListner(this); + fCashBook_ID.addValueChangeListener(this); boxCashBook.appendChild(fCashBook_ID.getLabel()); boxCashBook.appendChild(fCashBook_ID.getComponent()); @@ -198,7 +198,7 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, fInvoice_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5354, DisplayType.Search), Msg.translate(Env.getCtx(), "C_Invoice_ID"), "", false, false, true); - fInvoice_ID.addValueChangeListner(this); + fInvoice_ID.addValueChangeListener(this); boxInvoice.appendChild(fInvoice_ID.getLabel()); boxInvoice.appendChild(fInvoice_ID.getComponent()); @@ -209,7 +209,7 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, fBankAccount_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 5295, DisplayType.TableDir), Msg.translate(Env.getCtx(), "C_BankAccount_ID"), "", false, false, true); - fBankAccount_ID.addValueChangeListner(this); + fBankAccount_ID.addValueChangeListener(this); boxBankAcct.appendChild(fBankAccount_ID.getLabel()); boxBankAcct.appendChild(fBankAccount_ID.getComponent()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java index db44f4459c..7e11ca6bed 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java @@ -189,7 +189,7 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev fBPartner_ID = new WSearchEditor( MLookupFactory.get (Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search), Msg.translate(Env.getCtx(), "BPartner"), "", false, false, true); - fBPartner_ID.addValueChangeListner(this); + fBPartner_ID.addValueChangeListener(this); boxBPartner.appendChild(fBPartner_ID.getLabel()); boxBPartner.appendChild(fBPartner_ID.getComponent()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInvoicePanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInvoicePanel.java index d6e26fbaf2..52a704a827 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInvoicePanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoInvoicePanel.java @@ -165,13 +165,13 @@ public class InfoInvoicePanel extends InfoPanel implements ValueChangeListener 0, 3499, DisplayType.Search); editorBPartner = new WSearchEditor(lookupBP, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", false, false, true); - editorBPartner.addValueChangeListner(this); + editorBPartner.addValueChangeListener(this); MLookup lookupOrder = MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, 4247, DisplayType.Search); editorOrder = new WSearchEditor(lookupOrder, Msg.translate( Env.getCtx(), "C_Order_ID"), "", false, false, true); - editorOrder.addValueChangeListner(this); + editorOrder.addValueChangeListener(this); contentPanel = new WListbox(); contentPanel.setWidth("99%"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java index 0c64a7e725..5eb68ae4b7 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoOrderPanel.java @@ -150,7 +150,7 @@ public class InfoOrderPanel extends InfoPanel implements ValueChangeListener 0, 3499, DisplayType.Search); editorBPartner = new WSearchEditor(lookupBP, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - editorBPartner.addValueChangeListner(this); + editorBPartner.addValueChangeListener(this); contentPanel = new WListbox(); contentPanel.setWidth("99%"); contentPanel.setHeight("400px"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java index 9b30e09213..9de9a84497 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java @@ -185,7 +185,7 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener, fBPartner_ID = new WSearchEditor( MLookupFactory.get(Env.getCtx(), p_WindowNo, 0, 3499, DisplayType.Search), Msg.translate(Env.getCtx(), "C_BPartner_ID"), "", false, false, true); - fBPartner_ID.addValueChangeListner(this); + fBPartner_ID.addValueChangeListener(this); boxBPartner.appendChild(fBPartner_ID.getLabel()); boxBPartner.appendChild(fBPartner_ID.getComponent()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java index 9024665522..3a9f5c40b4 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java @@ -172,7 +172,7 @@ public final class InfoProductPanel extends InfoPanel implements EventListener lblVendor.setValue(Msg.translate(Env.getCtx(), "Vendor")); /* p_attributeInfo = new Button(); - p_attributeInfo.setImage("/images/PAttribute16.gif"); + p_attributeInfo.setImage("/images/PAttribute16.png"); p_attributeInfo.setTooltiptext("Poduct Atribute Info"); p_attributeInfo.addEventListener(Events.ON_CLICK,this);*/ diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java index c804093189..ebc6186eab 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java @@ -18,13 +18,14 @@ package org.adempiere.webui.panel; import java.util.Properties; +import java.util.ResourceBundle; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Window; import org.adempiere.webui.window.LoginWindow; import org.compiere.util.Env; @@ -52,6 +53,9 @@ import org.zkoss.zul.Listbox; public class LoginPanel extends Window implements EventListener { private static final long serialVersionUID = 1L; + + private static final String RESOURCE = "org.compiere.apps.ALoginRes"; + private ResourceBundle res = ResourceBundle.getBundle(RESOURCE); private Properties ctx; private Label lblUserId; @@ -79,14 +83,13 @@ public class LoginPanel extends Window implements EventListener private void init() { Grid grid = new Grid(); - //grid.setSclass("grid-no-striped"); grid.setOddRowSclass("even"); grid.setId("grdLogin"); Rows rows = new Rows(); Row logo = new Row(); logo.setSpans("2"); Image image = new Image(); - image.setSrc("images/Logo.gif"); + image.setSrc("images/logo.png"); logo.appendChild(image); Row rowUser = new Row(); rowUser.setId("rowUser"); @@ -95,24 +98,19 @@ public class LoginPanel extends Window implements EventListener Row rowLanguage = new Row(); rowLanguage.setId("rowLanguage"); - rowUser.appendChild(lblUserId); - rowUser.appendChild(this.txtUserId); + rowUser.appendChild(lblUserId.rightAlign()); + rowUser.appendChild(txtUserId); - rowPassword.appendChild(lblPassword); + rowPassword.appendChild(lblPassword.rightAlign()); rowPassword.appendChild(txtPassword); - rowLanguage.appendChild(lblLanguage); + rowLanguage.appendChild(lblLanguage.rightAlign()); rowLanguage.appendChild(lstLanguage); Row rowButtons = new Row(); - //rowButtons.setAlign("right"); - //Label lblButtons = new Label(); rowButtons.setSpans("2"); - //rowButtons.appendChild(lblButtons); - WConfirmPanel pnlButtons = new WConfirmPanel(false); - pnlButtons.addEventListener(this); - //pnlButtons.appendChild(btnOk); - //pnlButtons.appendChild(btnCancel); + ConfirmPanel pnlButtons = new ConfirmPanel(false); + pnlButtons.addActionListener(this); rowButtons.appendChild(pnlButtons); rows.appendChild(logo); @@ -128,21 +126,22 @@ public class LoginPanel extends Window implements EventListener { lblUserId = new Label(); lblUserId.setId("lblUserId"); - lblUserId.setValue("User ID: "); + lblUserId.setValue("User ID"); lblPassword = new Label(); lblPassword.setId("lblPassword"); - lblPassword.setValue("Password: "); + lblPassword.setValue("Password"); lblLanguage = new Label(); lblLanguage.setId("lblLanguage"); - lblLanguage.setValue("Language: "); + lblLanguage.setValue("Language"); txtUserId = new Textbox(); txtUserId.setId("txtUserId"); txtUserId.setConstraint("no empty"); txtUserId.setCols(25); txtUserId.setMaxlength(40); + txtUserId.setWidth("220px"); txtPassword = new Textbox(); txtPassword.setId("txtPassword"); @@ -150,13 +149,14 @@ public class LoginPanel extends Window implements EventListener txtPassword.setType("password"); txtPassword.setCols(25); txtPassword.setMaxlength(40); + txtPassword.setWidth("220px"); lstLanguage = new Listbox(); lstLanguage.setId("lstLanguage"); lstLanguage.setRows(1); lstLanguage.setMold("select"); lstLanguage.addEventListener(Events.ON_SELECT, this); - lstLanguage.setWidth("180px"); + lstLanguage.setWidth("220px"); // Update Language List lstLanguage.getItems().clear(); @@ -165,23 +165,13 @@ public class LoginPanel extends Window implements EventListener Language language = Language.getLanguage(langName); lstLanguage.appendItem(langName, language.getAD_Language()); } - -/* btnOk = new Button(); - btnOk.setName("btnOk"); - btnOk.setLabel("Ok"); - btnOk.addEventListener(EventConstants.ONCLICK, this); - - btnCancel = new Button(); - btnCancel.setName("btnCancel"); - btnCancel.setLabel("Cancel"); - btnCancel.addEventListener(EventConstants.ONCLICK, this);*/ } public void onEvent(Event event) { Component eventComp = event.getTarget(); - if (event.getName().equals(WConfirmPanel.A_OK)) + if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) { validateLogin(); } @@ -192,6 +182,11 @@ public class LoginPanel extends Window implements EventListener Env.setContext(ctx, Env.LANGUAGE, langName); Language language = Language.getLanguage(langName); Env.verifyLanguage(ctx, language); + + res = ResourceBundle.getBundle(RESOURCE, language.getLocale()); + lblUserId.setValue(res.getString("User")); + lblPassword.setValue(res.getString("Password")); + lblLanguage.setValue(res.getString("Language")); } } } @@ -209,7 +204,17 @@ public class LoginPanel extends Window implements EventListener throw new WrongValueException("User Id or Password invalid!!!"); else + { + String langName = null; + if ( lstLanguage.getSelectedItem() != null ) + langName = (String) lstLanguage.getSelectedItem().getValue(); + else + langName = Language.getBaseLanguage().getName(); + Env.setContext(ctx, Env.LANGUAGE, langName); + Language language = Language.getLanguage(langName); + Env.verifyLanguage(ctx, language); wndLogin.loginOk(userId, userPassword); + } } public boolean isAsap() diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java index fa9fe22fae..9ede4ef420 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java @@ -165,13 +165,13 @@ public class MenuPanel extends Panel implements EventListener treeitem.setValue(String.valueOf(mChildNode.getNode_ID())); if (mChildNode.isReport()) - treeitem.setImage("/images/mReport.gif"); + treeitem.setImage("/images/mReport.png"); else if (mChildNode.isProcess()) - treeitem.setImage("/images/mProcess.gif"); + treeitem.setImage("/images/mProcess.png"); else if (mChildNode.isWorkFlow()) - treeitem.setImage("/images/mWorkFlow.gif"); + treeitem.setImage("/images/mWorkFlow.png"); else - treeitem.setImage("/images/mWindow.gif"); + treeitem.setImage("/images/mWindow.png"); treeitem.getTreerow().setDraggable("favourite"); // Elaine 2008/07/24 pnlSearch.addTreeItem(treeitem); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index 2cc9246f8b..ce87f65100 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -18,16 +18,18 @@ package org.adempiere.webui.panel; import java.util.Properties; +import java.util.ResourceBundle; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; +import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Window; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.window.LoginWindow; import org.compiere.db.CConnection; import org.compiere.util.Env; import org.compiere.util.KeyNamePair; +import org.compiere.util.Language; import org.compiere.util.Login; -import org.compiere.util.Msg; import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -37,7 +39,6 @@ import org.zkoss.zul.Button; import org.zkoss.zul.Div; import org.zkoss.zul.Grid; import org.zkoss.zul.Image; -import org.zkoss.zul.Label; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; import org.zkoss.zul.Row; @@ -54,6 +55,8 @@ import org.zkoss.zul.Rows; public class RolePanel extends Window implements EventListener { private static final long serialVersionUID = 1L; + + private static final String RESOURCE = "org.compiere.apps.ALoginRes"; private LoginWindow wndLogin; private Login login; @@ -94,7 +97,7 @@ public class RolePanel extends Window implements EventListener Row logo = new Row(); logo.setSpans("2"); Image image = new Image(); - image.setSrc("images/Logo.gif"); + image.setSrc("images/logo.png"); logo.appendChild(image); Row rowRole = new Row(); @@ -102,27 +105,21 @@ public class RolePanel extends Window implements EventListener Row rowOrg = new Row(); Row rowWarehouse = new Row(); - rowRole.appendChild(lblRole); + rowRole.appendChild(lblRole.rightAlign()); rowRole.appendChild(lstRole); - rowClient.appendChild(lblClient); + rowClient.appendChild(lblClient.rightAlign()); rowClient.appendChild(lstClient); - rowOrg.appendChild(lblOrganisation); + rowOrg.appendChild(lblOrganisation.rightAlign()); rowOrg.appendChild(lstOrganisation); - rowWarehouse.appendChild(lblWarehouse); + rowWarehouse.appendChild(lblWarehouse.rightAlign()); rowWarehouse.appendChild(lstWarehouse); Row rowButtons = new Row(); - //rowButtons.setAlign("right"); - //Label lblButtons = new Label(); - //rowButtons.appendChild(lblButtons); - //Panel pnlButtons = new Panel(); - //divButtons.appendChild(btnOk); - //divButtons.appendChild(btnCancel); - WConfirmPanel pnlButtons = new WConfirmPanel(true, false, false, false, false, false, false); - pnlButtons.addEventListener(this); + ConfirmPanel pnlButtons = new ConfirmPanel(true); + pnlButtons.addActionListener(this); rowButtons.setSpans("2"); rowButtons.appendChild(pnlButtons); @@ -143,52 +140,56 @@ public class RolePanel extends Window implements EventListener private void initComponents() { + Language language = Env.getLanguage(Env.getCtx()); + + ResourceBundle res = ResourceBundle.getBundle(RESOURCE, language.getLocale()); + lblErrorMsg = new Label(); lblErrorMsg.setValue(" "); lblRole = new Label(); lblRole.setId("lblRole"); - lblRole.setValue(Msg.getMsg(Env.getCtx(),"Role")+ ":"); + lblRole.setValue(res.getString("Role")); lblClient = new Label(); lblClient.setId("lblClient"); - lblClient.setValue(Msg.getMsg(Env.getCtx(),"Client")+ ":"); + lblClient.setValue(res.getString("Client")); lblOrganisation = new Label(); lblOrganisation.setId("lblOrganisation"); - lblOrganisation.setValue(Msg.getMsg(Env.getCtx(),"Organization")+ " :"); + lblOrganisation.setValue(res.getString("Organization")); lblWarehouse = new Label(); lblWarehouse.setId("lblWarehouse"); - lblWarehouse.setValue(Msg.getMsg(Env.getCtx(),"Warehouse")+ " :"); + lblWarehouse.setValue(res.getString("Warehouse")); lstRole = new Listbox(); lstRole.setId("lstRole"); lstRole.setRows(1); lstRole.setMold("select"); lstRole.addEventListener(Events.ON_SELECT, this); - lstRole.setWidth("180px"); + lstRole.setWidth("220px"); lstClient = new Listbox(); lstClient.setId("lstClient"); lstClient.setRows(1); lstClient.setMold("select"); lstClient.addEventListener(Events.ON_SELECT, this); - lstClient.setWidth("180px"); + lstClient.setWidth("220px"); lstOrganisation = new Listbox(); lstOrganisation.setId("lstOrganisation"); lstOrganisation.setRows(1); lstOrganisation.setMold("select"); lstOrganisation.addEventListener(Events.ON_SELECT, this); - lstOrganisation.setWidth("180px"); + lstOrganisation.setWidth("220px"); lstWarehouse = new Listbox(); lstWarehouse.setId("lstWarehouse"); lstWarehouse.setRows(1); lstWarehouse.setMold("select"); lstWarehouse.addEventListener(Events.ON_SELECT, this); - lstWarehouse.setWidth("180px"); + lstWarehouse.setWidth("220px"); btnOk = new Button(); btnOk.setId("btnOk"); @@ -272,22 +273,11 @@ public class RolePanel extends Window implements EventListener else if(eventCompId.equals(lstOrganisation.getId())) updateWarehouseList(); } -/* else if(eventName.equals("onClick")) - { - if(eventCompId.equals(btnOk.getId())) - { - validateRoles(); - } - else if(eventCompId.equals(btnCancel.getId())) - { - - } - }*/ - if (event.getName().equals(WConfirmPanel.A_OK)) + if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) { validateRoles(); } - else if (event.getName().equals(WConfirmPanel.A_CANCEL)) + else if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) { wndLogin.loginCancelled(); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index ea1533951d..fa60d275ca 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -178,15 +178,15 @@ public class WAttachment extends Window implements EventListener northPanel.appendChild(toolBar); bSave.setEnabled(false); - bSave.setSrc("/images/Export24.gif"); + bSave.setSrc("/images/Export24.png"); bSave.setTooltiptext(Msg.getMsg(Env.getCtx(), "AttachmentSave")); bSave.addEventListener(Events.ON_CLICK, this); - bLoad.setSrc("/images/Import24.gif"); + bLoad.setSrc("/images/Import24.png"); bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load")); bLoad.addEventListener(Events.ON_CLICK, this); - bDelete.setSrc("/images/Delete24.gif"); + bDelete.setSrc("/images/Delete24.png"); bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete")); bDelete.addEventListener(Events.ON_CLICK, this); @@ -212,13 +212,13 @@ public class WAttachment extends Window implements EventListener southPane.appendChild(confirmPanel); southPane.setHeight("30px"); - bCancel.setImage("/images/Cancel24.gif"); + bCancel.setImage("/images/Cancel24.png"); bCancel.addEventListener(Events.ON_CLICK, this); - bOk.setImage("/images/Ok24.gif"); + bOk.setImage("/images/Ok24.png"); bOk.addEventListener(Events.ON_CLICK, this); - bDeleteAll.setImage("/images/Delete24.gif"); + bDeleteAll.setImage("/images/Delete24.png"); bDeleteAll.addEventListener(Events.ON_CLICK, this); confirmPanel.appendChild(bDeleteAll); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java index e1ad4f4587..6fa584d3d0 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/WDocActionPanel.java @@ -22,6 +22,7 @@ import java.util.List; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; @@ -39,6 +40,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Label; import org.zkoss.zul.Listbox; import org.zkoss.zul.Listitem; +import org.zkoss.zul.Space; @@ -210,7 +212,6 @@ public class WDocActionPanel extends Window implements EventListener lstDocAction.addEventListener(Events.ON_SELECT, this); confirmPanel = new ConfirmPanel(true); - confirmPanel.addComponentsLeft(confirmPanel.createButton("Process")); confirmPanel.addActionListener(Events.ON_CLICK, this); } @@ -218,7 +219,7 @@ public class WDocActionPanel extends Window implements EventListener private void init() { - Grid grid = new Grid(); + Grid grid = GridFactory.newGridLayout(); grid.setId("grd"); grid.setWidth("400px"); @@ -227,7 +228,8 @@ public class WDocActionPanel extends Window implements EventListener Row rowDocAction = new Row(); Row rowLabel = new Row(); Row rowConfirm = new Row(); - + Row rowSpacer = new Row(); + Panel pnlDocAction = new Panel(); pnlDocAction.appendChild(lblDocAction); pnlDocAction.appendChild(lstDocAction); @@ -236,8 +238,10 @@ public class WDocActionPanel extends Window implements EventListener rowDocAction.setAlign("right"); rowLabel.appendChild(label); rowConfirm.appendChild(confirmPanel); + rowSpacer.appendChild(new Space()); rows.appendChild(rowDocAction); rows.appendChild(rowLabel); + rows.appendChild(rowSpacer); rows.appendChild(rowConfirm); grid.appendChild(rows); @@ -272,11 +276,7 @@ public class WDocActionPanel extends Window implements EventListener { m_OKpressed = false; this.detach(); - } - else if (confirmPanel.getButton("Process").equals(event.getTarget())) - { - - } + } } else if (Events.ON_SELECT.equals(event.getName())) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java index 437e487886..8148a7e07e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java @@ -33,6 +33,8 @@ import org.zkoss.zkex.zul.Borderlayout; public class WindowContainer extends AbstractUIPart implements EventListener { private static final long serialVersionUID = 1L; + + private static final int MAX_TITLE_LENGTH = 30; private Tabbox tabbox; @@ -79,7 +81,17 @@ public class WindowContainer extends AbstractUIPart implements EventListener public void addWindow(Component comp, String title, boolean closeable, boolean enable) { Tab tab = new Tab(); - tab.setLabel(title); + title = title.replaceAll("[&]", ""); + if (title.length() <= MAX_TITLE_LENGTH) + { + tab.setLabel(title); + } + else + { + tab.setTooltiptext(title); + title = title.substring(0, 27) + "..."; + tab.setLabel(title); + } tab.setClosable(closeable); // tab.setHeight("20px"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebContext.java b/zkwebui/WEB-INF/src/org/adempiere/webui/session/ServerContext.java similarity index 64% rename from zkwebui/WEB-INF/src/org/adempiere/webui/session/WebContext.java rename to zkwebui/WEB-INF/src/org/adempiere/webui/session/ServerContext.java index ec58997f0c..c68a1aaedf 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebContext.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/session/ServerContext.java @@ -29,9 +29,9 @@ import org.compiere.util.Language; * @version $Revision: 0.10 $ */ @SuppressWarnings("serial") -public final class WebContext extends Properties +public final class ServerContext extends Properties { - public WebContext() + private ServerContext() { super(); /** @@ -40,21 +40,46 @@ public final class WebContext extends Properties this.put(Env.LANGUAGE, Language.getBaseAD_Language()); } - private static InheritableThreadLocal context = new InheritableThreadLocal() { - protected WebContext initialValue() + private static InheritableThreadLocal context = new InheritableThreadLocal() { + protected ServerContext initialValue() { - return new WebContext(); + return new ServerContext(); } }; - public static WebContext getCurrentInstance() + /** + * Get server context for current thread + * @return ServerContext + */ + public static ServerContext getCurrentInstance() { - return (WebContext)context.get(); + return (ServerContext)context.get(); } - @SuppressWarnings("unchecked") - public static void setCurrentInstance(WebContext webCtx) + /** + * dispose server context for current thread + */ + public static void dispose() { - context.set(webCtx); + context.remove(); + } + + /** + * Allocate new server context for current thread + * @return ServerContext + */ + public static ServerContext newInstance() + { + dispose(); + return getCurrentInstance(); + } + + /** + * Set server context for current thread + * @param ctx + */ + public static void setCurrentInstance(ServerContext ctx) + { + context.set(ctx); } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java b/zkwebui/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java index b11c17f2f4..574f60f93b 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/session/SessionContextListener.java @@ -44,13 +44,16 @@ public class SessionContextListener implements ExecutionInit, { if (parent == null) { - WebContext ctx = (WebContext)exec.getDesktop().getSession().getAttribute(SESSION_CTX); + ServerContext ctx = (ServerContext)exec.getDesktop().getSession().getAttribute(SESSION_CTX); if (ctx == null) { - ctx = new WebContext(); + ctx = ServerContext.newInstance(); exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx); } - setWebContext(ctx); + else + { + ServerContext.setCurrentInstance(ctx); + } exec.setAttribute(SESSION_CTX, ctx); } } @@ -60,7 +63,8 @@ public class SessionContextListener implements ExecutionInit, if (parent == null) { exec.removeAttribute(SESSION_CTX); - } + ServerContext.dispose(); + } } public void prepare(Component comp, Event evt) @@ -69,9 +73,9 @@ public class SessionContextListener implements ExecutionInit, public boolean init(Component comp, Event evt) { - WebContext ctx = (WebContext) Executions.getCurrent().getAttribute( + ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute( SESSION_CTX); - setWebContext(ctx); + ServerContext.setCurrentInstance(ctx); return true; } @@ -82,26 +86,13 @@ public class SessionContextListener implements ExecutionInit, public void afterResume(Component comp, Event evt) { - WebContext ctx = (WebContext) Executions.getCurrent().getAttribute( + ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute( SESSION_CTX); - setWebContext(ctx); + ServerContext.setCurrentInstance(ctx); } public void abortResume(Component comp, Event evt) { // do nothing - } - - @SuppressWarnings("unchecked") - public void setWebContext(WebContext ctx) - { - getContextThreadLocal().set(ctx); - WebContext.setCurrentInstance(ctx); - } - - private ThreadLocal getContextThreadLocal() - { - return ThreadLocals.getThreadLocal( - "org.adempiere.webui.session.WebContext", "context"); - } + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebUIServlet.java b/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebUIServlet.java index 2800378d5b..c985029676 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebUIServlet.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/session/WebUIServlet.java @@ -62,7 +62,7 @@ public class WebUIServlet extends DHtmlLayoutServlet super.init(servletConfig); /** Initialise context for the current thread*/ - WebContext.setCurrentInstance(new WebContext()); + ServerContext.newInstance(); Env.setContextProvider(new ZkContextProvider()); /** diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java index cd5193396d..355ac5884d 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java @@ -124,7 +124,7 @@ public class AboutWindow extends Window implements EventListener { hbox.setPack("end"); hbox.setWidth("100%"); Button btnOk = new Button(); - btnOk.setImage("/images/Ok24.gif"); + btnOk.setImage("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); btnOk.setParent(hbox); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 70efc1107e..ee5088df89 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -249,17 +249,17 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe Button btnNew = new Button(); btnNew.setName("btnNew"); - btnNew.setSrc("/images/New24.gif"); + btnNew.setSrc("/images/New24.png"); btnNew.addEventListener(Events.ON_CLICK,this); Button btnOk = new Button(); btnOk.setName("btnOkSimple"); - btnOk.setSrc("/images/Ok24.gif"); + btnOk.setSrc("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK,this); Button btnCancel = new Button(); btnCancel.setName("btnCancel"); - btnCancel.setSrc("/images/Cancel24.gif"); + btnCancel.setSrc("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK,this); Panel pnlButtonRight = new Panel(); @@ -321,18 +321,18 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe private void initAdvanced() { ToolBarButton btnNew = new ToolBarButton(); - btnNew.setSrc("/images/New24.gif"); + btnNew.setSrc("/images/New24.png"); btnNew.setAttribute("name", "btnNewAdv"); btnNew.addEventListener(Events.ON_CLICK, this); ToolBarButton btnDelete = new ToolBarButton(); btnDelete.setAttribute("name","btnDeleteAdv"); - btnDelete.setSrc("/images/Delete24.gif"); + btnDelete.setSrc("/images/Delete24.png"); btnDelete.addEventListener(Events.ON_CLICK, this); ToolBarButton btnSave = new ToolBarButton(); btnSave.setAttribute("name","btnSaveAdv"); - btnSave.setSrc("/images/Save24.gif"); + btnSave.setSrc("/images/Save24.png"); btnSave.addEventListener(Events.ON_CLICK, this); fQueryName = new Combobox(); @@ -349,12 +349,12 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe Button btnOk = new Button(); btnOk.setName("btnOkAdv"); - btnOk.setSrc("/images/Ok24.gif"); + btnOk.setSrc("/images/Ok24.png"); btnOk.addEventListener(Events.ON_CLICK, this); Button btnCancel = new Button(); btnCancel.setName("btnCancel"); - btnCancel.setSrc("/images/Cancel24.gif"); + btnCancel.setSrc("/images/Cancel24.png"); btnCancel.addEventListener(Events.ON_CLICK, this); Panel pnlButtonRight = new Panel(); @@ -1178,7 +1178,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe m_editor = new WStringEditor(field); field.addPropertyChangeListener(m_editor); - m_editor.addValueChangeListner(this); + m_editor.addValueChangeListener(this); m_editor.setValue(null); m_editor.setReadWrite(enabled); m_editor.setVisible(enabled); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java index f01790d464..2fe746e220 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java @@ -184,7 +184,7 @@ public class InfoSchedule extends Window implements EventListener //, ChangeList Button btnNew = new Button(); btnNew.setName("btnNew"); btnNew.setId("New"); - btnNew.setSrc("/images/New24.gif"); + btnNew.setSrc("/images/New24.png"); confirmPanel.addComponentsLeft(btnNew); btnNew.addEventListener(Events.ON_CLICK, this); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index 543435bde9..5998b6781a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -169,13 +169,13 @@ public final class WAccountDialog extends Window toolBar.setOrient("vertical"); toolBar.setStyle("border: none; margin: 5px"); - bSave.setImage("images/Save24.gif"); + bSave.setImage("images/Save24.png"); bSave.setTooltiptext(Msg.getMsg(Env.getCtx(),"AccountNewUpdate")); bSave.addEventListener(Events.ON_CLICK, this); - bRefresh.setImage("images/Refresh24.gif"); + bRefresh.setImage("images/Refresh24.png"); bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(),"Refresh")); bRefresh.addEventListener(Events.ON_CLICK, this); - bIgnore.setImage("images/Ignore24.gif"); + bIgnore.setImage("images/Ignore24.png"); bIgnore.setTooltiptext(Msg.getMsg(Env.getCtx(),"Ignore")); bIgnore.addEventListener(Events.ON_CLICK, this); // @@ -320,7 +320,7 @@ public final class WAccountDialog extends Window f_Account_ID = WebEditorFactory.getEditor(field, false); // ((VLookup)f_Account_ID).setWidth(400); addLine(field, f_Account_ID, isMandatory); - f_Account_ID.addValueChangeListner(this); + f_Account_ID.addValueChangeListener(this); } else if (type.equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount)) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java index fa14acc654..cf38dae5a1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java @@ -28,7 +28,7 @@ import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.WStatusBar; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WSearchEditor; @@ -116,9 +116,9 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi "EMail IS NOT NULL"); fUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true); - fUser.addValueChangeListner(this); + fUser.addValueChangeListener(this); fCcUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true); - fCcUser.addValueChangeListner(this); + fCcUser.addValueChangeListener(this); jbInit(); } catch(Exception ex) @@ -166,7 +166,7 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi private Label lAttachment = new Label(); private Textbox fAttachment = new Textbox();//40); private Textbox fMessage = new Textbox(); - private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private ConfirmPanel confirmPanel = new ConfirmPanel(true); private WStatusBar statusBar = new WStatusBar(); /** @@ -270,7 +270,7 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi rows.appendChild(row); row.setSpans("2"); row.appendChild(confirmPanel); - confirmPanel.addEventListener(this); + confirmPanel.addActionListener(this); Borderlayout layout = new Borderlayout(); layout.setWidth("490px"); @@ -435,7 +435,7 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi * Action Listener - Send email */ public void onEvent(Event event) throws Exception { - if (event.getName().equals(WConfirmPanel.A_CANCEL)) + if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) onClose(); if (getTo() == null || getTo().length() == 0) @@ -443,10 +443,8 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi return; } // Send - if (event.getName().equals(WConfirmPanel.A_OK)) + if (event.getTarget().getId().equals(ConfirmPanel.A_OK)) { -// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); -// confirmPanel.getOKButton().setEnabled(false); StringTokenizer st = new StringTokenizer(getTo(), " ,;", false); String to = st.nextToken(); @@ -485,7 +483,7 @@ public class WEMailDialog extends Window implements EventListener, ValueChangeLi // confirmPanel.getOKButton().setEnabled(false); // setCursor(Cursor.getDefaultCursor()); } - else if (event.getName().equals(WConfirmPanel.A_CANCEL)) + else if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) onClose(); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index 404b8e567c..b8172786ad 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -165,10 +165,10 @@ public class WLocationDialog extends Window implements EventListener lstCountry.setRows(0); btnOk = new Button(); - btnOk.setImage("/images/Ok16.gif"); + btnOk.setImage("/images/Ok16.png"); btnOk.addEventListener(Events.ON_CLICK,this); btnCancel = new Button(); - btnCancel.setImage("/images/Cancel16.gif"); + btnCancel.setImage("/images/Cancel16.png"); btnCancel.addEventListener(Events.ON_CLICK,this); mainPanel = new VerticalBox(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index 6cff5af3e9..7750717193 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -208,10 +208,10 @@ public class WLocatorDialog extends Window implements EventListener boxButtons.setWidths("80%, 10%, 10%"); boxButtons.setStyle("text-align:right"); - btnCancel.setImage("/images/Cancel16.gif"); + btnCancel.setImage("/images/Cancel16.png"); btnCancel.addEventListener(Events.ON_CLICK, this); - btnOk.setImage("/images/Ok16.gif"); + btnOk.setImage("/images/Ok16.png"); btnOk.addEventListener(Events.ON_CLICK, this); boxButtons.appendChild(new Label()); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java index ac388b3ecd..55fd28d8ba 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java @@ -147,15 +147,15 @@ public class WMediaDialog extends Window implements EventListener bSave.setEnabled(false); - bSave.setSrc("/images/Export24.gif"); + bSave.setSrc("/images/Export24.png"); bSave.setTooltiptext(Msg.getMsg(Env.getCtx(), "AttachmentSave")); bSave.addEventListener(Events.ON_CLICK, this); - bLoad.setSrc("/images/Import24.gif"); + bLoad.setSrc("/images/Import24.png"); bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load")); bLoad.addEventListener(Events.ON_CLICK, this); - bDelete.setSrc("/images/Delete24.gif"); + bDelete.setSrc("/images/Delete24.png"); bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete")); bDelete.addEventListener(Events.ON_CLICK, this); @@ -174,10 +174,10 @@ public class WMediaDialog extends Window implements EventListener southPane.appendChild(confirmPanel); southPane.setHeight("30px"); - bCancel.setImage("/images/Cancel24.gif"); + bCancel.setImage("/images/Cancel24.png"); bCancel.addEventListener(Events.ON_CLICK, this); - bOk.setImage("/images/Ok24.gif"); + bOk.setImage("/images/Ok24.png"); bOk.addEventListener(Events.ON_CLICK, this); confirmPanel.appendChild(bCancel); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java index 8a1385684c..a6ef8a3424 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java @@ -267,7 +267,7 @@ public class WPAttributeDialog extends Window implements EventListener cbNewEdit.addEventListener(Events.ON_CHECK, this); row.appendChild(cbNewEdit); bSelect.setLabel(Msg.getMsg(Env.getCtx(), "SelectExisting")); - bSelect.setImage("images/PAttribute16.gif"); + bSelect.setImage("images/PAttribute16.png"); bSelect.addEventListener(Events.ON_CLICK, this); row.appendChild(bSelect); rows.appendChild(row); @@ -341,7 +341,7 @@ public class WPAttributeDialog extends Window implements EventListener } // Popup // fieldLot.addMouseListener(new VPAttributeDialog_mouseAdapter(this)); // popup - mZoom = new Menuitem(Msg.getMsg(Env.getCtx(), "Zoom"), "images/Zoom16.gif"); + mZoom = new Menuitem(Msg.getMsg(Env.getCtx(), "Zoom"), "images/Zoom16.png"); mZoom.addEventListener(Events.ON_CLICK, this); popupMenu.appendChild(mZoom); this.appendChild(popupMenu); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java index bf8f4e0477..531cbb1e51 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java @@ -256,7 +256,7 @@ public class WRecordInfo extends Window implements EventListener for (int i = 0; i < columnNames.size(); i++) { - Listheader listheader = new Listheader(columnNames.get(i)); + Listheader listheader = new Listheader(columnNames.get(i).replaceAll("[&]", "")); listhead.appendChild(listheader); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java index 86309fc2e1..6a76ea2b26 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java @@ -32,7 +32,7 @@ public class ZkJRViewer extends Window { Toolbar toolbar = new Toolbar(); toolbar.setHeight("26px"); Toolbarbutton button = new Toolbarbutton(); - button.setImage("/images/Print24.gif"); + button.setImage("/images/Print24.png"); button.setTooltiptext("Print"); toolbar.appendChild(button); row.appendChild(toolbar); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 30551228a4..d78fa3b45c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -34,7 +34,7 @@ import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; -import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Window; import org.adempiere.webui.panel.StatusBarPanel; import org.adempiere.webui.session.SessionManager; @@ -147,7 +147,7 @@ public class ZkReportViewer extends Window implements EventListener { private Iframe iframe; private Window winExportFile = null; - private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private ConfirmPanel confirmPanel = new ConfirmPanel(true); private Listbox cboType = new Listbox(); // private ArrayList fileTypes = new ArrayList(); @@ -208,38 +208,38 @@ public class ZkReportViewer extends Window implements EventListener { comboReport.setTooltiptext(Msg.translate(m_ctx, "AD_PrintFormat_ID")); toolBar.appendChild(comboReport); - bCustomize.setImage("/images/Preference24.gif"); + bCustomize.setImage("/images/Preference24.png"); bCustomize.setTooltiptext("Customize Report"); toolBar.appendChild(bCustomize); bCustomize.addEventListener(Events.ON_CLICK, this); - bFind.setImage("/images/Find24.gif"); + bFind.setImage("/images/Find24.png"); bFind.setTooltiptext("Lookup Record"); toolBar.appendChild(bFind); bFind.addEventListener(Events.ON_CLICK, this); toolBar.appendChild(new Separator("vertical")); -// bPrint.setImage("/images/Print24.gif"); +// bPrint.setImage("/images/Print24.png"); // bPrint.setTooltiptext("Print"); // toolBar.appendChild(bPrint); // bPrint.addEventListener(Events.ON_CLICK, this); // // toolBar.appendChild(new Separator("vertical")); - bSendMail.setImage("/images/SendMail24.gif"); + bSendMail.setImage("/images/SendMail24.png"); bSendMail.setTooltiptext("Send Mail"); toolBar.appendChild(bSendMail); bSendMail.addEventListener(Events.ON_CLICK, this); - bArchive.setImage("/images/Archive24.gif"); + bArchive.setImage("/images/Archive24.png"); bArchive.setTooltiptext("Archived Documents/Reports"); toolBar.appendChild(bArchive); bArchive.addEventListener(Events.ON_CLICK, this); if (m_isCanExport) { - bExport.setImage("/images/ExportX24.gif"); + bExport.setImage("/images/ExportX24.png"); bExport.setTooltiptext("Export"); toolBar.appendChild(bExport); bExport.addEventListener(Events.ON_CLICK, this); @@ -247,7 +247,7 @@ public class ZkReportViewer extends Window implements EventListener { toolBar.appendChild(new Separator("vertical")); - bRefresh.setImage("/images/Refresh24.gif"); + bRefresh.setImage("/images/Refresh24.png"); bRefresh.setTooltiptext("Refresh"); toolBar.appendChild(bRefresh); bRefresh.addEventListener(Events.ON_CLICK, this); @@ -423,9 +423,9 @@ public class ZkReportViewer extends Window implements EventListener { public void onEvent(Event event) throws Exception { - if(event.getName().equals(WConfirmPanel.A_CANCEL)) + if(event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) winExportFile.onClose(); - else if(event.getName().equals(WConfirmPanel.A_OK)) + else if(event.getTarget().getId().equals(ConfirmPanel.A_OK)) exportFile(); else if(event.getName().equals(Events.ON_CLICK) || event.getName().equals(Events.ON_SELECT)) actionPerformed(event); @@ -527,7 +527,7 @@ public class ZkReportViewer extends Window implements EventListener { return; // Create Menu Menupopup pop = new Menupopup(); -// Icon wi = Env.getImageIcon("mWindow.gif"); +// Icon wi = Env.getImageIcon("mWindow.png"); if (m_ddQ != null) { m_ddM = new Menuitem(m_ddQ.getDisplayName(Env.getCtx())); @@ -707,7 +707,7 @@ public class ZkReportViewer extends Window implements EventListener { winExportFile.appendChild(vb); vb.appendChild(hb); vb.appendChild(confirmPanel); - confirmPanel.addEventListener(this); + confirmPanel.addActionListener(this); } AEnv.showCenterScreen(winExportFile); diff --git a/zkwebui/css/default.css.dsp b/zkwebui/css/default.css.dsp index e42364c44a..764d3b4007 100644 --- a/zkwebui/css/default.css.dsp +++ b/zkwebui/css/default.css.dsp @@ -41,6 +41,15 @@ html,body { font-size: 10px; } +.action-button { + height: 32px; + width: 48px; +} + +div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { + background-color: white; +} + <%-- desktop tabbox --%> .desktop-tb { position:absolute;