From 740908e0c528294ec4dfe5cdbedbe989eb6f27fc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Thu, 20 Dec 2012 15:46:40 -0500 Subject: [PATCH] IDEMPIERE-455 Discover and fix FindBugs problems / Eclipse warning -> dead code --- .../compiere/process/ReplicationLocal.java | 11 +--- org.adempiere.base/src/org/compiere/Base.java | 4 +- .../src/org/compiere/db/LDAP.java | 4 +- .../impexp/OFXFileBankStatementLoader.java | 8 +-- .../src/org/compiere/model/MEXPFormat.java | 4 +- .../src/org/compiere/model/MIssue.java | 12 ++-- .../org/compiere/model/MMovementConfirm.java | 4 +- .../src/org/compiere/model/MTemplate.java | 3 - .../org/compiere/model/NaturalAccountMap.java | 4 +- .../src/org/compiere/model/PO.java | 1 + .../src/org/compiere/print/ArchiveEngine.java | 12 ++-- .../src/org/compiere/util/Secure.java | 6 +- .../process/ExportFormatGenerator.java | 15 ++--- .../pipo/handler/DataElementHandler.java | 4 +- .../org/compiere/server/AlertProcessor.java | 22 ++----- .../adempiere/apps/graph/FCHtmlEditorKit.java | 22 +++---- .../src/org/adempiere/plaf/AdempierePLAF.java | 8 +-- .../compiere/apps/form/VTreeMaintenance.java | 2 +- .../src/org/compiere/grid/VPanel.java | 8 +-- .../src/org/compiere/util/IniDialog.java | 4 +- .../webui/panel/InfoCashLinePanel.java | 16 +++-- .../adempiere/webui/panel/InfoInOutPanel.java | 16 +++-- .../webui/panel/InfoPaymentPanel.java | 64 ++++++++++++++----- 23 files changed, 138 insertions(+), 116 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java b/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java index cddc337828..5fffb0e8d4 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java @@ -559,8 +559,6 @@ public class ReplicationLocal extends SvrProcess // ResultSet rs = pstmt.executeQuery(); rowSet = CCachedRowSet.getRowSet(rs); - pstmt.close(); - pstmt = null; } catch (Exception ex) { @@ -568,16 +566,11 @@ public class ReplicationLocal extends SvrProcess throw new RuntimeException (ex); } // Close Cursor - try + finally { - if (pstmt != null) - pstmt.close(); + DB.close(pstmt); pstmt = null; } - catch (Exception e) - { - s_log.log(Level.SEVERE, "close pstmt", e); - } return rowSet; } // getRowSet diff --git a/org.adempiere.base/src/org/compiere/Base.java b/org.adempiere.base/src/org/compiere/Base.java index 1c1d0f56fc..e0c8f41798 100644 --- a/org.adempiere.base/src/org/compiere/Base.java +++ b/org.adempiere.base/src/org/compiere/Base.java @@ -59,12 +59,12 @@ class Base GridWindow w = new GridWindow(vo); long endDef = System.currentTimeMillis(); System.out.println("Load Definition Time in ms = " + String.valueOf(endDef-startTime)); - if (1==2) // optional step + /*if (1==2) // optional step { w.loadCompete(); long endDefComplete = System.currentTimeMillis(); System.out.println("Load Definition Complete Time in ms = " + String.valueOf(endDefComplete-startTime)); - } + }*/ w.query(); long endData = System.currentTimeMillis(); System.out.println("Load Data Time in ms = " + String.valueOf(endData-startTime)); diff --git a/org.adempiere.base/src/org/compiere/db/LDAP.java b/org.adempiere.base/src/org/compiere/db/LDAP.java index 3bc7257edc..47dd6816d4 100644 --- a/org.adempiere.base/src/org/compiere/db/LDAP.java +++ b/org.adempiere.base/src/org/compiere/db/LDAP.java @@ -69,8 +69,8 @@ public class LDAP Attributes answer = ctx.getAttributes(""); // Print the answer - if (false) - dump (answer); + //if (false) + // dump (answer); } catch (AuthenticationException e) { diff --git a/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java b/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java index 4b8a4cfa4f..bc444d6d98 100644 --- a/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java +++ b/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java @@ -61,10 +61,10 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im { return result; } - if (m_stream == null) - { - return result; - } + //if (m_stream == null) + //{ + //return result; + //} result = attachInput(m_stream); } catch(Exception e) diff --git a/org.adempiere.base/src/org/compiere/model/MEXPFormat.java b/org.adempiere.base/src/org/compiere/model/MEXPFormat.java index 7a2c38259b..40b3298b65 100644 --- a/org.adempiere.base/src/org/compiere/model/MEXPFormat.java +++ b/org.adempiere.base/src/org/compiere/model/MEXPFormat.java @@ -129,8 +129,8 @@ public class MEXPFormat extends X_EXP_Format { { String key = new String(value+version); MEXPFormat retValue=null; - if(retValue!=null) - return retValue; + //if(retValue!=null) + // return retValue; StringBuilder whereClause = new StringBuilder(X_EXP_Format.COLUMNNAME_Value).append("=?") .append(" AND AD_Client_ID = ?") diff --git a/org.adempiere.base/src/org/compiere/model/MIssue.java b/org.adempiere.base/src/org/compiere/model/MIssue.java index 50662876aa..a7c6fce69c 100644 --- a/org.adempiere.base/src/org/compiere/model/MIssue.java +++ b/org.adempiere.base/src/org/compiere/model/MIssue.java @@ -416,9 +416,9 @@ public class MIssue extends X_AD_Issue */ public String report() { - if (true) - return "-"; - StringBuilder parameter = new StringBuilder("?"); + //if (true) + return "-"; + /*StringBuilder parameter = new StringBuilder("?"); if (getRecord_ID() == 0) // don't report return "ID=0"; if (getRecord_ID() == 1) // new @@ -479,7 +479,7 @@ public class MIssue extends X_AD_Issue } return msg.toString(); } - return readResponse(in); + return readResponse(in);*/ } // report /** @@ -487,7 +487,7 @@ public class MIssue extends X_AD_Issue * @param in input stream * @return error message */ - private String readResponse(InputStreamReader in) + /*private String readResponse(InputStreamReader in) { StringBuilder sb = new StringBuilder(); int Record_ID = 0; @@ -539,7 +539,7 @@ public class MIssue extends X_AD_Issue if (RequestDocumentNo != null) setRequestDocumentNo(RequestDocumentNo); return null; - } // readResponse + } // readResponse*/ /** * String Representation diff --git a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java index 0e78e9fcfc..a21a4bb9bb 100644 --- a/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java +++ b/org.adempiere.base/src/org/compiere/model/MMovementConfirm.java @@ -59,9 +59,9 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction if (checkExisting) { MMovementConfirm[] confirmations = move.getConfirmations(false); - for (int i = 0; i < confirmations.length; i++) + if (confirmations.length > 0) { - MMovementConfirm confirm = confirmations[i]; + MMovementConfirm confirm = confirmations[0]; return confirm; } } diff --git a/org.adempiere.base/src/org/compiere/model/MTemplate.java b/org.adempiere.base/src/org/compiere/model/MTemplate.java index 2908f2df12..e6bcc03eaf 100644 --- a/org.adempiere.base/src/org/compiere/model/MTemplate.java +++ b/org.adempiere.base/src/org/compiere/model/MTemplate.java @@ -50,9 +50,6 @@ public class MTemplate extends X_CM_Template public static MTemplate get (Properties ctx, int CM_Template_ID, String trxName) { MTemplate retValue = new MTemplate (ctx, CM_Template_ID, trxName); - if (retValue != null) - return retValue; - retValue = new MTemplate (ctx, CM_Template_ID, null); return retValue; } // get diff --git a/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java b/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java index 96dc438e7f..6121fead12 100644 --- a/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java +++ b/org.adempiere.base/src/org/compiere/model/NaturalAccountMap.java @@ -192,10 +192,10 @@ public final class NaturalAccountMap extends CCache { String s = st.nextToken().trim(); // Ignore, if is it header line - if (s.startsWith("[") && s.endsWith("]")) - return ""; if (s == null) s = ""; + if (s.startsWith("[") && s.endsWith("]")) + return ""; // if (i == 0) // A - Value Value = s; diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index d9c3038c66..58e9660c82 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -1957,6 +1957,7 @@ public abstract class PO * To reload call load() - not updated * @return true if saved */ + @SuppressWarnings("unused") public boolean save() { CLogger.resetLast(); diff --git a/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java b/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java index db23742186..ee00b5079d 100644 --- a/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ArchiveEngine.java @@ -60,18 +60,18 @@ public class ArchiveEngine // Do we need to Archive ? MClient client = MClient.get(layout.getCtx()); String aaClient = client.getAutoArchive(); - String aaRole = null; // role.getAutoArchive(); // TODO String aa = aaClient; if (aa == null) aa = MClient.AUTOARCHIVE_None; + /* String aaRole = null; // role.getAutoArchive(); // TODO if (aaRole != null) { if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments)) aa = aaRole; else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments)) aa = aaRole; - } - // Mothing to Archive + }*/ + // Nothing to Archive if (aa.equals(MClient.AUTOARCHIVE_None)) return null; // Archive External only @@ -110,18 +110,18 @@ public class ArchiveEngine // Do we need to Archive ? MClient client = MClient.get(Env.getCtx()); String aaClient = client.getAutoArchive(); - String aaRole = null; // role.getAutoArchive(); // TODO String aa = aaClient; if (aa == null) aa = MClient.AUTOARCHIVE_None; + /* String aaRole = null; // role.getAutoArchive(); // TODO if (aaRole != null) { if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments)) aa = aaRole; else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments)) aa = aaRole; - } - // Mothing to Archive + }*/ + // Nothing to Archive if (aa.equals(MClient.AUTOARCHIVE_None)) return; // Archive External only diff --git a/org.adempiere.base/src/org/compiere/util/Secure.java b/org.adempiere.base/src/org/compiere/util/Secure.java index d6fa0c4492..8b88d34734 100644 --- a/org.adempiere.base/src/org/compiere/util/Secure.java +++ b/org.adempiere.base/src/org/compiere/util/Secure.java @@ -152,7 +152,7 @@ public class Secure implements SecureInterface { cc = Cipher.getInstance("DES/ECB/PKCS5Padding"); // Key - if (false) + /*if (false) { KeyGenerator keygen = KeyGenerator.getInstance("DES"); m_key = keygen.generateKey(); @@ -164,8 +164,8 @@ public class Secure implements SecureInterface sb.append(key[i]).append(","); log.info(sb.toString()); } - else - m_key = new javax.crypto.spec.SecretKeySpec + else*/ + m_key = new javax.crypto.spec.SecretKeySpec (new byte[] {100,25,28,-122,-26,94,-3,-26}, "DES"); } catch (Exception ex) diff --git a/org.adempiere.base/src/org/eevolution/process/ExportFormatGenerator.java b/org.adempiere.base/src/org/eevolution/process/ExportFormatGenerator.java index 343cfeaa7b..7519d2e5af 100644 --- a/org.adempiere.base/src/org/eevolution/process/ExportFormatGenerator.java +++ b/org.adempiere.base/src/org/eevolution/process/ExportFormatGenerator.java @@ -335,21 +335,16 @@ public class ExportFormatGenerator extends SvrProcess tabledir = MTable.get(getCtx(), tableName); if(tabledir==null) return 0; - // throw new Exception ("Ilegal Table Name"); + // throw new Exception ("Illegal Table Name"); formatLine.setValue(tabledir.getTableName()+"_Reference"); formatLine.setName("Referenced "+ tabledir.getTableName()); //formatLine.setType(MEXPFormatLine.TYPE_XMLElement); - if (tabledir!=null) - { - String format_value = createFormat(tabledir); - int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID(); - formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat); - formatLine.setEXP_EmbeddedFormat_ID(embedded); - } - else - formatLine.setType(MEXPFormatLine.TYPE_XMLElement); + String format_value = createFormat(tabledir); + int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID(); + formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat); + formatLine.setEXP_EmbeddedFormat_ID(embedded); } formatLine.setAD_Column_ID(col.getAD_Column_ID()); formatLine.saveEx(); diff --git a/org.adempiere.pipo.legacy/src/org/adempiere/pipo/handler/DataElementHandler.java b/org.adempiere.pipo.legacy/src/org/adempiere/pipo/handler/DataElementHandler.java index b3621d2baf..c56f98abfd 100644 --- a/org.adempiere.pipo.legacy/src/org/adempiere/pipo/handler/DataElementHandler.java +++ b/org.adempiere.pipo.legacy/src/org/adempiere/pipo/handler/DataElementHandler.java @@ -183,14 +183,14 @@ public class DataElementHandler extends AbstractElementHandler { } // for debug GenericPO. - if (false) { + /*if (false) { POInfo poInfo = POInfo.getPOInfo(ctx, get_ID(ctx, "AD_Table", d_tablename), getTrxName(ctx)); if (poInfo == null) log.info("poInfo is null."); for (int i = 0; i < poInfo.getColumnCount(); i++) { log.info(d_tablename+" column: "+poInfo.getColumnName(i)); } - } + }*/ // globalqss: set AD_Client_ID to the client setted in adempieredata if (getClientId(ctx) > 0 && genericPO.getAD_Client_ID() != getClientId(ctx)) genericPO.set_ValueOfColumn("AD_Client_ID", getClientId(ctx)); diff --git a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java index f647def48f..f2c2810660 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/AlertProcessor.java @@ -136,7 +136,6 @@ public class AlertProcessor extends AdempiereServer { if (i > 0) message.append(Env.NL); - String trxName = null; // assume r/o MAlertRule rule = rules[i]; if (!rule.isValid()) @@ -147,7 +146,7 @@ public class AlertProcessor extends AdempiereServer String sql = rule.getPreProcessing(); if (sql != null && sql.length() > 0) { - int no = DB.executeUpdate(sql, false, trxName); + int no = DB.executeUpdate(sql, false, null); if (no == -1) { ValueNamePair error = CLogger.retrieveError(); @@ -166,9 +165,9 @@ public class AlertProcessor extends AdempiereServer { String text = null; if (MSysConfig.getBooleanValue(MSysConfig.ALERT_SEND_ATTACHMENT_AS_XLS, true, Env.getAD_Client_ID(getCtx()))) - text = getExcelReport(rule, sql, trxName, attachments); + text = getExcelReport(rule, sql, null, attachments); else - text = getPlainTextReport(rule, sql, trxName, attachments); + text = getPlainTextReport(rule, sql, null, attachments); if (text != null && text.length() > 0) { message.append(text); @@ -189,7 +188,7 @@ public class AlertProcessor extends AdempiereServer sql = rule.getPostProcessing(); if (sql != null && sql.length() > 0) { - int no = DB.executeUpdate(sql, false, trxName); + int no = DB.executeUpdate(sql, false, null); if (no == -1) { ValueNamePair error = CLogger.retrieveError(); @@ -201,17 +200,7 @@ public class AlertProcessor extends AdempiereServer break; } } // Post - - /** Trx */ - if (trxName != null) - { - Trx trx = Trx.get(trxName, false); - if (trx != null) - { - trx.commit(); - trx.close(); - } - } + } // for all rules // Update header if error @@ -361,7 +350,6 @@ public class AlertProcessor extends AdempiereServer * @param attachments (ignored) * @return list of rows & values * @throws Exception - * @deprecated */ private String getPlainTextReport(MAlertRule rule, String sql, String trxName, Collection attachments) throws Exception diff --git a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java index 574903144d..643f506906 100644 --- a/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java +++ b/org.adempiere.ui.swing/src/org/adempiere/apps/graph/FCHtmlEditorKit.java @@ -73,20 +73,20 @@ public class FCHtmlEditorKit extends HTMLEditorKit { // state where it thinks that image was loaded. // ImageView is calling getImage to get image for // measurement and painting when image was loaded - if (false) { + /*if (false) { return getClass().getClassLoader(). getResource("javax/swing/text/html/icons/image-delayed.gif"); - } else { - String src = (String)elem.getAttributes(). - getAttribute(HTML.Attribute.SRC); - //System.out.println("img load: " + src.substring(4)); - URL url = getClass().getClassLoader(). - getResource(src.substring(4)); - if (url != null) { - // System.out.println("load image: " + url); - return url; - } + } else {*/ + String src = (String)elem.getAttributes(). + getAttribute(HTML.Attribute.SRC); + //System.out.println("img load: " + src.substring(4)); + URL url = getClass().getClassLoader(). + getResource(src.substring(4)); + if (url != null) { + // System.out.println("load image: " + url); + return url; } + //} return null; } private static Image smileImage = null; diff --git a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java index 7e86a7d51c..8e5c30d52b 100644 --- a/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java +++ b/org.adempiere.ui.swing/src/org/adempiere/plaf/AdempierePLAF.java @@ -701,14 +701,14 @@ public final class AdempierePLAF try { Method[] methods = startClass.getMethods(); - for (int i = 0; i < methods.length; i++) + if (methods.length > 0) { - if (Modifier.isStatic(methods[i].getModifiers()) && methods[i].getName().equals("main")) + if (Modifier.isStatic(methods[0].getModifiers()) && methods[0].getName().equals("main")) { String[] startArgs = new String[args.length-1]; for (int ii = 1; ii < args.length; ii++) - startArgs[ii-i] = args[ii]; - methods[i].invoke(null, new Object[] {startArgs}); + startArgs[ii] = args[ii]; + methods[0].invoke(null, new Object[] {startArgs}); } return; } diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java index f1390f36ee..9a55d4c2f2 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/form/VTreeMaintenance.java @@ -244,9 +244,9 @@ public class VTreeMaintenance extends TreeMaintenance public void propertyChange (PropertyChangeEvent e) { MTreeNode tn = (MTreeNode)e.getNewValue(); - log.info(tn.toString()); if (tn == null) return; + log.info(tn.toString()); ListModel model = centerList.getModel(); int size = model.getSize(); int index = -1; diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java b/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java index 25300dbbc9..4615f1e9c8 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/VPanel.java @@ -355,10 +355,10 @@ public final class VPanel extends CTabbedPane fieldMinWidth = field.getPreferredSize().width > fieldMinWidth ? field.getPreferredSize().width : fieldMinWidth; } // Link Label to Field - if (label != null) - label.setLabelFor(field); - else if (mField.isCreateMnemonic()) - setMnemonic(editor, mField.getMnemonic()); + //if (label != null) + label.setLabelFor(field); + //else if (mField.isCreateMnemonic()) + //setMnemonic(editor, mField.getMnemonic()); } } // addField diff --git a/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java b/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java index b1d7a0d09b..81ae3d535c 100644 --- a/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/util/IniDialog.java @@ -68,8 +68,8 @@ public final class IniDialog extends JDialog implements ActionListener log.warning("No license in resource "); url = new URL("http://www.adempiere.org/license.htm"); } - if (url == null) - cmd_reject(); + //if (url == null) + //cmd_reject(); // licensePane.setPage(url); AdempierePLAF.showCenterScreen(this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java index 52dfe412ee..5672530611 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoCashLinePanel.java @@ -326,10 +326,14 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { Date f = fDateFrom.getValue(); - Timestamp from = new Timestamp(f.getTime()); + Timestamp from = null; + if (f != null) + from = new Timestamp(f.getTime()); Date t = fDateTo.getValue(); - Timestamp to = new Timestamp(t.getTime()); + Timestamp to = null; + if (t != null) + to = new Timestamp(t.getTime()); if (from == null && to != null) sql.append(" AND TRUNC(c.StatementDate) <= ?"); @@ -401,10 +405,14 @@ public class InfoCashLinePanel extends InfoPanel implements ValueChangeListener, if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { Date f = fDateFrom.getValue(); - Timestamp from = new Timestamp(f.getTime()); + Timestamp from = null; + if (f != null) + from = new Timestamp(f.getTime()); Date t = fDateTo.getValue(); - Timestamp to = new Timestamp(t.getTime()); + Timestamp to = null; + if (t != null) + to = new Timestamp(t.getTime()); log.fine("Date From=" + from + ", To=" + to); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java index b6f13377a6..58c41470e6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoInOutPanel.java @@ -311,10 +311,14 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { Date f = fDateFrom.getValue(); - Timestamp from = new Timestamp(f.getTime()); + Timestamp from = null; + if (f != null) + from = new Timestamp(f.getTime()); Date t = fDateTo.getValue(); - Timestamp to = new Timestamp(t.getTime()); + Timestamp to = null; + if (t != null) + to = new Timestamp(t.getTime()); if (from == null && to != null) sql.append(" AND TRUNC(i.MovementDate) <= ?"); @@ -359,10 +363,14 @@ public class InfoInOutPanel extends InfoPanel implements ValueChangeListener, Ev if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { Date f = fDateFrom.getValue(); - Timestamp from = new Timestamp(f.getTime()); + Timestamp from = null; + if (f != null) + from = new Timestamp(f.getTime()); Date t = fDateTo.getValue(); - Timestamp to = new Timestamp(t.getTime()); + Timestamp to = null; + if (t != null) + to = new Timestamp(t.getTime()); log.fine("Date From=" + from + ", To=" + to); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java index f04c9e5303..2f4a1c11a9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPaymentPanel.java @@ -45,6 +45,7 @@ import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; +import org.zkoss.zk.ui.WrongValueException; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; @@ -310,17 +311,15 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener, if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { + Date f = fDateFrom.getValue(); Timestamp from = null; - if (fDateFrom.getValue() != null) { - Date f = fDateFrom.getValue(); + if (f != null) from = new Timestamp(f.getTime()); - } + Date t = fDateTo.getValue(); Timestamp to = null; - if (fDateTo.getValue() != null) { - Date t = fDateTo.getValue(); + if (t != null) to = new Timestamp(t.getTime()); - } if (from == null && to != null) sql.append(" AND TRUNC(p.DateTrx) <= ?"); @@ -332,8 +331,25 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener, if (!"".equals(fAmtFrom.getText()) || !"".equals(fAmtTo.getText())) { - BigDecimal from = new BigDecimal(fAmtFrom.getValue()); - BigDecimal to = new BigDecimal(fAmtTo.getValue()); + String f = fAmtFrom.getValue(); + BigDecimal from = null; + if (f != null) { + try { + from = new BigDecimal(fAmtFrom.getValue()); + } catch (NumberFormatException e) { + fAmtFrom.setValue(null); + } + } + + String t = fAmtTo.getValue(); + BigDecimal to = null; + if (t != null) { + try { + to = new BigDecimal(fAmtTo.getValue()); + } catch (NumberFormatException e) { + fAmtTo.setValue(null); + } + } if (from == null && to != null) sql.append(" AND p.PayAmt <= ?"); @@ -373,17 +389,15 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener, if (fDateFrom.getValue() != null || fDateTo.getValue() != null) { + Date f = fDateFrom.getValue(); Timestamp from = null; - if (fDateFrom.getValue() != null) { - Date f = fDateFrom.getValue(); + if (f != null) from = new Timestamp(f.getTime()); - } + Date t = fDateTo.getValue(); Timestamp to = null; - if (fDateTo.getValue() != null) { - Date t = fDateTo.getValue(); + if (t != null) to = new Timestamp(t.getTime()); - } log.fine("Date From=" + from + ", To=" + to); @@ -400,8 +414,26 @@ public class InfoPaymentPanel extends InfoPanel implements ValueChangeListener, if (!"".equals(fAmtFrom.getText()) || !"".equals(fAmtTo.getText())) { - BigDecimal from = new BigDecimal(fAmtFrom.getValue()); - BigDecimal to = new BigDecimal(fAmtTo.getValue()); + String f = fAmtFrom.getValue(); + BigDecimal from = null; + if (f != null) { + try { + from = new BigDecimal(fAmtFrom.getValue()); + } catch (NumberFormatException e) { + fAmtFrom.setValue(null); + } + } + + String t = fAmtTo.getValue(); + BigDecimal to = null; + if (t != null) { + try { + to = new BigDecimal(fAmtTo.getValue()); + } catch (NumberFormatException e) { + fAmtTo.setValue(null); + } + } + log.fine("Amt From=" + from + ", To=" + to); if (from == null && to != null)