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) {
DestroyAllSession();
// bring from depricate class WebUIServlet
/** Initialise context for the current thread*/
Properties serverContext = new Properties();
serverContext.put(ServerContextURLHandler.SERVER_CONTEXT_URL_HANDLER, new ServerContextURLHandler() {
@ -91,7 +90,7 @@ public class LoggedSessionListener implements HttpSessionListener, ServletContex
File file = new File(propertyFile);
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())
{

View File

@ -96,7 +96,7 @@ import com.lowagie.text.DocumentException;
*/
public final class AEnv
{
/** Environment context attribute for Locale **/
/** Environment context attribute for Locale */
public static final String LOCALE = Env.LOCALE;
/**
@ -259,12 +259,12 @@ public final class AEnv
AEnv.zoom(s_workflow_Window_ID, query);
} // startWorkflowProcess
/** Cache Workflow Window ID **/
/** Cache Workflow Window ID */
private static int s_workflow_Window_ID = 0;
/** Logger */
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>>();
/**
@ -321,7 +321,7 @@ public final class AEnv
if (mWindowVO == null)
return null;
// Check context
// Check context (Just in case, usually both is ServerContextPropertiesWrapper)
if (!mWindowVO.ctx.equals(Env.getCtx()))
{
// Add Window properties to context
@ -824,17 +824,12 @@ public final class AEnv
}
/**
* Get adWindowId below gridField
* 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
* Get AD_Window_ID from windowNo.
* @param windowNo
* @return
* @return AD_Window_ID or {@link Env#adWindowDummyID} (if it is ProcessDialog of InfoWindow)
*/
public static int getADWindowID (int windowNo){
int adWindowID = 0;
// form process parameter panel
Object window = SessionManager.getAppDesktop().findWindow(windowNo);
// case show a process dialog, window is below window of process dialog
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;
import java.io.StringWriter;
@ -37,27 +58,33 @@ import org.zkoss.zul.Timer;
import org.zkoss.zul.Vlayout;
/**
* Form to compare suggested text from AD_CtxHelpSuggestion with the original text from AD_CtxHelpMsg.
* @author hengsin
*
*/
@org.idempiere.ui.zk.annotation.Form
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
*/
private static final long serialVersionUID = -100362034024824442L;
/** Grid layout for content of form */
private Grid grid;
private ConfirmPanel confirmPanel;
/** Cell to show diff between original and changed text */
private Cell helpDiff;
private CKeditor helpTextbox;
private X_AD_CtxHelpMsg ctxHelpMsg;
/** AD Language from calling GridTab */
private String AD_Language;
/** Timer to process onChanging text from {@link #helpTextbox} asynchronously */
private Timer helpTimer;
/**
*
* default constructor
*/
public CompareCtxHelpSuggestion() {
}
@ -100,6 +127,9 @@ public class CompareCtxHelpSuggestion extends ADForm {
renderGrid();
}
/**
* Render content grid.
*/
private void renderGrid() {
Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c);
@ -133,6 +163,7 @@ public class CompareCtxHelpSuggestion extends ADForm {
if (original != null)
original = removeHeaderTag(original);
row.appendCellChild(new Html(original));
//suggestion from AD_CtxHelpSuggestion
String changed = (String) gridTab.getValue("MsgText");
if (changed != null)
changed = removeHeaderTag(changed);
@ -154,6 +185,11 @@ public class CompareCtxHelpSuggestion extends ADForm {
this.addEventListener(Events.ON_OK, this);
}
/**
* @param original
* @param changed
* @return difference between original and changed
*/
private Html diff(String original, String changed) {
if (original == null)
original = "";
@ -210,7 +246,7 @@ public class CompareCtxHelpSuggestion extends ADForm {
} else if (event.getTarget() == helpTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event;
helpTimer.setAttribute(NEW_VALUE, inputEvent.getValue());
helpTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (helpTimer.isRunning()) {
return;
} else {
@ -222,17 +258,25 @@ public class CompareCtxHelpSuggestion extends ADForm {
helpTimer.stop();
}
} else if (event.getTarget() == helpTimer) {
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE));
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE_ATTR));
} else {
super.onEvent(event);
}
}
/**
* Handle changes from {@link #helpTextbox}.
* @param text
*/
private void onHelpChanged(String text) {
helpDiff.getChildren().clear();
Html html = diff(ctxHelpMsg.get_Translation("MsgText", AD_Language), text);
helpDiff.appendChild(html);
}
/**
* Apply changes to calling GridTab (AD_CtxHelpSuggestion).
*/
private void applyChanges() {
Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c);
@ -250,6 +294,10 @@ public class CompareCtxHelpSuggestion extends ADForm {
return Mode.HIGHLIGHTED;
}
/**
* @param htmlString
* @return htmlString after removal of html header tag
*/
private String removeHeaderTag(String htmlString) {
htmlString = htmlString
.replace("<html>", "")
@ -261,6 +309,11 @@ public class CompareCtxHelpSuggestion extends ADForm {
return htmlString;
}
/**
* @param s1
* @param s2
* @return difference between s1 and s2
*/
private String htmlDiff(String s1, String s2) {
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;
import java.util.LinkedList;
@ -33,34 +54,44 @@ import org.zkoss.zul.Timer;
import org.zkoss.zul.Vlayout;
/**
* Form to compare suggested text from AD_FieldSuggestion with the original text from AD_Field.
* @author hengsin
*
*/
@org.idempiere.ui.zk.annotation.Form
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
*/
private static final long serialVersionUID = -100362034024824442L;
/** Grid layout for content of form */
private Grid grid;
private ConfirmPanel confirmPanel;
/** Cell to show diff between original and changed description */
private Cell descriptionDiff;
/** Cell to show diff between original and changed name */
private Cell nameDiff;
/** Cell to show diff between original and changed help */
private Cell helpDiff;
private Textbox nameTextbox;
private Textbox descriptionTextbox;
private Textbox helpTextbox;
private MField field;
/** AD Language from calling GridTab */
private String AD_Language;
private diff_match_patch diff;
/** Timer to process onChanging text from {@link #nameTextbox} asynchronously */
private Timer nameTimer;
/** Timer to process onChanging text from {@link #descriptionTextbox} asynchronously */
private Timer descriptionTimer;
/** Timer to process onChanging text from {@link #helpTextbox} asynchronously */
private Timer helpTimer;
/**
*
* default constructor
*/
public CompareFieldSuggestion() {
}
@ -119,6 +150,9 @@ public class CompareFieldSuggestion extends ADForm {
renderGrid();
}
/**
* Render content grid.
*/
private void renderGrid() {
Component c = SessionManager.getAppDesktop().getActiveWindow();
ADWindow adwindow = ADWindow.findADWindow(c);
@ -155,6 +189,7 @@ public class CompareFieldSuggestion extends ADForm {
String original = field.get_Translation("Name", AD_Language);
row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
String changed = (String) gridTab.getValue("Name");
nameTextbox = new Textbox(changed);
row.appendCellChild(nameTextbox);
@ -173,6 +208,7 @@ public class CompareFieldSuggestion extends ADForm {
original = field.get_Translation("Description", AD_Language);
row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
changed = (String) gridTab.getValue("Description");
descriptionTextbox = new Textbox(changed);
descriptionTextbox.setRows(4);
@ -193,6 +229,7 @@ public class CompareFieldSuggestion extends ADForm {
original = field.get_Translation("Help", AD_Language);
row.appendCellChild(new Label(original));
//suggested text from AD_FieldSuggestion
changed = (String) gridTab.getValue("Help");
helpTextbox = new Textbox(changed);
helpTextbox.setRows(8);
@ -211,6 +248,11 @@ public class CompareFieldSuggestion extends ADForm {
this.addEventListener(Events.ON_OK, this);
}
/**
* @param original
* @param changed
* @return difference between original and changed
*/
private Html diff(String original, String changed) {
if (original == null) original = "";
if (changed == null) changed = "";
@ -233,7 +275,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == nameTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event;
nameTimer.setAttribute(NEW_VALUE, inputEvent.getValue());
nameTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (nameTimer.isRunning()) {
return;
} else {
@ -247,7 +289,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == descriptionTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event;
descriptionTimer.setAttribute(NEW_VALUE, inputEvent.getValue());
descriptionTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (descriptionTimer.isRunning()) {
return;
} else {
@ -261,7 +303,7 @@ public class CompareFieldSuggestion extends ADForm {
} else if (event.getTarget() == helpTextbox) {
if (event.getName().equals(Events.ON_CHANGING)) {
InputEvent inputEvent = (InputEvent) event;
helpTimer.setAttribute(NEW_VALUE, inputEvent.getValue());
helpTimer.setAttribute(NEW_VALUE_ATTR, inputEvent.getValue());
if (helpTimer.isRunning()) {
return;
} else {
@ -273,34 +315,49 @@ public class CompareFieldSuggestion extends ADForm {
helpTimer.stop();
}
} else if (event.getTarget() == nameTimer) {
onNameChanged((String) nameTimer.removeAttribute(NEW_VALUE));
onNameChanged((String) nameTimer.removeAttribute(NEW_VALUE_ATTR));
} else if (event.getTarget() == descriptionTimer) {
onDescriptionChanged((String) descriptionTimer.removeAttribute(NEW_VALUE));
onDescriptionChanged((String) descriptionTimer.removeAttribute(NEW_VALUE_ATTR));
} else if (event.getTarget() == helpTimer) {
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE));
onHelpChanged((String) helpTimer.removeAttribute(NEW_VALUE_ATTR));
} else {
super.onEvent(event);
}
}
/**
* Handle changes from {@link #helpTextbox}.
* @param text
*/
private void onHelpChanged(String text) {
helpDiff.getChildren().clear();
Html html = diff(field.get_Translation("Help", AD_Language), text);
helpDiff.appendChild(html);
}
/**
* Handle changes from {@link #descriptionTextbox}.
* @param text
*/
private void onDescriptionChanged(String text) {
descriptionDiff.getChildren().clear();
Html html = diff(field.get_Translation("Description", AD_Language), text);
descriptionDiff.appendChild(html);
}
/**
* Handle changes from {@link #nameTextbox}.
* @param text
*/
private void onNameChanged(String text) {
nameDiff.getChildren().clear();
Html html = diff(field.get_Translation("Name", AD_Language), text);
nameDiff.appendChild(html);
}
/**
* Apply changes to calling GridTab (AD_FieldSuggestion).
*/
private void applyChanges() {
Component c = SessionManager.getAppDesktop().getActiveWindow();
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;
/**
*
* Default implementation of {@link ICreateFromFactory}
* @author Elaine
*
*/
public class DefaultCreateFromFactory implements ICreateFromFactory
{

View File

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

View File

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

View File

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

View File

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

View File

@ -81,6 +81,9 @@ import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Space;
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")
public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChangeListener
{
@ -89,11 +92,13 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
*/
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;
/** BOM Qty */
@ -102,60 +107,71 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
/** Logger */
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>();
/** List of all quantities */
/** List of quantity for each BOM line */
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>();
/** list child panel of each checkbox+product */
/** list of child panel for each BOM line */
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>();
/** Alternative Group Map */
/** GroupKey:RadioGroup. Alternative Group Map */
private HashMap<String, Radiogroup> m_alternativeGroups = new HashMap<String,Radiogroup>();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
//content panel of selectionGroupbox
private Grid selectionPanel = GridFactory.newGridLayout();
/** Main layout */
private Borderlayout borderLayout;
/** 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();
/** Order field of {@link #selectionPanel} */
private Listbox orderField = new Listbox();
/** Invoice field of {@link #selectionPanel} */
private Listbox invoiceField = new Listbox();
/** Project field of {@link #selectionPanel} */
private Listbox projectField = new Listbox();
//north selection group box
private Groupbox selectionGroupbox = new Groupbox();
//center bom group box
/** BOM group box, center of {@link #borderLayout} */
private Groupbox centerGroupbox = new Groupbox();
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();
/** ParentProductID_ParentBOMLineLevel:Child Panel (in {@link #m_childPanelList}) */
private HashMap<String, Component> m_parentContainerMap = new HashMap<>();
/** BOMLevel|Feature:Groupbox */
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<>();
//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<>();
/**
* Default constructor
*/
public WBOMDrop()
{}
/**
* Initialize Panel
* Layout form
*/
protected void initForm()
{
@ -194,7 +210,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
{
log.log(Level.SEVERE, e.getMessage(), e);
}
} // init
}
/**
* Dispose
@ -238,14 +254,13 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
m_alternativeGroups = null;
} // dispose
/**************************************************************************
* Create Selection Panel
/**
* Create Selection/Parameters Panel.
* @param order
* @param invoice
* @param project
* @throws Exception
*/
private void createSelectionPanel (boolean order, boolean invoice, boolean project) throws Exception
{
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);
} // getInvoices
/**************************************************************************
/**
* Create Main Panel.
* Called when changing Product
* Called after change of selected product.
*/
private void createMainPanel ()
{
@ -425,8 +440,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
private int maxBomDeep = 0;
/**
* Add BOM Line to this.
* Calls addBOMLines if added product is a BOM
* Add BOM line to {@link #m_productPanelList}.
* @param bomLine BOM Line
*/
private void addBOMLine (BOMLine bomLine)
@ -460,15 +474,16 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // addBOMLine
/**
* Add Line to Display
* Render single BOM line.
* @param parentM_Product_ID parent product
* @param M_Product_ID product
* @param bomType bom type
* @param name name
* @param lineQty qty
* @param parentPanel
* @param parentPanel child panel of parent product
* @param bomLevel
* @param feature
* @return {@link Layout}
*/
private Layout addDisplay (int parentM_Product_ID,
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
checkbox = new Radio();
}
checkbox.setAttribute(OPTION_PRODUCT_KEY, optionKey);
checkbox.setAttribute(OPTION_PRODUCT_KEY_ATTR, optionKey);
selectPanel.appendChild(checkbox);
m_selectorList.add(checkbox);
@ -556,7 +571,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
featureGroup = m_featureGroup.get(key);
if (featureGroup == null) {
featureGroup = new Groupbox();
featureGroup.setAttribute(FEATURE_GROUP_KEY, key);
featureGroup.setAttribute(FEATURE_GROUP_KEY_ATTR, key);
featureGroup.appendChild(new Caption(feature));
m_featureGroup.put(key, featureGroup);
}
@ -574,7 +589,7 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} else {
String groupName = String.valueOf(parentM_Product_ID) + "_" + bomType + "_" + parentPanel.toString();
if (featureGroup != null) {
groupName = groupName + "_" + featureGroup.getAttribute(FEATURE_GROUP_KEY);
groupName = groupName + "_" + featureGroup.getAttribute(FEATURE_GROUP_KEY_ATTR);
}
Radiogroup radioGroup = m_alternativeGroups.get(groupName);
@ -623,13 +638,21 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return outerProductPanel;
} // addDisplay
private Div createDivPanel (int with) {
/**
* @param width
* @return {@link Div}
*/
private Div createDivPanel (int width) {
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");
return divPanel;
}
/**
* @param width
* @return {@link Hlayout}
*/
private Hlayout createHlayoutPanel (String width) {
Hlayout layout = new Hlayout();
layout.setSpacing("0");
@ -637,6 +660,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return layout;
}
/**
* @param width
* @return {@link Vlayout}
*/
private Vlayout createVlayoutPanel (String width) {
Vlayout layout = new Vlayout();
layout.setSpacing("0");
@ -644,10 +671,11 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
return layout;
}
/**************************************************************************
* Action Listener
/**
* Event Listener
* @param e event
*/
@Override
public void onEvent (Event e) throws Exception
{
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
index = m_selectorList.indexOf(radio);
m_qtyList.get(index).setReadonly(true);
m_selectedOtions.remove(radio.getAttribute(OPTION_PRODUCT_KEY));
m_unselectedOtions.add((String) radio.getAttribute(OPTION_PRODUCT_KEY));
m_selectedOtions.remove(radio.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_unselectedOtions.add((String) radio.getAttribute(OPTION_PRODUCT_KEY_ATTR));
}
}
}
updateBOMChildVisibility();
if (checkbox.isChecked()) {
m_selectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY));
m_unselectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY));
m_selectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_unselectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
} else {
m_unselectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY));
m_selectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY));
m_unselectedOtions.add((String) checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
m_selectedOtions.remove(checkbox.getAttribute(OPTION_PRODUCT_KEY_ATTR));
}
}
// Product / Qty
@ -766,6 +794,9 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
enableSave();
}
/**
* Update state of Ok button in {@link #confirmPanel}.
*/
private void enableSave() {
// Enable OK
boolean OK = m_product != null;
@ -803,6 +834,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
confirmPanel.setEnabled("Ok", OK);
}
/**
* Handle changes to {@link #fieldProduct}
* @param productFieldValue
*/
private void onProductChanged(Object productFieldValue) {
int id = (productFieldValue != null && productFieldValue instanceof Integer) ? (Integer)productFieldValue : 0;
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
* for item is not selected, hide child of it.
* Update display of bom tree.
* For item not selected, hide corresponding panel (in {@link #m_childPanelList}).
*/
protected void updateBOMChildVisibility() {
int index = 0;
@ -831,8 +866,8 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
}
/**
* Enable/disable qty based on selection
* @param source JCheckBox or JRadioButton
* Save changes. Delegate to {@link #cmd_save(Trx)}.
* @return true if save successfully, false otherwise.
*/
private boolean onSave()
{
@ -859,10 +894,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
}
}
/**************************************************************************
* Save Selection
/**
* Save changes to DB.
* @param trx
* @return true if saved
* @return true if saved, false otherwise.
*/
private boolean cmd_save(Trx trx)
{
@ -901,10 +936,10 @@ public class WBOMDrop extends ADForm implements EventListener<Event>, ValueChang
} // cmd_save
/**
* Save to Order
* Create and save order lines from BOM.
* @param C_Order_ID id
* @param trx
* @return true if saved
* @return true if saved, false otherwise.
*/
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
/**
* Save to Invoice
* Create and save invoice lines from BOM.
* @param C_Invoice_ID id
* @param trx
* @return true if saved
* @return true if saved, false otherwise.
*/
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
/**
* Save to Project
* Create and save project lines from BOM.
* @param C_Project_ID id
* @param trx
* @return true if saved
* @return true if saved, false otherwise
*/
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
* from natural accounts.
*
* <br/>
* The form is comprised of two parts.
* 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.
@ -77,6 +77,7 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
*/
private static final long serialVersionUID = 4571016052942218676L;
/** UI Form instance */
private CustomForm form = new CustomForm();
/** AD_Message for "Create". */
@ -84,8 +85,8 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
/** Logger. */
private static final CLogger log = CLogger.getCLogger(WCharge.class);
// new panel
/** Grid for components for creating a new charge account. */
// new charge panel
/** Grid for components for creating a new charge account. North of {@link #form}. */
private Grid m_grdNew = GridFactory.newGridLayout();
/** Value (key) field 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();
// 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();
/** 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();
/** Table to hold data of accounts. */
/** Table to hold data of accounts. Center of {@link #m_pnlAccount}. */
private WListbox m_tblData = new WListbox();
/** selected account count */
private int m_selectedCount;
@ -120,7 +121,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
initForm();
}
/**
* Initialises the panel.
*/
@ -137,11 +137,8 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{
log.log(Level.SEVERE, "", e);
}
return;
}
/**
* Initialises the static components of the form.
*/
@ -149,10 +146,11 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{
createNewChargePanel();
createAccountPanel();
return;
}
/**
* Layout {@link #form}
*/
private void zkInit()
{
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:
* <li>a table detailing all 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);
southPanel.appendChild(new Separator());
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
* 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;");
row.appendCellChild(label, 3);
row = new Row();
rows.appendChild(row);
row.appendChild(m_lblValue.rightAlign());
@ -266,8 +261,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
row = new Row();
rows.appendChild(row);
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.
*/
@Override
public void onEvent(Event event)
{
if (log.isLoggable(Level.INFO)) log.info(event.getName());
@ -319,8 +313,6 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
{
createAccount();
}
return;
}
/**
@ -363,7 +355,7 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
} // createNew
/**
* Creates Charges from Accounts.
* Creates Charges from Accounts.<br/>
* Charges are created for the selected accounts.
* The selection is cleared upon completion.
*/
@ -381,16 +373,17 @@ public class WCharge extends Charge implements IFormController, EventListener<Ev
m_selectedCount = 0;
m_btnAccount.setDisabled(true);
return;
} // createAccount
/**
* Close form.
*/
public void close()
{
SessionManager.getAppDesktop().closeActiveWindow();
}
@Override
public ADForm getForm() {
return form;
}

View File

@ -44,6 +44,7 @@ import org.compiere.model.GridTab;
import org.compiere.model.MBankStatement;
import org.compiere.model.MColumn;
import org.compiere.model.MDepositBatch;
import org.compiere.model.MDepositBatchLine;
import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory;
import org.compiere.model.MPayment;
@ -60,16 +61,15 @@ import org.zkoss.zul.Center;
import org.zkoss.zul.Hbox;
/**
*
* Form to create Deposit Batch ({@link MDepositBatch} and {@link MDepositBatchLine}) from payment transactions.
* @author Elaine
*
*/
public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements EventListener<Event>
{
/** UI form instance */
private WCreateFromWindow window;
/**
*
* @param tab
*/
public WCreateFromDepositBatchUI(GridTab tab)
@ -102,6 +102,8 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
/** Logger */
private static final CLogger log = CLogger.getCLogger(WCreateFromDepositBatchUI.class);
/** form parameters for loading of payment transactions ({@link #loadBankAccount}) */
protected Label bankAccountLabel = new Label();
protected WTableDirEditor bankAccountField;
@ -119,6 +121,7 @@ public class WCreateFromDepositBatchUI extends CreateFromDepositBatch implements
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 Label amtToLabel = new Label("-");
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 WDateEditor dateFromField = new WDateEditor("DateFrom", false, false, true, Msg.translate(Env.getCtx(), "DateFrom"));
protected Label dateToLabel = new Label("-");
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;
} // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception
{
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
* @throws Exception
*/
@Override
public void onEvent(Event e) throws Exception
{
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;
/**
*
* Static method to instantiate {@link ICreateFrom} instance.
* @author hengsin
*
*/
public class WCreateFromFactory
{
/**
*
* Instantiate Create From form instance.
* Delegate to {@link Extensions#getCreateFrom(GridTab)}.
* @param mTab
* @return ICreateFrom instance
*/

View File

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

View File

@ -56,21 +56,21 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zul.Space;
/**
*
* Form to create Invoice Lines from Purchase Order, Material Receipt or Vendor RMA.
* @author hengsin
*
*/
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener<Event>, ValueChangeListener
{
/** UI form instance */
private WCreateFromWindow window;
/**
*
* @param tab
*/
public WCreateFromInvoiceUI(GridTab tab)
{
super(tab);
if (log.isLoggable(Level.INFO))
log.info(getGridTab().toString());
window = new WCreateFromWindow(this, getGridTab().getWindowNo());
@ -99,12 +99,15 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
private static final CLogger log = CLogger.getCLogger(WCreateFromInvoiceUI.class);
protected Label bPartnerLabel = new Label();
/** Business partner parameter field */
protected WEditor bPartnerField;
protected Label orderLabel = new Label();
/** Orders parameter field */
protected Listbox orderField = ListboxFactory.newDropdownListbox();
protected Label shipmentLabel = new Label();
/** Shipments parameter field */
protected Listbox shipmentField = ListboxFactory.newDropdownListbox();
/** Label for the rma selection */
@ -112,10 +115,16 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
/** Combo box for selecting RMA document */
protected Listbox rmaField = ListboxFactory.newDropdownListbox();
/** Grid layout for parameter panel */
private Grid parameterStdLayout;
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
public boolean dynInit() throws Exception
{
@ -143,6 +152,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
return true;
} // dynInit
/**
* Layout {@link #window}
* @throws Exception
*/
protected void zkInit() throws Exception
{
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
@ -194,6 +207,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
hideEmptyRow(rows);
}
/**
* Hide a row if all parameter fields within a row is invisible.
* @param rows
*/
private void hideEmptyRow(org.zkoss.zul.Rows rows) {
for(Component a : rows.getChildren()) {
Row row = (Row) a;
@ -221,10 +238,6 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
}
}
private boolean m_actionActive = false;
private int noOfParameterColumn;
@Override
public void onEvent(Event e) throws Exception
{
@ -286,7 +299,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
window.tableChanged(null);
} // vetoableChange
/**************************************************************************
/**
* Load BPartner Field
* @param forInvoice true if Invoices are to be created, false receipts
* @throws Exception if Lookups cannot be initialized
@ -329,6 +342,10 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
initBPDetails(C_BPartner_ID);
} // initBPartnerOIS
/**
* Call {@link #initBPShipmentDetails(int)} and {@link #initBPRMADetails(int)}.
* @param C_BPartner_ID
*/
private void initBPDetails(int 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
*/
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
*/
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 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)
{
@ -407,7 +424,7 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
}
/**
* Load datas into list box
* Load data into list box
* @param data 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
*/
protected void setupColumns(Grid parameterGrid) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -68,18 +68,17 @@ import org.zkoss.zul.South;
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
* Aug 16, 2007
*
*/
@org.idempiere.ui.zk.annotation.Form(name = "org.compiere.apps.form.VFileImport")
public class WFileImport extends ADForm implements EventListener<Event>
{
/**
*
* generated serial id
*/
private static final long serialVersionUID = -7462842139127270429L;
private static final int MAX_LOADED_LINES = 100;
@ -88,51 +87,74 @@ public class WFileImport extends ADForm implements EventListener<Event>
/** Logger */
private static final CLogger log = CLogger.getCLogger(WFileImport.class);
/** Current index pointer for {@link #m_data} */
private int m_record = -1;
private Listbox pickFormat = new Listbox();
private Listbox fCharset = new Listbox();
/** Lines of loaded text file */
private ArrayList<String> m_data = new ArrayList<String>();
private static final String s_none = "----"; // no format indicator
/** Import format helper */
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 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();
/** 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 Textbox rawData = new Textbox();
/** Array of column/field. Child of {@link #previewPanel}. */
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 record = new Label();
private Label labelFormat = new Label();
/** Preview panel, child of {@link #centerPanel} */
private Div previewPanel = new Div();
/** North part of form */
private Vbox northPanel = new Vbox();
/** Center part of form */
private Div centerPanel = new Div();
/** Action buttons panel. South of form */
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/**
* Default constructor
*/
public WFileImport()
{
}
/**
* Initialize Panel
* Initialize form
*/
protected void initForm()
{
log.info("");
if (log.isLoggable(Level.INFO)) log.info("");
try
{
jbInit();
zkInit();
dynInit();
ZKUpdateUtil.setWidth(this, "100%");
@ -163,11 +185,10 @@ public class WFileImport extends ADForm implements EventListener<Event>
} // init
/**
* Static Init
* Layout form
* @throws Exception
*/
private void jbInit() throws Exception
private void zkInit() throws Exception
{
Charset[] charsets = Ini.getAvailableCharsets();
@ -525,7 +546,6 @@ public class WFileImport extends ADForm implements EventListener<Event>
* Apply Current Pattern
* @param next next
*/
private void cmd_applyFormat (boolean next)
{
if (m_format == null || m_data.size() == 0)

View File

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

View File

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

View File

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

View File

@ -16,25 +16,36 @@ package org.adempiere.webui.apps.form;
import org.adempiere.webui.panel.CustomForm;
/**
*
* Custom form for {@link WMerge}.
* @author hengsin
*
*/
public class WMergeUI extends CustomForm {
/**
* generated serial id
*/
private static final long serialVersionUID = -8576926702378868806L;
/** Controller */
private WMerge m_merge;
/**
* @param merge
*/
public WMergeUI(WMerge merge) {
super();
m_merge = merge;
}
/**
* Run merge process
*/
public void runProcess() {
m_merge.runProcess();
}
/**
* After execution of merge process
*/
public void 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.MLookupFactory;
import org.compiere.model.MPaySelectionCheck;
import org.compiere.model.X_C_Order;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -70,10 +71,7 @@ import org.zkoss.zul.Filedownload;
import org.zkoss.zul.South;
/**
* Payment Print and Export
*
* @author Jorg Janke
* @version $Id: VPayPrint.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
* Form to Print and Export payment.
*
* Contributors:
* 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")
public class WPayPrint extends PayPrint implements IFormController, EventListener<Event>, ValueChangeListener
{
/** Custom form/window instance */
private CustomForm form = new CustomForm();
/**
* Initialize Panel
* Default constructor
*/
public WPayPrint()
{
@ -114,41 +113,54 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
}
} // WPayPrint
// Instance Variables
protected Panel centerPanel = new Panel();
/** Action buttons panel. South of {@link #form} */
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);
/** Button to export payment to file */
protected Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT);
protected Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL);
/** Button to process PAYMENTRULE_DirectDeposit payments */
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();
/** Payment selections */
protected WSearchEditor paySelectSearch = null;
protected Label lBank = new Label();
/** Bank name from C_BankAccount.C_Bank_ID */
protected Label fBank = new Label();
protected Label lPaymentRule = new Label();
/** Payment rules */
protected Listbox fPaymentRule = ListboxFactory.newDropdownListbox();
protected Label lDocumentNo = new Label();
/** Bank account document number (C_BankAccountDoc). Usually for check number. */
protected WNumberEditor fDocumentNo = new WNumberEditor();
protected Label lNoPayments = new Label();
/** Number of C_PaySelectionCheck records */
protected Label fNoPayments = new Label();
protected Label lBalance = new Label();
/** C_PaySelection.CurrentBalance */
protected WNumberEditor fBalance = new WNumberEditor();
protected Label lCurrency = new Label();
/** ISO_Code from C_BankAccount.C_Currency_ID */
protected Label fCurrency = new Label();
protected Label lDepositBatch = new Label();
protected WYesNoEditor fDepositBatch = new WYesNoEditor("", "", "Book as one post", false, false, true) ;
protected Label lSumPayments = new Label();
/** Sum of C_PaySelectionCheck.PayAmt */
protected WNumberEditor fSumPayments = new WNumberEditor();
/**
* Static Init
* Layout {@link #form}
* @throws Exception
*/
protected void zkInit() throws Exception
{
//
centerPanel.appendChild(centerLayout);
//
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);
paySelectSearch = new WSearchEditor("C_PaySelection_ID", true, false, true, lookupPS);
paySelectSearch.addValueChangeListener(this);
} // dynInit
/**
* Dispose
* Close form.
*/
public void dispose()
{
@ -266,8 +277,8 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // setsetPaySelection
/**************************************************************************
* Action Listener
/**
* Event Listener
* @param e event
*/
@Override
@ -350,7 +361,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
if(sumPayments != null)
fSumPayments.setValue(sumPayments);
bProcess.setEnabled(PaymentRule.equals("T"));
bProcess.setEnabled(PaymentRule.equals(X_C_Order.PAYMENTRULE_DirectDeposit));
if(documentNo != null)
fDocumentNo.setValue(documentNo);
@ -398,7 +409,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // getPluginFeatures
/**************************************************************************
/**
* Export payments to file
*/
protected void cmd_export()
@ -568,7 +579,7 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
} // cmd_print
/**************************************************************************
/**
* Get Checks
* @param PaymentRule Payment Rule
* @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
* @param e event
*/
@ -612,5 +623,4 @@ public class WPayPrint extends PayPrint implements IFormController, EventListene
loadPaySelectInfo();
}
}
} // PayPrint
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -14,17 +14,17 @@
package org.adempiere.webui.apps.form;
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
*
*/
public class WPaymentFormDirectDebit extends WPaymentFormDirect {
/**
*
* @param windowNo
* @param mTab
*/

View File

@ -14,17 +14,16 @@
package org.adempiere.webui.apps.form;
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
*
*/
public class WPaymentFormDirectDeposit extends WPaymentFormDirect {
/**
*
* @param windowNo
* @param mTab
*/

View File

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

View File

@ -15,16 +15,22 @@ package org.adempiere.webui.apps.form;
import org.compiere.grid.PaymentFormMixedPOS;
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
*
*/
public class WPaymentFormMixedPOS extends PaymentFormMixedPOS {
/** Payment form window instance */
private WPaymentFormWindow window;
/**
* @param windowNo
* @param mTab
*/
public WPaymentFormMixedPOS(int windowNo, GridTab mTab) {
super(windowNo, mTab);
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.compiere.grid.PaymentFormOnCredit;
import org.compiere.model.GridTab;
import org.compiere.model.X_C_Order;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
/**
*
* Form for on credit payment rule ({@link X_C_Order#PAYMENTRULE_OnCredit}).
* @author Elaine
*
*/
public class WPaymentFormOnCredit extends PaymentFormOnCredit {
/** Payment form window instance */
private WPaymentFormWindow window;
private Label pTermLabel = new Label();
/** Payment terms */
private Listbox pTermCombo = ListboxFactory.newDropdownListbox();
/**
*
* @param windowNo
* @param mTab
*/
@ -55,6 +55,9 @@ public class WPaymentFormOnCredit extends PaymentFormOnCredit {
init();
}
/**
* Layout {@link #window}
*/
protected void init() {
Grid pPanelLayout = GridFactory.newGridLayout();
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.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog;
import org.compiere.grid.IPaymentForm;
import org.compiere.grid.PaymentForm;
import org.compiere.util.Env;
import org.compiere.util.Msg;
@ -32,29 +33,37 @@ import org.zkoss.zul.Center;
import org.zkoss.zul.South;
/**
*
* Window for {@link IPaymentForm}.
* @author Elaine
*
*/
public class WPaymentFormWindow extends Window implements EventListener<Event>, DialogEvents {
/**
*
* generated serial id
*/
private static final long serialVersionUID = 2710316463655831868L;
/** Form Controller */
private PaymentForm paymentForm;
private int windowNo;
/** Main panel of form */
private Panel mainPanel = new Panel();
/** Center of {@link #mainLayout} */
private Panel centerPanel = new Panel();
/** Layout of {@link #mainPanel} */
private Borderlayout mainLayout = new Borderlayout();
/** South of {@link #mainLayout}. Action buttons panel. */
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
/** True when UI is lock */
private boolean m_isLocked = false;
/** Status of initialization */
private boolean initOK = false;
private BusyDialog progressWindow;
/**
* @param paymentForm
* @param windowNo
*/
public WPaymentFormWindow(PaymentForm paymentForm, int windowNo)
{
super();
@ -79,10 +88,17 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
this.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
}
/**
* @return window number
*/
protected int getWindowNo() {
return this.windowNo;
}
/**
* Layout form.
* @throws Exception
*/
private void zkInit() throws Exception {
this.appendChild(mainPanel);
mainPanel.appendChild(mainLayout);
@ -104,34 +120,45 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
confirmPanel.addActionListener(this);
}
/**
* Dynamic initialization.
* Call {@link PaymentForm#dynInit()}.
* @return initialization status
* @throws Exception
*/
private boolean dynInit() throws Exception {
boolean isInitOK = paymentForm.dynInit();
centerPanel.setVisible(!paymentForm.isOnlyRule());
return isInitOK;
}
/**
* @return {@link #centerPanel}
*/
public Panel getPanel() {
return centerPanel;
}
/**************************************************************************
* Action Listener
/**
* Event Listener
*
* @param e
* event
* @param e event
*/
public void onEvent(Event e) {
// Finish
if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) {
if (paymentForm.checkMandatory()) {
paymentForm.saveChanges(); // cannot recover
paymentForm.saveChanges();
dispose();
}
} else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
dispose();
}
} // actionPerformed
/**
* Handle runProcessOnline event.
* Call {@link PaymentForm#processOnline()}.
*/
public void runProcessOnline() {
try {
paymentForm.processOnline();
@ -140,6 +167,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
}
}
/**
* Unlock and update UI.
*/
public void unlockUI() {
if (!m_isLocked) return;
@ -148,6 +178,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
updateUI();
}
/**
* Lock UI and show in progress dialog.
*/
public void lockUI() {
if (m_isLocked) return;
@ -156,6 +189,9 @@ public class WPaymentFormWindow extends Window implements EventListener<Event>,
showBusyDialog();
}
/**
* Close in progress dialog.
*/
private void hideBusyDialog() {
if (progressWindow != null) {
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() {
if (paymentForm.isApproved())
dispose();
}
/**
* Show in progress window.
*/
private void showBusyDialog() {
progressWindow = new BusyDialog();
progressWindow.setPage(this.getPage());
progressWindow.doHighlighted();
}
/**
* @return true if initialization have been completed sucessfully
*/
public boolean isInitOK()
{
return initOK;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -64,13 +64,13 @@ import org.zkoss.zul.South;
/**
* 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
public class WSQLQuery extends ADForm implements EventListener<Event>
{
/**
*
* generated serial id
*/
private static final long serialVersionUID = -6641250848300700313L;
@ -92,17 +92,17 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
private WListbox listbox = new WListbox();
/**
* REGEX_REMOVE_COMMENTS
* Remove comment
*/
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])*?'";
/**
* REGEX_REMOVE_LEADING_SPACES
* Remove leading space
*/
private static final String REGEX_REMOVE_LEADING_SPACES = "^\\s+";
@ -113,6 +113,9 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
super();
}
/**
* Layout form
*/
@Override
protected void initForm() {
North north = new North();
@ -328,6 +331,7 @@ public class WSQLQuery extends ADForm implements EventListener<Event>
* Process the events for this form
* @param event
*/
@Override
public void onEvent(Event event) throws Exception {
if (event.getTarget() == m_btnSql)
m_txbResultField.setText(processStatement(m_txbSqlField.getText()));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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