IDEMPIERE-5570 Zk: Improve readability of code (#1690)

- Improve code readability for org.adempieere.webui.apps.form package.
This commit is contained in:
hengsin 2023-02-27 21:23:19 +08:00 committed by GitHub
parent 3e83d5ff67
commit 1e70b29ca2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 1746 additions and 874 deletions

View File

@ -77,7 +77,6 @@ public class LoggedSessionListener implements HttpSessionListener, ServletContex
public void contextInitialized(ServletContextEvent arg0) { public void contextInitialized(ServletContextEvent arg0) {
DestroyAllSession(); DestroyAllSession();
// bring from depricate class WebUIServlet
/** Initialise context for the current thread*/ /** Initialise context for the current thread*/
Properties serverContext = new Properties(); Properties serverContext = new Properties();
serverContext.put(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER, new ServerContextURLHandler() { serverContext.put(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER, new ServerContextURLHandler() {
@ -91,7 +90,7 @@ public class LoggedSessionListener implements HttpSessionListener, ServletContex
File file = new File(propertyFile); File file = new File(propertyFile);
if (!file.exists()) if (!file.exists())
{ {
throw new IllegalStateException("idempiere.properties is not setup. PropertyFile="+propertyFile); throw new IllegalStateException("idempiere.properties file missing. Path="+file.getAbsolutePath());
} }
if (!Adempiere.isStarted()) if (!Adempiere.isStarted())
{ {

View File

@ -96,7 +96,7 @@ import com.lowagie.text.DocumentException;
*/ */
public final class AEnv public final class AEnv
{ {
/** Environment context attribute for Locale **/ /** Environment context attribute for Locale */
public static final String LOCALE = Env.LOCALE; public static final String LOCALE = Env.LOCALE;
/** /**
@ -259,12 +259,12 @@ public final class AEnv
AEnv.zoom(s_workflow_Window_ID, query); AEnv.zoom(s_workflow_Window_ID, query);
} // startWorkflowProcess } // startWorkflowProcess
/** Cache Workflow Window ID **/ /** Cache Workflow Window ID */
private static int s_workflow_Window_ID = 0; private static int s_workflow_Window_ID = 0;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(AEnv.class); private static final CLogger log = CLogger.getCLogger(AEnv.class);
/** Register AD Window Cache **/ /** Register AD Window Cache */
private static Map<String, CCache<Integer,GridWindowVO>> windowCache = new HashMap<String, CCache<Integer,GridWindowVO>>(); private static Map<String, CCache<Integer,GridWindowVO>> windowCache = new HashMap<String, CCache<Integer,GridWindowVO>>();
/** /**
@ -321,7 +321,7 @@ public final class AEnv
if (mWindowVO == null) if (mWindowVO == null)
return null; return null;
// Check context // Check context (Just in case, usually both is ServerContextPropertiesWrapper)
if (!mWindowVO.ctx.equals(Env.getCtx())) if (!mWindowVO.ctx.equals(Env.getCtx()))
{ {
// Add Window properties to context // Add Window properties to context
@ -824,17 +824,12 @@ public final class AEnv
} }
/** /**
* Get adWindowId below gridField * Get AD_Window_ID from windowNo.
* when field lie in window, it's id of this window
* when field lie in process parameter dialog it's ad_window_id of window open this process
* when field lie in process parameter open in a standalone window (run process from menu) return id of dummy window
* @param windowNo * @param windowNo
* @return * @return AD_Window_ID or {@link Env#adWindowDummyID} (if it is ProcessDialog of InfoWindow)
*/ */
public static int getADWindowID (int windowNo){ public static int getADWindowID (int windowNo){
int adWindowID = 0; int adWindowID = 0;
// form process parameter panel
Object window = SessionManager.getAppDesktop().findWindow(windowNo); Object window = SessionManager.getAppDesktop().findWindow(windowNo);
// case show a process dialog, window is below window of process dialog // case show a process dialog, window is below window of process dialog
if (window != null && window instanceof ADWindow){ if (window != null && window instanceof ADWindow){

View File

@ -1,6 +1,27 @@
/** /***********************************************************************
* * This file is part of iDempiere ERP Open Source *
*/ * http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import java.io.StringWriter; import java.io.StringWriter;
@ -37,27 +58,33 @@ import org.zkoss.zul.Timer;
import org.zkoss.zul.Vlayout; import org.zkoss.zul.Vlayout;
/** /**
* Form to compare suggested text from AD_CtxHelpSuggestion with the original text from AD_CtxHelpMsg.
* @author hengsin * @author hengsin
*
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class CompareCtxHelpSuggestion extends ADForm { public class CompareCtxHelpSuggestion extends ADForm {
private static final String NEW_VALUE = "newValue"; /** {@link #helpTimer} attribute to store text value from {@link #helpTextbox} onChanging event. */
private static final String NEW_VALUE_ATTR = "newValue";
/** /**
* generated serial id * generated serial id
*/ */
private static final long serialVersionUID = -100362034024824442L; private static final long serialVersionUID = -100362034024824442L;
/** Grid layout for content of form */
private Grid grid; private Grid grid;
private ConfirmPanel confirmPanel; private ConfirmPanel confirmPanel;
/** Cell to show diff between original and changed text */
private Cell helpDiff; private Cell helpDiff;
private CKeditor helpTextbox; private CKeditor helpTextbox;
private X_AD_CtxHelpMsg ctxHelpMsg; private X_AD_CtxHelpMsg ctxHelpMsg;
/** AD Language from calling GridTab */
private String AD_Language; private String AD_Language;
/** Timer to process onChanging text from {@link #helpTextbox} asynchronously */
private Timer helpTimer; private Timer helpTimer;
/** /**
* * default constructor
*/ */
public CompareCtxHelpSuggestion() { public CompareCtxHelpSuggestion() {
} }
@ -100,6 +127,9 @@ public class CompareCtxHelpSuggestion extends ADForm {
renderGrid(); renderGrid();
} }
/**
* Render content grid.
*/
private void renderGrid() { private void renderGrid() {
Component c = SessionManager.getAppDesktop().getActiveWindow(); Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c); ADWindow adwindow = ADWindow.findADWindow(c);
@ -133,6 +163,7 @@ public class CompareCtxHelpSuggestion extends ADForm {
if (original != null) if (original != null)
original = removeHeaderTag(original); original = removeHeaderTag(original);
row.appendCellChild(new Html(original)); row.appendCellChild(new Html(original));
//suggestion from AD_CtxHelpSuggestion
String changed = (String) gridTab.getValue("MsgText"); String changed = (String) gridTab.getValue("MsgText");
if (changed != null) if (changed != null)
changed = removeHeaderTag(changed); changed = removeHeaderTag(changed);
@ -154,6 +185,11 @@ public class CompareCtxHelpSuggestion extends ADForm {
this.addEventListener(Events.ON_OK, this); this.addEventListener(Events.ON_OK, this);
} }
/**
* @param original
* @param changed
* @return difference between original and changed
*/
private Html diff(String original, String changed) { private Html diff(String original, String changed) {
if (original == null) if (original == null)
original = ""; original = "";
@ -210,7 +246,7 @@ public class CompareCtxHelpSuggestion extends ADForm {
} else if (event.getTarget() == helpTextbox) { } else if (event.getTarget() == helpTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) { if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event; InputEvent inputEvent = (InputEvent) event;
helpTimer.setAttribute(NEW_VALUE, inputEvent.getValue()); helpTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (helpTimer.isRunning()) { if (helpTimer.isRunning()) {
return; return;
} else { } else {
@ -222,17 +258,25 @@ public class CompareCtxHelpSuggestion extends ADForm {
helpTimer.stop(); helpTimer.stop();
} }
} else if (event.getTarget() == helpTimer) { } else if (event.getTarget() == helpTimer) {
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE)); onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE_ATTR));
} else { } else {
super.onEvent(event); super.onEvent(event);
} }
} }
/**
* Handle changes from {@link #helpTextbox}.
* @param text
*/
private void onHelpChanged(String text) { private void onHelpChanged(String text) {
helpDiff.getChildren().clear(); helpDiff.getChildren().clear();
Html html = diff(ctxHelpMsg.get_Translation("MsgText", AD_Language), text); Html html = diff(ctxHelpMsg.get_Translation("MsgText", AD_Language), text);
helpDiff.appendChild(html); helpDiff.appendChild(html);
} }
/**
* Apply changes to calling GridTab (AD_CtxHelpSuggestion).
*/
private void applyChanges() { private void applyChanges() {
Component c = SessionManager.getAppDesktop().getActiveWindow(); Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c); ADWindow adwindow = ADWindow.findADWindow(c);
@ -250,6 +294,10 @@ public class CompareCtxHelpSuggestion extends ADForm {
return Mode.HIGHLIGHTED; return Mode.HIGHLIGHTED;
} }
/**
* @param htmlString
* @return htmlString after removal of html header tag
*/
private String removeHeaderTag(String htmlString) { private String removeHeaderTag(String htmlString) {
htmlString = htmlString htmlString = htmlString
.replace("<html>", "") .replace("<html>", "")
@ -261,6 +309,11 @@ public class CompareCtxHelpSuggestion extends ADForm {
return htmlString; return htmlString;
} }
/**
* @param s1
* @param s2
* @return difference between s1 and s2
*/
private String htmlDiff(String s1, String s2) { private String htmlDiff(String s1, String s2) {
try { try {

View File

@ -1,6 +1,27 @@
/** /***********************************************************************
* * This file is part of iDempiere ERP Open Source *
*/ * http://www.idempiere.org *
* *
* Copyright (C) Contributors *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* 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., 51 Franklin Street, Fifth Floor, Boston, *
* MA 02110-1301, USA. *
* *
* Contributors: *
* - hengsin *
**********************************************************************/
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import java.util.LinkedList; import java.util.LinkedList;
@ -33,34 +54,44 @@ import org.zkoss.zul.Timer;
import org.zkoss.zul.Vlayout; import org.zkoss.zul.Vlayout;
/** /**
* Form to compare suggested text from AD_FieldSuggestion with the original text from AD_Field.
* @author hengsin * @author hengsin
*
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class CompareFieldSuggestion extends ADForm { public class CompareFieldSuggestion extends ADForm {
private static final String NEW_VALUE = "newValue"; /** Timer attribute to store text value from Textbox onChanging event. */
private static final String NEW_VALUE_ATTR = "newValue";
/** /**
* generated serial id * generated serial id
*/ */
private static final long serialVersionUID = -100362034024824442L; private static final long serialVersionUID = -100362034024824442L;
/** Grid layout for content of form */
private Grid grid; private Grid grid;
private ConfirmPanel confirmPanel; private ConfirmPanel confirmPanel;
/** Cell to show diff between original and changed description */
private Cell descriptionDiff; private Cell descriptionDiff;
/** Cell to show diff between original and changed name */
private Cell nameDiff; private Cell nameDiff;
/** Cell to show diff between original and changed help */
private Cell helpDiff; private Cell helpDiff;
private Textbox nameTextbox; private Textbox nameTextbox;
private Textbox descriptionTextbox; private Textbox descriptionTextbox;
private Textbox helpTextbox; private Textbox helpTextbox;
private MField field; private MField field;
/** AD Language from calling GridTab */
private String AD_Language; private String AD_Language;
private diff_match_patch diff; private diff_match_patch diff;
/** Timer to process onChanging text from {@link #nameTextbox} asynchronously */
private Timer nameTimer; private Timer nameTimer;
/** Timer to process onChanging text from {@link #descriptionTextbox} asynchronously */
private Timer descriptionTimer; private Timer descriptionTimer;
/** Timer to process onChanging text from {@link #helpTextbox} asynchronously */
private Timer helpTimer; private Timer helpTimer;
/** /**
* * default constructor
*/ */
public CompareFieldSuggestion() { public CompareFieldSuggestion() {
} }
@ -119,6 +150,9 @@ public class CompareFieldSuggestion extends ADForm {
renderGrid(); renderGrid();
} }
/**
* Render content grid.
*/
private void renderGrid() { private void renderGrid() {
Component c = SessionManager.getAppDesktop().getActiveWindow(); Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c); ADWindow adwindow = ADWindow.findADWindow(c);
@ -155,6 +189,7 @@ public class CompareFieldSuggestion extends ADForm {
String original = field.get_Translation("Name", AD_Language); String original = field.get_Translation("Name", AD_Language);
row.appendCellChild(new Label(original)); row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
String changed = (String) gridTab.getValue("Name"); String changed = (String) gridTab.getValue("Name");
nameTextbox = new Textbox(changed); nameTextbox = new Textbox(changed);
row.appendCellChild(nameTextbox); row.appendCellChild(nameTextbox);
@ -173,6 +208,7 @@ public class CompareFieldSuggestion extends ADForm {
original = field.get_Translation("Description", AD_Language); original = field.get_Translation("Description", AD_Language);
row.appendCellChild(new Label(original)); row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
changed = (String) gridTab.getValue("Description"); changed = (String) gridTab.getValue("Description");
descriptionTextbox = new Textbox(changed); descriptionTextbox = new Textbox(changed);
descriptionTextbox.setRows(4); descriptionTextbox.setRows(4);
@ -193,6 +229,7 @@ public class CompareFieldSuggestion extends ADForm {
original = field.get_Translation("Help", AD_Language); original = field.get_Translation("Help", AD_Language);
row.appendCellChild(new Label(original)); row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
changed = (String) gridTab.getValue("Help"); changed = (String) gridTab.getValue("Help");
helpTextbox = new Textbox(changed); helpTextbox = new Textbox(changed);
helpTextbox.setRows(8); helpTextbox.setRows(8);
@ -211,6 +248,11 @@ public class CompareFieldSuggestion extends ADForm {
this.addEventListener(Events.ON_OK, this); this.addEventListener(Events.ON_OK, this);
} }
/**
* @param original
* @param changed
* @return difference between original and changed
*/
private Html diff(String original, String changed) { private Html diff(String original, String changed) {
if (original == null) original = ""; if (original == null) original = "";
if (changed == null) changed = ""; if (changed == null) changed = "";
@ -233,7 +275,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == nameTextbox) { } else if (event.getTarget() == nameTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) { if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event; InputEvent inputEvent = (InputEvent) event;
nameTimer.setAttribute(NEW_VALUE, inputEvent.getValue()); nameTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (nameTimer.isRunning()) { if (nameTimer.isRunning()) {
return; return;
} else { } else {
@ -247,7 +289,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == descriptionTextbox) { } else if (event.getTarget() == descriptionTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) { if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event; InputEvent inputEvent = (InputEvent) event;
descriptionTimer.setAttribute(NEW_VALUE, inputEvent.getValue()); descriptionTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (descriptionTimer.isRunning()) { if (descriptionTimer.isRunning()) {
return; return;
} else { } else {
@ -261,7 +303,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == helpTextbox) { } else if (event.getTarget() == helpTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) { if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event; InputEvent inputEvent = (InputEvent) event;
helpTimer.setAttribute(NEW_VALUE, inputEvent.getValue()); helpTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (helpTimer.isRunning()) { if (helpTimer.isRunning()) {
return; return;
} else { } else {
@ -273,34 +315,49 @@ public class CompareFieldSuggestion extends ADForm {
helpTimer.stop(); helpTimer.stop();
} }
} else if (event.getTarget() == nameTimer) { } else if (event.getTarget() == nameTimer) {
onNameChanged((String) nameTimer.removeAttribute(NEW_VALUE)); onNameChanged((String) nameTimer.removeAttribute(NEW_VALUE_ATTR));
} else if (event.getTarget() == descriptionTimer) { } else if (event.getTarget() == descriptionTimer) {
onDescriptionChanged((String) descriptionTimer.removeAttribute(NEW_VALUE)); onDescriptionChanged((String) descriptionTimer.removeAttribute(NEW_VALUE_ATTR));
} else if (event.getTarget() == helpTimer) { } else if (event.getTarget() == helpTimer) {
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE)); onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE_ATTR));
} else { } else {
super.onEvent(event); super.onEvent(event);
} }
} }
/**
* Handle changes from {@link #helpTextbox}.
* @param text
*/
private void onHelpChanged(String text) { private void onHelpChanged(String text) {
helpDiff.getChildren().clear(); helpDiff.getChildren().clear();
Html html = diff(field.get_Translation("Help", AD_Language), text); Html html = diff(field.get_Translation("Help", AD_Language), text);
helpDiff.appendChild(html); helpDiff.appendChild(html);
} }
/**
* Handle changes from {@link #descriptionTextbox}.
* @param text
*/
private void onDescriptionChanged(String text) { private void onDescriptionChanged(String text) {
descriptionDiff.getChildren().clear(); descriptionDiff.getChildren().clear();
Html html = diff(field.get_Translation("Description", AD_Language), text); Html html = diff(field.get_Translation("Description", AD_Language), text);
descriptionDiff.appendChild(html); descriptionDiff.appendChild(html);
} }
/**
* Handle changes from {@link #nameTextbox}.
* @param text
*/
private void onNameChanged(String text) { private void onNameChanged(String text) {
nameDiff.getChildren().clear(); nameDiff.getChildren().clear();
Html html = diff(field.get_Translation("Name", AD_Language), text); Html html = diff(field.get_Translation("Name", AD_Language), text);
nameDiff.appendChild(html); nameDiff.appendChild(html);
} }
/**
* Apply changes to calling GridTab (AD_FieldSuggestion).
*/
private void applyChanges() { private void applyChanges() {
Component c = SessionManager.getAppDesktop().getActiveWindow(); Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c); ADWindow adwindow = ADWindow.findADWindow(c);

View File

@ -24,9 +24,8 @@ import org.compiere.model.I_M_RMA;
import org.compiere.model.I_C_DepositBatch; import org.compiere.model.I_C_DepositBatch;
/** /**
* * Default implementation of {@link ICreateFromFactory}
* @author Elaine * @author Elaine
*
*/ */
public class DefaultCreateFromFactory implements ICreateFromFactory public class DefaultCreateFromFactory implements ICreateFromFactory
{ {

View File

@ -19,12 +19,12 @@ import org.compiere.model.GridTab;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
/** /**
* * Default implementation of {@link IPaymentFormFactory}
* @author Elaine * @author Elaine
*
*/ */
public class DefaultPaymentFormFactory implements IPaymentFormFactory { public class DefaultPaymentFormFactory implements IPaymentFormFactory {
@Override
public IPaymentForm create(int windowNo, GridTab mTab, String paymentRule) public IPaymentForm create(int windowNo, GridTab mTab, String paymentRule)
{ {
if (paymentRule.equals(MInvoice.PAYMENTRULE_Cash)) if (paymentRule.equals(MInvoice.PAYMENTRULE_Cash))

View File

@ -60,7 +60,7 @@ import org.zkoss.zul.Space;
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class MFARegisterForm extends ADForm { public class MFARegisterForm extends ADForm {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = 6186035815377577281L; private static final long serialVersionUID = 6186035815377577281L;
@ -91,7 +91,7 @@ public class MFARegisterForm extends ADForm {
private MMFARegistration registration = null; private MMFARegistration registration = null;
/** /**
* * Default constructor
*/ */
public MFARegisterForm() { public MFARegisterForm() {
} }

View File

@ -79,10 +79,7 @@ import org.zkoss.zul.North;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* Allocation Form * Form to create allocation (C_AllocationHdr and C_AllocationLine).
*
* @author Jorg Janke
* @version $Id: VAllocation.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
* *
* Contributor : Fabian Aguilar - OFBConsulting - Multiallocation * Contributor : Fabian Aguilar - OFBConsulting - Multiallocation
*/ */
@ -90,11 +87,11 @@ import org.zkoss.zul.South;
public class WAllocation extends Allocation public class WAllocation extends Allocation
implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener
{ {
/** UI form instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** /**
* Initialize Panel * Default constructor
*/ */
public WAllocation() public WAllocation()
{ {
@ -116,61 +113,94 @@ public class WAllocation extends Allocation
} }
} // init } // init
// /** Main layout for {@link #form} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
//Parameter
/** Parameter panel. North of {@link #mainLayout} */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
private Panel allocationPanel = new Panel(); //footer /** Grid layout of {@link #parameterPanel} */
private Grid parameterLayout = GridFactory.newGridLayout(); private Grid parameterLayout = GridFactory.newGridLayout();
private Label bpartnerLabel = new Label(); private Label bpartnerLabel = new Label();
/** bpartner parameter */
private WSearchEditor bpartnerSearch = null; 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 Button refreshButton = new Button();
private Label currencyLabel = new Label(); private Label currencyLabel = new Label();
/** Currency parameter */
private WTableDirEditor currencyPick = null; private WTableDirEditor currencyPick = null;
/** Multi currency parameter */
private Checkbox multiCurrency = new Checkbox(); private Checkbox multiCurrency = new Checkbox();
private Label chargeLabel = new Label(); private Label chargeLabel = new Label();
private WTableDirEditor chargePick = null;
private Label DocTypeLabel = new Label();
private WTableDirEditor DocTypePick = null;
private Label allocCurrencyLabel = new Label();
private Hlayout statusBar = new Hlayout();
private Label dateLabel = new Label(); private Label dateLabel = new Label();
/** Document date parameter */
private WDateEditor dateField = new WDateEditor(); private WDateEditor dateField = new WDateEditor();
/** Auto write off parameter */
private Checkbox autoWriteOff = new Checkbox(); private Checkbox autoWriteOff = new Checkbox();
private Label organizationLabel = new Label(); private Label organizationLabel = new Label();
/** Organization parameter */
private WTableDirEditor organizationPick; private WTableDirEditor organizationPick;
/** Number of column for {@link #parameterLayout} */
private int noOfColumn; private int noOfColumn;
/** Center of {@link #mainLayout}. */
private Borderlayout infoPanel = new Borderlayout();
/** North of {@link #infoPanel} */
private Panel paymentPanel = new Panel();
/** Center of {@link #infoPanel} */
private Panel invoicePanel = new Panel();
//Invoice
/** Layout of {@link #invoicePanel} */
private Borderlayout invoiceLayout = new Borderlayout();
/** North of {@link #invoiceLayout} */
private Label invoiceLabel = new Label();
/** Center of {@link #invoiceLayout}. List of invoice documents. */
private WListbox invoiceTable = ListboxFactory.newDataTable();
/** South of {@link #invoiceLayout} */
private Label invoiceInfo = new Label();
//Payments
/** Layout of {@link #paymentPanel} */
private Borderlayout paymentLayout = new Borderlayout();
/** North of {@link #paymentLayout} */
private Label paymentLabel = new Label();
/** Center of {@link #paymentLayout}. List of payment documents. */
private WListbox paymentTable = ListboxFactory.newDataTable();
/** South of {@link #paymentLayout} */
private Label paymentInfo = new Label();
//Allocation
/** South of {@link #mainLayout} */
private Panel allocationPanel = new Panel(); //footer
/** Grid layout of {@link #allocationPanel} */
private Grid allocationLayout = GridFactory.newGridLayout();
private Label differenceLabel = new Label();
/** Difference between payment and invoice. Part of {@link #allocationLayout}. */
private Textbox differenceField = new Textbox();
/** Button to apply allocation. Part of {@link #allocationLayout}. */
private Button allocateButton = new Button();
/** Button to refresh {@link #paymentTable} and {@link #invoiceTable}. Part of {@link #allocationLayout}. */
private Button refreshButton = new Button();
/** Charges. Part of {@link #allocationLayout}. */
private WTableDirEditor chargePick = null;
private Label DocTypeLabel = new Label();
/** Document types. Part of {@link #allocationLayout}. */
private WTableDirEditor DocTypePick = null;
private Label allocCurrencyLabel = new Label();
/** Status bar, bottom of {@link #allocationPanel} */
private Hlayout statusBar = new Hlayout();
/** /**
* Static Init * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
private void zkInit() throws Exception private void zkInit() throws Exception
{ {
//
Div div = new Div(); Div div = new Div();
div.setStyle("height: 100%; width: 100%; overflow: auto;"); div.setStyle("height: 100%; width: 100%; overflow: auto;");
div.appendChild(mainLayout); div.appendChild(mainLayout);
form.appendChild(div); form.appendChild(div);
ZKUpdateUtil.setWidth(mainLayout, "100%"); ZKUpdateUtil.setWidth(mainLayout, "100%");
/////
mainLayout.setStyle("min-height: 600px"); mainLayout.setStyle("min-height: 600px");
/////
dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date")); dateLabel.setText(Msg.getMsg(Env.getCtx(), "Date"));
autoWriteOff.setSelected(false); autoWriteOff.setSelected(false);
@ -201,7 +231,6 @@ public class WAllocation extends Allocation
multiCurrency.setText(Msg.getMsg(Env.getCtx(), "MultiCurrency")); multiCurrency.setText(Msg.getMsg(Env.getCtx(), "MultiCurrency"));
multiCurrency.addActionListener(this); multiCurrency.addActionListener(this);
allocCurrencyLabel.setText("."); allocCurrencyLabel.setText(".");
organizationLabel.setText(Msg.translate(Env.getCtx(), "AD_Org_ID")); organizationLabel.setText(Msg.translate(Env.getCtx(), "AD_Org_ID"));
// parameters layout // parameters layout
@ -295,8 +324,11 @@ public class WAllocation extends Allocation
center.appendChild(invoicePanel); center.appendChild(invoicePanel);
center.setAutoscroll(true); center.setAutoscroll(true);
infoPanel.setStyle("min-height: 300px;"); infoPanel.setStyle("min-height: 300px;");
} // jbInit }
/**
* Layout {@link #parameterLayout} and {@link #allocationPanel}.
*/
protected void layoutParameterAndSummary() { protected void layoutParameterAndSummary() {
Rows rows = null; Rows rows = null;
Row row = null; Row row = null;
@ -404,6 +436,9 @@ public class WAllocation extends Allocation
} }
} }
/**
* Setup columns for {@link #parameterLayout}.
*/
protected void setupParameterColumns() { protected void setupParameterColumns() {
noOfColumn = 6; noOfColumn = 6;
if (maxWidth(MEDIUM_WIDTH-1)) if (maxWidth(MEDIUM_WIDTH-1))
@ -452,11 +487,11 @@ public class WAllocation extends Allocation
bpartnerSearch = new WSearchEditor("C_BPartner_ID", true, false, true, lookupBP); bpartnerSearch = new WSearchEditor("C_BPartner_ID", true, false, true, lookupBP);
bpartnerSearch.addValueChangeListener(this); bpartnerSearch.addValueChangeListener(this);
// Translation // Status bar
statusBar.appendChild(new Label(Msg.getMsg(Env.getCtx(), "AllocateStatus"))); statusBar.appendChild(new Label(Msg.getMsg(Env.getCtx(), "AllocateStatus")));
ZKUpdateUtil.setVflex(statusBar, "min"); ZKUpdateUtil.setVflex(statusBar, "min");
// Date set to Login Date // Default dateField to Login Date
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(Env.getContextAsDate(Env.getCtx(), Env.DATE)); cal.setTime(Env.getContextAsDate(Env.getCtx(), Env.DATE));
cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.HOUR_OF_DAY, 0);
@ -479,9 +514,11 @@ public class WAllocation extends Allocation
DocTypePick = new WTableDirEditor("C_DocType_ID", false, false, true, lookupDocType); DocTypePick = new WTableDirEditor("C_DocType_ID", false, false, true, lookupDocType);
DocTypePick.setValue(getC_DocType_ID()); DocTypePick.setValue(getC_DocType_ID());
DocTypePick.addValueChangeListener(this); DocTypePick.addValueChangeListener(this);
} // dynInit } // dynInit
/**
* Handle onClientInfo event from browser.
*/
protected void onClientInfo() protected void onClientInfo()
{ {
if (ClientInfo.isMobile() && form.getPage() != null) if (ClientInfo.isMobile() && form.getPage() != null)
@ -512,15 +549,14 @@ public class WAllocation extends Allocation
} }
} }
/************************************************************************** /**
* Action Listener. * Event listener
* - MultiCurrency
* - Allocate
* @param e event * @param e event
*/ */
@Override
public void onEvent(Event e) public void onEvent(Event e)
{ {
log.config(""); if (log.isLoggable(Level.CONFIG)) log.config("");
if (e.getTarget().equals(multiCurrency)) if (e.getTarget().equals(multiCurrency))
loadBPartner(); loadBPartner();
// Allocate // Allocate
@ -543,10 +579,11 @@ public class WAllocation extends Allocation
} }
/** /**
* Table Model Listener. * Table Model Listener for {@link #paymentTable} and {@link #invoiceTable}
* - Recalculate Totals * - Recalculate Totals
* @param e event * @param e event
*/ */
@Override
public void tableChanged(WTableModelEvent e) public void tableChanged(WTableModelEvent e)
{ {
boolean isUpdate = (e.getType() == WTableModelEvent.CONTENTS_CHANGED); boolean isUpdate = (e.getType() == WTableModelEvent.CONTENTS_CHANGED);
@ -579,12 +616,10 @@ public class WAllocation extends Allocation
} // tableChanged } // tableChanged
/** /**
* Vetoable Change Listener. * Value change listener for parameter and allocation fields.
* - Business Partner
* - Currency
* - Date
* @param e event * @param e event
*/ */
@Override
public void valueChange (ValueChangeEvent e) public void valueChange (ValueChangeEvent e)
{ {
String name = e.getPropertyName(); String name = e.getPropertyName();
@ -631,6 +666,9 @@ public class WAllocation extends Allocation
loadBPartner(); loadBPartner();
} // vetoableChange } // vetoableChange
/**
* Set {@link #allocateButton} to enable or disable.
*/
private void setAllocateButton() { private void setAllocateButton() {
if (isOkToAllocate() ) if (isOkToAllocate() )
{ {
@ -649,9 +687,11 @@ public class WAllocation extends Allocation
} }
/** /**
* Load Business Partner Info * Load Business Partner Info.
* - Payments * <ul>
* - Invoices * <li>Payments</li>
* <li>Invoices</li>
* </ul>
*/ */
private void loadBPartner () private void loadBPartner ()
{ {
@ -718,8 +758,8 @@ public class WAllocation extends Allocation
setAllocateButton(); setAllocateButton();
} }
/************************************************************************** /**
* Save Data * Save Data to C_AllocationHdr and C_AllocationLine.
*/ */
private MAllocationHdr saveData() private MAllocationHdr saveData()
{ {
@ -753,6 +793,7 @@ public class WAllocation extends Allocation
* Called by org.adempiere.webui.panel.ADForm.openForm(int) * Called by org.adempiere.webui.panel.ADForm.openForm(int)
* @return {@link ADForm} * @return {@link ADForm}
*/ */
@Override
public ADForm getForm() public ADForm getForm()
{ {
return form; return form;

View File

@ -95,7 +95,7 @@ import org.zkoss.zul.impl.Utils;
import org.zkoss.zul.impl.XulElement; import org.zkoss.zul.impl.XulElement;
/** /**
* Archive Viewer * Archive Viewer Form with query and viewer tab.
* *
* @author Niraj Sohun * @author Niraj Sohun
* @date September 28, 2007 * @date September 28, 2007
@ -132,7 +132,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
if (newpage != null) { if (newpage != null) {
try { try {
dynInit(); dynInit();
jbInit(); zkInit();
if (ClientInfo.isMobile() || MSysConfig.getBooleanValue(MSysConfig.ZK_USE_PDF_JS_VIEWER, false, Env.getAD_Client_ID(Env.getCtx()))) { if (ClientInfo.isMobile() || MSysConfig.getBooleanValue(MSysConfig.ZK_USE_PDF_JS_VIEWER, false, Env.getAD_Client_ID(Env.getCtx()))) {
if (media != null && iframe.getSrc() == null) { if (media != null && iframe.getSrc() == null) {
String url = Utils.getDynamicMediaURI(form, mediaVersion, media.getName(), media.getFormat()); String url = Utils.getDynamicMediaURI(form, mediaVersion, media.getName(), media.getFormat());
@ -148,59 +148,93 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} }
} }
}; };
/** UI Form */
private CustomForm form; private CustomForm form;
//Query Tab
/** Report (Y/N) field of query tab */
private Checkbox reportField = new Checkbox(); private Checkbox reportField = new Checkbox();
private Label processLabel = new Label(Msg.translate(Env.getCtx(), "AD_Process_ID")); private Label processLabel = new Label(Msg.translate(Env.getCtx(), "AD_Process_ID"));
/** AD_Process list field of query tab */
private Listbox processField = new Listbox(); private Listbox processField = new Listbox();
private Label tableLabel = new Label(Msg.translate(Env.getCtx(), "AD_Table_ID")); private Label tableLabel = new Label(Msg.translate(Env.getCtx(), "AD_Table_ID"));
/** AD_Table list field of query tab */
private Listbox tableField = new Listbox(); private Listbox tableField = new Listbox();
private Label bPartnerLabel = new Label(Msg.translate(Env.getCtx(), "C_BPartner_ID")); private Label bPartnerLabel = new Label(Msg.translate(Env.getCtx(), "C_BPartner_ID"));
/** Business partner field of query tab */
private WSearchEditor bPartnerField = null; private WSearchEditor bPartnerField = null;
private Label nameQLabel = new Label(Msg.translate(Env.getCtx(), "Name")); private Label nameQLabel = new Label(Msg.translate(Env.getCtx(), "Name"));
/** Name field of query tab */
private Textbox nameQField = new Textbox(); private Textbox nameQField = new Textbox();
private Label descriptionQLabel = new Label(Msg.translate(Env.getCtx(), "Description")); private Label descriptionQLabel = new Label(Msg.translate(Env.getCtx(), "Description"));
/** Description field of query tab */
private Textbox descriptionQField = new Textbox(); private Textbox descriptionQField = new Textbox();
private Label helpQLabel = new Label(Msg.translate(Env.getCtx(), "Help")); private Label helpQLabel = new Label(Msg.translate(Env.getCtx(), "Help"));
/** Help field of query tab */
private Textbox helpQField = new Textbox(); private Textbox helpQField = new Textbox();
private Label createdByQLabel = new Label(Msg.translate(Env.getCtx(), "CreatedBy")); private Label createdByQLabel = new Label(Msg.translate(Env.getCtx(), "CreatedBy"));
/** Created by user list field of query tab */
private Listbox createdByQField = new Listbox(); private Listbox createdByQField = new Listbox();
private Label createdQLabel = new Label(Msg.translate(Env.getCtx(), "Created")); private Label createdQLabel = new Label(Msg.translate(Env.getCtx(), "Created"));
/** Created date from field of query tab */
private Datebox createdQFrom = new Datebox(); private Datebox createdQFrom = new Datebox();
/** Created date to field of query tab */
private Datebox createdQTo = new Datebox(); private Datebox createdQTo = new Datebox();
//Viewer Tab
/** Prior button of viewer tab */
private Button bBack = new Button(); private Button bBack = new Button();
/** Next button of viewer tab */
private Button bNext = new Button(); private Button bNext = new Button();
/** Show index of current archive record, part of viewer tab */
private Label positionInfo = new Label("."); private Label positionInfo = new Label(".");
private Label createdByLabel = new Label(Msg.translate(Env.getCtx(), "CreatedBy")); private Label createdByLabel = new Label(Msg.translate(Env.getCtx(), "CreatedBy"));
/** Created by field of viewer tab */
private Textbox createdByField = new Textbox(); private Textbox createdByField = new Textbox();
/** Created field of viewer tab */
private DatetimeBox createdField = new DatetimeBox(); private DatetimeBox createdField = new DatetimeBox();
private Label nameLabel = new Label(Msg.translate(Env.getCtx(), "Name")); private Label nameLabel = new Label(Msg.translate(Env.getCtx(), "Name"));
/** Name field of viewer tab */
private Textbox nameField = new Textbox(); private Textbox nameField = new Textbox();
private Label descriptionLabel = new Label(Msg.translate(Env.getCtx(), "Description")); private Label descriptionLabel = new Label(Msg.translate(Env.getCtx(), "Description"));
/** Description field of viewer tab */
private Textbox descriptionField = new Textbox(); private Textbox descriptionField = new Textbox();
private Label helpLabel = new Label(Msg.translate(Env.getCtx(), "Help")); private Label helpLabel = new Label(Msg.translate(Env.getCtx(), "Help"));
/** Help field of viewer tab */
private Textbox helpField = new Textbox(); private Textbox helpField = new Textbox();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private Button updateArchive = new Button(); private Button updateArchive = new Button();
private Button deleteArchive = new Button(); private Button deleteArchive = new Button();
/** Button to email current archive */
private Button bEmail = new Button(); private Button bEmail = new Button();
/** Iframe to view archive content, part of viewer tab. */
private Iframe iframe = new Iframe();
/** Button to refresh {@link #iframe} */
private Button bRefresh = new Button();
/** Content of {@link #form} */
private Tabbox tabbox = new Tabbox(); private Tabbox tabbox = new Tabbox();
/** Tabs of {@link #tabbox} */
private Tabs tabs = new Tabs(); private Tabs tabs = new Tabs();
/** Tabpanels of {@link #tabbox} */
private Tabpanels tabpanels = new Tabpanels(); private Tabpanels tabpanels = new Tabpanels();
private Iframe iframe = new Iframe(); /** Bottom button panel of {@link #form} */
private Button bRefresh = new Button(); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** If true, query tab is visible, false otherwise */
private boolean showQuery = true; private boolean showQuery = true;
/** For ZK_USE_PDF_JS_VIEWER, increment by 1 for each refresh of {@link #media}. */
private int mediaVersion = 0; private int mediaVersion = 0;
private AMedia media; private AMedia media;
/**
* Default constructor
*/
public WArchiveViewer() public WArchiveViewer()
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
form = new WArchiveViewerForm(); form = new WArchiveViewerForm();
@ -208,9 +242,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} }
/** /**
* Dynamic Init * Dynamic Init
*/ */
private void dynInit() private void dynInit()
{ {
processField = new Listbox(); processField = new Listbox();
@ -234,6 +267,11 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
Env.getCtx(), "C_BPartner_ID"), "", true, false, true); Env.getCtx(), "C_BPartner_ID"), "", true, false, true);
} // dynInit } // dynInit
/**
* Show archive content in {@link #iframe}.
* @param name
* @param data
*/
private void reportViewer(String name, byte[] data) private void reportViewer(String name, byte[] data)
{ {
media = new AMedia(name + ".pdf", "pdf", "application/pdf", data); media = new AMedia(name + ".pdf", "pdf", "application/pdf", data);
@ -261,11 +299,10 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} }
/** /**
* Static Init * Layout {@link #form}.
* @throws Exception * @throws Exception
*/ */
private void zkInit() throws Exception
private void jbInit() throws Exception
{ {
ZKUpdateUtil.setWidth(tabbox, "100%"); ZKUpdateUtil.setWidth(tabbox, "100%");
ZKUpdateUtil.setVflex(tabbox, "1"); ZKUpdateUtil.setVflex(tabbox, "1");
@ -607,10 +644,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
form.appendChild(confirmPanel); form.appendChild(confirmPanel);
} }
@Override
public void onEvent(Event e) throws Exception public void onEvent(Event e) throws Exception
{ {
log.info(e.getName());
if (e.getTarget() == updateArchive) if (e.getTarget() == updateArchive)
cmd_updateArchive(); cmd_updateArchive();
else if(e.getTarget() == deleteArchive) else if(e.getTarget() == deleteArchive)
@ -648,7 +684,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} }
/** /**
* Update Query Display * Update Query Tab
*/ */
private void updateQDisplay() private void updateQDisplay()
{ {
@ -669,6 +705,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
bPartnerLabel.getParent().setVisible(!reports); bPartnerLabel.getParent().setVisible(!reports);
} // updateQDisplay } // updateQDisplay
/**
* Delete current archive record.
*/
public void cmd_deleteArchive(){ public void cmd_deleteArchive(){
Dialog.ask(m_WindowNo, "DeleteRecord?", new Callback<Boolean>() { Dialog.ask(m_WindowNo, "DeleteRecord?", new Callback<Boolean>() {
@ -709,10 +748,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} }
/** /**
* Update View Display * Update Viewer Tab
* @param next show next Archive * @param next true to show next archive, false to show previous archive
*/ */
private void updateVDisplay (boolean next) private void updateVDisplay (boolean next)
{ {
if (m_archives == null) if (m_archives == null)
@ -734,7 +772,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
deleteArchive.setEnabled(m_archives.length > 0); deleteArchive.setEnabled(m_archives.length > 0);
updateArchive.setEnabled(false); updateArchive.setEnabled(false);
log.info("Index=" + m_index + ", Length=" + m_archives.length); if (log.isLoggable(Level.INFO))
log.info("Index=" + m_index + ", Length=" + m_archives.length);
if (m_archives.length == 0) if (m_archives.length == 0)
{ {
@ -760,16 +799,15 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
try try
{ {
in = ar.getInputStream(); in = ar.getInputStream();
//pdfViewer.setScale(reportField.isSelected() ? 50 : 75);
if (in != null) if (in != null)
reportViewer(ar.getName(), ar.getBinaryData());//pdfViewer.loadPDF(in); reportViewer(ar.getName(), ar.getBinaryData());
else else
iframe.getChildren().clear();//pdfViewer.clearDocument(); iframe.getChildren().clear();
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, "pdf", e); log.log(Level.SEVERE, e.getMessage(), e);
iframe.getChildren().clear();//pdfViewer.clearDocument(); iframe.getChildren().clear();
} }
finally finally
{ {
@ -785,9 +823,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} // updateVDisplay } // updateVDisplay
/** /**
* Update Archive Info * Update {@link MArchive} and viewer tab.
*/ */
private void cmd_updateArchive() private void cmd_updateArchive()
{ {
MArchive ar = m_archives[m_index]; MArchive ar = m_archives[m_index];
@ -815,7 +852,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
update = true; update = true;
} }
log.info("Update=" + update); if (log.isLoggable(Level.INFO))
log.info("Update=" + update);
if (update) if (update)
ar.saveEx(); ar.saveEx();
@ -826,12 +864,11 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
} // cmd_updateArchive } // cmd_updateArchive
/** /**
* Query Directly * Execute query.
* @param isReport report * @param isReport report
* @param AD_Table_ID table * @param AD_Table_ID table
* @param Record_ID tecord * @param Record_ID tecord
*/ */
public void query (boolean isReport, int AD_Table_ID, int Record_ID) public void query (boolean isReport, int AD_Table_ID, int Record_ID)
{ {
if (log.isLoggable(Level.CONFIG)) log.config("Report=" + isReport + ", AD_Table_ID=" + AD_Table_ID + ",Record_ID=" + Record_ID); if (log.isLoggable(Level.CONFIG)) log.config("Report=" + isReport + ", AD_Table_ID=" + AD_Table_ID + ",Record_ID=" + Record_ID);
@ -841,10 +878,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
cmd_query(); cmd_query();
} // query } // query
/************************************************************************** /**
* Create Query * Execute Query
*/ */
private void cmd_query() private void cmd_query()
{ {
boolean reports = reportField.isChecked(); boolean reports = reportField.isChecked();
@ -907,10 +943,14 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
updateVDisplay(false); updateVDisplay(false);
} // cmd_query } // cmd_query
/**
* @param showQuery true to show query tab, false otherwise
*/
public void setShowQuery(boolean showQuery) { public void setShowQuery(boolean showQuery) {
this.showQuery = showQuery; this.showQuery = showQuery;
} }
@Override
public ADForm getForm() { public ADForm getForm() {
return form; return form;
} }

View File

@ -81,6 +81,9 @@ import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
import org.zkoss.zul.Vlayout; import org.zkoss.zul.Vlayout;
/**
* Form to create order, invoice or project lines from BOM.
*/
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VBOMDrop") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VBOMDrop")
public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChangeListener public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChangeListener
{ {
@ -89,73 +92,86 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
*/ */
private static final long serialVersionUID = -525234460800183807L; private static final long serialVersionUID = -525234460800183807L;
private static final String FEATURE_GROUP_KEY = "FeatureGroupKey"; /** Groupbox attribute to store BOMLevel|Feature string */
private static final String FEATURE_GROUP_KEY_ATTR = "FeatureGroupKey";
private static final String OPTION_PRODUCT_KEY = "OptionProductKey"; /** Checkbox/Radio attribute to store ParentProductID_ChildProductID string */
private static final String OPTION_PRODUCT_KEY_ATTR = "OptionProductKey";
/** Product to create BOMs from */ /** BOM parent product */
private MProduct m_product; private MProduct m_product;
/** BOM Qty */ /** BOM Qty */
private BigDecimal m_qty = Env.ONE; private BigDecimal m_qty = Env.ONE;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WBOMDrop.class); private static final CLogger log = CLogger.getCLogger(WBOMDrop.class);
/** List of all selectors */ /** List of selector/checkbox for each BOM line */
private ArrayList<org.zkoss.zul.Checkbox> m_selectorList = new ArrayList<org.zkoss.zul.Checkbox>(); private ArrayList<org.zkoss.zul.Checkbox> m_selectorList = new ArrayList<org.zkoss.zul.Checkbox>();
/** List of all quantities */ /** List of quantity for each BOM line */
private ArrayList<Decimalbox> m_qtyList = new ArrayList<Decimalbox>(); private ArrayList<Decimalbox> m_qtyList = new ArrayList<Decimalbox>();
/** List of all products */ /** List of product for each BOM line */
private ArrayList<Integer> m_productList = new ArrayList<Integer>(); private ArrayList<Integer> m_productList = new ArrayList<Integer>();
/** list child panel of each checkbox+product */ /** list of child panel for each BOM line */
private ArrayList<Layout> m_childPanelList = new ArrayList<Layout>(); private ArrayList<Layout> m_childPanelList = new ArrayList<Layout>();
/** list of panel for checkbox and child panel of a product */ /** list of panel for each BOM line */
private ArrayList<Layout> m_productPanelList = new ArrayList<Layout>(); private ArrayList<Layout> m_productPanelList = new ArrayList<Layout>();
/** Alternative Group Map */ /** GroupKey:RadioGroup. Alternative Group Map */
private HashMap<String, Radiogroup> m_alternativeGroups = new HashMap<String,Radiogroup>(); private HashMap<String, Radiogroup> m_alternativeGroups = new HashMap<String,Radiogroup>();
private ConfirmPanel confirmPanel = new ConfirmPanel(true); /** Main layout */
//content panel of selectionGroupbox private Borderlayout borderLayout;
private Grid selectionPanel = GridFactory.newGridLayout();
/** Selection/parameters group box, north of {@link #borderLayout} */
private Groupbox selectionGroupbox = new Groupbox();
/** Grid layout of {@link #selectionGroupbox} */
private Grid selectionPanel = GridFactory.newGridLayout();
/** BOM parent product field of {@link #selectionPanel} */
private WSearchEditor fieldProduct;
/** Quantity field of {@link #selectionPanel} */
private Decimalbox productQty = new Decimalbox(); private Decimalbox productQty = new Decimalbox();
/** Order field of {@link #selectionPanel} */
private Listbox orderField = new Listbox(); private Listbox orderField = new Listbox();
/** Invoice field of {@link #selectionPanel} */
private Listbox invoiceField = new Listbox(); private Listbox invoiceField = new Listbox();
/** Project field of {@link #selectionPanel} */
private Listbox projectField = new Listbox(); private Listbox projectField = new Listbox();
//north selection group box /** BOM group box, center of {@link #borderLayout} */
private Groupbox selectionGroupbox = new Groupbox();
//center bom group box
private Groupbox centerGroupbox = new Groupbox(); private Groupbox centerGroupbox = new Groupbox();
private int indend = 20; private int indend = 20;
private WSearchEditor fieldProduct; /** Panel of action buttons. South of {@link #borderLayout} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** Form controller */
private BOMDrop bomDrop = new BOMDrop(); private BOMDrop bomDrop = new BOMDrop();
/** ParentProductID_ParentBOMLineLevel:Child Panel (in {@link #m_childPanelList}) */
private HashMap<String, Component> m_parentContainerMap = new HashMap<>(); private HashMap<String, Component> m_parentContainerMap = new HashMap<>();
/** BOMLevel|Feature:Groupbox */
private Map<String, Groupbox> m_featureGroup = new HashMap<>(); private Map<String, Groupbox> m_featureGroup = new HashMap<>();
private Borderlayout borderLayout; /** selected variant or option with key of ParentProductId_ProductId */
//selected variant or option with key of ParentProductId_ProductId
private List<String> m_selectedOtions = new ArrayList<>(); private List<String> m_selectedOtions = new ArrayList<>();
//unselected variant or option with key of ParentProductId_ProductId /** unselected variant or option with key of ParentProductId_ProductId */
private List<String> m_unselectedOtions = new ArrayList<>(); private List<String> m_unselectedOtions = new ArrayList<>();
/**
* Default constructor
*/
public WBOMDrop() public WBOMDrop()
{} {}
/** /**
* Initialize Panel * Layout form
*/ */
protected void initForm() protected void initForm()
{ {
@ -194,7 +210,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
{ {
log.log(Level.SEVERE, e.getMessage(), e); log.log(Level.SEVERE, e.getMessage(), e);
} }
} // init }
/** /**
* Dispose * Dispose
@ -238,14 +254,13 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
m_alternativeGroups = null; m_alternativeGroups = null;
} // dispose } // dispose
/************************************************************************** /**
* Create Selection Panel * Create Selection/Parameters Panel.
* @param order * @param order
* @param invoice * @param invoice
* @param project * @param project
* @throws Exception * @throws Exception
*/ */
private void createSelectionPanel (boolean order, boolean invoice, boolean project) throws Exception private void createSelectionPanel (boolean order, boolean invoice, boolean project) throws Exception
{ {
Caption caption = new Caption(Msg.translate(Env.getCtx(), "Selection")); Caption caption = new Caption(Msg.translate(Env.getCtx(), "Selection"));
@ -383,9 +398,9 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return bomDrop.getDraftInvoices(null); return bomDrop.getDraftInvoices(null);
} // getInvoices } // getInvoices
/************************************************************************** /**
* Create Main Panel. * Create Main Panel.
* Called when changing Product * Called after change of selected product.
*/ */
private void createMainPanel () private void createMainPanel ()
{ {
@ -425,8 +440,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
private int maxBomDeep = 0; private int maxBomDeep = 0;
/** /**
* Add BOM Line to this. * Add BOM line to {@link #m_productPanelList}.
* Calls addBOMLines if added product is a BOM
* @param bomLine BOM Line * @param bomLine BOM Line
*/ */
private void addBOMLine (BOMLine bomLine) private void addBOMLine (BOMLine bomLine)
@ -460,15 +474,16 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // addBOMLine } // addBOMLine
/** /**
* Add Line to Display * Render single BOM line.
* @param parentM_Product_ID parent product * @param parentM_Product_ID parent product
* @param M_Product_ID product * @param M_Product_ID product
* @param bomType bom type * @param bomType bom type
* @param name name * @param name name
* @param lineQty qty * @param lineQty qty
* @param parentPanel * @param parentPanel child panel of parent product
* @param bomLevel * @param bomLevel
* @param feature * @param feature
* @return {@link Layout}
*/ */
private Layout addDisplay (int parentM_Product_ID, private Layout addDisplay (int parentM_Product_ID,
int M_Product_ID, String bomType, String name, BigDecimal lineQty, Component parentPanel, int bomLevel, String feature) int M_Product_ID, String bomType, String name, BigDecimal lineQty, Component parentPanel, int bomLevel, String feature)
@ -508,7 +523,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} else { // Variant } else { // Variant
checkbox = new Radio(); checkbox = new Radio();
} }
checkbox.setAttribute(OPTION_PRODUCT_KEY, optionKey); checkbox.setAttribute(OPTION_PRODUCT_KEY_ATTR, optionKey);
selectPanel.appendChild(checkbox); selectPanel.appendChild(checkbox);
m_selectorList.add(checkbox); m_selectorList.add(checkbox);
@ -556,7 +571,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
featureGroup = m_featureGroup.get(key); featureGroup = m_featureGroup.get(key);
if (featureGroup == null) { if (featureGroup == null) {
featureGroup = new Groupbox(); featureGroup = new Groupbox();
featureGroup.setAttribute(FEATURE_GROUP_KEY, key); featureGroup.setAttribute(FEATURE_GROUP_KEY_ATTR, key);
featureGroup.appendChild(new Caption(feature)); featureGroup.appendChild(new Caption(feature));
m_featureGroup.put(key, featureGroup); m_featureGroup.put(key, featureGroup);
} }
@ -574,7 +589,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} else { } else {
String groupName = String.valueOf(parentM_Product_ID) + "_" + bomType + "_" + parentPanel.toString(); String groupName = String.valueOf(parentM_Product_ID) + "_" + bomType + "_" + parentPanel.toString();
if (featureGroup != null) { if (featureGroup != null) {
groupName = groupName + "_" + featureGroup.getAttribute(FEATURE_GROUP_KEY); groupName = groupName + "_" + featureGroup.getAttribute(FEATURE_GROUP_KEY_ATTR);
} }
Radiogroup radioGroup = m_alternativeGroups.get(groupName); Radiogroup radioGroup = m_alternativeGroups.get(groupName);
@ -623,13 +638,21 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return outerProductPanel; return outerProductPanel;
} // addDisplay } // addDisplay
private Div createDivPanel (int with) { /**
* @param width
* @return {@link Div}
*/
private Div createDivPanel (int width) {
Div divPanel = new Div (); Div divPanel = new Div ();
ZKUpdateUtil.setWidth(divPanel, String.format("%1$spx", with)); ZKUpdateUtil.setWidth(divPanel, String.format("%1$spx", width));
divPanel.setStyle("padding-right:0;padding-left:0"); divPanel.setStyle("padding-right:0;padding-left:0");
return divPanel; return divPanel;
} }
/**
* @param width
* @return {@link Hlayout}
*/
private Hlayout createHlayoutPanel (String width) { private Hlayout createHlayoutPanel (String width) {
Hlayout layout = new Hlayout(); Hlayout layout = new Hlayout();
layout.setSpacing("0"); layout.setSpacing("0");
@ -637,6 +660,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return layout; return layout;
} }
/**
* @param width
* @return {@link Vlayout}
*/
private Vlayout createVlayoutPanel (String width) { private Vlayout createVlayoutPanel (String width) {
Vlayout layout = new Vlayout(); Vlayout layout = new Vlayout();
layout.setSpacing("0"); layout.setSpacing("0");
@ -644,10 +671,11 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return layout; return layout;
} }
/************************************************************************** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent (Event e) throws Exception public void onEvent (Event e) throws Exception
{ {
if (log.isLoggable(Level.CONFIG)) log.config(e.getName()); if (log.isLoggable(Level.CONFIG)) log.config(e.getName());
@ -675,19 +703,19 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
// set qty input of uncheck radio button // set qty input of uncheck radio button
index = m_selectorList.indexOf(radio); index = m_selectorList.indexOf(radio);
m_qtyList.get(index).setReadonly(true); m_qtyList.get(index).setReadonly(true);
m_selectedOtions.remove(radio.getAttribute(OPTION_PRODUCT_KEY)); m_selectedOtions.remove(radio.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_unselectedOtions.add((String) radio.getAttribute(OPTION_PRODUCT_KEY)); m_unselectedOtions.add((String) radio.getAttribute(OPTION_PRODUCT_KEY_ATTR));
} }
} }
} }
updateBOMChildVisibility(); updateBOMChildVisibility();
if (checkbox.isChecked()) { if (checkbox.isChecked()) {
m_selectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY)); m_selectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_unselectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY)); m_unselectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
} else { } else {
m_unselectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY)); m_unselectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_selectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY)); m_selectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
} }
} }
// Product / Qty // Product / Qty
@ -766,6 +794,9 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
enableSave(); enableSave();
} }
/**
* Update state of Ok button in {@link #confirmPanel}.
*/
private void enableSave() { private void enableSave() {
// Enable OK // Enable OK
boolean OK = m_product != null; boolean OK = m_product != null;
@ -803,6 +834,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
confirmPanel.setEnabled("Ok", OK); confirmPanel.setEnabled("Ok", OK);
} }
/**
* Handle changes to {@link #fieldProduct}
* @param productFieldValue
*/
private void onProductChanged(Object productFieldValue) { private void onProductChanged(Object productFieldValue) {
int id = (productFieldValue != null && productFieldValue instanceof Integer) ? (Integer)productFieldValue : 0; int id = (productFieldValue != null && productFieldValue instanceof Integer) ? (Integer)productFieldValue : 0;
if (m_product == null || m_product.get_ID() != id) if (m_product == null || m_product.get_ID() != id)
@ -812,8 +847,8 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} }
/** /**
* update display of bom tree * Update display of bom tree.
* for item is not selected, hide child of it. * For item not selected, hide corresponding panel (in {@link #m_childPanelList}).
*/ */
protected void updateBOMChildVisibility() { protected void updateBOMChildVisibility() {
int index = 0; int index = 0;
@ -831,8 +866,8 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} }
/** /**
* Enable/disable qty based on selection * Save changes. Delegate to {@link #cmd_save(Trx)}.
* @param source JCheckBox or JRadioButton * @return true if save successfully, false otherwise.
*/ */
private boolean onSave() private boolean onSave()
{ {
@ -859,10 +894,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} }
} }
/************************************************************************** /**
* Save Selection * Save changes to DB.
* @param trx * @param trx
* @return true if saved * @return true if saved, false otherwise.
*/ */
private boolean cmd_save(Trx trx) private boolean cmd_save(Trx trx)
{ {
@ -901,10 +936,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // cmd_save } // cmd_save
/** /**
* Save to Order * Create and save order lines from BOM.
* @param C_Order_ID id * @param C_Order_ID id
* @param trx * @param trx
* @return true if saved * @return true if saved, false otherwise.
*/ */
private boolean cmd_saveOrder (int C_Order_ID, Trx trx) private boolean cmd_saveOrder (int C_Order_ID, Trx trx)
{ {
@ -947,10 +982,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // cmd_saveOrder } // cmd_saveOrder
/** /**
* Save to Invoice * Create and save invoice lines from BOM.
* @param C_Invoice_ID id * @param C_Invoice_ID id
* @param trx * @param trx
* @return true if saved * @return true if saved, false otherwise.
*/ */
private boolean cmd_saveInvoice (int C_Invoice_ID, Trx trx) private boolean cmd_saveInvoice (int C_Invoice_ID, Trx trx)
{ {
@ -992,10 +1027,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // cmd_saveInvoice } // cmd_saveInvoice
/** /**
* Save to Project * Create and save project lines from BOM.
* @param C_Project_ID id * @param C_Project_ID id
* @param trx * @param trx
* @return true if saved * @return true if saved, false otherwise
*/ */
private boolean cmd_saveProject (int C_Project_ID, Trx trx) private boolean cmd_saveProject (int C_Project_ID, Trx trx)
{ {

View File

@ -61,7 +61,7 @@ import org.zkoss.zul.South;
/** /**
* This class represents the Custom Form for generating charges * This class represents the Custom Form for generating charges
* from natural accounts. * from natural accounts.
* * <br/>
* The form is comprised of two parts. * The form is comprised of two parts.
* The upper portion can be used to create new charges using the general charge accounts. * The upper portion can be used to create new charges using the general charge accounts.
* The lower portion can be used to create charges based on the natural account. * The lower portion can be used to create charges based on the natural account.
@ -77,6 +77,7 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
*/ */
private static final long serialVersionUID = 4571016052942218676L; private static final long serialVersionUID = 4571016052942218676L;
/** UI Form instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** AD_Message for "Create". */ /** AD_Message for "Create". */
@ -84,8 +85,8 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
/** Logger. */ /** Logger. */
private static final CLogger log = CLogger.getCLogger(WCharge.class); private static final CLogger log = CLogger.getCLogger(WCharge.class);
// new panel // new charge panel
/** Grid for components for creating a new charge account. */ /** Grid for components for creating a new charge account. North of {@link #form}. */
private Grid m_grdNew = GridFactory.newGridLayout(); private Grid m_grdNew = GridFactory.newGridLayout();
/** Value (key) field label. */ /** Value (key) field label. */
private Label m_lblValue = new Label(); private Label m_lblValue = new Label();
@ -101,11 +102,11 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
private Button m_btnNew = new Button(); private Button m_btnNew = new Button();
// account panel // account panel
/** Grid for components for creating a charge form a selected account. **/ /** Grid for components for creating a charge form a selected account. Center of {@link #form}. */
private Panel m_pnlAccount = new Panel(); private Panel m_pnlAccount = new Panel();
/** Button to create charge from selected account. */ /** Button to create charge from selected account. South of {@link #m_pnlAccount}. */
private Button m_btnAccount = new Button(); private Button m_btnAccount = new Button();
/** Table to hold data of accounts. */ /** Table to hold data of accounts. Center of {@link #m_pnlAccount}. */
private WListbox m_tblData = new WListbox(); private WListbox m_tblData = new WListbox();
/** selected account count */ /** selected account count */
private int m_selectedCount; private int m_selectedCount;
@ -120,7 +121,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
initForm(); initForm();
} }
/** /**
* Initialises the panel. * Initialises the panel.
*/ */
@ -137,11 +137,8 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{ {
log.log(Level.SEVERE, "", e); log.log(Level.SEVERE, "", e);
} }
return;
} }
/** /**
* Initialises the static components of the form. * Initialises the static components of the form.
*/ */
@ -149,10 +146,11 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{ {
createNewChargePanel(); createNewChargePanel();
createAccountPanel(); createAccountPanel();
return;
} }
/**
* Layout {@link #form}
*/
private void zkInit() private void zkInit()
{ {
Borderlayout contentPane = new Borderlayout(); Borderlayout contentPane = new Borderlayout();
@ -170,8 +168,8 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
} }
/** /**
* Creates the account panel. * Creates the account panel ({@link #m_pnlAccount}).
* * <br/>
* The account panel contains: * The account panel contains:
* <li>a table detailing all accounts * <li>a table detailing all accounts
* <li>a button for creating charges for selected accounts * <li>a button for creating charges for selected accounts
@ -212,13 +210,11 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
m_btnAccount.setDisabled(true); m_btnAccount.setDisabled(true);
southPanel.appendChild(new Separator()); southPanel.appendChild(new Separator());
southPanel.appendChild(m_btnAccount); southPanel.appendChild(m_btnAccount);
return;
} }
/** /**
* Creates the New Charge panel. * Creates the New Charge panel ({@link #m_grdNew}).
* * <br/>
* The New Charge panel is used to specify the name and key of an account * The New Charge panel is used to specify the name and key of an account
* and whether or not the account is a charge account. * and whether or not the account is a charge account.
*/ */
@ -248,7 +244,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
label.setStyle("font-weight: bold;"); label.setStyle("font-weight: bold;");
row.appendCellChild(label, 3); row.appendCellChild(label, 3);
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
row.appendChild(m_lblValue.rightAlign()); row.appendChild(m_lblValue.rightAlign());
@ -266,8 +261,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
row.appendCellChild(new Separator(), 3); row.appendCellChild(new Separator(), 3);
return;
} }
@ -302,6 +295,7 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
* *
* @param event event that has been fired. * @param event event that has been fired.
*/ */
@Override
public void onEvent(Event event) public void onEvent(Event event)
{ {
if (log.isLoggable(Level.INFO)) log.info(event.getName()); if (log.isLoggable(Level.INFO)) log.info(event.getName());
@ -319,8 +313,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{ {
createAccount(); createAccount();
} }
return;
} }
/** /**
@ -363,7 +355,7 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
} // createNew } // createNew
/** /**
* Creates Charges from Accounts. * Creates Charges from Accounts.<br/>
* Charges are created for the selected accounts. * Charges are created for the selected accounts.
* The selection is cleared upon completion. * The selection is cleared upon completion.
*/ */
@ -381,16 +373,17 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
m_selectedCount = 0; m_selectedCount = 0;
m_btnAccount.setDisabled(true); m_btnAccount.setDisabled(true);
return;
} // createAccount } // createAccount
/**
* Close form.
*/
public void close() public void close()
{ {
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }
@Override
public ADForm getForm() { public ADForm getForm() {
return form; return form;
} }

View File

@ -44,6 +44,7 @@ import org.compiere.model.GridTab;
import org.compiere.model.MBankStatement; import org.compiere.model.MBankStatement;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MDepositBatch; import org.compiere.model.MDepositBatch;
import org.compiere.model.MDepositBatchLine;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MPayment; import org.compiere.model.MPayment;
@ -60,16 +61,15 @@ import org.zkoss.zul.Center;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
/** /**
* * Form to create Deposit Batch ({@link MDepositBatch} and {@link MDepositBatchLine}) from payment transactions.
* @author Elaine * @author Elaine
*
*/ */
public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements EventListener<Event> public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements EventListener<Event>
{ {
/** UI form instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
*
* @param tab * @param tab
*/ */
public WCreateFromDepositBatchUI(GridTab tab) public WCreateFromDepositBatchUI(GridTab tab)
@ -96,12 +96,14 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
AEnv.showWindow(window); AEnv.showWindow(window);
} }
/** Window No */ /** Window No */
private int p_WindowNo; private int p_WindowNo;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WCreateFromDepositBatchUI.class); private static final CLogger log = CLogger.getCLogger(WCreateFromDepositBatchUI.class);
/** form parameters for loading of payment transactions ({@link #loadBankAccount}) */
protected Label bankAccountLabel = new Label(); protected Label bankAccountLabel = new Label();
protected WTableDirEditor bankAccountField; protected WTableDirEditor bankAccountField;
@ -119,6 +121,7 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt")); protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt"));
protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom"));
protected Label amtToLabel = new Label("-"); protected Label amtToLabel = new Label("-");
protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo"));
@ -127,6 +130,7 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx")); protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx"));
protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom")); protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom"));
protected Label dateToLabel = new Label("-"); protected Label dateToLabel = new Label("-");
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo")); protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
@ -185,6 +189,10 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
return true; return true;
} // dynInit } // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
@ -265,10 +273,11 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
} }
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
* @throws Exception * @throws Exception
*/ */
@Override
public void onEvent(Event e) throws Exception public void onEvent(Event e) throws Exception
{ {
if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId()); if (log.isLoggable(Level.CONFIG)) log.config("Action=" + e.getTarget().getId());

View File

@ -18,14 +18,15 @@ import org.compiere.grid.ICreateFrom;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
/** /**
* * Static method to instantiate {@link ICreateFrom} instance.
* @author hengsin * @author hengsin
* *
*/ */
public class WCreateFromFactory public class WCreateFromFactory
{ {
/** /**
* * Instantiate Create From form instance.
* Delegate to {@link Extensions#getCreateFrom(GridTab)}.
* @param mTab * @param mTab
* @return ICreateFrom instance * @return ICreateFrom instance
*/ */

View File

@ -45,31 +45,32 @@ import org.zkoss.zul.Separator;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* * Create from form window
* @author Elaine * @author Elaine
*
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WCreateFromForm extends ADForm implements EventListener<Event>, WTableModelListener, DialogEvents public class WCreateFromForm extends ADForm implements EventListener<Event>, WTableModelListener, DialogEvents
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -3703236565441597403L; private static final long serialVersionUID = -3703236565441597403L;
/** Form controller */
private CreateFromForm form; private CreateFromForm form;
/** Form parameter panel. North of form. */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
/** Action buttons panel. South of form. */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** Form status bar. South of form. */
private StatusBarPanel statusBar = new StatusBarPanel(); private StatusBarPanel statusBar = new StatusBarPanel();
/** Data grid. Center of form. */
private WListbox dataTable = ListboxFactory.newDataTable(); private WListbox dataTable = ListboxFactory.newDataTable();
/** true if form cancelled by user */
private boolean isCancel; private boolean isCancel;
/** Select all action button Id */
public static final String SELECT_ALL = "SelectAll"; public static final String SELECT_ALL = "SelectAll";
/** /**
*
* @param createFrom * @param createFrom
*/ */
public WCreateFromForm(CreateFromForm createFrom) public WCreateFromForm(CreateFromForm createFrom)
@ -100,6 +101,10 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
} }
/**
* Layout form.<br/>
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
Borderlayout contentPane = new Borderlayout(); Borderlayout contentPane = new Borderlayout();
@ -211,7 +216,7 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
/** /**
* * Call {@link CreateFromForm#save(org.compiere.minigrid.IMiniTable, String, org.compiere.model.GridTab)}.
* @param trxName * @param trxName
* @return true if save success * @return true if save success
*/ */
@ -260,7 +265,6 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
/** /**
*
* @return {@link WListbox} * @return {@link WListbox}
*/ */
public WListbox getWListbox() public WListbox getWListbox()
@ -269,7 +273,6 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
/** /**
*
* @return {@link Panel} * @return {@link Panel}
*/ */
public Panel getParameterPanel() public Panel getParameterPanel()
@ -278,7 +281,6 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
/** /**
*
* @return {@link ConfirmPanel} * @return {@link ConfirmPanel}
*/ */
public ConfirmPanel getConfirmPanel() public ConfirmPanel getConfirmPanel()
@ -287,7 +289,6 @@ public class WCreateFromForm extends ADForm implements EventListener<Event>, WTa
} }
/** /**
*
* @return true if cancel by user * @return true if cancel by user
*/ */
public boolean isCancel() public boolean isCancel()

View File

@ -56,22 +56,22 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
/** /**
* * Form to create Invoice Lines from Purchase Order, Material Receipt or Vendor RMA.
* @author hengsin * @author hengsin
*
*/ */
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener
{ {
/** UI form instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
*
* @param tab * @param tab
*/ */
public WCreateFromInvoiceUI(GridTab tab) public WCreateFromInvoiceUI(GridTab tab)
{ {
super(tab); super(tab);
log.info(getGridTab().toString()); if (log.isLoggable(Level.INFO))
log.info(getGridTab().toString());
window = new WCreateFromWindow(this, getGridTab().getWindowNo()); window = new WCreateFromWindow(this, getGridTab().getWindowNo());
@ -92,19 +92,22 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
AEnv.showWindow(window); AEnv.showWindow(window);
} }
/** Window No */ /** Window No */
private int p_WindowNo; private int p_WindowNo;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WCreateFromInvoiceUI.class); private static final CLogger log = CLogger.getCLogger(WCreateFromInvoiceUI.class);
protected Label bPartnerLabel = new Label(); protected Label bPartnerLabel = new Label();
/** Business partner parameter field */
protected WEditor bPartnerField; protected WEditor bPartnerField;
protected Label orderLabel = new Label(); protected Label orderLabel = new Label();
/** Orders parameter field */
protected Listbox orderField = ListboxFactory.newDropdownListbox(); protected Listbox orderField = ListboxFactory.newDropdownListbox();
protected Label shipmentLabel = new Label(); protected Label shipmentLabel = new Label();
/** Shipments parameter field */
protected Listbox shipmentField = ListboxFactory.newDropdownListbox(); protected Listbox shipmentField = ListboxFactory.newDropdownListbox();
/** Label for the rma selection */ /** Label for the rma selection */
@ -112,10 +115,16 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
/** Combo box for selecting RMA document */ /** Combo box for selecting RMA document */
protected Listbox rmaField = ListboxFactory.newDropdownListbox(); protected Listbox rmaField = ListboxFactory.newDropdownListbox();
/** Grid layout for parameter panel */
private Grid parameterStdLayout; private Grid parameterStdLayout;
private boolean isCreditMemo = false; private boolean isCreditMemo = false;
/** true when form is handling an event */
private boolean m_actionActive = false;
/** Number of column for {@link #parameterStdLayout} */
private int noOfParameterColumn;
@Override @Override
public boolean dynInit() throws Exception public boolean dynInit() throws Exception
{ {
@ -143,6 +152,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
return true; return true;
} // dynInit } // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
@ -194,6 +207,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
hideEmptyRow(rows); hideEmptyRow(rows);
} }
/**
* Hide a row if all parameter fields within a row is invisible.
* @param rows
*/
private void hideEmptyRow(org.zkoss.zul.Rows rows) { private void hideEmptyRow(org.zkoss.zul.Rows rows) {
for(Component a : rows.getChildren()) { for(Component a : rows.getChildren()) {
Row row = (Row) a; Row row = (Row) a;
@ -221,10 +238,6 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
} }
private boolean m_actionActive = false;
private int noOfParameterColumn;
@Override @Override
public void onEvent(Event e) throws Exception public void onEvent(Event e) throws Exception
{ {
@ -286,7 +299,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
window.tableChanged(null); window.tableChanged(null);
} // vetoableChange } // vetoableChange
/************************************************************************** /**
* Load BPartner Field * Load BPartner Field
* @param forInvoice true if Invoices are to be created, false receipts * @param forInvoice true if Invoices are to be created, false receipts
* @throws Exception if Lookups cannot be initialized * @throws Exception if Lookups cannot be initialized
@ -329,6 +342,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
initBPDetails(C_BPartner_ID); initBPDetails(C_BPartner_ID);
} // initBPartnerOIS } // initBPartnerOIS
/**
* Call {@link #initBPShipmentDetails(int)} and {@link #initBPRMADetails(int)}.
* @param C_BPartner_ID
*/
private void initBPDetails(int C_BPartner_ID) private void initBPDetails(int C_BPartner_ID)
{ {
initBPShipmentDetails(C_BPartner_ID); initBPShipmentDetails(C_BPartner_ID);
@ -336,7 +353,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
/** /**
* Load PBartner dependent Shipment Field. * Load BPartner dependent Shipments.
* @param C_BPartner_ID * @param C_BPartner_ID
*/ */
private void initBPShipmentDetails(int C_BPartner_ID) private void initBPShipmentDetails(int C_BPartner_ID)
@ -359,7 +376,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
/** /**
* Load RMA that are candidates for billing * Load RMA documents that are candidates for billing
* @param C_BPartner_ID BPartner * @param C_BPartner_ID BPartner
*/ */
private void initBPRMADetails(int C_BPartner_ID) private void initBPRMADetails(int C_BPartner_ID)
@ -379,9 +396,9 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
/** /**
* Load Order Line records * Load Order Line records.
* @param C_Order_ID Order * @param C_Order_ID Order
* @param forInvoice true if for invoice vs. delivery qty * @param forInvoice true for invoice line, false for inout line
*/ */
protected void loadOrder (int C_Order_ID, boolean forInvoice) protected void loadOrder (int C_Order_ID, boolean forInvoice)
{ {
@ -407,7 +424,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
/** /**
* Load datas into list box * Load data into list box
* @param data data * @param data data
*/ */
protected void loadTableOIS (Vector<?> data) protected void loadTableOIS (Vector<?> data)
@ -443,7 +460,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
} }
/** /**
* configure layout of parameter grid * Setup columns for parameterGrid
* @param parameterGrid * @param parameterGrid
*/ */
protected void setupColumns(Grid parameterGrid) { protected void setupColumns(Grid parameterGrid) {

View File

@ -26,16 +26,15 @@ import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
/** /**
* * Form to create shipment package lines (M_PackageLine) from shipment lines (through M_PackageMPS).
* @author Elaine * @author Elaine
*
*/ */
public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
{ {
/** Create from window instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
*
* @param mTab * @param mTab
*/ */
public WCreateFromPackageShipmentUI(GridTab mTab) public WCreateFromPackageShipmentUI(GridTab mTab)
@ -59,9 +58,12 @@ public class WCreateFromPackageShipmentUI extends CreateFromPackageShipment
AEnv.showWindow(window); AEnv.showWindow(window);
} }
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WCreateFromPackageShipmentUI.class); private static final CLogger log = CLogger.getCLogger(WCreateFromPackageShipmentUI.class);
/**
* Load shipments lines
*/
@Override @Override
protected boolean dynInit() throws Exception protected boolean dynInit() throws Exception
{ {

View File

@ -43,16 +43,15 @@ import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
/** /**
* * Form to create RMA lines from shipment lines.
* @author hengsin * @author hengsin
*
*/ */
public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener
{ {
/** Create from window instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
*
* @param tab * @param tab
*/ */
public WCreateFromRMAUI(GridTab tab) public WCreateFromRMAUI(GridTab tab)
@ -79,19 +78,20 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
AEnv.showWindow(window); AEnv.showWindow(window);
} }
/** Window No */ /** Window No */
private int p_WindowNo; private int p_WindowNo;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WCreateFromRMAUI.class); private static final CLogger log = CLogger.getCLogger(WCreateFromRMAUI.class);
protected Label bPartnerLabel = new Label(); protected Label bPartnerLabel = new Label();
/** Business partner parameter field */
protected WEditor bPartnerField; protected WEditor bPartnerField;
@Override @Override
protected boolean dynInit() throws Exception protected boolean dynInit() throws Exception
{ {
log.config(""); if (log.isLoggable(Level.CONFIG)) log.config("");
super.dynInit(); super.dynInit();
@ -105,6 +105,10 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
return true; return true;
} // dynInit } // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID")); bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
@ -142,7 +146,7 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
window.tableChanged(null); window.tableChanged(null);
} // vetoableChange } // vetoableChange
/************************************************************************** /**
* Load BPartner Field * Load BPartner Field
* @param forInvoice true if Invoices are to be created, false receipts * @param forInvoice true if Invoices are to be created, false receipts
* @throws Exception if Lookups cannot be initialized * @throws Exception if Lookups cannot be initialized
@ -181,9 +185,8 @@ public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListen
model.addTableModelListener(window); model.addTableModelListener(window);
window.getWListbox().setData(model, getOISColumnNames()); window.getWListbox().setData(model, getOISColumnNames());
// //
configureMiniTable(window.getWListbox()); configureMiniTable(window.getWListbox());
} // loadOrder }
@Override @Override
public void showWindow() public void showWindow()

View File

@ -64,13 +64,12 @@ import org.zkoss.zul.Space;
import org.zkoss.zul.Vlayout; import org.zkoss.zul.Vlayout;
/** /**
* * Form to create shipment lines (M_InOutLine) from Purchase Order, Vendor Invoice or Customer RMA.
* @author hengsin * @author hengsin
*
*/ */
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener<Event>, ValueChangeListener public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener<Event>, ValueChangeListener
{ {
/** Create from window instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
@ -109,9 +108,11 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
private final static CLogger log = CLogger.getCLogger(WCreateFromShipmentUI.class); private final static CLogger log = CLogger.getCLogger(WCreateFromShipmentUI.class);
protected Label bPartnerLabel = new Label(); protected Label bPartnerLabel = new Label();
/** Business partner parameter field */
protected WEditor bPartnerField; protected WEditor bPartnerField;
protected Label orderLabel = new Label(); protected Label orderLabel = new Label();
/** Purchase order parameter field */
protected Listbox orderField = ListboxFactory.newDropdownListbox(); protected Listbox orderField = ListboxFactory.newDropdownListbox();
/** Label for the rma selection */ /** Label for the rma selection */
@ -120,17 +121,29 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
protected Listbox rmaField = ListboxFactory.newDropdownListbox(); protected Listbox rmaField = ListboxFactory.newDropdownListbox();
protected Label invoiceLabel = new Label(); protected Label invoiceLabel = new Label();
/** Vendor invoice parameter field */
protected Listbox invoiceField = ListboxFactory.newDropdownListbox(); protected Listbox invoiceField = ListboxFactory.newDropdownListbox();
/** True to show only documents from same warehouse with calling M_InOut record */
protected Checkbox sameWarehouseCb = new Checkbox(); protected Checkbox sameWarehouseCb = new Checkbox();
protected Label locatorLabel = new Label(); protected Label locatorLabel = new Label();
/** Locator parameter field */
protected WLocatorEditor locatorField = new WLocatorEditor(); protected WLocatorEditor locatorField = new WLocatorEditor();
protected Label upcLabel = new Label(); protected Label upcLabel = new Label();
/** Product UPC field. Use to select product in data grid. */
protected WStringEditor upcField = new WStringEditor(); protected WStringEditor upcField = new WStringEditor();
/** Grid layout for parameter panel */
private Grid parameterStdLayout; private Grid parameterStdLayout;
/** Number of column for {@link #parameterStdLayout} */
private int noOfParameterColumn; private int noOfParameterColumn;
/** true when form is handling event */
private boolean m_actionActive = false;
@Override @Override
protected boolean dynInit() throws Exception protected boolean dynInit() throws Exception
{ {
@ -156,6 +169,10 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
return true; return true;
} // dynInit } // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
boolean isRMAWindow = ((getGridTab().getAD_Window_ID() == WINDOW_RETURNTOVENDOR) || (getGridTab().getAD_Window_ID() == WINDOW_CUSTOMERRETURN)); boolean isRMAWindow = ((getGridTab().getAD_Window_ID() == WINDOW_RETURNTOVENDOR) || (getGridTab().getAD_Window_ID() == WINDOW_CUSTOMERRETURN));
@ -225,8 +242,6 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} }
} }
private boolean m_actionActive = false;
@Override @Override
public void onEvent(Event e) throws Exception public void onEvent(Event e) throws Exception
{ {
@ -288,8 +303,8 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} }
/** /**
* Checks the UPC value and checks if the UPC matches any of the products in the * Find product from data grid ({@link WCreateFromWindow#getWListbox()} with UPC value that matched the value from {@link #upcField}.<br/>
* list. * If a match is found, select the data grid row and set quantity to 1.
*/ */
private void checkProductUsingUPC() private void checkProductUsingUPC()
{ {
@ -372,7 +387,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} // initBPartner } // initBPartner
/** /**
* Init Details - load invoices not shipped * Load invoices not shipped for C_BPartner_ID
* @param C_BPartner_ID BPartner * @param C_BPartner_ID BPartner
*/ */
private void initBPInvoiceDetails(int C_BPartner_ID) private void initBPInvoiceDetails(int C_BPartner_ID)
@ -396,7 +411,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} }
/** /**
* Load BPartner dependent Order Field. * Load Orders for C_BPartner_ID
* @param C_BPartner_ID BPartner * @param C_BPartner_ID BPartner
* @param forInvoice for invoice * @param forInvoice for invoice
*/ */
@ -430,7 +445,8 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} // initBPOrderDetails } // initBPOrderDetails
/** /**
* load bpartner related details * Load bpartner related details. <br/>
* Call {@link #initBPInvoiceDetails(int)} and {@link #initBPRMADetails(int)}.
* @param C_BPartner_ID * @param C_BPartner_ID
*/ */
protected void initBPDetails(int C_BPartner_ID) protected void initBPDetails(int C_BPartner_ID)
@ -439,7 +455,6 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
initBPRMADetails(C_BPartner_ID); initBPRMADetails(C_BPartner_ID);
} }
/** /**
* Load RMA that are candidates for shipment * Load RMA that are candidates for shipment
* @param C_BPartner_ID BPartner * @param C_BPartner_ID BPartner
@ -463,7 +478,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
/** /**
* Load Order lines * Load Order lines
* @param C_Order_ID Order * @param C_Order_ID Order
* @param forInvoice true if for invoice vs. delivery qty * @param forInvoice true for invoice line, false for shipment line
* @param M_Locator_ID * @param M_Locator_ID
*/ */
protected void loadOrder (int C_Order_ID, boolean forInvoice, int M_Locator_ID) protected void loadOrder (int C_Order_ID, boolean forInvoice, int M_Locator_ID)
@ -508,7 +523,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
// //
configureMiniTable(window.getWListbox()); configureMiniTable(window.getWListbox());
} // loadOrder }
@Override @Override
public void showWindow() public void showWindow()
@ -528,7 +543,7 @@ public class WCreateFromShipmentUI extends CreateFromShipment implements EventLi
} }
/** /**
* Configure layout of parameter grid * Setup columns of parameter grid
* @param parameterGrid * @param parameterGrid
*/ */
protected void setupColumns(Grid parameterGrid) { protected void setupColumns(Grid parameterGrid) {

View File

@ -59,12 +59,13 @@ import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
/** /**
* * Form to create bank statement line (C_BankStatementLine) from payment transactions.
* @author Elaine * @author Elaine
* *
*/ */
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener<Event> public class WCreateFromStatementUI extends CreateFromStatement implements EventListener<Event>
{ {
/** Create from window instance */
private WCreateFromWindow window; private WCreateFromWindow window;
/** /**
@ -101,6 +102,8 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
/** Logger */ /** Logger */
private final static CLogger log = CLogger.getCLogger(WCreateFromStatementUI.class); private final static CLogger log = CLogger.getCLogger(WCreateFromStatementUI.class);
/** Parameter fields for {@link #parameterBankLayout} */
protected Label bankAccountLabel = new Label(); protected Label bankAccountLabel = new Label();
protected WTableDirEditor bankAccountField; protected WTableDirEditor bankAccountField;
@ -118,6 +121,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt")); protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt"));
protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom"));
protected Label amtToLabel = new Label("-"); protected Label amtToLabel = new Label("-");
protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo"));
@ -126,15 +130,17 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx")); protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx"));
protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom")); protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom"));
protected Label dateToLabel = new Label("-"); protected Label dateToLabel = new Label("-");
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo")); protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
/** Grid layout for parameter panel */
protected Grid parameterBankLayout; protected Grid parameterBankLayout;
@Override @Override
protected boolean dynInit() throws Exception protected boolean dynInit() throws Exception
{ {
log.config(""); if (log.isLoggable(Level.CONFIG)) log.config("");
super.dynInit(); super.dynInit();
@ -180,6 +186,10 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
return true; return true;
} // dynInit } // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
LayoutUtils.addSclass("create-from-bank-statement", window); LayoutUtils.addSclass("create-from-bank-statement", window);
@ -247,7 +257,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
} }
/** /**
* Configure layout of parameter grid * Setup columns of {@link #parameterBankLayout}
* @param parameterBankLayout * @param parameterBankLayout
*/ */
protected void setupColumns(Grid parameterBankLayout) { protected void setupColumns(Grid parameterBankLayout) {
@ -280,7 +290,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
} }
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
* @throws Exception * @throws Exception
*/ */
@ -296,7 +306,7 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
} }
/** /**
* load bank account transactions * load payment transactions
*/ */
protected void loadBankAccount() protected void loadBankAccount()
{ {
@ -321,7 +331,6 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
model.addTableModelListener(window); model.addTableModelListener(window);
window.getWListbox().setData(model, getOISColumnNames()); window.getWListbox().setData(model, getOISColumnNames());
// //
configureMiniTable(window.getWListbox()); configureMiniTable(window.getWListbox());
} }
@ -343,6 +352,9 @@ public class WCreateFromStatementUI extends CreateFromStatement implements Event
return window; return window;
} }
/**
* Handle onClientInfo event from browser.
*/
protected void onClientInfo() protected void onClientInfo()
{ {
if (ClientInfo.isMobile() && parameterBankLayout != null && parameterBankLayout.getColumns() != null) if (ClientInfo.isMobile() && parameterBankLayout != null && parameterBankLayout.getColumns() != null)

View File

@ -14,6 +14,7 @@
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.adwindow.StatusBar;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.ListModelTable; import org.adempiere.webui.component.ListModelTable;
@ -41,27 +42,33 @@ import org.zkoss.zul.Separator;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* * Window for create from form
* @author hengsin * @author hengsin
*
*/ */
public class WCreateFromWindow extends Window implements EventListener<Event>, WTableModelListener, DialogEvents public class WCreateFromWindow extends Window implements EventListener<Event>, WTableModelListener, DialogEvents
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = 6750121735083748182L; private static final long serialVersionUID = 6750121735083748182L;
/** Create from form controller */
private CreateFrom createFrom; private CreateFrom createFrom;
private int windowNo; private int windowNo;
/** Parameter panel. North of window. */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
/** Action buttons panel. South of window. */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** Status bar. South of window. */
private StatusBarPanel statusBar = new StatusBarPanel(); private StatusBarPanel statusBar = new StatusBarPanel();
/** Data grid. Center of window. */
private WListbox dataTable = ListboxFactory.newDataTable(); private WListbox dataTable = ListboxFactory.newDataTable();
/** true if window is cancel by user */
private boolean isCancel; private boolean isCancel;
/** select all action */
public static final String SELECT_DESELECT_ALL = "SelectAll"; public static final String SELECT_DESELECT_ALL = "SelectAll";
private boolean checkAllSelected = true; private boolean checkAllSelected = true;
@ -92,6 +99,10 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
} }
/**
* Layout window.
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
Borderlayout contentPane = new Borderlayout(); Borderlayout contentPane = new Borderlayout();
@ -223,7 +234,8 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
* * Save changes.
* Delegate to {@link CreateFrom#save(org.compiere.minigrid.IMiniTable, String)}.
* @param trxName * @param trxName
* @return true if save successfully * @return true if save successfully
*/ */
@ -238,7 +250,8 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
* update status * Update {@link #statusBar}.<br/>
* Delegate to {@link CreateFrom#info(org.compiere.minigrid.IMiniTable, org.compiere.apps.IStatusBar)}.
*/ */
public void info() public void info()
{ {
@ -256,7 +269,8 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
* * Update {@link #statusBar}.
* Call {@link StatusBar#setStatusLine(String)}.
* @param selectedRowCount * @param selectedRowCount
* @param text * @param text
*/ */
@ -272,7 +286,6 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
*
* @return {@link StatusBarPanel} * @return {@link StatusBarPanel}
*/ */
public StatusBarPanel getStatusBar() public StatusBarPanel getStatusBar()
@ -281,16 +294,15 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
*
* @param statusBar * @param statusBar
*/ */
@Deprecated(forRemoval = true, since = "11")
public void setStatusBar(StatusBarPanel statusBar) public void setStatusBar(StatusBarPanel statusBar)
{ {
this.statusBar = statusBar; this.statusBar = statusBar;
} }
/** /**
*
* @return {@link WListbox} * @return {@link WListbox}
*/ */
public WListbox getWListbox() public WListbox getWListbox()
@ -299,7 +311,6 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
*
* @return {@link Panel} * @return {@link Panel}
*/ */
public Panel getParameterPanel() public Panel getParameterPanel()
@ -308,7 +319,6 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
*
* @return {@link ConfirmPanel} * @return {@link ConfirmPanel}
*/ */
public ConfirmPanel getConfirmPanel() public ConfirmPanel getConfirmPanel()
@ -317,7 +327,6 @@ public class WCreateFromWindow extends Window implements EventListener<Event>, W
} }
/** /**
*
* @return true if dialog cancel by user * @return true if dialog cancel by user
*/ */
public boolean isCancel() public boolean isCancel()

View File

@ -71,6 +71,7 @@ import org.compiere.apps.form.FactReconcile;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MFactAcct; import org.compiere.model.MFactAcct;
import org.compiere.model.MFactReconciliation;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.X_C_ElementValue; import org.compiere.model.X_C_ElementValue;
@ -97,15 +98,16 @@ import org.zkoss.zul.South;
public class WFactReconcile extends FactReconcile public class WFactReconcile extends FactReconcile
implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener{ implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener{
/** Form window instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** Format */ /** Amount Format */
private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount); private DecimalFormat m_format = DisplayType.getNumberFormat(DisplayType.Amount);
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WFactReconcile.class); private static final CLogger log = CLogger.getCLogger(WFactReconcile.class);
/** /**
* Initialize Panel * Default constructor
*/ */
public WFactReconcile() public WFactReconcile()
{ {
@ -121,55 +123,65 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
} }
} }
/** Main layout of {@link #form} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** Parameters panel. North of {@link #mainLayout} */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
private Label labelAcctSchema = new Label(); /** Grid layout of {@link #parameterPanel} */
private WTableDirEditor fieldAcctSchema = null;
private Grid parameterLayout = GridFactory.newGridLayout(); private Grid parameterLayout = GridFactory.newGridLayout();
private Label labelAcctSchema = new Label();
/** Accounting schema parameter */
private WTableDirEditor fieldAcctSchema = null;
private Label labelOrg = new Label(); private Label labelOrg = new Label();
/** Organization parameter */
private WTableDirEditor fieldOrg = null; private WTableDirEditor fieldOrg = null;
private Label labelReconciled = new Label(); private Label labelReconciled = new Label();
/** Reconciled Yes/No parameter */
private Checkbox isReconciled = new Checkbox(); private Checkbox isReconciled = new Checkbox();
private Label labelAccount = new Label(); private Label labelAccount = new Label();
/** Account parameter */
private WTableDirEditor fieldAccount = null; private WTableDirEditor fieldAccount = null;
private Label labelBPartner = new Label(); private Label labelBPartner = new Label();
/** Business Partner parameter */
private WSearchEditor fieldBPartner = null; private WSearchEditor fieldBPartner = null;
private Label labelDateAcct = new Label();
/** Accounting Date parameter */
private WDateEditor fieldDateAcct = new WDateEditor();
private Label labelDateAcct2 = new Label();
/** Accounting Date2 parameter */
private WDateEditor fieldDateAcct2 = new WDateEditor();
private Label labelProduct = new Label();
/** Product parameter */
private WSearchEditor fieldProduct = null;
// data panel
private Label dataStatus = new Label(); private Label dataStatus = new Label();
/** Data grid. Center of {@link #mainLayout} */
private WListbox miniTable = ListboxFactory.newDataTable(); private WListbox miniTable = ListboxFactory.newDataTable();
// command panel /** Command panel. South of {@link #mainLayout} */
private Panel commandPanel = new Panel(); private Panel commandPanel = new Panel();
ConfirmPanel cp = new ConfirmPanel(); /** Grid layout of {@link #commandPanel} */
private Grid commandLayout = GridFactory.newGridLayout();
protected ConfirmPanel cp = new ConfirmPanel();
private Button bCancel = cp.createButton(ConfirmPanel.A_CANCEL); private Button bCancel = cp.createButton(ConfirmPanel.A_CANCEL);
private Button bGenerate = cp.createButton(ConfirmPanel.A_PROCESS); private Button bGenerate = cp.createButton(ConfirmPanel.A_PROCESS);
private Button bReset = cp.createButton(ConfirmPanel.A_RESET); private Button bReset = cp.createButton(ConfirmPanel.A_RESET);
private Button bZoom = cp.createButton(ConfirmPanel.A_ZOOM); private Button bZoom = cp.createButton(ConfirmPanel.A_ZOOM);
private Button bZoomDoc = cp.createButton(ConfirmPanel.A_ZOOM); private Button bZoomDoc = cp.createButton(ConfirmPanel.A_ZOOM);
private Grid commandLayout = GridFactory.newGridLayout();
private Button bRefresh = cp.createButton(ConfirmPanel.A_REFRESH); private Button bRefresh = cp.createButton(ConfirmPanel.A_REFRESH);
private Label labelDateAcct = new Label();
private WDateEditor fieldDateAcct = new WDateEditor();
private Label labelDateAcct2 = new Label();
private WDateEditor fieldDateAcct2 = new WDateEditor();
private Label labelProduct = new Label();
private WSearchEditor fieldProduct = null;
private boolean loading = false;
private Label differenceLabel = new Label(); private Label differenceLabel = new Label();
private Textbox differenceField = new Textbox(); private Textbox differenceField = new Textbox();
private ToolBarButton bSelect = new ToolBarButton("SelectAll"); private ToolBarButton bSelect = new ToolBarButton("SelectAll");
private boolean checkAllSelected = true; private boolean checkAllSelected = true;
private boolean loading = false;
/** /**
* init UI * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
private void zkInit() throws Exception private void zkInit() throws Exception
{ {
//
form.appendChild(mainLayout); form.appendChild(mainLayout);
parameterPanel.appendChild(parameterLayout); parameterPanel.appendChild(parameterLayout);
bRefresh.addActionListener(this); bRefresh.addActionListener(this);
@ -363,8 +375,10 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
fieldAccount = new WTableDirEditor("C_ElementValue_ID", true, false, true, lookupAccount); fieldAccount = new WTableDirEditor("C_ElementValue_ID", true, false, true, lookupAccount);
} }
/**
* Load data into {@link #miniTable}.
*/
private void loadData(){ private void loadData(){
if(fieldAccount.isNullOrEmpty()) if(fieldAccount.isNullOrEmpty())
throw new WrongValueException(fieldAccount.getComponent(), Msg.getMsg(Env.getCtx(), "FillMandatory")); throw new WrongValueException(fieldAccount.getComponent(), Msg.getMsg(Env.getCtx(), "FillMandatory"));
@ -420,7 +434,7 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
/** /**
* Calculate selected rows. * Calculate selected rows.
* - add up selected rows * <li>add up selected rows</li>
*/ */
private void calculateSelection() private void calculateSelection()
{ {
@ -505,6 +519,10 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
} }
/**
* Call {@link #generate(org.compiere.minigrid.IMiniTable, List)}
* to generate {@link MFactReconciliation} record from selected row in miniTable.
*/
private void generateReconciliation() { private void generateReconciliation() {
if (miniTable.getRowCount() == 0) if (miniTable.getRowCount() == 0)
return; return;
@ -525,8 +543,9 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
} }
/** /**
* Zoom to target * Zoom to window for current focus row of {@link #miniTable}.
* @param tableID table id * @param tableID if tableID is MFactAcct.Table_ID, zoom to window for MFactAcct. otherwise
* zoom to AD_Table_ID and Record_ID value of focus row.
*/ */
protected void zoom (int tableID) protected void zoom (int tableID)
{ {
@ -547,6 +566,10 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
} }
} // zoom } // zoom
/**
* Call {@link #reset(org.compiere.minigrid.IMiniTable, List)} to
* Reset/Delete {@link MFactReconciliation} record from selected row in {@link #miniTable}.
*/
private void resetReconciliation() { private void resetReconciliation() {
if (miniTable.getRowCount() == 0) if (miniTable.getRowCount() == 0)
return; return;
@ -571,6 +594,10 @@ implements IFormController, EventListener<Event>, WTableModelListener, ValueChan
return form; return form;
} }
/**
* Handle {@link #bSelect} ON_CLICK event.<br/>
* Select/Deselect all rows of {@link #miniTable}.
*/
private void onbSelect() { private void onbSelect() {
ListModelTable model = miniTable.getModel(); ListModelTable model = miniTable.getModel();
int rows = model.getSize(); int rows = model.getSize();

View File

@ -68,71 +68,93 @@ import org.zkoss.zul.South;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
/** /**
* Fixed length file import * Fixed length file import.<br/>
* Import data from text file into DB with definition from AD_ImpFormat.
* *
* @author Niraj Sohun * @author Niraj Sohun
* Aug 16, 2007 * Aug 16, 2007
*
*/ */
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VFileImport") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VFileImport")
public class WFileImport extends ADForm implements EventListener<Event> public class WFileImport extends ADForm implements EventListener<Event>
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -7462842139127270429L; private static final long serialVersionUID = -7462842139127270429L;
private static final int MAX_LOADED_LINES = 100; private static final int MAX_LOADED_LINES = 100;
private static final int MAX_SHOWN_LINES = 10; private static final int MAX_SHOWN_LINES = 10;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WFileImport.class); private static final CLogger log = CLogger.getCLogger(WFileImport.class);
/** Current index pointer for {@link #m_data} */
private int m_record = -1; private int m_record = -1;
private Listbox pickFormat = new Listbox(); /** Lines of loaded text file */
private Listbox fCharset = new Listbox();
private ArrayList<String> m_data = new ArrayList<String>(); private ArrayList<String> m_data = new ArrayList<String>();
private static final String s_none = "----"; // no format indicator private static final String s_none = "----"; // no format indicator
/** Import format helper */
private ImpFormat m_format; private ImpFormat m_format;
private ConfirmPanel confirmPanel = new ConfirmPanel(true); /** Parameter fields, child of {@link #northPanel} */
/** Button to load import file */
private Button bFile = new Button(); private Button bFile = new Button();
private Button bNext = new Button(); /** Character set of import file */
private Listbox fCharset = new Listbox();
/** Info text for loaded file */
private Label info = new Label();
/** Label for {@link #pickFormat} */
private Label labelFormat = new Label();
/** List of import format (AD_ImpFormat) */
private Listbox pickFormat = new Listbox();
/** Button to decrease {@link #m_record} by 1 */
private Button bPrevious = new Button(); private Button bPrevious = new Button();
/** Info text for {@link #m_record} */
private Label record = new Label();
/** Button to increase {@link #m_record} by 1 */
private Button bNext = new Button();
/** Raw text from import file */
private Textbox rawData = new Textbox();
/** Input file stream */
private InputStream m_file_istream; private InputStream m_file_istream;
private Textbox rawData = new Textbox(); /** Array of column/field. Child of {@link #previewPanel}. */
private Textbox[] m_fields; private Textbox[] m_fields;
private Label info = new Label(); /** Array of label for {@link #m_fields}. Child of {@link #previewPanel}. */
private Label[] m_labels; private Label[] m_labels;
private Label record = new Label();
private Label labelFormat = new Label();
/** Preview panel, child of {@link #centerPanel} */
private Div previewPanel = new Div(); private Div previewPanel = new Div();
/** North part of form */
private Vbox northPanel = new Vbox(); private Vbox northPanel = new Vbox();
/** Center part of form */
private Div centerPanel = new Div(); private Div centerPanel = new Div();
/** Action buttons panel. South of form */
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/**
* Default constructor
*/
public WFileImport() public WFileImport()
{ {
} }
/** /**
* Initialize Panel * Initialize form
*/ */
protected void initForm() protected void initForm()
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
try try
{ {
jbInit(); zkInit();
dynInit(); dynInit();
ZKUpdateUtil.setWidth(this, "100%"); ZKUpdateUtil.setWidth(this, "100%");
@ -163,11 +185,10 @@ public class WFileImport extends ADForm implements EventListener<Event>
} // init } // init
/** /**
* Static Init * Layout form
* @throws Exception * @throws Exception
*/ */
private void zkInit() throws Exception
private void jbInit() throws Exception
{ {
Charset[] charsets = Ini.getAvailableCharsets(); Charset[] charsets = Ini.getAvailableCharsets();
@ -525,7 +546,6 @@ public class WFileImport extends ADForm implements EventListener<Event>
* Apply Current Pattern * Apply Current Pattern
* @param next next * @param next next
*/ */
private void cmd_applyFormat (boolean next) private void cmd_applyFormat (boolean next)
{ {
if (m_format == null || m_data.size() == 0) if (m_format == null || m_data.size() == 0)

View File

@ -77,42 +77,58 @@ import org.zkoss.zul.North;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* Generate custom form window * Window for use together with {@link GenForm} to support the select source document and generate new target document UI pattern.
*
*/ */
public class WGenForm extends ADForm implements EventListener<Event>, WTableModelListener public class WGenForm extends ADForm implements EventListener<Event>, WTableModelListener
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = 4240430312911412710L; private static final long serialVersionUID = 4240430312911412710L;
/** Controller */
private GenForm genForm; private GenForm genForm;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WGenForm.class); private static final CLogger log = CLogger.getCLogger(WGenForm.class);
// /** Center of form. Tabbox with Select and Generate tab. */
private Tabbox tabbedPane = new Tabbox(); private Tabbox tabbedPane = new Tabbox();
/** Layout for Select tab */
private Borderlayout selPanel = new Borderlayout(); private Borderlayout selPanel = new Borderlayout();
/** Grid layout for North of {@link #selPanel} */
private Grid selNorthPanel = GridFactory.newGridLayout(); private Grid selNorthPanel = GridFactory.newGridLayout();
/** Action buttons panel. South of {@link #selPanel} */
private ConfirmPanel confirmPanelSel = new ConfirmPanel(true, true, false, false, false, false, false); private ConfirmPanel confirmPanelSel = new ConfirmPanel(true, true, false, false, false, false, false);
/** Action buttons panel. South of {@link #genPanel} */
private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, false, false, false, false, false, false); private ConfirmPanel confirmPanelGen = new ConfirmPanel(false, false, false, false, false, false, false);
/** Status bar. South of form */
private StatusBarPanel statusBar = new StatusBarPanel(); private StatusBarPanel statusBar = new StatusBarPanel();
/** Layout for Generate tab */
private Borderlayout genPanel = new Borderlayout(); private Borderlayout genPanel = new Borderlayout();
/** Child of {@link #messageDiv}. Info text from execution of Generate process */
private Html info = new Html(); private Html info = new Html();
/** Data grid for source document selection. Center of {@link #selPanel} */
private WListbox miniTable = ListboxFactory.newDataTable(); private WListbox miniTable = ListboxFactory.newDataTable();
private BusyDialog progressWindow; private BusyDialog progressWindow;
/** Center of {@link #genPanel}. Info text from execution of Generate process */
private Div messageDiv; private Div messageDiv;
/** Child of {@link #messageDiv}. Show message and link from {@link ProcessInfoLog} */
private Table logMessageTable; private Table logMessageTable;
private int[] m_ids; private int[] m_ids;
/**
* @param genForm
*/
public WGenForm(GenForm genForm) public WGenForm(GenForm genForm)
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
this.genForm = genForm; this.genForm = genForm;
} }
/**
* Layout form
*/
@Override @Override
protected void initForm() protected void initForm()
{ {
@ -144,19 +160,18 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} // init } // init
/** /**
* Static Init. * Layout Select and Generate tab.
* <pre> * <br/>
* selPanel (tabbed) * {@link #selPanel} tab:
* fOrg, fBPartner * <li>fOrg, fBPartner</li>
* scrollPane & miniTable * <li>scrollPane & miniTable</li>
* genPanel * <br/>
* info * {@link #genPanel} tab:
* </pre> * <li>info</li>
* @throws Exception * @throws Exception
*/ */
void zkInit() throws Exception void zkInit() throws Exception
{ {
//
ZKUpdateUtil.setWidth(selPanel, "100%"); ZKUpdateUtil.setWidth(selPanel, "100%");
ZKUpdateUtil.setHeight(selPanel, "100%"); ZKUpdateUtil.setHeight(selPanel, "100%");
selPanel.setStyle("border: none; position: relative"); selPanel.setStyle("border: none; position: relative");
@ -210,9 +225,9 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} // jbInit } // jbInit
/** /**
* Dynamic Init. * Dynamic Init.<br/>
* - Create GridController and Panel * - Configure {@link #miniTable}<br/>
* - AD_Column_ID from C_Order * - Setup listeners
*/ */
public void dynInit() public void dynInit()
{ {
@ -227,6 +242,10 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
button.setEnabled(false); button.setEnabled(false);
} // dynInit } // dynInit
/**
* Handle onClick event from {@link ConfirmPanel#A_REFRESH} button.<br/>
* Echo onExecuteQuery event.
*/
public void postQueryEvent() public void postQueryEvent()
{ {
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing")); Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
@ -234,7 +253,8 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} }
/** /**
* Dont call this directly, use internally to handle execute query event * Dont call this directly, use internally to handle onExecuteQuery event. <br/>
* Call {@link GenForm#executeQuery()}.
*/ */
public void onExecuteQuery() public void onExecuteQuery()
{ {
@ -249,12 +269,13 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} }
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent(Event e) throws Exception public void onEvent(Event e) throws Exception
{ {
log.info("Cmd=" + e.getTarget().getId()); if (log.isLoggable(Level.INFO)) log.info("Event Target Id=" + e.getTarget().getId());
// //
if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{ {
@ -287,10 +308,10 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
{ {
super.onEvent(e); super.onEvent(e);
} }
} // actionPerformed }
/** /**
* Table Model Listener * Table Model Listener for {@link #miniTable}.
* @param e event * @param e event
*/ */
public void tableChanged(WTableModelEvent e) public void tableChanged(WTableModelEvent e)
@ -320,8 +341,8 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} // saveSelection } // saveSelection
/************************************************************************** /**
* Generate Shipments * Generate Document
*/ */
public void generate() public void generate()
{ {
@ -332,7 +353,8 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} // generate } // generate
/** /**
* Internal use, don't call this directly * Handle runProcess event echo from {@link #generate()} (don't call this directly). <br/>
* Call {@link WProcessCtl#run()} to execute generate document process.
*/ */
public void runProcess() public void runProcess()
{ {
@ -345,8 +367,8 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} }
/** /**
* Complete generating shipments. * After complete generating documents.<br/>
* Called from Unlock UI * Called from Unlock UI.
* @param pi process info * @param pi process info
*/ */
private void generateComplete () private void generateComplete ()
@ -356,7 +378,7 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
progressWindow = null; progressWindow = null;
} }
// Switch Tabs // Set Generate tab as the active tab to display result from generate document process.
tabbedPane.getTabpanel(1).getLinkedTab().setDisabled(false); tabbedPane.getTabpanel(1).getLinkedTab().setDisabled(false);
tabbedPane.setSelectedIndex(1); tabbedPane.setSelectedIndex(1);
// //
@ -365,11 +387,10 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
iText.append("<b>").append(genForm.getProcessInfo().getSummary()) iText.append("<b>").append(genForm.getProcessInfo().getSummary())
.append("</b><br>(") .append("</b><br>(")
.append(Msg.getMsg(Env.getCtx(), genForm.getTitle())) .append(Msg.getMsg(Env.getCtx(), genForm.getTitle()))
// Shipments are generated depending on the Delivery Rule selection in the Order
.append(")<br><br>"); .append(")<br><br>");
info.setContent(iText.toString()); info.setContent(iText.toString());
//If log Message Table presents, remove it //If log Message Table exists, remove it first
if(logMessageTable!=null){ if(logMessageTable!=null){
messageDiv.removeChild(logMessageTable); messageDiv.removeChild(logMessageTable);
} }
@ -387,7 +408,9 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} // generateShipments_complete } // generateShipments_complete
/**
* Handle onAfterProcess event echo from {@link #generateComplete()}.
*/
public void onAfterProcess() public void onAfterProcess()
{ {
// OK to print // OK to print
@ -406,9 +429,12 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
}); });
} }
/**
* Print generated documents.
*/
public void onPrint() public void onPrint()
{ {
// Loop through all items // Loop through all items
List<File> pdfList = new ArrayList<File>(); List<File> pdfList = new ArrayList<File>();
for (int i = 0; i < m_ids.length; i++) for (int i = 0; i < m_ids.length; i++)
{ {
@ -476,27 +502,39 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
generateComplete(); generateComplete();
} // unlockUI } // unlockUI
/**
* Close window
*/
public void dispose() { public void dispose() {
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} }
/**
* @return {@link Grid} Parameter panel
*/
public Grid getParameterPanel() public Grid getParameterPanel()
{ {
return selNorthPanel; return selNorthPanel;
} }
/**
* @return {@link WListbox} source document list.
*/
public WListbox getMiniTable() public WListbox getMiniTable()
{ {
return miniTable; return miniTable;
} }
/**
* @return {@link StatusBarPanel}
*/
public StatusBarPanel getStatusBar() public StatusBarPanel getStatusBar()
{ {
return statusBar; return statusBar;
} }
/** /**
*append process log info to response panel * Append process log info to {@link #logMessageTable}.
* @param m_logs * @param m_logs
*/ */
private void appendRecordLogInfo(ProcessInfoLog[] m_logs) { private void appendRecordLogInfo(ProcessInfoLog[] m_logs) {
@ -512,8 +550,6 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
logMessageTable.setDynamicProperty("cellspacing", "0"); logMessageTable.setDynamicProperty("cellspacing", "0");
logMessageTable.setDynamicProperty("width", "100%"); logMessageTable.setDynamicProperty("width", "100%");
this.appendChild(logMessageTable);
boolean datePresents = false; boolean datePresents = false;
boolean numberPresents = false; boolean numberPresents = false;
boolean msgPresents = false; boolean msgPresents = false;
@ -527,7 +563,6 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
msgPresents = true; msgPresents = true;
} }
for (int i = 0; i < m_logs.length; i++) for (int i = 0; i < m_logs.length; i++)
{ {
@ -576,5 +611,4 @@ public class WGenForm extends ADForm implements EventListener<Event>, WTableMode
} }
messageDiv.appendChild(logMessageTable); messageDiv.appendChild(logMessageTable);
} }
} }

View File

@ -72,7 +72,7 @@ import org.zkoss.zul.Space;
import org.zkoss.zul.Vlayout; import org.zkoss.zul.Vlayout;
/** /**
* Manual Matching * Form to perform Matching between Purchase Order, Vendor Invoice and Material Receipt.
* *
* @author Jorg Janke * @author Jorg Janke
* @version $Id: VMatch.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ * @version $Id: VMatch.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
@ -81,10 +81,11 @@ import org.zkoss.zul.Vlayout;
public class WMatch extends Match public class WMatch extends Match
implements IFormController, EventListener<Event>, WTableModelListener implements IFormController, EventListener<Event>, WTableModelListener
{ {
/** UI form instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** /**
* Initialize Panel * Default constructor
*/ */
public WMatch() public WMatch()
{ {
@ -120,22 +121,22 @@ public class WMatch extends Match
} }
} }
/** Window No */ /** Window No */
private int m_WindowNo = 0; private int m_WindowNo = 0;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WMatch.class); private static final CLogger log = CLogger.getCLogger(WMatch.class);
private int m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx()); private int m_AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
private int m_AD_Org_ID = Env.getAD_Org_ID(Env.getCtx()); private int m_AD_Org_ID = Env.getAD_Org_ID(Env.getCtx());
private int m_by = Env.getAD_User_ID(Env.getCtx()); private int m_by = Env.getAD_User_ID(Env.getCtx());
/** Match Options */ /** Matching To Options */
private String[] m_matchOptions = new String[] { private String[] m_matchOptions = new String[] {
Msg.getElement(Env.getCtx(), "C_Invoice_ID", false), Msg.getElement(Env.getCtx(), "C_Invoice_ID", false),
Msg.getElement(Env.getCtx(), "M_InOut_ID", false), Msg.getElement(Env.getCtx(), "M_InOut_ID", false),
Msg.getElement(Env.getCtx(), "C_Order_ID", false) }; Msg.getElement(Env.getCtx(), "C_Order_ID", false) };
/** Match Mode */ /** Matching Mode */
private String[] m_matchMode = new String[] { private String[] m_matchMode = new String[] {
Msg.translate(Env.getCtx(), "NotMatched"), Msg.translate(Env.getCtx(), "NotMatched"),
Msg.translate(Env.getCtx(), "Matched")}; Msg.translate(Env.getCtx(), "Matched")};
@ -145,15 +146,21 @@ public class WMatch extends Match
private BigDecimal m_xMatched = Env.ZERO; private BigDecimal m_xMatched = Env.ZERO;
private BigDecimal m_xMatchedTo = Env.ZERO; private BigDecimal m_xMatchedTo = Env.ZERO;
// /** Main panel of {@link #form} */
private Panel mainPanel = new Panel(); private Panel mainPanel = new Panel();
private StatusBarPanel statusBar = new StatusBarPanel(); private StatusBarPanel statusBar = new StatusBarPanel();
/** Layout of {@link #mainPanel} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** North of {@link #mainLayout}. Form parameters. */
private Panel northPanel = new Panel(); private Panel northPanel = new Panel();
/** Grid layout of {@link #northPanel} */
private Grid northLayout = GridFactory.newGridLayout(); private Grid northLayout = GridFactory.newGridLayout();
private Label matchFromLabel = new Label(); private Label matchFromLabel = new Label();
/** Select matching source (order, invoice or material receipt) */
private Listbox matchFrom = ListboxFactory.newDropdownListbox(m_matchOptions); private Listbox matchFrom = ListboxFactory.newDropdownListbox(m_matchOptions);
private Label matchToLabel = new Label(); private Label matchToLabel = new Label();
/** Select matching target (order, invoice or material receipt) */
private Listbox matchTo = ListboxFactory.newDropdownListbox(); private Listbox matchTo = ListboxFactory.newDropdownListbox();
private Label matchModeLabel = new Label(); private Label matchModeLabel = new Label();
private Listbox matchMode = ListboxFactory.newDropdownListbox(m_matchMode); private Listbox matchMode = ListboxFactory.newDropdownListbox(m_matchMode);
@ -165,30 +172,52 @@ public class WMatch extends Match
private Label dateToLabel = new Label(); private Label dateToLabel = new Label();
private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom"); private WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom");
private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo"); private WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo");
/** Button to start searching of source document */
private Button bSearch = new Button(); private Button bSearch = new Button();
/** South of {@link #mainLayout}. Matching summary info text. */
private Panel southPanel = new Panel(); private Panel southPanel = new Panel();
/** Grid layout of {@link #southPanel} */
private Grid southLayout = GridFactory.newGridLayout(); private Grid southLayout = GridFactory.newGridLayout();
private Label xMatchedLabel = new Label(); private Label xMatchedLabel = new Label();
private Label xMatchedToLabel = new Label(); private Label xMatchedToLabel = new Label();
private Label differenceLabel = new Label(); private Label differenceLabel = new Label();
/** Quantity from source documents */
private WNumberEditor xMatched = new WNumberEditor("xMatched", false, true, false, DisplayType.Quantity, "xMatched"); private WNumberEditor xMatched = new WNumberEditor("xMatched", false, true, false, DisplayType.Quantity, "xMatched");
/** Quantity from target documents */
private WNumberEditor xMatchedTo = new WNumberEditor("xMatchedTo", false, true, false, DisplayType.Quantity, "xMatchedTo"); private WNumberEditor xMatchedTo = new WNumberEditor("xMatchedTo", false, true, false, DisplayType.Quantity, "xMatchedTo");
/** Difference between {@link #xMatched} and {@link #xMatchedTo} */
private WNumberEditor difference = new WNumberEditor("Difference", false, true, false, DisplayType.Quantity, "Difference"); private WNumberEditor difference = new WNumberEditor("Difference", false, true, false, DisplayType.Quantity, "Difference");
/** Button to start the matching process */
private Button bProcess = new Button(); private Button bProcess = new Button();
/** Center of {@link #mainLayout} */
private Panel centerPanel = new Panel(); private Panel centerPanel = new Panel();
/** Layout of {@link #centerPanel} */
private Borderlayout centerLayout = new Borderlayout(); private Borderlayout centerLayout = new Borderlayout();
private Label xMatchedBorder = new Label("xMatched"); private Label xMatchedBorder = new Label("xMatched");
/** North of {@link #centerLayout}. Source documents. */
private WListbox xMatchedTable = ListboxFactory.newDataTable(); private WListbox xMatchedTable = ListboxFactory.newDataTable();
private Label xMatchedToBorder = new Label("xMatchedTo"); private Label xMatchedToBorder = new Label("xMatchedTo");
/** Center of {@link #centerLayout}. Target documents. */
private WListbox xMatchedToTable = ListboxFactory.newDataTable(); private WListbox xMatchedToTable = ListboxFactory.newDataTable();
/**
* Center of {@link #centerLayout} (Above {@link #xMatchedToTable}). <br/>
* Container of {@link #sameProduct}, {@link #sameProduct} and {@link #sameQty}.
*/
private Panel xPanel = new Panel(); private Panel xPanel = new Panel();
/** Same product flag between source and target document */
private Checkbox sameProduct = new Checkbox(); private Checkbox sameProduct = new Checkbox();
/** Same business partner flag between source and target document */
private Checkbox sameBPartner = new Checkbox(); private Checkbox sameBPartner = new Checkbox();
/** Same quantity flag between source and target document */
private Checkbox sameQty = new Checkbox(); private Checkbox sameQty = new Checkbox();
/** Number of column for {@link #northLayout} */
private int noOfColumn; private int noOfColumn;
/** /**
* Static Init. * Layout form.
* <pre> * <pre>
* mainPanel * mainPanel
* northPanel * northPanel
@ -286,6 +315,9 @@ public class WMatch extends Match
centerPanel.setStyle("min-height: 300px;"); centerPanel.setStyle("min-height: 300px;");
} }
/**
* Layout {@link #northPanel} and {@link #southPanel}
*/
protected void layoutParameterAndSummary() { protected void layoutParameterAndSummary() {
setupParameterColumns(); setupParameterColumns();
@ -341,6 +373,9 @@ public class WMatch extends Match
LayoutUtils.compactTo(southLayout, noOfColumn); LayoutUtils.compactTo(southLayout, noOfColumn);
} }
/**
* Setup columns of {@link #northLayout}
*/
protected void setupParameterColumns() { protected void setupParameterColumns() {
noOfColumn = 6; noOfColumn = 6;
if (maxWidth(MEDIUM_WIDTH-1)) if (maxWidth(MEDIUM_WIDTH-1))
@ -378,7 +413,7 @@ public class WMatch extends Match
/** /**
* Dynamic Init. * Dynamic Init.
* Table Layout, Visual, Listener * Configure {@link #xMatchedTable} and {@link #xMatchedToTable}. Setup Listeners.
*/ */
private void dynInit() private void dynInit()
{ {
@ -416,14 +451,16 @@ public class WMatch extends Match
} // dynInit } // dynInit
/** /**
* Dispose * Close form.
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose
/**
* Handle onClientInfo event from browser.
*/
protected void onClientInfo() protected void onClientInfo()
{ {
if (ClientInfo.isMobile() && form.getPage() != null) if (ClientInfo.isMobile() && form.getPage() != null)
@ -454,9 +491,9 @@ public class WMatch extends Match
} }
} }
/************************************************************************** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override @Override
public void onEvent (Event e) public void onEvent (Event e)
@ -514,9 +551,8 @@ public class WMatch extends Match
cmd_searchTo(); cmd_searchTo();
} }
/** /**
* Match To Changed - set Title * Handle selection change of {@link #matchTo}.
*/ */
private void cmd_matchTo() private void cmd_matchTo()
{ {
@ -529,7 +565,7 @@ public class WMatch extends Match
/** /**
* Fill xMatchedTo * Fill {@link #xMatchedToTable} from selected row of {@link #xMatchedTable}.
*/ */
private void cmd_searchTo() private void cmd_searchTo()
{ {
@ -565,14 +601,17 @@ public class WMatch extends Match
statusBar.setStatusDB("0"); statusBar.setStatusDB("0");
} // cmd_seachTo } // cmd_seachTo
/**
* @return selected text from {@link #matchTo}
*/
private String getMatchToLabel() { private String getMatchToLabel() {
int index = matchTo.getSelectedIndex(); int index = matchTo.getSelectedIndex();
return matchTo.getModel().getElementAt(index).toString(); return matchTo.getModel().getElementAt(index).toString();
} }
/*************************************************************************** /**
* Table Model Listener - calculate matchd Qty * Table Model Listener - calculate matched Qty
* @param e event * @param e event
*/ */
@Override @Override
public void tableChanged (WTableModelEvent e) public void tableChanged (WTableModelEvent e)

View File

@ -49,32 +49,30 @@ import org.zkoss.zul.Center;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* Merge Dialog. * Form to Merge source/from record to target/to record (support Organization, User, Business Partner and Product).
* Restriction - fails for Accounting * Restriction - fails for Accounting.
*
* @author Jorg Janke
* @version $Id: VMerge.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/ */
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VMerge") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VMerge")
public class WMerge extends Merge implements IFormController, EventListener<Event> public class WMerge extends Merge implements IFormController, EventListener<Event>
{ {
/** /** UI form instance */
*
*/
@SuppressWarnings("unused")
private static final long serialVersionUID = 5797395051958101596L;
private WMergeUI form; private WMergeUI form;
private Label[] m_label = null; private Label[] m_label = null;
private WEditor[] m_from = null; /** Editor to pick source/from record */
private WEditor[] m_to = null; private WEditor[] m_from = null;
/** Editor to pick target/to record */
private WEditor[] m_to = null;
/** Main layout of {@link #form} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
private Panel CenterPanel = new Panel(); /** Center of {@link #mainLayout} */
private Panel centerPanel = new Panel();
/** Grid layout of {@link #centerPanel} */
private Grid centerLayout = GridFactory.newGridLayout(); private Grid centerLayout = GridFactory.newGridLayout();
private Label mergeFromLabel = new Label(); private Label mergeFromLabel = new Label();
private Label mergeToLabel = new Label(); private Label mergeToLabel = new Label();
/** Action buttons panel. South of {@link #form} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private String m_msg; private String m_msg;
private boolean m_success; private boolean m_success;
@ -82,7 +80,7 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
private MergeRunnable runnable; private MergeRunnable runnable;
/** /**
* Initialize Panel * Default constructor
*/ */
public WMerge() public WMerge()
{ {
@ -99,10 +97,10 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
{ {
log.log(Level.SEVERE, "", ex); log.log(Level.SEVERE, "", ex);
} }
} // init }
/** /**
* Pre Init * Prepare m_columnName, {@link #m_label}, {@link #m_from} and {@link #m_to}.
*/ */
private void preInit() private void preInit()
{ {
@ -120,7 +118,7 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
} // preInit } // preInit
/** /**
* Pre Init Line * Prepare m_columnName, {@link #m_label}, {@link #m_from} and {@link #m_to}.
* @param index index * @param index index
* @param AD_Column_ID id * @param AD_Column_ID id
* @param displayType display type * @param displayType display type
@ -146,7 +144,7 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
} // preInit } // preInit
/** /**
* Static init * Layout {@link #form}
* @throws java.lang.Exception * @throws java.lang.Exception
*/ */
void zkInit () throws Exception void zkInit () throws Exception
@ -161,13 +159,10 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
// //
Rows rows = centerLayout.newRows(); Rows rows = centerLayout.newRows();
centerPanel.appendChild(centerLayout);
//
CenterPanel.appendChild(centerLayout);
Center center = new Center(); Center center = new Center();
mainLayout.appendChild(center); mainLayout.appendChild(center);
center.appendChild(CenterPanel); center.appendChild(centerPanel);
Row row = rows.newRow(); Row row = rows.newRow();
row.appendChild(new Label()); row.appendChild(new Label());
@ -186,10 +181,10 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
row.appendChild(m_from[i].getComponent()); row.appendChild(m_from[i].getComponent());
row.appendChild(m_to[i].getComponent()); row.appendChild(m_to[i].getComponent());
} }
} // jbInit }
/** /**
* Dispose * Close window
*/ */
public void dispose() public void dispose()
{ {
@ -197,9 +192,10 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
} // dispose } // dispose
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent (Event e) public void onEvent (Event e)
{ {
if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
@ -258,11 +254,13 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef); runnable = new MergeRunnable(columnNameRef, fromIdRef, toIdRef);
Clients.response(new AuEcho(form, "runProcess", null)); Clients.response(new AuEcho(form, "runProcess", null));
} }
} }
}); });
} // actionPerformed }
/**
* Custom runnable to call {@link Merge#merge(String, int, int)}.
*/
private class MergeRunnable implements Runnable { private class MergeRunnable implements Runnable {
private int to_ID; private int to_ID;
private int from_ID; private int from_ID;
@ -285,7 +283,8 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
} }
/** /**
* execute merge, call from echo event * Handle runProcess event echo from onEvent.
* Call runnable.run() to execute merge.
*/ */
public void runProcess() public void runProcess()
{ {
@ -293,7 +292,8 @@ public class WMerge extends Merge implements IFormController, EventListener<Even
} }
/** /**
* clean up, call form echo event * After execution of merge.
* Show info/error message and close form (if merge is success).
*/ */
public void onAfterProcess() public void onAfterProcess()
{ {

View File

@ -16,25 +16,36 @@ package org.adempiere.webui.apps.form;
import org.adempiere.webui.panel.CustomForm; import org.adempiere.webui.panel.CustomForm;
/** /**
* * Custom form for {@link WMerge}.
* @author hengsin * @author hengsin
*
*/ */
public class WMergeUI extends CustomForm { public class WMergeUI extends CustomForm {
/**
* generated serial id
*/
private static final long serialVersionUID = -8576926702378868806L; private static final long serialVersionUID = -8576926702378868806L;
/** Controller */
private WMerge m_merge; private WMerge m_merge;
/**
* @param merge
*/
public WMergeUI(WMerge merge) { public WMergeUI(WMerge merge) {
super(); super();
m_merge = merge; m_merge = merge;
} }
/**
* Run merge process
*/
public void runProcess() { public void runProcess() {
m_merge.runProcess(); m_merge.runProcess();
} }
/**
* After execution of merge process
*/
public void onAfterProcess() { public void onAfterProcess() {
m_merge.onAfterProcess(); m_merge.onAfterProcess();
} }

View File

@ -58,6 +58,7 @@ import org.compiere.apps.form.PayPrint;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MPaySelectionCheck; import org.compiere.model.MPaySelectionCheck;
import org.compiere.model.X_C_Order;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -70,10 +71,7 @@ import org.zkoss.zul.Filedownload;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* Payment Print and Export * Form to Print and Export payment.
*
* @author Jorg Janke
* @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
* *
* Contributors: * Contributors:
* Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank * Carlos Ruiz - GlobalQSS - FR 3132033 - Make payment export class configurable per bank
@ -82,10 +80,11 @@ import org.zkoss.zul.South;
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VPayPrint") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VPayPrint")
public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener
{ {
/** Custom form/window instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** /**
* Initialize Panel * Default constructor
*/ */
public WPayPrint() public WPayPrint()
{ {
@ -114,41 +113,54 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} }
} // WPayPrint } // WPayPrint
// Instance Variables /** Action buttons panel. South of {@link #form} */
protected Panel centerPanel = new Panel();
protected ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false); protected ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false);
protected Grid centerLayout = GridFactory.newGridLayout(); /** Button to print check */
protected Button bPrint = southPanel.createButton(ConfirmPanel.A_PRINT); protected Button bPrint = southPanel.createButton(ConfirmPanel.A_PRINT);
/** Button to export payment to file */
protected Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT); protected Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT);
protected Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL); protected Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL);
/** Button to process PAYMENTRULE_DirectDeposit payments */
protected Button bProcess = southPanel.createButton(ConfirmPanel.A_PROCESS); protected Button bProcess = southPanel.createButton(ConfirmPanel.A_PROCESS);
/** Center of {@link #form} */
protected Panel centerPanel = new Panel();
/** Layout of {@link #centerPanel} */
protected Grid centerLayout = GridFactory.newGridLayout();
protected Label lPaySelect = new Label(); protected Label lPaySelect = new Label();
/** Payment selections */
protected WSearchEditor paySelectSearch = null; protected WSearchEditor paySelectSearch = null;
protected Label lBank = new Label(); protected Label lBank = new Label();
/** Bank name from C_BankAccount.C_Bank_ID */
protected Label fBank = new Label(); protected Label fBank = new Label();
protected Label lPaymentRule = new Label(); protected Label lPaymentRule = new Label();
/** Payment rules */
protected Listbox fPaymentRule = ListboxFactory.newDropdownListbox(); protected Listbox fPaymentRule = ListboxFactory.newDropdownListbox();
protected Label lDocumentNo = new Label(); protected Label lDocumentNo = new Label();
/** Bank account document number (C_BankAccountDoc). Usually for check number. */
protected WNumberEditor fDocumentNo = new WNumberEditor(); protected WNumberEditor fDocumentNo = new WNumberEditor();
protected Label lNoPayments = new Label(); protected Label lNoPayments = new Label();
/** Number of C_PaySelectionCheck records */
protected Label fNoPayments = new Label(); protected Label fNoPayments = new Label();
protected Label lBalance = new Label(); protected Label lBalance = new Label();
/** C_PaySelection.CurrentBalance */
protected WNumberEditor fBalance = new WNumberEditor(); protected WNumberEditor fBalance = new WNumberEditor();
protected Label lCurrency = new Label(); protected Label lCurrency = new Label();
/** ISO_Code from C_BankAccount.C_Currency_ID */
protected Label fCurrency = new Label(); protected Label fCurrency = new Label();
protected Label lDepositBatch = new Label(); protected Label lDepositBatch = new Label();
protected WYesNoEditor fDepositBatch = new WYesNoEditor("", "", "Book as one post", false, false, true) ; protected WYesNoEditor fDepositBatch = new WYesNoEditor("", "", "Book as one post", false, false, true) ;
protected Label lSumPayments = new Label(); protected Label lSumPayments = new Label();
/** Sum of C_PaySelectionCheck.PayAmt */
protected WNumberEditor fSumPayments = new WNumberEditor(); protected WNumberEditor fSumPayments = new WNumberEditor();
/** /**
* Static Init * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
//
centerPanel.appendChild(centerLayout); centerPanel.appendChild(centerLayout);
// //
bPrint.addActionListener(this); bPrint.addActionListener(this);
@ -240,11 +252,10 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
MLookup lookupPS = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search); MLookup lookupPS = MLookupFactory.get (Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
paySelectSearch = new WSearchEditor("C_PaySelection_ID", true, false, true, lookupPS); paySelectSearch = new WSearchEditor("C_PaySelection_ID", true, false, true, lookupPS);
paySelectSearch.addValueChangeListener(this); paySelectSearch.addValueChangeListener(this);
} // dynInit } // dynInit
/** /**
* Dispose * Close form.
*/ */
public void dispose() public void dispose()
{ {
@ -266,9 +277,9 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // setsetPaySelection } // setsetPaySelection
/************************************************************************** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override @Override
public void onEvent(Event e) public void onEvent(Event e)
@ -289,7 +300,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} }
/** /**
* load pay selection details * load pay selection details
*/ */
protected void loadPaySelectInfo() protected void loadPaySelectInfo()
{ {
@ -350,7 +361,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
if(sumPayments != null) if(sumPayments != null)
fSumPayments.setValue(sumPayments); fSumPayments.setValue(sumPayments);
bProcess.setEnabled(PaymentRule.equals("T")); bProcess.setEnabled(PaymentRule.equals(X_C_Order.PAYMENTRULE_DirectDeposit));
if(documentNo != null) if(documentNo != null)
fDocumentNo.setValue(documentNo); fDocumentNo.setValue(documentNo);
@ -398,8 +409,8 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // getPluginFeatures } // getPluginFeatures
/************************************************************************** /**
* Export payments to file * Export payments to file
*/ */
protected void cmd_export() protected void cmd_export()
{ {
@ -568,7 +579,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // cmd_print } // cmd_print
/************************************************************************** /**
* Get Checks * Get Checks
* @param PaymentRule Payment Rule * @param PaymentRule Payment Rule
* @return true if payments were created * @return true if payments were created
@ -592,7 +603,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} }
/** /**
* Vetoable Change Listener. * Vetoable Change Listener.<br/>
* - Payment Selection * - Payment Selection
* @param e event * @param e event
*/ */
@ -612,5 +623,4 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
loadPaySelectInfo(); loadPaySelectInfo();
} }
} }
}
} // PayPrint

View File

@ -83,53 +83,75 @@ import org.zkoss.zul.South;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
/** /**
* Create Manual Payments From (AP) Invoices or (AR) Credit Memos. * Create Manual Payments From (AP) Invoices or (AR) Credit Memos.<br/>
* Allows user to select Invoices for payment. * Allows user to select Invoices for payment.<br/>
* When Processed, PaySelection is created * When Processed, PaySelection is created and optionally process and printed.
* and optionally posted/generated and printed
*
* @author Jorg Janke
* @version $Id: VPaySelect.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
*/ */
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VPaySelect") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VPaySelect")
public class WPaySelect extends PaySelect public class WPaySelect extends PaySelect
implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener implements IFormController, EventListener<Event>, WTableModelListener, ValueChangeListener
{ {
/** Custom form/window instance */
protected CustomForm form = new CustomForm(); protected CustomForm form = new CustomForm();
//
/** Main panel of {@link #form} */
private Panel mainPanel = new Panel(); private Panel mainPanel = new Panel();
/** Layout of {@link #mainPanel} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** Parameters panel. North of {@link #mainLayout} */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
private Label labelBankAccount = new Label(); private Label labelBankAccount = new Label();
/** Bank account parameter */
private Listbox fieldBankAccount = ListboxFactory.newDropdownListbox(); private Listbox fieldBankAccount = ListboxFactory.newDropdownListbox();
/** Layout of {@link #parameterPanel} */
private Grid parameterLayout = GridFactory.newGridLayout(); private Grid parameterLayout = GridFactory.newGridLayout();
/** Label of {@link #labelBalance} */
private Label labelBankBalance = new Label(); private Label labelBankBalance = new Label();
/** Bank account currency */
private Label labelCurrency = new Label(); private Label labelCurrency = new Label();
/** Current bank account balance */
private Label labelBalance = new Label(); private Label labelBalance = new Label();
private Checkbox onlyDue = new Checkbox(); private Checkbox onlyDue = new Checkbox();
private Checkbox onlyPositiveBalance = new Checkbox(); private Checkbox onlyPositiveBalance = new Checkbox();
private Label labelBPartner = new Label(); private Label labelBPartner = new Label();
private Listbox fieldBPartner = ListboxFactory.newDropdownListbox(); private Listbox fieldBPartner = ListboxFactory.newDropdownListbox();
private Label dataStatus = new Label();
private WListbox miniTable = ListboxFactory.newDataTable();
private ConfirmPanel commandPanel = new ConfirmPanel(true, false, false, false, false, false, false);
private Button bCancel = commandPanel.getButton(ConfirmPanel.A_CANCEL);
private Button bGenerate = commandPanel.createButton(ConfirmPanel.A_PROCESS);
private Button bRefresh = commandPanel.createButton(ConfirmPanel.A_REFRESH);
private Label labelPayDate = new Label(); private Label labelPayDate = new Label();
/** C_PaySelection.PayDate */
private WDateEditor fieldPayDate = new WDateEditor(); private WDateEditor fieldPayDate = new WDateEditor();
private Label labelPaymentRule = new Label(); private Label labelPaymentRule = new Label();
private Listbox fieldPaymentRule = ListboxFactory.newDropdownListbox(); private Listbox fieldPaymentRule = ListboxFactory.newDropdownListbox();
private Label labelDtype = new Label(); private Label labelDtype = new Label();
/** Document Type */
private Listbox fieldDtype = ListboxFactory.newDropdownListbox(); private Listbox fieldDtype = ListboxFactory.newDropdownListbox();
private Panel southPanel; /** MPaySelection.COLUMNNAME_IsOnePaymentPerInvoice */
private Checkbox chkOnePaymentPerInv = new Checkbox(); private Checkbox chkOnePaymentPerInv = new Checkbox();
/** Center of {@link #mainLayout}. Open document list. */
private WListbox miniTable = ListboxFactory.newDataTable();
/** South of {@link #mainLayout} */
private Panel southPanel;
/** Child of {@link #southPanel} */
private Hlayout statusBar = new Hlayout();
/** Child of {@link #statusBar} */
private Label dataStatus = new Label();
/** Child of {@link #southPanel} */
private ConfirmPanel commandPanel = new ConfirmPanel(true, false, false, false, false, false, false);
private Button bCancel = commandPanel.getButton(ConfirmPanel.A_CANCEL);
/** Child of {@link #commandPanel} */
private Button bGenerate = commandPanel.createButton(ConfirmPanel.A_PROCESS);
/** Child of {@link #parameterLayout} */
private Button bRefresh = commandPanel.createButton(ConfirmPanel.A_REFRESH);
private ProcessInfo m_pi; private ProcessInfo m_pi;
private boolean m_isLock; private boolean m_isLock;
private Hlayout statusBar = new Hlayout();
/** /**
* Initialize Panel * Default constructor
*/ */
public WPaySelect() public WPaySelect()
{ {
@ -151,12 +173,11 @@ public class WPaySelect extends PaySelect
} }
/** /**
* Init UI component and layout * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
private void zkInit() throws Exception private void zkInit() throws Exception
{ {
//
form.appendChild(mainPanel); form.appendChild(mainPanel);
mainPanel.appendChild(mainLayout); mainPanel.appendChild(mainLayout);
mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0"); mainPanel.setStyle("width: 100%; height: 100%; padding: 0; margin: 0");
@ -305,13 +326,13 @@ public class WPaySelect extends PaySelect
// //
commandPanel.addButton(bGenerate); commandPanel.addButton(bGenerate);
commandPanel.getButton(ConfirmPanel.A_OK).setVisible(false); commandPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
} // jbInit }
/** /**
* Dynamic Init. * Dynamic Initialization. <br/>
* - Load Bank Info * - Load Bank Accounts. <br/>
* - Load BPartner * - Load BPartners. <br/>
* - Init Table * - Initialize {@link #miniTable}. <br/>
*/ */
private void dynInit() private void dynInit()
{ {
@ -342,7 +363,7 @@ public class WPaySelect extends PaySelect
} // dynInit } // dynInit
/** /**
* Load Bank Info - Load Info from Bank Account and valid Documents (PaymentRule) * Load Bank Info - Load Info from Bank Account and valid Documents (PaymentRule)
*/ */
protected void loadBankInfo() protected void loadBankInfo()
{ {
@ -364,7 +385,7 @@ public class WPaySelect extends PaySelect
} // loadBankInfo } // loadBankInfo
/** /**
* Load open documents * Load open documents into {@link #miniTable}
*/ */
protected void loadTableInfo() protected void loadTableInfo()
{ {
@ -387,7 +408,6 @@ public class WPaySelect extends PaySelect
return; return;
} }
BankInfo bi = fieldBankAccount.getSelectedItem().getValue(); BankInfo bi = fieldBankAccount.getSelectedItem().getValue();
ValueNamePair paymentRule = (fieldPaymentRule.getSelectedItem() != null ? (ValueNamePair) fieldPaymentRule.getSelectedItem().getValue() : null); ValueNamePair paymentRule = (fieldPaymentRule.getSelectedItem() != null ? (ValueNamePair) fieldPaymentRule.getSelectedItem().getValue() : null);
@ -405,7 +425,7 @@ public class WPaySelect extends PaySelect
} // loadTableInfo } // loadTableInfo
/** /**
* Dispose * Close form.
*/ */
public void dispose() public void dispose()
{ {
@ -413,9 +433,9 @@ public class WPaySelect extends PaySelect
} // dispose } // dispose
/************************************************************************** /**
* ActionListener * Event Listener
* @param e event * @param e event
*/ */
@Override @Override
public void onEvent (Event e) public void onEvent (Event e)
@ -510,7 +530,7 @@ public class WPaySelect extends PaySelect
} }
/** /**
* Calculate selected rows. * Calculate selected rows.<br/>
* - add up selected rows * - add up selected rows
*/ */
public void calculateSelection() public void calculateSelection()
@ -521,7 +541,7 @@ public class WPaySelect extends PaySelect
} // calculateSelection } // calculateSelection
/** /**
* Generate PaySelection * Generate C_PaySelection records.
*/ */
protected void generatePaySelect() protected void generatePaySelect()
{ {
@ -546,11 +566,9 @@ public class WPaySelect extends PaySelect
return; return;
} }
if (MSysConfig.getBooleanValue(MSysConfig.PAYMENT_SELECTION_MANUAL_ASK_INVOKE_GENERATE, true, m_ps.getAD_Client_ID(), m_ps.getAD_Org_ID())) { if (MSysConfig.getBooleanValue(MSysConfig.PAYMENT_SELECTION_MANUAL_ASK_INVOKE_GENERATE, true, m_ps.getAD_Client_ID(), m_ps.getAD_Org_ID())) {
// Ask to Post it // Open dialog to create MPaySelectionCheck records.
Dialog.ask(m_WindowNo, "VPaySelectGenerate?", new Callback<Boolean>() { Dialog.ask(m_WindowNo, "VPaySelectGenerate?", new Callback<Boolean>() {
@Override @Override
public void onCallback(Boolean result) public void onCallback(Boolean result)
{ {
@ -559,7 +577,7 @@ public class WPaySelect extends PaySelect
miniTable.clearSelection(); miniTable.clearSelection();
loadTableInfo(); loadTableInfo();
// Prepare Process // Prepare Process
int AD_Proces_ID = PROCESS_C_PAYSELECTION_CREATEPAYMENT; // C_PaySelection_CreatePayment int AD_Proces_ID = PROCESS_C_PAYSELECTION_CREATEPAYMENT; // PaySelectionCreateCheck
// Execute Process // Execute Process
ProcessModalDialog dialog = new ProcessModalDialog(WPaySelect.this, m_WindowNo, ProcessModalDialog dialog = new ProcessModalDialog(WPaySelect.this, m_WindowNo,
@ -592,7 +610,6 @@ public class WPaySelect extends PaySelect
} }
} }
} }
} }
}); });
} else { } else {
@ -603,8 +620,8 @@ public class WPaySelect extends PaySelect
} // generatePaySelect } // generatePaySelect
/** /**
* Lock User Interface * Lock User Interface.
* Called from the Worker before processing * Called from the Worker before processing.
*/ */
public void lockUI (ProcessInfo pi) public void lockUI (ProcessInfo pi)
{ {
@ -615,7 +632,7 @@ public class WPaySelect extends PaySelect
/** /**
* Unlock User Interface. * Unlock User Interface.
* Called from the Worker when processing is done * Called from the Worker when processing is done.
*/ */
public void unlockUI (ProcessInfo pi) public void unlockUI (ProcessInfo pi)
{ {
@ -628,7 +645,6 @@ public class WPaySelect extends PaySelect
} }
/** /**
*
* @return true if UI is lock * @return true if UI is lock
*/ */
public boolean isUILocked() { public boolean isUILocked() {
@ -641,7 +657,6 @@ public class WPaySelect extends PaySelect
} }
/** /**
*
* @return {@link ProcessInfo} * @return {@link ProcessInfo}
*/ */
public ProcessInfo getProcessInfo() { public ProcessInfo getProcessInfo() {

View File

@ -33,17 +33,17 @@ import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
import org.compiere.grid.PaymentFormCash; import org.compiere.grid.PaymentFormCash;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.KeyNamePair; import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg; import org.compiere.util.Msg;
/** /**
* * Form for cash payment rule ({@link X_C_Order#PAYMENTRULE_Cash}).
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormCash extends PaymentFormCash { public class WPaymentFormCash extends PaymentFormCash {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
private Label bBankAccountLabel = new Label(); private Label bBankAccountLabel = new Label();
@ -55,6 +55,10 @@ public class WPaymentFormCash extends PaymentFormCash {
private Label bAmountLabel = new Label(); private Label bAmountLabel = new Label();
private WNumberEditor bAmountField = new WNumberEditor(); private WNumberEditor bAmountField = new WNumberEditor();
/**
* @param windowNo
* @param mTab
*/
public WPaymentFormCash(int windowNo, GridTab mTab) { public WPaymentFormCash(int windowNo, GridTab mTab) {
super(windowNo, mTab); super(windowNo, mTab);
bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct"); bDateField = new WDateEditor("DateAcct", false, false, true, "DateAcct");
@ -64,6 +68,9 @@ public class WPaymentFormCash extends PaymentFormCash {
bAmountField.setValue(m_Amount); bAmountField.setValue(m_Amount);
} }
/**
* Layout {@link #window}
*/
public void init() { public void init() {
Grid bPanelLayout = GridFactory.newGridLayout(); Grid bPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(bPanelLayout); window.getPanel().appendChild(bPanelLayout);

View File

@ -36,6 +36,7 @@ import org.adempiere.webui.window.Dialog;
import org.compiere.grid.PaymentFormCheck; import org.compiere.grid.PaymentFormCheck;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MPaymentValidate; import org.compiere.model.MPaymentValidate;
import org.compiere.model.X_C_Order;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.KeyNamePair; import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -47,12 +48,11 @@ import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
/** /**
* * Form for check payment rule ({@link X_C_Order#PAYMENTRULE_Check}).
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormCheck extends PaymentFormCheck implements EventListener<Event> { public class WPaymentFormCheck extends PaymentFormCheck implements EventListener<Event> {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
private Label sBankAccountLabel = new Label(); private Label sBankAccountLabel = new Label();
@ -62,14 +62,15 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
private Label sRoutingLabel = new Label(); private Label sRoutingLabel = new Label();
private Textbox sRoutingField = new Textbox(); private Textbox sRoutingField = new Textbox();
private Label sNumberLabel = new Label(); private Label sNumberLabel = new Label();
/** Account number field */
private Textbox sNumberField = new Textbox(); private Textbox sNumberField = new Textbox();
/** Check number field */
private Textbox sCheckField = new Textbox(); private Textbox sCheckField = new Textbox();
private Label sCheckLabel = new Label(); private Label sCheckLabel = new Label();
private Button sOnline = new Button(); private Button sOnline = new Button();
private Label sStatus = new Label(); private Label sStatus = new Label();
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
*/ */
@ -79,6 +80,9 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
init(); init();
} }
/**
* Layout {@link #window}
*/
protected void init() { protected void init() {
Grid sPanelLayout = GridFactory.newGridLayout(); Grid sPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(sPanelLayout); window.getPanel().appendChild(sPanelLayout);
@ -164,6 +168,7 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
updateOnlineButton(); updateOnlineButton();
} }
@Override
public void onEvent(Event e) public void onEvent(Event e)
{ {
if (e.getTarget() == sAmountField) if (e.getTarget() == sAmountField)
@ -177,6 +182,10 @@ public class WPaymentFormCheck extends PaymentFormCheck implements EventListener
} }
} }
/**
* Set visibility of {@link #sOnline} depends on the availability of bank account processor
* ({@link #isBankAccountProcessorExist(int, BigDecimal)}).
*/
private void updateOnlineButton() private void updateOnlineButton()
{ {
boolean exist = isBankAccountProcessorExist(m_C_Currency_ID, (BigDecimal) sAmountField.getValue()); boolean exist = isBankAccountProcessorExist(m_C_Currency_ID, (BigDecimal) sAmountField.getValue());

View File

@ -14,6 +14,7 @@
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.logging.Level;
import org.adempiere.util.PaymentUtil; import org.adempiere.util.PaymentUtil;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
@ -36,6 +37,7 @@ import org.compiere.grid.PaymentFormCreditCard;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MBankAccountProcessor; import org.compiere.model.MBankAccountProcessor;
import org.compiere.model.MInvoice; import org.compiere.model.MInvoice;
import org.compiere.model.X_C_Order;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair; import org.compiere.util.ValueNamePair;
@ -47,19 +49,21 @@ import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
/** /**
* * Form for credit card payment rule ({@link X_C_Order#PAYMENTRULE_CreditCard}).
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormCreditCard extends PaymentFormCreditCard implements EventListener<Event> { public class WPaymentFormCreditCard extends PaymentFormCreditCard implements EventListener<Event> {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
private Label kTypeLabel = new Label(); private Label kTypeLabel = new Label();
/** Credit Card Type list */
private Listbox kTypeCombo = ListboxFactory.newDropdownListbox(); private Listbox kTypeCombo = ListboxFactory.newDropdownListbox();
private Label kNumberLabel = new Label(); private Label kNumberLabel = new Label();
/** Credit card number field */
private Textbox kNumberField = new Textbox(); private Textbox kNumberField = new Textbox();
private Label kExpLabel = new Label(); private Label kExpLabel = new Label();
/** Expire date field */
private Textbox kExpField = new Textbox(); private Textbox kExpField = new Textbox();
private Label kAmountLabel = new Label(); private Label kAmountLabel = new Label();
private WNumberEditor kAmountField = new WNumberEditor(); private WNumberEditor kAmountField = new WNumberEditor();
@ -69,7 +73,6 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
private Label kStatus = new Label(); private Label kStatus = new Label();
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
*/ */
@ -79,6 +82,9 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
init(); init();
} }
/**
* Layout {@link #window}
*/
protected void init() { protected void init() {
Grid kLayout = GridFactory.newGridLayout(); Grid kLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(kLayout); window.getPanel().appendChild(kLayout);
@ -242,6 +248,9 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
updateOnlineButton(); updateOnlineButton();
} }
/**
* Set state of {@link #kOnline} depending on availability of {@link MBankAccountProcessor} for selected Credit Card type.
*/
private void updateOnlineButton() private void updateOnlineButton()
{ {
String CCType = null; String CCType = null;
@ -295,7 +304,7 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
@Override @Override
public void processOnline() public void processOnline()
{ {
log.config(""); if (log.isLoggable(Level.CONFIG)) log.config("");
if (!checkMandatory()) if (!checkMandatory())
return; return;
@ -311,7 +320,7 @@ public class WPaymentFormCreditCard extends PaymentFormCreditCard implements Eve
if (processMsg != null) if (processMsg != null)
Dialog.info(getWindowNo(), "PaymentProcessed", processMsg); Dialog.info(getWindowNo(), "PaymentProcessed", processMsg);
} }
} // online }
@Override @Override
public void showWindow() { public void showWindow() {

View File

@ -45,28 +45,32 @@ import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
/** /**
* * Abstract base payment form class for payment rule direct debit and direct deposit.
* @author Elaine * @author Elaine
* *
*/ */
public abstract class WPaymentFormDirect extends PaymentFormDirect implements EventListener<Event> { public abstract class WPaymentFormDirect extends PaymentFormDirect implements EventListener<Event> {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
private Label tAccountLabel = new Label(); private Label tAccountLabel = new Label();
/** Bank accounts */
private Listbox tAccountCombo = ListboxFactory.newDropdownListbox(); private Listbox tAccountCombo = ListboxFactory.newDropdownListbox();
private Button tOnline = new Button(); private Button tOnline = new Button();
/** Routing number */
private Textbox tRoutingField = new Textbox(); private Textbox tRoutingField = new Textbox();
/** Account number */
private Textbox tNumberField = new Textbox(); private Textbox tNumberField = new Textbox();
private Label tStatus = new Label(); private Label tStatus = new Label();
/** Label for {@link #tRoutingField} */
private Label tRoutingText = new Label(); private Label tRoutingText = new Label();
/** Label for {@link #tNumberField} */
private Label tNumberText = new Label(); private Label tNumberText = new Label();
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
* @param isDebit * @param isDebit true for direct debit, false for direct deposit
*/ */
public WPaymentFormDirect(int windowNo, GridTab mTab, boolean isDebit) { public WPaymentFormDirect(int windowNo, GridTab mTab, boolean isDebit) {
super(windowNo, mTab, isDebit); super(windowNo, mTab, isDebit);
@ -74,6 +78,9 @@ public abstract class WPaymentFormDirect extends PaymentFormDirect implements Ev
init(); init();
} }
/**
* Layout {@link #window}
*/
protected void init() { protected void init() {
Grid tPanelLayout = GridFactory.newGridLayout(); Grid tPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(tPanelLayout); window.getPanel().appendChild(tPanelLayout);

View File

@ -14,17 +14,17 @@
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
/** /**
* * Form for direct debit payment rule ({@link X_C_Order#PAYMENTRULE_DirectDebit}).
* @author Elaine * @author Elaine
* *
*/ */
public class WPaymentFormDirectDebit extends WPaymentFormDirect { public class WPaymentFormDirectDebit extends WPaymentFormDirect {
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
*/ */

View File

@ -14,17 +14,16 @@
package org.adempiere.webui.apps.form; package org.adempiere.webui.apps.form;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
/** /**
* * Form for direct deposit payment rule ({@link X_C_Order#PAYMENTRULE_DirectDeposit}).
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormDirectDeposit extends WPaymentFormDirect { public class WPaymentFormDirectDeposit extends WPaymentFormDirect {
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
*/ */

View File

@ -18,14 +18,13 @@ import org.compiere.grid.IPaymentForm;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
/** /**
* * Static method to initiate {@link IPaymentForm} instance.
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormFactory { public class WPaymentFormFactory {
/** /**
* * Call {@link Extensions#getPaymentForm(int, GridTab, String)}
* @param windowNo * @param windowNo
* @param mTab * @param mTab
* @param paymentRule * @param paymentRule

View File

@ -15,16 +15,22 @@ package org.adempiere.webui.apps.form;
import org.compiere.grid.PaymentFormMixedPOS; import org.compiere.grid.PaymentFormMixedPOS;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
/** /**
* * Form for mixed POS payment rule ({@link X_C_Order#PAYMENTRULE_MixedPOSPayment}).<br/>
* As it is, this is a dummy implementation that doesn't do anything.
* @author Elaine * @author Elaine
* *
*/ */
public class WPaymentFormMixedPOS extends PaymentFormMixedPOS { public class WPaymentFormMixedPOS extends PaymentFormMixedPOS {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
/**
* @param windowNo
* @param mTab
*/
public WPaymentFormMixedPOS(int windowNo, GridTab mTab) { public WPaymentFormMixedPOS(int windowNo, GridTab mTab) {
super(windowNo, mTab); super(windowNo, mTab);
window = new WPaymentFormWindow(this, windowNo); window = new WPaymentFormWindow(this, windowNo);

View File

@ -28,24 +28,24 @@ import org.adempiere.webui.component.Rows;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.grid.PaymentFormOnCredit; import org.compiere.grid.PaymentFormOnCredit;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.KeyNamePair; import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg; import org.compiere.util.Msg;
/** /**
* * Form for on credit payment rule ({@link X_C_Order#PAYMENTRULE_OnCredit}).
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormOnCredit extends PaymentFormOnCredit { public class WPaymentFormOnCredit extends PaymentFormOnCredit {
/** Payment form window instance */
private WPaymentFormWindow window; private WPaymentFormWindow window;
private Label pTermLabel = new Label(); private Label pTermLabel = new Label();
/** Payment terms */
private Listbox pTermCombo = ListboxFactory.newDropdownListbox(); private Listbox pTermCombo = ListboxFactory.newDropdownListbox();
/** /**
*
* @param windowNo * @param windowNo
* @param mTab * @param mTab
*/ */
@ -55,6 +55,9 @@ public class WPaymentFormOnCredit extends PaymentFormOnCredit {
init(); init();
} }
/**
* Layout {@link #window}
*/
protected void init() { protected void init() {
Grid pPanelLayout = GridFactory.newGridLayout(); Grid pPanelLayout = GridFactory.newGridLayout();
window.getPanel().appendChild(pPanelLayout); window.getPanel().appendChild(pPanelLayout);

View File

@ -22,6 +22,7 @@ import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
import org.compiere.grid.IPaymentForm;
import org.compiere.grid.PaymentForm; import org.compiere.grid.PaymentForm;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -32,29 +33,37 @@ import org.zkoss.zul.Center;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* * Window for {@link IPaymentForm}.
* @author Elaine * @author Elaine
*
*/ */
public class WPaymentFormWindow extends Window implements EventListener<Event>, DialogEvents { public class WPaymentFormWindow extends Window implements EventListener<Event>, DialogEvents {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = 2710316463655831868L; private static final long serialVersionUID = 2710316463655831868L;
/** Form Controller */
private PaymentForm paymentForm; private PaymentForm paymentForm;
private int windowNo; private int windowNo;
/** Main panel of form */
private Panel mainPanel = new Panel(); private Panel mainPanel = new Panel();
/** Center of {@link #mainLayout} */
private Panel centerPanel = new Panel(); private Panel centerPanel = new Panel();
/** Layout of {@link #mainPanel} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** South of {@link #mainLayout}. Action buttons panel. */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** True when UI is lock */
private boolean m_isLocked = false; private boolean m_isLocked = false;
/** Status of initialization */
private boolean initOK = false; private boolean initOK = false;
private BusyDialog progressWindow; private BusyDialog progressWindow;
/**
* @param paymentForm
* @param windowNo
*/
public WPaymentFormWindow(PaymentForm paymentForm, int windowNo) public WPaymentFormWindow(PaymentForm paymentForm, int windowNo)
{ {
super(); super();
@ -79,10 +88,17 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED); this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
} }
/**
* @return window number
*/
protected int getWindowNo() { protected int getWindowNo() {
return this.windowNo; return this.windowNo;
} }
/**
* Layout form.
* @throws Exception
*/
private void zkInit() throws Exception { private void zkInit() throws Exception {
this.appendChild(mainPanel); this.appendChild(mainPanel);
mainPanel.appendChild(mainLayout); mainPanel.appendChild(mainLayout);
@ -104,34 +120,45 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
confirmPanel.addActionListener(this); confirmPanel.addActionListener(this);
} }
/**
* Dynamic initialization.
* Call {@link PaymentForm#dynInit()}.
* @return initialization status
* @throws Exception
*/
private boolean dynInit() throws Exception { private boolean dynInit() throws Exception {
boolean isInitOK = paymentForm.dynInit(); boolean isInitOK = paymentForm.dynInit();
centerPanel.setVisible(!paymentForm.isOnlyRule()); centerPanel.setVisible(!paymentForm.isOnlyRule());
return isInitOK; return isInitOK;
} }
/**
* @return {@link #centerPanel}
*/
public Panel getPanel() { public Panel getPanel() {
return centerPanel; return centerPanel;
} }
/************************************************************************** /**
* Action Listener * Event Listener
* *
* @param e * @param e event
* event
*/ */
public void onEvent(Event e) { public void onEvent(Event e) {
// Finish // Finish
if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) { if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) {
if (paymentForm.checkMandatory()) { if (paymentForm.checkMandatory()) {
paymentForm.saveChanges(); // cannot recover paymentForm.saveChanges();
dispose(); dispose();
} }
} else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) } else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
dispose(); dispose();
}
} // actionPerformed /**
* Handle runProcessOnline event.
* Call {@link PaymentForm#processOnline()}.
*/
public void runProcessOnline() { public void runProcessOnline() {
try { try {
paymentForm.processOnline(); paymentForm.processOnline();
@ -140,6 +167,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
} }
} }
/**
* Unlock and update UI.
*/
public void unlockUI() { public void unlockUI() {
if (!m_isLocked) return; if (!m_isLocked) return;
@ -148,6 +178,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
updateUI(); updateUI();
} }
/**
* Lock UI and show in progress dialog.
*/
public void lockUI() { public void lockUI() {
if (m_isLocked) return; if (m_isLocked) return;
@ -156,6 +189,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
showBusyDialog(); showBusyDialog();
} }
/**
* Close in progress dialog.
*/
private void hideBusyDialog() { private void hideBusyDialog() {
if (progressWindow != null) { if (progressWindow != null) {
progressWindow.dispose(); progressWindow.dispose();
@ -163,17 +199,27 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
} }
} }
/**
* Update UI after completion of processing/save.<br/>
* Call from {@link #unlockUI()}.
*/
private void updateUI() { private void updateUI() {
if (paymentForm.isApproved()) if (paymentForm.isApproved())
dispose(); dispose();
} }
/**
* Show in progress window.
*/
private void showBusyDialog() { private void showBusyDialog() {
progressWindow = new BusyDialog(); progressWindow = new BusyDialog();
progressWindow.setPage(this.getPage()); progressWindow.setPage(this.getPage());
progressWindow.doHighlighted(); progressWindow.doHighlighted();
} }
/**
* @return true if initialization have been completed sucessfully
*/
public boolean isInitOK() public boolean isInitOK()
{ {
return initOK; return initOK;

View File

@ -67,18 +67,24 @@ import org.zkoss.zul.Vbox;
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WPluginManager extends ADForm implements EventListener<Event> { public class WPluginManager extends ADForm implements EventListener<Event> {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -5661912464378243252L; private static final long serialVersionUID = -5661912464378243252L;
/** Log. */ /** Log. */
private static final CLogger log = CLogger.getCLogger(WPluginManager.class); private static final CLogger log = CLogger.getCLogger(WPluginManager.class);
/** Center of form */
private WListbox pluginsTable; private WListbox pluginsTable;
/** Available actions for plugins */
private Listbox pluginActions; private Listbox pluginActions;
/** Button to apply {@link #pluginActions} to bundle */
private Button pluginProcess; private Button pluginProcess;
/** Data for {@link #pluginsTable} */
private Vector<Vector<Object>> pluginData; private Vector<Vector<Object>> pluginData;
/** Column headers of {@link #pluginsTable} */
private Vector<String> pluginColumnNames; private Vector<String> pluginColumnNames;
/** filter by bundle symbolic name (using contains) */
private Textbox fFilter = new Textbox(); private Textbox fFilter = new Textbox();
private Button btnRefresh = null; private Button btnRefresh = null;
@ -158,6 +164,10 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
this.appendChild(vbox); this.appendChild(vbox);
} }
/**
* @param state
* @return Text for bundle state
*/
private String state(int state) { private String state(int state) {
switch (state) { switch (state) {
case Bundle.ACTIVE: case Bundle.ACTIVE:
@ -177,6 +187,9 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
} }
} }
/**
* Refresh {@link #pluginActions}
*/
private void refreshActionList() { private void refreshActionList() {
pluginActions.getItemAtIndex(PLUGIN_ACTION_UPDATE).setVisible(false); // not implemented yet pluginActions.getItemAtIndex(PLUGIN_ACTION_UPDATE).setVisible(false); // not implemented yet
pluginActions.getItemAtIndex(PLUGIN_ACTION_UNINSTALL).setVisible(false); // not implemented yet pluginActions.getItemAtIndex(PLUGIN_ACTION_UNINSTALL).setVisible(false); // not implemented yet
@ -221,6 +234,9 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
} }
} }
/**
* @return selected @link {@link Bundle}
*/
private Bundle getSelectedBundle() { private Bundle getSelectedBundle() {
Bundle retValue = null; Bundle retValue = null;
int idx = pluginsTable.getSelectedIndex(); int idx = pluginsTable.getSelectedIndex();
@ -233,6 +249,9 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
return retValue; return retValue;
} }
/**
* Apply selected {@link #pluginActions} to selected {@link Bundle} (from selected {@link #pluginsTable} row).
*/
private void processPlugin() { private void processPlugin() {
Listitem actionItem = pluginActions.getSelectedItem(); Listitem actionItem = pluginActions.getSelectedItem();
if (actionItem != null && actionItem.getValue() instanceof Integer) { if (actionItem != null && actionItem.getValue() instanceof Integer) {
@ -265,6 +284,10 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
refreshAll(); refreshAll();
} }
/**
* Refresh {@link #pluginsTable}.
* Bundle list is loaded from {@link BundleContext#getBundles()}.
*/
private void refreshPluginTable() { private void refreshPluginTable() {
int idx = pluginsTable.getSelectedIndex(); int idx = pluginsTable.getSelectedIndex();
pluginsTable.getModel().removeAll(pluginData); pluginsTable.getModel().removeAll(pluginData);
@ -291,11 +314,15 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
pluginsTable.setSelectedIndex(idx); pluginsTable.setSelectedIndex(idx);
} }
/**
* Call {@link #refreshPluginTable()} and {@link #refreshActionList()}.
*/
private void refreshAll() { private void refreshAll() {
refreshPluginTable(); refreshPluginTable();
refreshActionList(); refreshActionList();
} }
@Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (Events.ON_SELECT.equals(event.getName()) && event.getTarget() == pluginsTable) if (Events.ON_SELECT.equals(event.getName()) && event.getTarget() == pluginsTable)
refreshActionList(); refreshActionList();
@ -308,5 +335,4 @@ public class WPluginManager extends ADForm implements EventListener<Event> {
refreshAll(); refreshAll();
} }
} }
} }

View File

@ -32,12 +32,13 @@ import org.compiere.util.Util;
import org.idempiere.model.IProcessParameter; import org.idempiere.model.IProcessParameter;
/** /**
* Form to create MSchedulerPara or MProcessDrillRulePara records.
* @author hengsin * @author hengsin
*
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WProcessParameter implements IFormController { public class WProcessParameter implements IFormController {
/** Form/window UI instance */
private WProcessParameterForm parameterForm = null; private WProcessParameterForm parameterForm = null;
/** /**
@ -56,22 +57,22 @@ public class WProcessParameter implements IFormController {
} }
/** /**
* Save parameters * Create MSchedulerPara or MProcessDrillRulePara from paras.
* @param paras * @param instanceParas
* @param tableName * @param tableName
*/ */
public void saveParameters(MPInstancePara[] paras, String tableName) { public void saveParameters(MPInstancePara[] instanceParas, String tableName) {
MTable table = MTable.get(Env.getCtx(), tableName); MTable table = MTable.get(Env.getCtx(), tableName);
PO po = table.getPO(parameterForm.getProcessInfo().getRecord_ID(), null); PO po = table.getPO(parameterForm.getProcessInfo().getRecord_ID(), null);
String idColumn = ""; String idColumn = "";
int AD_Process_ID = po.get_ValueAsInt("AD_Process_ID"); //scheduler.getAD_Process_ID(); int AD_Process_ID = po.get_ValueAsInt("AD_Process_ID"); //scheduler.getAD_Process_ID();
if (AD_Process_ID > 0 && paras.length > 0) { if (AD_Process_ID > 0 && instanceParas.length > 0) {
MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID); MProcess process = MProcess.get(Env.getCtx(), AD_Process_ID);
MProcessPara[] processParameters = process.getParameters(); MProcessPara[] processParameters = process.getParameters();
//delete parameters //clear old before create new
if(tableName.equalsIgnoreCase(MScheduler.Table_Name)) { if(tableName.equalsIgnoreCase(MScheduler.Table_Name)) {
idColumn = "AD_Scheduler_ID"; idColumn = "AD_Scheduler_ID";
MScheduler scheduler = new MScheduler(Env.getCtx(), po.get_ID(), null); MScheduler scheduler = new MScheduler(Env.getCtx(), po.get_ID(), null);
@ -88,9 +89,9 @@ public class WProcessParameter implements IFormController {
para.deleteEx(true); para.deleteEx(true);
} }
} }
//
//child table always must have "_Para" suffix //child table always must have "_Para" suffix
for(MPInstancePara para : paras) { for(MPInstancePara instancePara : instanceParas) {
table = MTable.get(Env.getCtx(), tableName+"_Para"); table = MTable.get(Env.getCtx(), tableName+"_Para");
IProcessParameter poPara = null; IProcessParameter poPara = null;
if(tableName.equalsIgnoreCase(MScheduler.Table_Name)) if(tableName.equalsIgnoreCase(MScheduler.Table_Name))
@ -99,37 +100,37 @@ public class WProcessParameter implements IFormController {
poPara = new MProcessDrillRulePara(Env.getCtx(), 0, null); poPara = new MProcessDrillRulePara(Env.getCtx(), 0, null);
poPara.setParentID(po.get_ValueAsInt(idColumn)); poPara.setParentID(po.get_ValueAsInt(idColumn));
for(MProcessPara processPara : processParameters) { for(MProcessPara processPara : processParameters) {
if (processPara.getColumnName().equals(para.getParameterName())) { if (processPara.getColumnName().equals(instancePara.getParameterName())) {
poPara.setAD_Process_Para_ID(processPara.getAD_Process_Para_ID()); poPara.setAD_Process_Para_ID(processPara.getAD_Process_Para_ID());
if (DisplayType.isNumeric(processPara.getAD_Reference_ID())) { if (DisplayType.isNumeric(processPara.getAD_Reference_ID())) {
if (para.get_Value(MPInstancePara.COLUMNNAME_P_Number) != null) if (instancePara.get_Value(MPInstancePara.COLUMNNAME_P_Number) != null)
poPara.setParameterDefault(para.getP_Number().toString()); poPara.setParameterDefault(instancePara.getP_Number().toString());
if (processPara.isRange() && para.get_Value(MPInstancePara.COLUMNNAME_P_Number_To) != null) if (processPara.isRange() && instancePara.get_Value(MPInstancePara.COLUMNNAME_P_Number_To) != null)
poPara.setParameterToDefault(para.getP_Number_To().toString()); poPara.setParameterToDefault(instancePara.getP_Number_To().toString());
} else if (DisplayType.isID(processPara.getAD_Reference_ID())) { } else if (DisplayType.isID(processPara.getAD_Reference_ID())) {
if (para.get_Value(MPInstancePara.COLUMNNAME_P_Number) != null) if (instancePara.get_Value(MPInstancePara.COLUMNNAME_P_Number) != null)
poPara.setParameterDefault(Integer.toString(para.getP_Number().intValue())); poPara.setParameterDefault(Integer.toString(instancePara.getP_Number().intValue()));
if (processPara.isRange() && para.get_Value(MPInstancePara.COLUMNNAME_P_Number_To) != null) if (processPara.isRange() && instancePara.get_Value(MPInstancePara.COLUMNNAME_P_Number_To) != null)
poPara.setParameterToDefault(Integer.toString(para.getP_Number_To().intValue())); poPara.setParameterToDefault(Integer.toString(instancePara.getP_Number_To().intValue()));
} else if (DisplayType.isDate(processPara.getAD_Reference_ID())) { } else if (DisplayType.isDate(processPara.getAD_Reference_ID())) {
if (para.getP_Date() != null) if (instancePara.getP_Date() != null)
poPara.setParameterDefault(para.getP_Date().toString()); poPara.setParameterDefault(instancePara.getP_Date().toString());
if (processPara.isRange() && para.getP_Date_To() != null) if (processPara.isRange() && instancePara.getP_Date_To() != null)
poPara.setParameterToDefault(para.getP_Date_To().toString()); poPara.setParameterToDefault(instancePara.getP_Date_To().toString());
} else { } else {
poPara.setParameterDefault(para.getP_String()); poPara.setParameterDefault(instancePara.getP_String());
if (processPara.isRange() && para.getP_String_To() != null) if (processPara.isRange() && instancePara.getP_String_To() != null)
poPara.setParameterToDefault(para.getP_String_To()); poPara.setParameterToDefault(instancePara.getP_String_To());
} }
if (!Util.isEmpty(para.getInfo())) { if (!Util.isEmpty(instancePara.getInfo())) {
poPara.setDescription(para.getInfo()); poPara.setDescription(instancePara.getInfo());
} }
if (!Util.isEmpty(para.getInfo_To())) { if (!Util.isEmpty(instancePara.getInfo_To())) {
String s = poPara.getDescription(); String s = poPara.getDescription();
if (Util.isEmpty(s)) if (Util.isEmpty(s))
s = para.getInfo_To(); s = instancePara.getInfo_To();
else else
s = s + ", " + para.getInfo_To(); s = s + ", " + instancePara.getInfo_To();
poPara.setDescription(s); poPara.setDescription(s);
} }
break; break;

View File

@ -50,7 +50,7 @@ import org.zkoss.zul.Column;
import org.zkoss.zul.Columns; import org.zkoss.zul.Columns;
/** /**
* Quick entry form * Quick entry form.
* *
* @author Logilite Technologies * @author Logilite Technologies
* @since Nov 03, 2017 * @since Nov 03, 2017
@ -58,17 +58,21 @@ import org.zkoss.zul.Columns;
public class WQuickForm extends Window implements IQuickForm public class WQuickForm extends Window implements IQuickForm
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -5363771364595732977L; private static final long serialVersionUID = -5363771364595732977L;
/** Main layout of form */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** Calling ADWindowContent instance */
private AbstractADWindowContent adWinContent = null; private AbstractADWindowContent adWinContent = null;
/** Center of {@link #mainLayout}. Grid/List view for multi record entry. */
private QuickGridView quickGridView = null; private QuickGridView quickGridView = null;
/** Current selected grid tab of {@link #adWinContent} */
private GridTab gridTab; private GridTab gridTab;
/** Action buttons panel. South of {@link #mainLayout} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, false, false, false, false); private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, false, false, false, false);
private Button bDelete = confirmPanel.createButton(ConfirmPanel.A_DELETE); private Button bDelete = confirmPanel.createButton(ConfirmPanel.A_DELETE);
private Button bSave = confirmPanel.createButton("Save"); private Button bSave = confirmPanel.createButton("Save");
private Button bIgnore = confirmPanel.createButton("Ignore"); private Button bIgnore = confirmPanel.createButton("Ignore");
@ -79,12 +83,17 @@ public class WQuickForm extends Window implements IQuickForm
private int onlyCurrentDays = 0; private int onlyCurrentDays = 0;
QuickGridView prevQGV = null; protected QuickGridView prevQGV = null;
private int windowNo; private int windowNo;
private boolean stayInParent; private boolean stayInParent;
/**
* @param winContent
* @param m_onlyCurrentRows
* @param m_onlyCurrentDays
*/
public WQuickForm(AbstractADWindowContent winContent, boolean m_onlyCurrentRows, int m_onlyCurrentDays) public WQuickForm(AbstractADWindowContent winContent, boolean m_onlyCurrentRows, int m_onlyCurrentDays)
{ {
super(); super();
@ -109,6 +118,9 @@ public class WQuickForm extends Window implements IQuickForm
addCallback(AFTER_PAGE_DETACHED, t -> adWinContent.focusToLastFocusEditor()); addCallback(AFTER_PAGE_DETACHED, t -> adWinContent.focusToLastFocusEditor());
} }
/**
* Initialize form.
*/
protected void initForm( ) protected void initForm( )
{ {
initZk(); initZk();
@ -116,6 +128,9 @@ public class WQuickForm extends Window implements IQuickForm
quickGridView.refresh(gridTab); quickGridView.refresh(gridTab);
} }
/**
* Layout form.
*/
private void initZk( ) private void initZk( )
{ {
// Center // Center
@ -213,6 +228,9 @@ public class WQuickForm extends Window implements IQuickForm
event.stopPropagation(); event.stopPropagation();
} // onEvent } // onEvent
/**
* Cancel/Close form.
*/
public void onCancel( ) public void onCancel( )
{ {
if (gridTab.getTableModel().getRowChanged() > -1) if (gridTab.getTableModel().getRowChanged() > -1)
@ -234,6 +252,9 @@ public class WQuickForm extends Window implements IQuickForm
} }
} // onCancel } // onCancel
/**
* Reset sort state
*/
public void onUnSort( ) public void onUnSort( )
{ {
adWinContent.getActiveGridTab().getTableModel().resetCacheSortState(); adWinContent.getActiveGridTab().getTableModel().resetCacheSortState();
@ -247,6 +268,9 @@ public class WQuickForm extends Window implements IQuickForm
adWinContent.getStatusBarQF().setStatusLine(Msg.getMsg(Env.getCtx(), "UnSort"), false); adWinContent.getStatusBarQF().setStatusLine(Msg.getMsg(Env.getCtx(), "UnSort"), false);
} // onUnSort } // onUnSort
/**
* Open {@link CustomizeGridViewDialog} for {@link #quickGridView}.
*/
public void onCustomize( ) public void onCustomize( )
{ {
onSave(); onSave();
@ -271,6 +295,9 @@ public class WQuickForm extends Window implements IQuickForm
CustomizeGridViewDialog.showCustomize(0, gridTab.getAD_Tab_ID(), columnsWidth, gridFieldIds, null, quickGridView, true, null); CustomizeGridViewDialog.showCustomize(0, gridTab.getAD_Tab_ID(), columnsWidth, gridFieldIds, null, quickGridView, true, null);
} // onCustomize } // onCustomize
/**
* Ignore/Undo changes
*/
public void onIgnore( ) public void onIgnore( )
{ {
gridTab.dataIgnore(); gridTab.dataIgnore();
@ -284,6 +311,9 @@ public class WQuickForm extends Window implements IQuickForm
Events.echoEvent(QuickGridView.EVENT_ON_SET_FOCUS_TO_FIRST_CELL, quickGridView, null); Events.echoEvent(QuickGridView.EVENT_ON_SET_FOCUS_TO_FIRST_CELL, quickGridView, null);
} // onIgnore } // onIgnore
/**
* Delete selected rows.
*/
public void onDelete( ) public void onDelete( )
{ {
if (gridTab == null || !quickGridView.isNewLineSaved) if (gridTab == null || !quickGridView.isNewLineSaved)
@ -346,6 +376,9 @@ public class WQuickForm extends Window implements IQuickForm
} }
} // onDelete } // onDelete
/**
* Save {@link #quickGridView} changes.
*/
public void onSave( ) public void onSave( )
{ {
if (gridTab.getTableModel().getRowChanged() == gridTab.getCurrentRow()) if (gridTab.getTableModel().getRowChanged() == gridTab.getCurrentRow())
@ -363,6 +396,9 @@ public class WQuickForm extends Window implements IQuickForm
} }
} // onSave } // onSave
/**
* Refresh {@link #gridTab} and {@link #quickGridView}.
*/
public void onRefresh( ) public void onRefresh( )
{ {
gridTab.dataRefreshAll(); gridTab.dataRefreshAll();
@ -375,6 +411,9 @@ public class WQuickForm extends Window implements IQuickForm
createNewRow(); createNewRow();
} // onRefresh } // onRefresh
/**
* Close form.
*/
@Override @Override
public void dispose( ) public void dispose( )
{ {
@ -413,6 +452,9 @@ public class WQuickForm extends Window implements IQuickForm
} }
} // dispose } // dispose
/**
* Add new row to {@link #quickGridView}.
*/
private void createNewRow( ) private void createNewRow( )
{ {
int row = gridTab.getRowCount(); int row = gridTab.getRowCount();
@ -445,11 +487,10 @@ public class WQuickForm extends Window implements IQuickForm
} // dataStatusChanged } // dataStatusChanged
/** /**
* Return to parent when closing the quick form * If stayInParent is true, {@link #adWinContent} should navigate to parent record after closing this form instance.
* @param stayInParent * @param stayInParent
*/ */
public void setStayInParent(boolean stayInParent) { public void setStayInParent(boolean stayInParent) {
this.stayInParent = stayInParent; this.stayInParent = stayInParent;
} }
} }

View File

@ -72,66 +72,82 @@ import org.zkoss.zul.Hlayout;
import org.zkoss.zul.Separator; import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
/**
* Form to customise print format of a {@link ReportEngine} instance (i.e starting from report output).<br/>
* Open from {@link ZkReportViewer}.
*/
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WReportCustomization implements IFormController,EventListener<Event> { public class WReportCustomization implements IFormController,EventListener<Event> {
/** Custom form/window instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** Window No */
private int m_WindowNo = -1;
/** Window No */ protected int curStep = 0;
private int m_WindowNo = -1; /** Context */
private Properties m_ctx;
int curStep = 0; /** true if current login role has export right */
/** Print Context */ private boolean m_isCanExport;
private Properties m_ctx;
private boolean m_isCanExport;
private ReportEngine m_reportEngine=null; private ReportEngine m_reportEngine=null;
public ArrayList<MPrintFormatItem> pfi ; /** Print format items from {@link ReportEngine#getPrintFormat()} */
protected ArrayList<MPrintFormatItem> pfi ;
/** North of {@link #form} */
private Hlayout headerPanel=new Hlayout(); private Hlayout headerPanel=new Hlayout();
/** Print format name */
private WStringEditor name = new WStringEditor(); private WStringEditor name = new WStringEditor();
private String tempName = ""; private String tempName = "";
/** Button to create new print format */
private Button newPrintFormat; private Button newPrintFormat;
private Label selectAll; private Label selectAll;
private Label deselectAll; private Label deselectAll;
private Label pipeSeparator; private Label pipeSeparator;
private Button bExport = new Button();
private Button bnext ; /** Center of {@link #form} */
private Button btnSave;
private Tabbox tabbox = new Tabbox(); private Tabbox tabbox = new Tabbox();
private Tabs tabs = new Tabs(); private Tabs tabs = new Tabs();
private Tabpanels tabpanels = new Tabpanels(); private Tabpanels tabpanels = new Tabpanels();
/** Dialog for export of {@link #m_reportEngine} to file */
private Window winExportFile = null; private Window winExportFile = null;
/** Output type (pdf, html, etc) for {@link #winExportFile} */
private Listbox cboType = new Listbox(); private Listbox cboType = new Listbox();
/** Confirm panel for {@link #winExportFile} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** Footer of {@link #form} */
private ConfirmPanel confirmPanelMain = new ConfirmPanel(true); private ConfirmPanel confirmPanelMain = new ConfirmPanel(true);
public boolean isChange=false; private Button bExport = new Button();
public ZkReportViewer viewer; private Button bnext ;
MPrintFormat fm; private Button btnSave;
/** true if {@link #name} has change */
protected boolean isChange=false;
/** Print format from {@link ReportEngine#getPrintFormat()} */
protected MPrintFormat fm;
Tab tabdf1=new Tab(Msg.getMsg(Env.getCtx(), "DisplayFields")); protected Tab tabdf1=new Tab(Msg.getMsg(Env.getCtx(), "DisplayFields"));
Tab tabfo2=new Tab(Msg.getMsg(Env.getCtx(), "FieldOrder")); protected Tab tabfo2=new Tab(Msg.getMsg(Env.getCtx(), "FieldOrder"));
Tab tabsc3=new Tab(Msg.getMsg(Env.getCtx(), "SortCriteria")); protected Tab tabsc3=new Tab(Msg.getMsg(Env.getCtx(), "SortCriteria"));
Tab tabgc4=new Tab(Msg.getMsg(Env.getCtx(), "GroupingCriteria")); protected Tab tabgc4=new Tab(Msg.getMsg(Env.getCtx(), "GroupingCriteria"));
Tab tabsf5=new Tab(Msg.getMsg(Env.getCtx(), "SummaryFields")); protected Tab tabsf5=new Tab(Msg.getMsg(Env.getCtx(), "SummaryFields"));
WRC1DisplayFieldsPanel tpdf1 = new WRC1DisplayFieldsPanel(); protected WRC1DisplayFieldsPanel tpdf1 = new WRC1DisplayFieldsPanel();
WRC2FieldOrderPanel tpfo2 =new WRC2FieldOrderPanel(); protected WRC2FieldOrderPanel tpfo2 =new WRC2FieldOrderPanel();
WRC3SortCriteriaPanel tpsc3=new WRC3SortCriteriaPanel(); protected WRC3SortCriteriaPanel tpsc3=new WRC3SortCriteriaPanel();
WRC4GroupingCriteriaPanel tpgc4=new WRC4GroupingCriteriaPanel(); protected WRC4GroupingCriteriaPanel tpgc4=new WRC4GroupingCriteriaPanel();
WRC5SummaryFieldsPanel tpsf5=new WRC5SummaryFieldsPanel(); protected WRC5SummaryFieldsPanel tpsf5=new WRC5SummaryFieldsPanel();
/** selected tab index */
private int oldtabidx = 0; private int oldtabidx = 0;
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WReportCustomization.class); private static final CLogger log = CLogger.getCLogger(WReportCustomization.class);
/** /**
* Static Layout * Default constructor
* @throws Exception * @throws Exception
*/ */
public WReportCustomization() { public WReportCustomization() {
@ -141,11 +157,10 @@ public class WReportCustomization implements IFormController,EventListener<Even
} }
/** /**
* Static Layout * Set report engine.
* @throws Exception * @throws Exception
*/ */
public void setReportEngine(ReportEngine re) { public void setReportEngine(ReportEngine re) {
m_reportEngine = re; m_reportEngine = re;
m_isCanExport=MRole.getDefault().isCanExport(); m_isCanExport=MRole.getDefault().isCanExport();
pfi = new ArrayList<MPrintFormatItem>() ; pfi = new ArrayList<MPrintFormatItem>() ;
@ -165,14 +180,13 @@ public class WReportCustomization implements IFormController,EventListener<Even
} }
} }
/**
* Layout {@link #form}
*/
private void init() private void init()
{ {
form.setStyle("width: 90%; height: 90%; position: absolute; border:none; padding:none; margin:none;"); form.setStyle("width: 90%; height: 90%; position: absolute; border:none; padding:none; margin:none;");
//ZKUpdateUtil.setHeight(headerPanel, "40px");
//headerPanel.setWidth("100%");
headerPanel.appendChild(new Separator("vertical")); headerPanel.appendChild(new Separator("vertical"));
fm = new MPrintFormat(m_ctx, m_reportEngine.getPrintFormat().getAD_PrintFormat_ID(), null); fm = new MPrintFormat(m_ctx, m_reportEngine.getPrintFormat().getAD_PrintFormat_ID(), null);
@ -373,7 +387,7 @@ public class WReportCustomization implements IFormController,EventListener<Even
} }
if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)){ if (event.getTarget().getId().equals(ConfirmPanel.A_CANCEL)){
close(); close();
}else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)){ } else if (event.getTarget().getId().equals(ConfirmPanel.A_OK)){
((WRCTabPanel) tabbox.getSelectedTabpanel()).updatePFI(); ((WRCTabPanel) tabbox.getSelectedTabpanel()).updatePFI();
onSave(); onSave();
close(); close();
@ -393,6 +407,9 @@ public class WReportCustomization implements IFormController,EventListener<Even
pipeSeparator.setVisible(oldtabidx == 0); pipeSeparator.setVisible(oldtabidx == 0);
} }
/**
* Save changes ({@link #name} and/or {@link #pfi}).
*/
private void onSave() { private void onSave() {
if (name.getValue() == null || Util.isEmpty((String) name.getValue())) if (name.getValue() == null || Util.isEmpty((String) name.getValue()))
@ -427,6 +444,9 @@ public class WReportCustomization implements IFormController,EventListener<Even
setIsChanged(false); setIsChanged(false);
} }
/**
* Update AD_PrintFormat_Trl
*/
private void updateTrl() private void updateTrl()
{ {
List<GenericPO> list = new Query(m_ctx, "AD_PrintFormat_Trl", "AD_PrintFormat_ID = ?", null) List<GenericPO> list = new Query(m_ctx, "AD_PrintFormat_Trl", "AD_PrintFormat_ID = ?", null)
@ -446,7 +466,7 @@ public class WReportCustomization implements IFormController,EventListener<Even
} }
/** /**
* Export * Export content of {@link #m_reportEngine} to file.
*/ */
private void cmd_export() private void cmd_export()
{ {
@ -513,6 +533,9 @@ public class WReportCustomization implements IFormController,EventListener<Even
AEnv.showWindow(winExportFile); AEnv.showWindow(winExportFile);
} // cmd_export } // cmd_export
/**
* Export content of {@link #m_reportEngine} to file.
*/
private void exportFile() private void exportFile()
{ {
try try
@ -599,11 +622,17 @@ public class WReportCustomization implements IFormController,EventListener<Even
} }
} }
/**
* Close form.
*/
public void close() public void close()
{ {
form.detach(); form.detach();
} }
/**
* Create new print format from m_reportEngine.getPrintFormat().
*/
public void copyFormat(){ public void copyFormat(){
pfi.clear(); pfi.clear();
MPrintFormat newpf=MPrintFormat.copyToClient(m_ctx, m_reportEngine.getPrintFormat().get_ID() ,Env.getAD_Client_ID(m_ctx)); MPrintFormat newpf=MPrintFormat.copyToClient(m_ctx, m_reportEngine.getPrintFormat().get_ID() ,Env.getAD_Client_ID(m_ctx));
@ -640,11 +669,14 @@ public class WReportCustomization implements IFormController,EventListener<Even
fm = newpf; fm = newpf;
} }
public void setIsChanged(boolean change){ /**
isChange=change; * @param change
*/
public void setIsChanged(boolean change){
isChange=change;
btnSave.setDisabled(!isChange); btnSave.setDisabled(!isChange);
bExport.setDisabled(isChange); bExport.setDisabled(isChange);
newPrintFormat.setDisabled(isChange); newPrintFormat.setDisabled(isChange);
} }
} }

View File

@ -66,9 +66,11 @@ import org.zkoss.zul.South;
public class WResetPassword implements IFormController, EventListener<Event>, ValueChangeListener { public class WResetPassword implements IFormController, EventListener<Event>, ValueChangeListener {
private static final CLogger log = CLogger.getCLogger(WResetPassword.class); private static final CLogger log = CLogger.getCLogger(WResetPassword.class);
/** Custom form/window UI instance */
private CustomForm form; private CustomForm form;
/** Center of {@link #form}. Grid layout for form fields. */
private Grid gridPanel; private Grid gridPanel;
/** South of {@link #form} */
private ConfirmPanel confirmPanel; private ConfirmPanel confirmPanel;
private Label lblUser; private Label lblUser;
@ -90,6 +92,9 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
private Textbox txtNewEMailUserPW; private Textbox txtNewEMailUserPW;
private Textbox txtRetypeNewEMailPW; private Textbox txtRetypeNewEMailPW;
/**
* Default constructor.
*/
public WResetPassword() public WResetPassword()
{ {
form = new CustomForm(); form = new CustomForm();
@ -121,6 +126,10 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
} }
} }
/**
* Dynamic initializatio of UI components.
* @throws Exception
*/
private void dynInit() throws Exception private void dynInit() throws Exception
{ {
lblUser = new Label(Msg.translate(Env.getCtx(), "AD_User_ID")); lblUser = new Label(Msg.translate(Env.getCtx(), "AD_User_ID"));
@ -186,6 +195,10 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
confirmPanel = new ConfirmPanel(true); confirmPanel = new ConfirmPanel(true);
} }
/**
* Layout {@link #gridPanel}
* @throws Exception
*/
private void zkInit() throws Exception private void zkInit() throws Exception
{ {
gridPanel = GridFactory.newGridLayout(); gridPanel = GridFactory.newGridLayout();
@ -253,7 +266,8 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
@Override @Override
public void valueChange(ValueChangeEvent e) { public void valueChange(ValueChangeEvent e) {
log.info(e.getPropertyName() + "=" + e.getNewValue()); if (log.isLoggable(Level.INFO))
log.info(e.getPropertyName() + "=" + e.getNewValue());
if (e.getPropertyName().equals("AD_User_ID")) if (e.getPropertyName().equals("AD_User_ID"))
fUser.setValue(e.getNewValue()); fUser.setValue(e.getNewValue());
} }
@ -295,6 +309,9 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
} }
} }
/**
* Validate changes and save.
*/
private void validateChangePassword() private void validateChangePassword()
{ {
int p_AD_User_ID = -1; int p_AD_User_ID = -1;
@ -386,6 +403,9 @@ public class WResetPassword implements IFormController, EventListener<Event>, Va
return; return;
} }
/**
* Reset form.
*/
private void clearForm() private void clearForm()
{ {
fUser.setValue(null); fUser.setValue(null);

View File

@ -63,7 +63,7 @@ import org.zkoss.zul.Center;
public class WSQLProcess extends ADForm implements EventListener<Event> public class WSQLProcess extends ADForm implements EventListener<Event>
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -4661224754061326223L; private static final long serialVersionUID = -4661224754061326223L;
@ -82,17 +82,17 @@ public class WSQLProcess extends ADForm implements EventListener<Event>
private Textbox m_txbResultField = new Textbox(); private Textbox m_txbResultField = new Textbox();
/** /**
* REGEX_REMOVE_COMMENTS * Remove comment
*/ */
private static final String REGEX_REMOVE_COMMENTS = "/\\*(?:.|[\\n\\r])*?\\*/"; private static final String REGEX_REMOVE_COMMENTS = "/\\*(?:.|[\\n\\r])*?\\*/";
/** /**
* REGEX_REMOVE_QUOTED_STRINGS * Remove quoted string
*/ */
private static final String REGEX_REMOVE_QUOTED_STRINGS = "'(?:.|[\\n\\r])*?'"; private static final String REGEX_REMOVE_QUOTED_STRINGS = "'(?:.|[\\n\\r])*?'";
/** /**
* REGEX_REMOVE_LEADING_SPACES * Remove leading space
*/ */
private static final String REGEX_REMOVE_LEADING_SPACES = "^\\s+"; private static final String REGEX_REMOVE_LEADING_SPACES = "^\\s+";
@ -103,6 +103,9 @@ public class WSQLProcess extends ADForm implements EventListener<Event>
super(); super();
} }
/**
* Layout form
*/
@Override @Override
protected void initForm() { protected void initForm() {
Row rwTop = new Row(); Row rwTop = new Row();
@ -178,7 +181,7 @@ public class WSQLProcess extends ADForm implements EventListener<Event>
* Process a semicolon delimited list of SQL Statements. * Process a semicolon delimited list of SQL Statements.
* *
* @param sqlStatements one or more statements separated by a semicolon (';') * @param sqlStatements one or more statements separated by a semicolon (';')
* @return a string summarizing the results * @return a string summarising the results
*/ */
public static String processStatements (String sqlStatements) { public static String processStatements (String sqlStatements) {
if (sqlStatements == null || sqlStatements.length() == 0) if (sqlStatements == null || sqlStatements.length() == 0)
@ -199,7 +202,7 @@ public class WSQLProcess extends ADForm implements EventListener<Event>
* Process SQL Statements. * Process SQL Statements.
* *
* @param sqlStatement a single SQL statement * @param sqlStatement a single SQL statement
* @return a string summarizing the results * @return a string summarising the results
*/ */
public static String processStatement (String sqlStatement) { public static String processStatement (String sqlStatement) {
if (sqlStatement == null) if (sqlStatement == null)

View File

@ -64,13 +64,13 @@ import org.zkoss.zul.South;
/** /**
* A Custom Form to process SQL queries. * A Custom Form to process SQL queries.
* *
* The statement to be executed can be restricted using SysConfig * The statement to be executed can be restricted using SysConfig.
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WSQLQuery extends ADForm implements EventListener<Event> public class WSQLQuery extends ADForm implements EventListener<Event>
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -6641250848300700313L; private static final long serialVersionUID = -6641250848300700313L;
@ -92,17 +92,17 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
private WListbox listbox = new WListbox(); private WListbox listbox = new WListbox();
/** /**
* REGEX_REMOVE_COMMENTS * Remove comment
*/ */
private static final String REGEX_REMOVE_COMMENTS = "/\\*(?:.|[\\n\\r])*?\\*/"; private static final String REGEX_REMOVE_COMMENTS = "/\\*(?:.|[\\n\\r])*?\\*/";
/** /**
* REGEX_REMOVE_QUOTED_STRINGS * Remove quoted string
*/ */
private static final String REGEX_REMOVE_QUOTED_STRINGS = "'(?:.|[\\n\\r])*?'"; private static final String REGEX_REMOVE_QUOTED_STRINGS = "'(?:.|[\\n\\r])*?'";
/** /**
* REGEX_REMOVE_LEADING_SPACES * Remove leading space
*/ */
private static final String REGEX_REMOVE_LEADING_SPACES = "^\\s+"; private static final String REGEX_REMOVE_LEADING_SPACES = "^\\s+";
@ -113,6 +113,9 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
super(); super();
} }
/**
* Layout form
*/
@Override @Override
protected void initForm() { protected void initForm() {
North north = new North(); North north = new North();
@ -328,6 +331,7 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
* Process the events for this form * Process the events for this form
* @param event * @param event
*/ */
@Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (event.getTarget() == m_btnSql) if (event.getTarget() == m_btnSql)
m_txbResultField.setText(processStatement(m_txbSqlField.getText())); m_txbResultField.setText(processStatement(m_txbSqlField.getText()));

View File

@ -71,7 +71,7 @@ import org.zkoss.zul.Treerow;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
/** /**
* View for Setup Wizard * Form for Client/Tenant Setup Wizard
* *
* @author Carlos Ruiz * @author Carlos Ruiz
* *
@ -79,13 +79,18 @@ import org.zkoss.zul.Vbox;
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VSetupWizard") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VSetupWizard")
public class WSetupWizard extends SetupWizard implements IFormController, EventListener<Event> public class WSetupWizard extends SetupWizard implements IFormController, EventListener<Event>
{ {
/** Custom form/window UI instance */
private CustomForm form = null; private CustomForm form = null;
/** Main layout of {@link #form} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** North of {@link #mainLayout} */
private Panel northPanel = new Panel(); private Panel northPanel = new Panel();
private Progressmeter progressbar = new Progressmeter(); private Progressmeter progressbar = new Progressmeter();
private Label progressLabel = new Label(); private Label progressLabel = new Label();
//
/** Workflow nodes. Child of {@link #centerBox}. */
private Tree wfnodeTree; private Tree wfnodeTree;
private Treeitem prevti = null; private Treeitem prevti = null;
private Treeitem firstOpenNode = null; private Treeitem firstOpenNode = null;
@ -94,12 +99,16 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
private int cntNodes = 0; private int cntNodes = 0;
private int cntSolved = 0; private int cntSolved = 0;
/** East of {@link #mainLayout}. Info for current selected node. */
private Label pretitleLabel = new Label(Msg.getMsg(Env.getCtx(), "SetupTask")); private Label pretitleLabel = new Label(Msg.getMsg(Env.getCtx(), "SetupTask"));
private Label titleLabel = new Label(); private Label titleLabel = new Label();
private Iframe helpFrame = new Iframe(); private Iframe helpFrame = new Iframe();
private Label notesLabel = new Label(Msg.getElement(Env.getCtx(), MWizardProcess.COLUMNNAME_Note)); private Label notesLabel = new Label(Msg.getElement(Env.getCtx(), MWizardProcess.COLUMNNAME_Note));
private Textbox notesField = new Textbox(); private Textbox notesField = new Textbox();
/** Footer of east panel of {@link #mainLayout} */
private Vbox westdown = new Vbox();
/** {@link #westdown} contents */
private Label userLabel = new Label(Msg.getMsg(Env.getCtx(), "User")); private Label userLabel = new Label(Msg.getMsg(Env.getCtx(), "User"));
private WSearchEditor userField; private WSearchEditor userField;
@ -111,8 +120,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
private Button bOK = new Button(); private Button bOK = new Button();
private Button bNext = new Button(); private Button bNext = new Button();
private Button bZoom = new Button(); private Button bZoom = new Button();
private Button bExpand = new Button();
/** Child of {@link #centerBoxdown} */
private Button bExpand = new Button();
private Checkbox justmine = new Checkbox(); private Checkbox justmine = new Checkbox();
private Checkbox showColors = new Checkbox(); private Checkbox showColors = new Checkbox();
@ -123,11 +133,15 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
private boolean expandTree = false; private boolean expandTree = false;
private boolean allFinished = true; private boolean allFinished = true;
private boolean allPending = true; private boolean allPending = true;
/** Center of {@link #mainLayout} */
private Vbox centerBox = new Vbox(); private Vbox centerBox = new Vbox();
/** Footer of {@link #centerBox} */
private Vbox centerBoxdown = new Vbox(); private Vbox centerBoxdown = new Vbox();
private Vbox westdown = new Vbox();
private ArrayList<Integer> openNodes = new ArrayList<Integer>(); private ArrayList<Integer> openNodes = new ArrayList<Integer>();
/**
* Default constructor
*/
public WSetupWizard() public WSetupWizard()
{ {
try try
@ -139,7 +153,7 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
{ {
log.log(Level.SEVERE, "WSetupWizard.init", ex); log.log(Level.SEVERE, "WSetupWizard.init", ex);
} }
} // init }
/** /**
* Fill Tree Combo * Fill Tree Combo
@ -149,10 +163,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
form = new CustomForm() form = new CustomForm()
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = 8563773513335140396L; private static final long serialVersionUID = 8563773513335140396L;
@Override
public void onEvent(Event event) throws Exception public void onEvent(Event event) throws Exception
{ {
if (event.getName().equals(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT)) if (event.getName().equals(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT))
@ -203,6 +218,10 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} }
/**
* Add workflow
* @param wfwizard
*/
protected void addWfEntry(MWorkflow wfwizard) { protected void addWfEntry(MWorkflow wfwizard) {
allFinished = true; allFinished = true;
allPending = true; allPending = true;
@ -258,6 +277,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
/**
* Add workflow nodes
* @param wfwizard
* @param treeitemwf
*/
private void addNodes(MWorkflow wfwizard, Treeitem treeitemwf) { private void addNodes(MWorkflow wfwizard, Treeitem treeitemwf) {
MWFNode[] nodes = wfwizard.getNodes(true, Env.getAD_Client_ID(Env.getCtx())); MWFNode[] nodes = wfwizard.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
for (MWFNode node : nodes) { for (MWFNode node : nodes) {
@ -265,6 +289,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} }
/**
* Add workflow node
* @param node
* @param treeitemwf
*/
private void addWfNode(MWFNode node, Treeitem treeitemwf) { private void addWfNode(MWFNode node, Treeitem treeitemwf) {
if (MWFNode.ACTION_UserWindow.equals(node.getAction()) && node.getAD_Window_ID() > 0) { if (MWFNode.ACTION_UserWindow.equals(node.getAction()) && node.getAD_Window_ID() > 0) {
if (MRole.getDefault().getWindowAccess(node.getAD_Window_ID()) == null) if (MRole.getDefault().getWindowAccess(node.getAD_Window_ID()) == null)
@ -344,7 +373,7 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
/** /**
* Static init * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
private void jbInit () throws Exception private void jbInit () throws Exception
@ -506,6 +535,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} // jbInit } // jbInit
/**
* Update {@link #progressbar}
*/
private void refreshProgress() { private void refreshProgress() {
int percent = cntSolved * 100; int percent = cntSolved * 100;
if (cntNodes > 0) if (cntNodes > 0)
@ -520,7 +552,7 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
/** /**
* Dispose * Close form
*/ */
public void dispose() public void dispose()
{ {
@ -528,9 +560,10 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} // dispose } // dispose
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent (Event e) public void onEvent (Event e)
{ {
if (e.getTarget() == wfnodeTree) { if (e.getTarget() == wfnodeTree) {
@ -557,8 +590,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
showColors(); showColors();
} }
} // actionPerformed }
/**
* Update colors of tree nodes.
*/
private void showColors() { private void showColors() {
if (showColors.isChecked()) if (showColors.isChecked())
{ {
@ -568,6 +604,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
repaintTree(); repaintTree();
} }
/**
* Filter tree nodes by login user or show all (by {@link #justmine} value).
*/
private void justMine() { private void justMine() {
if (justmine.isChecked()) { if (justmine.isChecked()) {
showChildren(false); showChildren(false);
@ -576,6 +615,10 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} }
/**
* Filter tree nodes by login user.
* @param showmine true to filter by login user, false to show all.
*/
private void showChildren(boolean showmine) { private void showChildren(boolean showmine) {
int user = Env.getAD_User_ID(Env.getCtx()); int user = Env.getAD_User_ID(Env.getCtx());
for (Treeitem nextItem : nextItems){ for (Treeitem nextItem : nextItems){
@ -590,6 +633,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
/**
* Expand or collapse all tree nodes.
*/
private void expandTree() { private void expandTree() {
if(!expandTree){ if(!expandTree){
TreeUtils.expandAll(wfnodeTree); TreeUtils.expandAll(wfnodeTree);
@ -601,6 +647,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
/**
* Zoom to window, form or info window of current node.
*/
private void zoom() { private void zoom() {
if (m_node != null) { if (m_node != null) {
if (MWFNode.ACTION_UserWindow.equals(m_node.getAction())) { if (MWFNode.ACTION_UserWindow.equals(m_node.getAction())) {
@ -616,6 +665,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} }
/**
* Repaint {@link #wfnodeTree}.
*/
private void repaintTree() { private void repaintTree() {
openNodes.removeAll(openNodes); openNodes.removeAll(openNodes);
for (Treeitem nextItem : nextItems) { for (Treeitem nextItem : nextItems) {
@ -629,6 +681,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
refreshProgress(); refreshProgress();
} }
/**
* Navigate to next node.
*/
private void navigateToNext() { private void navigateToNext() {
boolean repaint = false; boolean repaint = false;
if (m_node != null) { if (m_node != null) {
@ -662,6 +717,10 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
showItem(ti); showItem(ti);
} // propertyChange } // propertyChange
/**
* Update UI for tree item.
* @param ti
*/
private void showItem(Treeitem ti) { private void showItem(Treeitem ti) {
if (ti == null) if (ti == null)
return; return;
@ -681,6 +740,11 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
} }
} }
/**
* Update right panel (east) UI.
* @param ad_workflow_id
* @param ad_wf_node_id
*/
private void showInRightPanel(int ad_workflow_id, int ad_wf_node_id) { private void showInRightPanel(int ad_workflow_id, int ad_wf_node_id) {
String title = null; String title = null;
String help = null; String help = null;
@ -712,6 +776,10 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
helpFrame.invalidate(); helpFrame.invalidate();
} }
/**
* Set visibility of components in notes panel (top part of east panel)
* @param visible
*/
private void setNotesPanelVisible(boolean visible) { private void setNotesPanelVisible(boolean visible) {
notesLabel.setVisible(visible); notesLabel.setVisible(visible);
notesField.setVisible(visible); notesField.setVisible(visible);
@ -724,9 +792,9 @@ public class WSetupWizard extends SetupWizard implements IFormController, EventL
bZoom.setVisible(visible); bZoom.setVisible(visible);
} }
@Override
public ADForm getForm() public ADForm getForm()
{ {
return form; return form;
} }
} // WSetupWizard } // WSetupWizard

View File

@ -44,6 +44,7 @@ import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
import org.compiere.apps.form.StatementCreateFromBatch; import org.compiere.apps.form.StatementCreateFromBatch;
import org.compiere.model.MBankStatement; import org.compiere.model.MBankStatement;
import org.compiere.model.MBankStatementLine;
import org.compiere.model.MColumn; import org.compiere.model.MColumn;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
@ -58,13 +59,14 @@ import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Hbox; import org.zkoss.zul.Hbox;
/** /**
* * Form to create bank statement line ({@link MBankStatementLine}) from transactions (payment, receipt, etc).
* @author Elaine * @author Elaine
* *
*/ */
@org.idempiere.ui.zk.annotation.Form @org.idempiere.ui.zk.annotation.Form
public class WStatementCreateFromBatch extends StatementCreateFromBatch implements IFormController, EventListener<Event> public class WStatementCreateFromBatch extends StatementCreateFromBatch implements IFormController, EventListener<Event>
{ {
/** Create From Form instance */
private WCreateFromForm form; private WCreateFromForm form;
/** /**
@ -102,35 +104,49 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
private final static CLogger log = CLogger.getCLogger(WStatementCreateFromBatch.class); private final static CLogger log = CLogger.getCLogger(WStatementCreateFromBatch.class);
protected Label bankAccountLabel = new Label(); protected Label bankAccountLabel = new Label();
/** Bank account parameter */
protected WTableDirEditor bankAccountField; protected WTableDirEditor bankAccountField;
protected Label documentNoLabel = new Label(Msg.translate(Env.getCtx(), "DocumentNo")); protected Label documentNoLabel = new Label(Msg.translate(Env.getCtx(), "DocumentNo"));
/** Document number parameter */
protected WStringEditor documentNoField = new WStringEditor(); protected WStringEditor documentNoField = new WStringEditor();
protected Label documentTypeLabel = new Label(); protected Label documentTypeLabel = new Label();
/** Document type parameter */
protected WTableDirEditor documentTypeField; protected WTableDirEditor documentTypeField;
protected Label authorizationLabel = new Label(); protected Label authorizationLabel = new Label();
/** Authorization code parameter */
protected WStringEditor authorizationField = new WStringEditor(); protected WStringEditor authorizationField = new WStringEditor();
protected Label tenderTypeLabel = new Label(); protected Label tenderTypeLabel = new Label();
/** Tender type parameter */
protected WTableDirEditor tenderTypeField; protected WTableDirEditor tenderTypeField;
protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt")); protected Label amtFromLabel = new Label(Msg.translate(Env.getCtx(), "PayAmt"));
/** Amount from parameter */
protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom")); protected WNumberEditor amtFromField = new WNumberEditor("AmtFrom", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtFrom"));
protected Label amtToLabel = new Label("-"); protected Label amtToLabel = new Label("-");
/** Amount to parameter */
protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo")); protected WNumberEditor amtToField = new WNumberEditor("AmtTo", false, false, true, DisplayType.Amount, Msg.translate(Env.getCtx(), "AmtTo"));
protected Label BPartner_idLabel = new Label(Msg.translate(Env.getCtx(), "BPartner")); protected Label BPartner_idLabel = new Label(Msg.translate(Env.getCtx(), "BPartner"));
/** Business partner parameter */
protected WEditor bPartnerLookup; protected WEditor bPartnerLookup;
protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx")); protected Label dateFromLabel = new Label(Msg.translate(Env.getCtx(), "DateTrx"));
/** Date from parameter */
protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom")); protected WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom"));
protected Label dateToLabel = new Label("-"); protected Label dateToLabel = new Label("-");
/** Date to parameter */
protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo")); protected WDateEditor dateToField = new WDateEditor("DateTo", false, false, true, Msg.translate(Env.getCtx(), "DateTo"));
/** Layout of parameter panel */
protected Grid parameterBankLayout; protected Grid parameterBankLayout;
/**
* Dynamic initialization of UI components.
*/
@Override @Override
protected boolean dynInit() throws Exception protected boolean dynInit() throws Exception
{ {
@ -181,7 +197,7 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
} // dynInit } // dynInit
/** /**
* handle onClientInfo event * handle onClientInfo event from browser
*/ */
protected void onClientInfo() protected void onClientInfo()
{ {
@ -208,6 +224,10 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
} }
} }
/**
* Layout {@link #form}
* @throws Exception
*/
protected void zkInit() throws Exception protected void zkInit() throws Exception
{ {
bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID")); bankAccountLabel.setText(Msg.translate(Env.getCtx(), "C_BankAccount_ID"));
@ -273,7 +293,7 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
} }
/** /**
* Configure layout of parameter grid * Setup columns of {@link #parameterBankLayout}
* @param parameterBankLayout * @param parameterBankLayout
*/ */
protected void setupColumns(Grid parameterBankLayout) { protected void setupColumns(Grid parameterBankLayout) {
@ -327,7 +347,7 @@ public class WStatementCreateFromBatch extends StatementCreateFromBatch implemen
} }
/** /**
* load data into list box * load data into list box ({@link WCreateFromForm#getWListbox()})
* @param data * @param data
*/ */
protected void loadTableOIS (Vector<?> data) protected void loadTableOIS (Vector<?> data)

View File

@ -85,7 +85,7 @@ import org.zkoss.zul.Vlayout;
import org.zkoss.zul.West; import org.zkoss.zul.West;
/** /**
* * Form to visually layout an AD_Tab.
* @author Juan David Arboleda * @author Juan David Arboleda
* @author Carlos Ruiz * @author Carlos Ruiz
* *
@ -94,9 +94,10 @@ import org.zkoss.zul.West;
public class WTabEditor extends TabEditor implements IFormController, EventListener<Event>, ValueChangeListener public class WTabEditor extends TabEditor implements IFormController, EventListener<Event>, ValueChangeListener
{ {
// TODO: create messages Property, VisibleFields, NonVisibleField // TODO: create messages Property, VisibleFields, NonVisibleField
/** Form/window UI instance */
private WTabEditorForm tabform = null; private WTabEditorForm tabform = null;
/** Main layout of {@link #tabform} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** Window No */ /** Window No */
@ -107,44 +108,61 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
WEditor editorName = null; /** Properties editor for field (AD_Field). East of {@link #mainLayout} */
WEditor editorDescription = null;
WEditor editorHelp = null;
WEditor editorPlaceholder = null;
WEditor editorAD_FieldGroup_ID = null;
WEditor editorIsDisplayed = null;
WEditor editorSeqNo = null;
WEditor editorXPosition = null;
WEditor editorColumnSpan = null;
WEditor editorNumLines = null;
WEditor editorDisplayLogic = null;
WEditor editorMandatoryLogic = null;
WEditor editorReadOnlyLogic = null;
WEditor editorColumn = null;
WYesNoEditor editorIsReadOnly = null;
protected WEditor editorName = null;
protected WEditor editorDescription = null;
protected WEditor editorHelp = null;
protected WEditor editorPlaceholder = null;
protected WEditor editorAD_FieldGroup_ID = null;
protected WEditor editorIsDisplayed = null;
protected WEditor editorSeqNo = null;
protected WEditor editorXPosition = null;
protected WEditor editorColumnSpan = null;
protected WEditor editorNumLines = null;
protected WEditor editorDisplayLogic = null;
protected WEditor editorMandatoryLogic = null;
protected WEditor editorReadOnlyLogic = null;
protected WEditor editorColumn = null;
protected WYesNoEditor editorIsReadOnly = null;
//Child of westVLayout
/** List of display fields */
private Listbox visible = new Listbox(); private Listbox visible = new Listbox();
/** List of not dispaly fields */
private Listbox invisible = new Listbox(); private Listbox invisible = new Listbox();
// The grid components // The grid components
Group currentGroup; /** Current group. Temporary variable for form rendering in {@link #createUI()} */
ArrayList<Row> rowList; protected Group currentGroup;
/** List of all form row */
protected ArrayList<Row> rowList;
Map<Cell, GridField> mapCellField = new HashMap<Cell, GridField>(); protected Map<Cell, GridField> mapCellField = new HashMap<Cell, GridField>();
Map<Cell, Integer> mapEmptyCellField = new HashMap<Cell, Integer>(); /** Cell:Integer to decode SeqNo and XPosition. Use to support DropEvent */
protected Map<Cell, Integer> mapEmptyCellField = new HashMap<Cell, Integer>();
Grid form; /** Grid layout for fields. Child of {@link #centerVLayout} */
Vlayout centerVLayout; protected Grid form;
Vlayout westVLayout; /** Center of {@link #mainLayout} */
protected Vlayout centerVLayout;
/** West of {@link #mainLayout} */
protected Vlayout westVLayout;
private static final int POSSEQMULTIPLIER = 10000000; private static final int POSSEQMULTIPLIER = 10000000;
/**
* Default constructor
*/
public WTabEditor() public WTabEditor()
{ {
tabform = new WTabEditorForm(this); tabform = new WTabEditorForm(this);
LayoutUtils.addSclass("tab-editor-form", tabform); LayoutUtils.addSclass("tab-editor-form", tabform);
} }
/**
* Initialize form
*/
public void initForm() { public void initForm() {
try try
{ {
@ -177,7 +195,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
/** /**
* Initialize List of visible and non visible Fields * Initialize List of visible and not visible fields
*/ */
private void dynList() private void dynList()
{ {
@ -197,8 +215,8 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} // dynList } // dynList
/** /**
* Initialize Tab panel editor * Initialize Tab panel editor.
* Same createUI algorithm used on ADTabPanel * Base on createUI algorithm from ADTabPanel.
*/ */
private void createUI() { private void createUI() {
mapCellField.clear(); mapCellField.clear();
@ -253,7 +271,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
while (numCols - actualxpos + 1 > 0) { while (numCols - actualxpos + 1 > 0) {
row.appendCellChild(createSpacer(), 1); row.appendCellChild(createSpacer(), 1);
setLastCellProps(row.getLastCell(), actualxpos, field.getSeqNo()); setEmptyCellProps(row.getLastCell(), actualxpos, field.getSeqNo());
actualxpos++; actualxpos++;
} }
row.setGroup(currentGroup); row.setGroup(currentGroup);
@ -283,7 +301,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
Cell cell = (Cell) rowg.getFirstChild(); Cell cell = (Cell) rowg.getFirstChild();
cell.setSclass("z-group-inner"); cell.setSclass("z-group-inner");
cell.setColspan(numCols + 1); cell.setColspan(numCols + 1);
// rowg.appendChild(cell);
if (X_AD_FieldGroup.FIELDGROUPTYPE_Tab.equals(gridField.getFieldGroupType()) || gridField.getIsCollapsedByDefault()) if (X_AD_FieldGroup.FIELDGROUPTYPE_Tab.equals(gridField.getFieldGroupType()) || gridField.getIsCollapsedByDefault())
{ {
rowg.setOpen(false); rowg.setOpen(false);
@ -301,7 +318,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
// Fill right part of the row with spacers until number of columns // Fill right part of the row with spacers until number of columns
while (numCols - actualxpos + 1 > 0) { while (numCols - actualxpos + 1 > 0) {
row.appendCellChild(createSpacer(), 1); row.appendCellChild(createSpacer(), 1);
setLastCellProps(row.getLastCell(), actualxpos, field.getSeqNo()); setEmptyCellProps(row.getLastCell(), actualxpos, field.getSeqNo());
actualxpos++; actualxpos++;
} }
row.setGroup(currentGroup); row.setGroup(currentGroup);
@ -314,7 +331,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
// Fill left part of the field // Fill left part of the field
if (gridField.getXPosition() - 1 - actualxpos > 0) { if (gridField.getXPosition() - 1 - actualxpos > 0) {
row.appendCellChild(createSpacer(), gridField.getXPosition() - 1 - actualxpos); row.appendCellChild(createSpacer(), gridField.getXPosition() - 1 - actualxpos);
setLastCellProps(row.getLastCell(), actualxpos, field.getSeqNo()); setEmptyCellProps(row.getLastCell(), actualxpos, field.getSeqNo());
} }
boolean paintLabel = ! (gridField.getDisplayType() == DisplayType.Button || gridField.getDisplayType() == DisplayType.YesNo || gridField.isFieldOnly()); boolean paintLabel = ! (gridField.getDisplayType() == DisplayType.Button || gridField.getDisplayType() == DisplayType.YesNo || gridField.isFieldOnly());
if (gridField.isHeading()) if (gridField.isHeading())
@ -374,7 +391,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
row.appendCellChild(createSpacer(), 1); row.appendCellChild(createSpacer(), 1);
lastseq = lastseq + 10; lastseq = lastseq + 10;
// make every empty space droppable at the end // make every empty space droppable at the end
setLastCellProps(row.getLastCell(), actualxpos, lastseq); setEmptyCellProps(row.getLastCell(), actualxpos, lastseq);
actualxpos++; actualxpos++;
} }
row.setGroup(currentGroup); row.setGroup(currentGroup);
@ -383,6 +400,11 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
rowList.add(row); rowList.add(row);
} }
/**
* Setup cell properties and listeners
* @param lastCell
* @param field
*/
private void setLastCellProps(Cell lastCell, GridField field) { private void setLastCellProps(Cell lastCell, GridField field) {
lastCell.setDraggable("true"); lastCell.setDraggable("true");
lastCell.setDroppable("true"); lastCell.setDroppable("true");
@ -392,17 +414,29 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
mapCellField.put(lastCell, field); mapCellField.put(lastCell, field);
} }
private void setLastCellProps(Cell lastCell, int actualxpos, int seqNo) { /**
* Setup empty cell properties and listeners
* @param lastCell
* @param actualxpos
* @param seqNo
*/
private void setEmptyCellProps(Cell lastCell, int actualxpos, int seqNo) {
lastCell.setDroppable("true"); lastCell.setDroppable("true");
lastCell.addEventListener(Events.ON_DROP, this); lastCell.addEventListener(Events.ON_DROP, this);
int value = (actualxpos + 1) * POSSEQMULTIPLIER + seqNo; int value = (actualxpos + 1) * POSSEQMULTIPLIER + seqNo;
mapEmptyCellField.put(lastCell, value); mapEmptyCellField.put(lastCell, value);
} }
/**
* @return {@link Space}
*/
private Component createSpacer() { private Component createSpacer() {
return new Space(); return new Space();
} }
/**
* @return Number of column for grid form
*/
private int getNumColumns() { private int getNumColumns() {
int maxcol = 0; int maxcol = 0;
for (GridField gridField : getGridFields()) for (GridField gridField : getGridFields())
@ -423,8 +457,8 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
/** /**
* Initialize Grid of Field's Properties * Create Grid of field properties editor.
* return @Grid * return {@link Grid}
*/ */
private Grid createPropertiesGrid() private Grid createPropertiesGrid()
{ {
@ -527,7 +561,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
editorSeqNo = new WNumberEditor(MField.COLUMNNAME_SeqNo, false, true, false, DisplayType.Integer, labelSeqNo.getValue()); editorSeqNo = new WNumberEditor(MField.COLUMNNAME_SeqNo, false, true, false, DisplayType.Integer, labelSeqNo.getValue());
row.appendChild(labelSeqNo.rightAlign()); row.appendChild(labelSeqNo.rightAlign());
row.appendChild(editorSeqNo.getComponent()); row.appendChild(editorSeqNo.getComponent());
// editorSeqNo.addValueChangeListener(this);
row.setGroup(group); row.setGroup(group);
rows.appendChild(row); rows.appendChild(row);
@ -576,8 +609,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
((Textbox) editorDisplayLogic.getComponent()).setMultiline(true); ((Textbox) editorDisplayLogic.getComponent()).setMultiline(true);
row.appendChild(labelDisplayLogic.rightAlign()); row.appendChild(labelDisplayLogic.rightAlign());
row.appendChild(editorDisplayLogic.getComponent()); row.appendChild(editorDisplayLogic.getComponent());
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
editorDisplayLogic.addValueChangeListener(this); editorDisplayLogic.addValueChangeListener(this);
row.setGroup(group); row.setGroup(group);
rows.appendChild(row); rows.appendChild(row);
@ -589,8 +620,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
((Textbox) editorMandatoryLogic.getComponent()).setMultiline(true); ((Textbox) editorMandatoryLogic.getComponent()).setMultiline(true);
row.appendChild(labelMandatoryLogic.rightAlign()); row.appendChild(labelMandatoryLogic.rightAlign());
row.appendChild(editorMandatoryLogic.getComponent()); row.appendChild(editorMandatoryLogic.getComponent());
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
editorMandatoryLogic.addValueChangeListener(this); editorMandatoryLogic.addValueChangeListener(this);
row.setGroup(group); row.setGroup(group);
rows.appendChild(row); rows.appendChild(row);
@ -602,8 +631,6 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
((Textbox) editorReadOnlyLogic.getComponent()).setMultiline(true); ((Textbox) editorReadOnlyLogic.getComponent()).setMultiline(true);
row.appendChild(labelReadOnlyLogic.rightAlign()); row.appendChild(labelReadOnlyLogic.rightAlign());
row.appendChild(editorReadOnlyLogic.getComponent()); row.appendChild(editorReadOnlyLogic.getComponent());
//ZKUpdateUtil.setWidth((HtmlBasedComponent) row.getLastChild(), "100%");
//ZKUpdateUtil.setHeight((HtmlBasedComponent) row.getLastChild(), "80px");
editorReadOnlyLogic.addValueChangeListener(this); editorReadOnlyLogic.addValueChangeListener(this);
row.setGroup(group); row.setGroup(group);
rows.appendChild(row); rows.appendChild(row);
@ -633,7 +660,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
/** /**
* Static init * Layout {@link #tabform}
* @throws Exception * @throws Exception
*/ */
private void jbInit() throws Exception private void jbInit() throws Exception
@ -700,7 +727,7 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} // jbInit } // jbInit
/** /**
* Dispose * Close form
*/ */
public void dispose() public void dispose()
{ {
@ -708,9 +735,10 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} // dispose } // dispose
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent (Event e) throws Exception public void onEvent (Event e) throws Exception
{ {
// select an item within the list -- set it active and show the properties // select an item within the list -- set it active and show the properties
@ -867,8 +895,13 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
if (cmd_save()) if (cmd_save())
tabform.detach(); tabform.detach();
} }
} // actionPerformed }
/**
* Find ListItem from {@link #visible} with GridField from {@link #mapCellField}.
* @param cell
* @return {@link ListItem} or null
*/
private ListItem getItemFromCell(Cell cell) { private ListItem getItemFromCell(Cell cell) {
GridField field = mapCellField.get(cell); GridField field = mapCellField.get(cell);
if (field != null) { if (field != null) {
@ -882,6 +915,11 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
return null; return null;
} }
/**
* Going through entries in {@link #mapCellField} and set background color for cell with editor for field.
* Clear the background color of other cells.
* @param field
*/
private void setBackgroundField(MField field) { private void setBackgroundField(MField field) {
Iterator<Entry<Cell, GridField>> it = mapCellField.entrySet().iterator(); Iterator<Entry<Cell, GridField>> it = mapCellField.entrySet().iterator();
while (it.hasNext()) { while (it.hasNext()) {
@ -894,9 +932,12 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
cell.setStyle(""); cell.setStyle("");
} }
} }
} }
/**
* Populate properties editor for field (editorName, editorDescription, etc).
* @param field
*/
private void setProperties(MField field) { private void setProperties(MField field) {
String displayLogic = field.getDisplayLogic() == null ? "" : field.getDisplayLogic(); String displayLogic = field.getDisplayLogic() == null ? "" : field.getDisplayLogic();
String mandatoryLogic = field.getMandatoryLogic() == null ? "" : field.getMandatoryLogic(); String mandatoryLogic = field.getMandatoryLogic() == null ? "" : field.getMandatoryLogic();
@ -939,11 +980,16 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
@Override
public ADForm getForm() public ADForm getForm()
{ {
return tabform; return tabform;
} }
/**
* Update {@link #visible} and {@link #invisible}.
* @param focusField
*/
private void updateLists(MField focusField) { private void updateLists(MField focusField) {
visible.removeAllItems(); visible.removeAllItems();
invisible.removeAllItems(); invisible.removeAllItems();
@ -974,6 +1020,9 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
} }
/**
* Handle value change event from field properties editor (editorName editorDescription, etc).
*/
@Override @Override
public void valueChange(ValueChangeEvent e) { public void valueChange(ValueChangeEvent e) {
// changed a value on the properties editors // changed a value on the properties editors
@ -1031,6 +1080,9 @@ public class WTabEditor extends TabEditor implements IFormController, EventListe
} }
} }
/**
* Re-create {@link #form}
*/
private void repaintGrid() { private void repaintGrid() {
centerVLayout.removeChild(form); centerVLayout.removeChild(form);
if (form.getRows() != null) if (form.getRows() != null)

View File

@ -70,35 +70,57 @@ import org.zkoss.zul.Treecols;
import org.zkoss.zul.Treeitem; import org.zkoss.zul.Treeitem;
import org.zkoss.zul.West; import org.zkoss.zul.West;
/**
* Form to view BOM tree.
*/
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTreeBOM") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTreeBOM")
public class WTreeBOM extends TreeBOM implements IFormController, EventListener<Event> { public class WTreeBOM extends TreeBOM implements IFormController, EventListener<Event> {
private int m_WindowNo = 0; private int m_WindowNo = 0;
/** Custom form/window UI instance */
private CustomForm m_frame = new CustomForm(); private CustomForm m_frame = new CustomForm();
/** BOM Tree. Child of {@link #treePane}. */
private Tree m_tree = new Tree(); private Tree m_tree = new Tree();
/** Main layout of {@link #m_frame} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** North of {@link #mainLayout}. Parameter panel. */
private Panel northPanel = new Panel(); private Panel northPanel = new Panel();
private Panel southPanel = new Panel(); private Panel southPanel = new Panel();
private Label labelProduct = new Label(); private Label labelProduct = new Label();
/** Product parameter */
private WSearchEditor fieldProduct; private WSearchEditor fieldProduct;
/** West of {@link #mainLayout} */
private West west = new West(); private West west = new West();
/** BOM Implosion Y/N parameter */
private Checkbox implosion = new Checkbox (); private Checkbox implosion = new Checkbox ();
/** Show M_Product.Value of {@link #fieldProduct} */
private Label treeInfo = new Label (); private Label treeInfo = new Label ();
/** Center of {@link #mainLayout} */
private Panel dataPane = new Panel(); private Panel dataPane = new Panel();
/** Tree panel. Child of {@link #west} */
private Panel treePane = new Panel(); private Panel treePane = new Panel();
private mySimpleTreeNode m_selectedNode; // the selected model node private mySimpleTreeNode m_selectedNode; // the selected model node
/** M_Product_ID of selected tree node */
private int m_selected_id = 0; private int m_selected_id = 0;
/** Action buttons panel. Child of {@link #southLayout} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** List of BOM components. Child of {@link #dataPane} */
private WListbox tableBOM = ListboxFactory.newDataTable(); private WListbox tableBOM = ListboxFactory.newDataTable();
private Vector<Vector<Object>> dataBOM = new Vector<Vector<Object>>(); private Vector<Vector<Object>> dataBOM = new Vector<Vector<Object>>();
/** Layout of {@link #northPanel} */
private Hlayout northLayout = new Hlayout(); private Hlayout northLayout = new Hlayout();
/** Layout of {@link #southPanel} */
private Hlayout southLayout = new Hlayout(); private Hlayout southLayout = new Hlayout();
private mySimpleTreeNode m_root = null; private mySimpleTreeNode m_root = null;
private boolean reload = false; private boolean reload = false;
/** Expand or collapse all tree nodes. Child of {@link #southLayout}. */
private Checkbox treeExpand = new Checkbox(); private Checkbox treeExpand = new Checkbox();
/**
* Default constructor
*/
public WTreeBOM(){ public WTreeBOM(){
try{ try{
m_WindowNo = m_frame.getWindowNo(); m_WindowNo = m_frame.getWindowNo();
@ -111,6 +133,9 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
} }
/**
* Load data into {@link #tableBOM}.
*/
private void loadTableBOM() private void loadTableBOM()
{ {
// Header Info // Header Info
@ -136,6 +161,10 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} // dynInit } // dynInit
/**
* Initialize fields and listeners
* @throws Exception
*/
private void preInit() throws Exception private void preInit() throws Exception
{ {
Properties ctx = Env.getCtx(); Properties ctx = Env.getCtx();
@ -156,12 +185,13 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
implosion.addActionListener(this); implosion.addActionListener(this);
treeExpand.addActionListener(this); treeExpand.addActionListener(this);
} }
/**
* Layout {@link #m_frame}
*/
private void jbInit() private void jbInit()
{ {
ZKUpdateUtil.setWidth(m_frame, "99%"); ZKUpdateUtil.setWidth(m_frame, "99%");
ZKUpdateUtil.setHeight(m_frame, "100%"); ZKUpdateUtil.setHeight(m_frame, "100%");
m_frame.setStyle("position: absolute; padding: 0; margin: 0"); m_frame.setStyle("position: absolute; padding: 0; margin: 0");
@ -172,7 +202,6 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
southPanel.appendChild(southLayout); southPanel.appendChild(southLayout);
ZKUpdateUtil.setVflex(southPanel, "min"); ZKUpdateUtil.setVflex(southPanel, "min");
labelProduct.setText (Msg.getElement(Env.getCtx(), "M_Product_ID")); labelProduct.setText (Msg.getElement(Env.getCtx(), "M_Product_ID"));
implosion.setText (Msg.getElement(Env.getCtx(), "Implosion")); implosion.setText (Msg.getElement(Env.getCtx(), "Implosion"));
treeInfo.setText (Msg.getElement(Env.getCtx(), "Sel_Product_ID")+": "); treeInfo.setText (Msg.getElement(Env.getCtx(), "Sel_Product_ID")+": ");
@ -240,6 +269,9 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
center.setAutoscroll(true); center.setAutoscroll(true);
} }
/**
* Close form.
*/
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
@ -277,6 +309,9 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
/**
* Expand of collapse all nodes of {@link #m_tree}.
*/
private void expandOrCollapse() { private void expandOrCollapse() {
if (treeExpand.isChecked()) if (treeExpand.isChecked())
{ {
@ -291,8 +326,8 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
/** /**
* Set the selected node & initiate all listeners * Set selected node & load BOM.
* @param nd node * @param nd node
* @throws Exception * @throws Exception
*/ */
private void setSelectedNode (mySimpleTreeNode nd) throws Exception private void setSelectedNode (mySimpleTreeNode nd) throws Exception
@ -307,9 +342,12 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
if(m_selected_id > 0) if(m_selected_id > 0)
action_reloadBOM(); action_reloadBOM();
} // setSelectedNode } // setSelectedNode
/**
* Load BOM of selected product from {@link #fieldProduct}.
* @throws Exception
*/
private void action_loadBOM() throws Exception private void action_loadBOM() throws Exception
{ {
reload = false; reload = false;
@ -341,6 +379,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
if (isImplosion()) if (isImplosion())
{ {
//let selected product as BOM component and show BOM parent products as tree node.
try{ try{
m_tree.setModel(null); m_tree.setModel(null);
}catch(Exception e) }catch(Exception e)
@ -370,6 +409,7 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
else else
{ {
//let selected product as BOM parent and show BOM components as tree node.
try{ try{
m_tree.setModel(null); m_tree.setModel(null);
}catch(Exception e) }catch(Exception e)
@ -404,6 +444,10 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
treeExpand.setChecked(false); treeExpand.setChecked(false);
} }
/**
* Load BOM of selected tree node.
* @throws Exception
*/
private void action_reloadBOM() throws Exception private void action_reloadBOM() throws Exception
{ {
reload = true; reload = true;
@ -438,36 +482,49 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
loadTableBOM(); loadTableBOM();
} }
/**
* Add bomline to tree and children of bomline (if any) recursively.<br/>
* If bomline is component of current selected product ({@link #m_selected_id} or {@link #fieldProduct}), add to {@link #dataBOM}.
* @param bomline
* @param parent
* @throws Exception
*/
public void addChild(MPPProductBOMLine bomline, mySimpleTreeNode parent) throws Exception public void addChild(MPPProductBOMLine bomline, mySimpleTreeNode parent) throws Exception
{ {
MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID()); MProduct M_Product = MProduct.get(getCtx(), bomline.getM_Product_ID());
Vector<Object> line = new Vector<Object>(10); Vector<Object> line = new Vector<Object>(10);
line.add( Boolean.valueOf(bomline.isActive())); // 0 IsActive line.add( Boolean.valueOf(bomline.isActive())); // 0 IsActive
line.add( Integer.valueOf(bomline.getLine()).toString()); // 1 Line line.add( Integer.valueOf(bomline.getLine()).toString()); // 1 Line
KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getValue().concat("_").concat(M_Product.getName())); KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(),M_Product.getValue().concat("_").concat(M_Product.getName()));
line.add(pp); // 2 M_Product_ID line.add(pp); // 2 M_Product_ID
MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName()); MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName());
KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol()); KeyNamePair uom = new KeyNamePair(u.get_ID(),u.getUOMSymbol());
line.add(uom); // 3 C_UOM_ID line.add(uom); // 3 C_UOM_ID
line.add((BigDecimal) ((bomline.getQtyBOM()!=null) ? bomline.getQtyBOM() : Env.ZERO).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros()); // 4 QtyBOM line.add((BigDecimal) ((bomline.getQtyBOM()!=null) ? bomline.getQtyBOM() : Env.ZERO).setScale(4, RoundingMode.HALF_UP).stripTrailingZeros()); // 4 QtyBOM
mySimpleTreeNode child = new mySimpleTreeNode(line,new ArrayList<TreeNode<Object>>()); mySimpleTreeNode child = new mySimpleTreeNode(line,new ArrayList<TreeNode<Object>>());
if (!reload) if (!reload)
parent.getChildren().add(child); parent.getChildren().add(child);
if (m_selected_id == bomline.getParent().getM_Product_ID() || getM_Product_ID() == bomline.getParent().getM_Product_ID()) if (m_selected_id == bomline.getParent().getM_Product_ID() || getM_Product_ID() == bomline.getParent().getM_Product_ID())
dataBOM.add(line); dataBOM.add(line);
if (reload) return; if (reload) return;
for (MPPProductBOMLine bom : MPPProductBOMLine.getBOMLines(M_Product)) for (MPPProductBOMLine bom : MPPProductBOMLine.getBOMLines(M_Product))
{ {
addChild(bom, child); addChild(bom, child);
} }
} }
/**
* Add parent product of bomline to tree and parent of parent product (if any) recursively.<br/>
* If bomline is component of current selected product ({@link #m_selected_id} or {@link #fieldProduct}), add to {@link #dataBOM}.
* @param bomline
* @param parent
* @throws Exception
*/
public void addParent(MPPProductBOMLine bomline, mySimpleTreeNode parent) throws Exception public void addParent(MPPProductBOMLine bomline, mySimpleTreeNode parent) throws Exception
{ {
MPPProductBOM bom = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null); MPPProductBOM bom = new MPPProductBOM(getCtx(), bomline.getPP_Product_BOM_ID(), null);
@ -498,6 +555,9 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
} }
/**
* @return M_Product_ID from {@link #fieldProduct}
*/
private int getM_Product_ID() { private int getM_Product_ID() {
Integer Product = (Integer)fieldProduct.getValue(); Integer Product = (Integer)fieldProduct.getValue();
if (Product == null) if (Product == null)
@ -505,6 +565,9 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
return Product.intValue(); return Product.intValue();
} }
/**
* @return true for implosion, false for explosion.
*/
private boolean isImplosion() { private boolean isImplosion() {
return implosion.isSelected(); return implosion.isSelected();
} }
@ -516,28 +579,29 @@ public class WTreeBOM extends TreeBOM implements IFormController, EventListener<
} }
/************************************************************************** /**
* mySimpleTreeNode * mySimpleTreeNode
* - Override toString method for display * - Override toString method for display.
* *
*/ */
class mySimpleTreeNode extends DefaultTreeNode<Object> class mySimpleTreeNode extends DefaultTreeNode<Object>
{ {
/** /**
* * generated serial id
*/ */
private static final long serialVersionUID = -7430786399068849936L; private static final long serialVersionUID = -7430786399068849936L;
/**
* @param data
* @param children
*/
public mySimpleTreeNode(Object data, List<TreeNode<Object>> children) { public mySimpleTreeNode(Object data, List<TreeNode<Object>> children) {
super(data, children); super(data, children);
} }
@Override @Override
public String toString(){ public String toString(){
Vector <?> userObject = (Vector <?>)getData(); Vector <?> userObject = (Vector <?>)getData();
// Product // Product
StringBuilder sb = new StringBuilder(((KeyNamePair)userObject.elementAt(2)).getName()); StringBuilder sb = new StringBuilder(((KeyNamePair)userObject.elementAt(2)).getName());
@ -549,5 +613,4 @@ class mySimpleTreeNode extends DefaultTreeNode<Object>
return sb.toString(); return sb.toString();
} }
} }

View File

@ -56,40 +56,44 @@ import org.zkoss.zul.Hlayout;
import org.zkoss.zul.ListModel; import org.zkoss.zul.ListModel;
import org.zkoss.zul.North; import org.zkoss.zul.North;
import org.zkoss.zul.Space; import org.zkoss.zul.Space;
import org.zkoss.zul.Splitter;
import org.zkoss.zul.Tree; import org.zkoss.zul.Tree;
import org.zkoss.zul.TreeModel; import org.zkoss.zul.TreeModel;
import org.zkoss.zul.TreeNode; import org.zkoss.zul.TreeNode;
import org.zkoss.zul.Treeitem; import org.zkoss.zul.Treeitem;
/** /**
* Tree Maintenance * Tree maintenance form.
*
* @author Jorg Janke (modify: Sergio Oropeza sergioropeza@gmail.com, soropeza@dcsla.com 06/03/2014)
* @version $Id: VTreeMaintenance.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
*/ */
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTreeMaintenance") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTreeMaintenance")
public class WTreeMaintenance extends TreeMaintenance implements IFormController, EventListener<Event> public class WTreeMaintenance extends TreeMaintenance implements IFormController, EventListener<Event>
{ {
/** Custom form/window UI instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** Main layout of {@link #form} */
private Borderlayout mainLayout = new Borderlayout (); private Borderlayout mainLayout = new Borderlayout ();
/** North of {@link #mainLayout}. Form parameters and controls. */
private Panel northPanel = new Panel (); private Panel northPanel = new Panel ();
private Label treeLabel = new Label (); private Label treeLabel = new Label ();
/** AD_Tree records drop down list. */
private Listbox treeField; private Listbox treeField;
private ToolBarButton bAddAll = new ToolBarButton (); private ToolBarButton bAddAll = new ToolBarButton ();
private ToolBarButton bAdd = new ToolBarButton (); private ToolBarButton bAdd = new ToolBarButton ();
private ToolBarButton bDelete = new ToolBarButton (); private ToolBarButton bDelete = new ToolBarButton ();
private ToolBarButton bDeleteAll = new ToolBarButton (); private ToolBarButton bDeleteAll = new ToolBarButton ();
private Checkbox cbAllNodes = new Checkbox (); private Checkbox cbAllNodes = new Checkbox ();
/** Text to filter {@link #centerList} **/
private Searchbox searchBox = new Searchbox(); private Searchbox searchBox = new Searchbox();
//
@SuppressWarnings("unused") /** Center of {@link #mainLayout}. Tree of selected AD_Tree record from {@link #treeField}. */
private Splitter splitPane = new Splitter();
private Tree centerTree; private Tree centerTree;
/** East of {@link #mainLayout}. List of all tree node records. */
private Listbox centerList = new Listbox(); private Listbox centerList = new Listbox();
/**
* Default constructor
*/
public WTreeMaintenance() public WTreeMaintenance()
{ {
try try
@ -103,10 +107,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
{ {
log.log(Level.SEVERE, "VTreeMaintenance.init", ex); log.log(Level.SEVERE, "VTreeMaintenance.init", ex);
} }
} // init }
/** /**
* Fill Tree Combo * Fill {@link #treeField} and create {@link #centerTree}.
*/ */
private void preInit() private void preInit()
{ {
@ -121,7 +125,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} // preInit } // preInit
/** /**
* Static init * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
private void jbInit () throws Exception private void jbInit () throws Exception
@ -234,7 +238,8 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
centerList.addDoubleClickListener(centerListListener); centerList.addDoubleClickListener(centerListListener);
} // jbInit } // jbInit
EventListener<Event> centerListListener = new EventListener<Event>() { /** Double click listener for {@link #centerList} */
protected EventListener<Event> centerListListener = new EventListener<Event>() {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (Events.ON_DOUBLE_CLICK.equals(event.getName())) { if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
add(); add();
@ -244,7 +249,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
}; };
/** /**
* Dispose * Close form.
*/ */
public void dispose() public void dispose()
{ {
@ -252,9 +257,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} // dispose } // dispose
/** /**
* Action Listener * Event Listener
* @param e event * @param e event
*/ */
@Override
public void onEvent (Event e) public void onEvent (Event e)
{ {
if (e.getTarget() == treeField) if (e.getTarget() == treeField)
@ -283,9 +289,12 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} }
else if (e.getTarget() == searchBox.getButton() || e.getTarget() == searchBox.getTextbox()) else if (e.getTarget() == searchBox.getButton() || e.getTarget() == searchBox.getTextbox())
searchElement(); searchElement();
} // actionPerformed }
void add() { /**
* Add selected {@link #centerList} item to {@link #centerTree}.
*/
protected void add() {
SimpleListModel model = (SimpleListModel) centerList.getModel(); SimpleListModel model = (SimpleListModel) centerList.getModel();
int i = centerList.getSelectedIndex(); int i = centerList.getSelectedIndex();
if (i >= 0) { if (i >= 0) {
@ -293,8 +302,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} }
} }
void remove() { /**
* Remove selected {@link #centerList} item from {@link #centerTree}.
*/
protected void remove() {
if (cbAllNodes.isChecked()) if (cbAllNodes.isChecked())
return; return;
@ -305,24 +316,30 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} }
} }
/**
* Filter {@link #centerList} with text from {@link #searchBox}.
*/
private void searchElement() { private void searchElement() {
String filter = searchBox.getText() == null ? "" : searchBox.getText(); String filter = searchBox.getText() == null ? "" : searchBox.getText();
filter = Util.deleteAccents(filter.trim().toUpperCase()); filter = Util.deleteAccents(filter.trim().toUpperCase());
action_loadTree(filter); action_loadTree(filter);
} }
/**
* Load tree records into {@link #centerList} and {@link #centerTree}.
*/
private void action_loadTree() { private void action_loadTree() {
action_loadTree(null); action_loadTree(null);
} }
/** /**
* Action: Fill Tree with all nodes * Load tree records into {@link #centerList} and {@link #centerTree}.
* @param filter * @param filter text to filter {@link #centerList} items (using contains).
*/ */
private void action_loadTree(String filter) private void action_loadTree(String filter)
{ {
KeyNamePair tree = treeField.getSelectedItem().toKeyNamePair(); KeyNamePair tree = treeField.getSelectedItem().toKeyNamePair();
log.info("Tree=" + tree); if (log.isLoggable(Level.INFO)) log.info("Tree=" + tree);
if (tree.getKey() <= 0) if (tree.getKey() <= 0)
{ {
SimpleListModel tmp = new SimpleListModel(); SimpleListModel tmp = new SimpleListModel();
@ -371,11 +388,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
SimpleTreeModel.initADTree(centerTree, m_tree.getAD_Tree_ID(), m_WindowNo); SimpleTreeModel.initADTree(centerTree, m_tree.getAD_Tree_ID(), m_WindowNo);
if (m_tree.isLoadAllNodesImmediately()) if (m_tree.isLoadAllNodesImmediately())
TreeUtils.collapseTree(centerTree, true); TreeUtils.collapseTree(centerTree, true);
} // action_fillTree } // action_fillTree
/** /**
* List Selection Listener * On {@link #centerList} selection.
* @param e event * @param e event
*/ */
private void onListSelection(Event e) private void onListSelection(Event e)
@ -390,7 +406,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
catch (Exception ex) catch (Exception ex)
{ {
} }
log.info("Selected=" + selected); if (log.isLoggable(Level.INFO)) log.info("Selected=" + selected);
if (selected != null) // allow add if not in tree if (selected != null) // allow add if not in tree
{ {
SimpleTreeModel tm = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel(); SimpleTreeModel tm = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel();
@ -402,10 +418,10 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} }
bAdd.setDisabled(stn != null); bAdd.setDisabled(stn != null);
} }
} // valueChanged }
/** /**
* Tree selection * On {@link #centerTree} selection.
* @param e event * @param e event
*/ */
private void onTreeSelection (Event e) private void onTreeSelection (Event e)
@ -415,7 +431,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
MTreeNode tn = (MTreeNode)stn.getData(); MTreeNode tn = (MTreeNode)stn.getData();
if (tn == null) if (tn == null)
return; return;
log.info(tn.toString()); if (log.isLoggable(Level.INFO)) log.info(tn.toString());
ListModel<Object> model = centerList.getModel(); ListModel<Object> model = centerList.getModel();
int size = model.getSize(); int size = model.getSize();
int found = -1; int found = -1;
@ -428,15 +444,16 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} }
} }
centerList.setSelectedIndex(found); centerList.setSelectedIndex(found);
} // propertyChange }
/** /**
* Action: Add Node to Tree * Add item to {@link #centerTree}.<br/>
* @param item item * Add Tree Node (MTree_NodePR, MTree_NodeBP, MTree_NodeMM or MTree_Node) record.
* @param item {@link ListItem}
*/ */
private void action_treeAdd(ListItem item) private void action_treeAdd(ListItem item)
{ {
log.info("Item=" + item); if (log.isLoggable(Level.INFO)) log.info("Item=" + item);
if (item != null) if (item != null)
{ {
SimpleTreeModel model = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel(); SimpleTreeModel model = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel();
@ -456,24 +473,23 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
// May cause Error if in tree // May cause Error if in tree
addNode(item); addNode(item);
} }
} }
} // action_treeAdd } // action_treeAdd
/** /**
* Action: Delete Node from Tree * Remove item from {@link #centerTree}.<br/>
* @param item item * Delete Tree Node (MTree_NodePR, MTree_NodeBP, MTree_NodeMM or MTree_Node) record.
* @param item {@link ListItem}
*/ */
private void action_treeDelete(ListItem item) private void action_treeDelete(ListItem item)
{ {
log.info("Item=" + item); if (log.isLoggable(Level.INFO)) log.info("Item=" + item);
if (item != null) if (item != null)
{ {
SimpleTreeModel model = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel(); SimpleTreeModel model = (SimpleTreeModel)(TreeModel<?>) centerTree.getModel();
DefaultTreeNode<Object> stn = model.find(model.getRoot(), item.id); DefaultTreeNode<Object> stn = model.find(model.getRoot(), item.id);
if (stn != null) if (stn != null)
model.removeNode(stn); model.removeNode(stn);
// //
deleteNode(item); deleteNode(item);
} }
@ -481,19 +497,18 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
/** /**
* Action: Add All Nodes to Tree * Add all items from {@link #centerList} to {@link #centerTree}.
*/ */
private void action_treeAddAll() private void action_treeAddAll()
{ {
// idempiere-85 // idempiere-85
Dialog.ask(m_WindowNo, "TreeAddAllItems", new Callback<Boolean>() { Dialog.ask(m_WindowNo, "TreeAddAllItems", new Callback<Boolean>() {
@Override @Override
public void onCallback(Boolean result) public void onCallback(Boolean result)
{ {
if (result) if (result)
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
ListModel<Object> model = centerList.getModel(); ListModel<Object> model = centerList.getModel();
int size = model.getSize(); int size = model.getSize();
int index = -1; int index = -1;
@ -508,14 +523,13 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
} // action_treeAddAll } // action_treeAddAll
/** /**
* Action: Delete All Nodes from Tree * Delete All Nodes from Tree
*/ */
private void action_treeDeleteAll() private void action_treeDeleteAll()
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
// idempiere-85 // idempiere-85
Dialog.ask(m_WindowNo, "TreeRemoveAllItems", new Callback<Boolean>() { Dialog.ask(m_WindowNo, "TreeRemoveAllItems", new Callback<Boolean>() {
@Override @Override
public void onCallback(Boolean result) public void onCallback(Boolean result)
{ {
@ -535,9 +549,9 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
}); });
} // action_treeDeleteAll } // action_treeDeleteAll
@Override
public ADForm getForm() public ADForm getForm()
{ {
return form; return form;
} }
}
} // VTreeMaintenance

View File

@ -58,24 +58,27 @@ import org.zkoss.zul.North;
import org.zkoss.zul.South; import org.zkoss.zul.South;
/** /**
* Material Transaction History * Form to view Material Transaction History.
*
* @author Jorg Janke
* @version $Id: VTrxMaterial.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
*/ */
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTrxMaterial") @org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VTrxMaterial")
public class WTrxMaterial extends TrxMaterial public class WTrxMaterial extends TrxMaterial
implements IFormController, EventListener<Event>, ValueChangeListener implements IFormController, EventListener<Event>, ValueChangeListener
{ {
/** Custom form/window UI instance */
private CustomForm form = new CustomForm(); private CustomForm form = new CustomForm();
/** GridController */ /** Center of {@link #mainLayout} */
private ADTabpanel m_gridController = null; private ADTabpanel m_gridController = null;
// /** Main panel of {@link #form} */
private Panel mainPanel = new Panel(); private Panel mainPanel = new Panel();
/** Layout of {@link #mainPanel} */
private Borderlayout mainLayout = new Borderlayout(); private Borderlayout mainLayout = new Borderlayout();
/** North of {@link #mainLayout}. Form parameters panel */
private Panel parameterPanel = new Panel(); private Panel parameterPanel = new Panel();
/** Layout of {@link #parameterPanel} */
private Grid parameterLayout = GridFactory.newGridLayout();
private Label orgLabel = new Label(); private Label orgLabel = new Label();
private WTableDirEditor orgField; private WTableDirEditor orgField;
private Label locatorLabel = new Label(); private Label locatorLabel = new Label();
@ -88,20 +91,23 @@ public class WTrxMaterial extends TrxMaterial
private WDateEditor dateTField; private WDateEditor dateTField;
private Label mtypeLabel = new Label(); private Label mtypeLabel = new Label();
private WTableDirEditor mtypeField; private WTableDirEditor mtypeField;
private Grid parameterLayout = GridFactory.newGridLayout();
/** South of {@link #mainLayout} */
private Panel southPanel = new Panel(); private Panel southPanel = new Panel();
/** Action buttons panel. Child of {@link #southPanel} */
private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, false, false, false, true, false); private ConfirmPanel confirmPanel = new ConfirmPanel(true, true, false, false, false, true, false);
/** Status bar */
private StatusBarPanel statusBar = new StatusBarPanel(); private StatusBarPanel statusBar = new StatusBarPanel();
/** Number of columns for {@link #parameterLayout} */
private int noOfColumns; private int noOfColumns;
/** /**
* Initialize Panel * Default constructor
*/ */
public WTrxMaterial() public WTrxMaterial()
{ {
log.info(""); if (log.isLoggable(Level.INFO)) log.info("");
try try
{ {
m_WindowNo = form.getWindowNo(); m_WindowNo = form.getWindowNo();
@ -115,10 +121,10 @@ public class WTrxMaterial extends TrxMaterial
{ {
log.log(Level.SEVERE, "", ex); log.log(Level.SEVERE, "", ex);
} }
} // init }
/** /**
* Static Init * Layout {@link #form}
* @throws Exception * @throws Exception
*/ */
void zkInit() throws Exception void zkInit() throws Exception
@ -163,8 +169,11 @@ public class WTrxMaterial extends TrxMaterial
ZKUpdateUtil.setWidth(statusBar, "100%"); ZKUpdateUtil.setWidth(statusBar, "100%");
LayoutUtils.addSclass("status-border", statusBar); LayoutUtils.addSclass("status-border", statusBar);
} // jbInit }
/**
* Layout {@link #parameterLayout}
*/
protected void layoutParameters() { protected void layoutParameters() {
noOfColumns = 6; noOfColumns = 6;
if (ClientInfo.maxWidth(639)) if (ClientInfo.maxWidth(639))
@ -229,11 +238,9 @@ public class WTrxMaterial extends TrxMaterial
// Organization // Organization
MLookup orgLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3660, DisplayType.TableDir); MLookup orgLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3660, DisplayType.TableDir);
orgField = new WTableDirEditor("AD_Org_ID", false, false, true, orgLookup); orgField = new WTableDirEditor("AD_Org_ID", false, false, true, orgLookup);
// orgField.addVetoableChangeListener(this);
// Locator // Locator
MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo, null); MLocatorLookup locatorLookup = new MLocatorLookup(ctx, m_WindowNo, null);
locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo); locatorField = new WLocatorEditor ("M_Locator_ID", false, false, true, locatorLookup, m_WindowNo);
// locatorField.addVetoableChangeListener(this);
// Product // Product
MLookup productLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3668, DisplayType.Search); MLookup productLookup = MLookupFactory.get (ctx, m_WindowNo, 0, 3668, DisplayType.Search);
productField = new WSearchEditor("M_Product_ID", false, false, true, productLookup); productField = new WSearchEditor("M_Product_ID", false, false, true, productLookup);
@ -250,15 +257,15 @@ public class WTrxMaterial extends TrxMaterial
} // dynParameter } // dynParameter
/** /**
* Dynamic Layout (Grid). * Initialize {@link #m_gridController}.
* Based on AD_Window: Material Transactions * Based on AD_Window: Material Transactions (indirect use).
*/ */
private void dynInit() private void dynInit()
{ {
super.dynInit(statusBar); super.dynInit(statusBar);
// //
m_gridController = new ADTabpanel(); m_gridController = new ADTabpanel();
// m_mTab is level 0 GridTab of Material Transactions (indirect use)
m_gridController.init(null, m_mTab); m_gridController.init(null, m_mTab);
if (!m_gridController.isGridView()) if (!m_gridController.isGridView())
m_gridController.switchRowPresentation(); m_gridController.switchRowPresentation();
@ -269,19 +276,17 @@ public class WTrxMaterial extends TrxMaterial
ZKUpdateUtil.setHflex(m_gridController, "1"); ZKUpdateUtil.setHflex(m_gridController, "1");
} // dynInit } // dynInit
/** /**
* Dispose * Close form.
*/ */
public void dispose() public void dispose()
{ {
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
} // dispose } // dispose
/**
/************************************************************************** * Event Listener
* Action Listener * @param e event
* @param e event
*/ */
public void onEvent (Event e) public void onEvent (Event e)
{ {
@ -292,23 +297,20 @@ public class WTrxMaterial extends TrxMaterial
refresh(); refresh();
else if (e.getTarget().getId().equals(ConfirmPanel.A_ZOOM)) else if (e.getTarget().getId().equals(ConfirmPanel.A_ZOOM))
zoom(); zoom();
} // actionPerformed }
/**
/************************************************************************** * Value change listener
* Property Listener * @param e event
* @param e event
*/ */
public void valueChange (ValueChangeEvent e) public void valueChange (ValueChangeEvent e)
{ {
if (e.getPropertyName().equals("M_Product_ID")) if (e.getPropertyName().equals("M_Product_ID"))
productField.setValue(e.getNewValue()); productField.setValue(e.getNewValue());
} // vetoableChange }
/**
* Refresh - Create Query and refresh {@link #m_gridController}.
/**************************************************************************
* Refresh - Create Query and refresh grid
*/ */
private void refresh() private void refresh()
{ {
@ -325,7 +327,7 @@ public class WTrxMaterial extends TrxMaterial
} // refresh } // refresh
/** /**
* Zoom * Zoom to AD_Table_ID + Record_ID of current {@link #m_gridController} row.
*/ */
public void zoom() public void zoom()
{ {
@ -335,11 +337,15 @@ public class WTrxMaterial extends TrxMaterial
AEnv.zoom(AD_Table_ID, Record_ID); AEnv.zoom(AD_Table_ID, Record_ID);
} // zoom } // zoom
@Override
public ADForm getForm() public ADForm getForm()
{ {
return form; return form;
} }
/**
* Handle onClientInfo event from browser
*/
protected void onClientInfo() protected void onClientInfo()
{ {
if (noOfColumns > 0 && parameterLayout.getRows() != null) if (noOfColumns > 0 && parameterLayout.getRows() != null)
@ -357,4 +363,4 @@ public class WTrxMaterial extends TrxMaterial
} }
} }
} }
} // VTrxMaterial }