VPAttribute(Dialog):

* BF [ 1874419 ] JDBC Statement not close in a finally block
* organized imports
This commit is contained in:
teo_sarca 2008-02-18 14:10:26 +00:00
parent f0d46ccd6b
commit a15b92ec31
2 changed files with 86 additions and 33 deletions

View File

@ -16,17 +16,36 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.grid.ed; package org.compiere.grid.ed;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Color;
import java.beans.*; import java.awt.Component;
import java.util.logging.*; import java.awt.Dimension;
import javax.swing.*; import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import javax.swing.JComponent;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.LookAndFeel;
import javax.swing.SwingUtilities;
import org.adempiere.plaf.AdempierePLAF; import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.AWindow; import org.compiere.model.GridField;
import org.compiere.model.*; import org.compiere.model.GridTab;
import org.compiere.swing.*; import org.compiere.model.MAttributeSet;
import org.compiere.util.*; import org.compiere.model.MPAttributeLookup;
import org.compiere.model.MProduct;
import org.compiere.swing.CButton;
import org.compiere.swing.CMenuItem;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
/** /**
* Product Attribute Set Instance Editor * Product Attribute Set Instance Editor

View File

@ -16,19 +16,60 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.grid.ed; package org.compiere.grid.ed;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Component;
import java.math.*; import java.awt.Cursor;
import java.sql.*; import java.awt.Dimension;
import java.util.*; import java.awt.Font;
import java.util.logging.*; import java.awt.Frame;
import javax.swing.*; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.math.BigDecimal;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.apps.*; import javax.swing.JPopupMenu;
import org.compiere.apps.search.*; import javax.swing.SwingConstants;
import org.compiere.model.*; import javax.swing.SwingUtilities;
import org.compiere.swing.*;
import org.compiere.util.*; import org.compiere.apps.ADialog;
import org.compiere.apps.AEnv;
import org.compiere.apps.ALayout;
import org.compiere.apps.ALayoutConstraint;
import org.compiere.apps.AWindow;
import org.compiere.apps.ConfirmPanel;
import org.compiere.apps.search.PAttributeInstance;
import org.compiere.model.MAttribute;
import org.compiere.model.MAttributeInstance;
import org.compiere.model.MAttributeSet;
import org.compiere.model.MAttributeSetInstance;
import org.compiere.model.MAttributeValue;
import org.compiere.model.MDocType;
import org.compiere.model.MLot;
import org.compiere.model.MLotCtl;
import org.compiere.model.MQuery;
import org.compiere.model.MRole;
import org.compiere.model.MSerNoCtl;
import org.compiere.model.X_M_MovementLine;
import org.compiere.swing.CButton;
import org.compiere.swing.CCheckBox;
import org.compiere.swing.CComboBox;
import org.compiere.swing.CDialog;
import org.compiere.swing.CEditor;
import org.compiere.swing.CLabel;
import org.compiere.swing.CMenuItem;
import org.compiere.swing.CPanel;
import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
/** /**
* Product Attribute Set Product/Instance Dialog Editor. * Product Attribute Set Product/Instance Dialog Editor.
@ -524,33 +565,26 @@ public class VPAttributeDialog extends CDialog
+ "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID" + "WHERE p.M_Product_ID=? AND w.M_Warehouse_ID"
+ (M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)"); // teo_sarca [ 1564520 ] + (M_Locator_ID <= 0 ? "=?" : " IN (SELECT M_Warehouse_ID FROM M_Locator where M_Locator_ID=?)"); // teo_sarca [ 1564520 ]
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
try try
{ {
pstmt = DB.prepareStatement(sql, null); pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, m_M_Product_ID); pstmt.setInt(1, m_M_Product_ID);
pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID); pstmt.setInt(2, M_Locator_ID <= 0 ? M_Warehouse_ID : M_Locator_ID);
ResultSet rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) { if (rs.next()) {
title = rs.getString(1) + " - " + rs.getString(2); title = rs.getString(1) + " - " + rs.getString(2);
M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ] M_Warehouse_ID = rs.getInt(3); // fetch the actual warehouse - teo_sarca [ 1564520 ]
} }
rs.close();
pstmt.close();
pstmt = null;
} }
catch (Exception e) catch (Exception e)
{ {
log.log(Level.SEVERE, sql, e); log.log(Level.SEVERE, sql, e);
} }
try finally
{ {
if (pstmt != null) DB.close(rs, pstmt);
pstmt.close(); rs = null; pstmt = null;
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
} }
// //
PAttributeInstance pai = new PAttributeInstance(this, title, PAttributeInstance pai = new PAttributeInstance(this, title,