BF [ 1874419 ] JDBC Statement not close in a finally block - fixed for AMenu.java

* reorganized imports
* fixed some java warning
This commit is contained in:
teo_sarca 2008-02-07 13:52:41 +00:00
parent f5fbec1f66
commit 19bc8038df
1 changed files with 64 additions and 63 deletions

View File

@ -16,25 +16,62 @@
*****************************************************************************/ *****************************************************************************/
package org.compiere.apps; package org.compiere.apps;
import java.awt.*; import java.awt.BorderLayout;
import java.awt.event.*; import java.awt.Cursor;
import java.beans.*; import java.awt.Dimension;
import java.math.*; import java.awt.Event;
import java.sql.*; import java.awt.Frame;
import java.text.*; import java.awt.GridLayout;
import java.util.*; import java.awt.Insets;
import java.util.logging.*; import java.awt.KeyboardFocusManager;
import javax.swing.*; import java.awt.Point;
import javax.swing.event.*; import java.awt.event.ActionEvent;
// import java.awt.event.ActionListener;
import org.compiere.*; import java.awt.event.KeyEvent;
import org.compiere.apps.wf.*; import java.awt.event.MouseAdapter;
import org.adempiere.apps.graph.*; import java.awt.event.MouseEvent;
import org.compiere.db.*; import java.awt.event.WindowEvent;
import org.compiere.grid.tree.*; import java.awt.event.WindowListener;
import org.compiere.model.*; import java.beans.PropertyChangeEvent;
import org.compiere.swing.*; import java.beans.PropertyChangeListener;
import org.compiere.util.*; import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.Properties;
import java.util.logging.Level;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JProgressBar;
import javax.swing.KeyStroke;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.adempiere.apps.graph.PAPanel;
import org.compiere.Adempiere;
import org.compiere.apps.wf.WFActivity;
import org.compiere.apps.wf.WFPanel;
import org.compiere.grid.tree.VTreePanel;
import org.compiere.model.MRole;
import org.compiere.model.MSession;
import org.compiere.model.MSystem;
import org.compiere.model.MTreeNode;
import org.compiere.model.MUser;
import org.compiere.swing.CButton;
import org.compiere.swing.CFrame;
import org.compiere.swing.CPanel;
import org.compiere.swing.CScrollPane;
import org.compiere.swing.CTabbedPane;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Ini;
import org.compiere.util.Language;
import org.compiere.util.Msg;
import org.compiere.util.Splash;
/** /**
* Application Menu Controller * Application Menu Controller
* *
@ -158,7 +195,7 @@ public final class AMenu extends CFrame
private int m_request_Menu_ID = 0; private int m_request_Menu_ID = 0;
private int m_note_Menu_ID = 0; private int m_note_Menu_ID = 0;
private String m_requestSQL = null; private String m_requestSQL = null;
private DecimalFormat m_memoryFormat = DisplayType.getNumberFormat(DisplayType.Integer); // private DecimalFormat m_memoryFormat = DisplayType.getNumberFormat(DisplayType.Integer);
/** Logger */ /** Logger */
private static CLogger log = CLogger.getCLogger(AMenu.class); private static CLogger log = CLogger.getCLogger(AMenu.class);
@ -209,9 +246,7 @@ public final class AMenu extends CFrame
} }
// Check DB (AppsServer Version checked in Login) // Check DB (AppsServer Version checked in Login)
boolean dbOK = DB.isDatabaseOK(m_ctx); DB.isDatabaseOK(m_ctx);
// if (!dbOK)
// AEnv.exit(1);
} // initSystem } // initSystem
// UI // UI
@ -548,29 +583,14 @@ public final class AMenu extends CFrame
/** /**
* Get number of open Notes * Get number of open Notes
* @return bumber of notes * @return number of notes
*/ */
private int getNotes() private int getNotes()
{ {
int retValue = 0;
String sql = "SELECT COUNT(1) FROM AD_Note " String sql = "SELECT COUNT(1) FROM AD_Note "
+ "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)" + "WHERE AD_Client_ID=? AND AD_User_ID IN (0,?)"
+ " AND Processed='N'"; + " AND Processed='N'";
try int retValue = DB.getSQLValue(null, sql, Env.getAD_Client_ID(Env.getCtx()), m_AD_User_ID);
{
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
pstmt.setInt(2, m_AD_User_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, sql, e);
}
return retValue; return retValue;
} // getNotes } // getNotes
@ -596,28 +616,13 @@ public final class AMenu extends CFrame
*/ */
private int getRequests() private int getRequests()
{ {
int retValue = 0;
if (m_requestSQL == null) if (m_requestSQL == null)
m_requestSQL = MRole.getDefault().addAccessSQL ("SELECT COUNT(1) FROM R_Request " m_requestSQL = MRole.getDefault().addAccessSQL ("SELECT COUNT(1) FROM R_Request "
+ "WHERE (SalesRep_ID=? OR AD_Role_ID=?) AND Processed='N'" + "WHERE (SalesRep_ID=? OR AD_Role_ID=?) AND Processed='N'"
+ " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))" + " AND (DateNextAction IS NULL OR TRUNC(DateNextAction) <= TRUNC(SysDate))"
+ " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))", + " AND (R_Status_ID IS NULL OR R_Status_ID IN (SELECT R_Status_ID FROM R_Status WHERE IsClosed='N'))",
"R_Request", false, true); // not qualified - RW "R_Request", false, true); // not qualified - RW
try int retValue = DB.getSQLValue(null, m_requestSQL, m_AD_User_ID, m_AD_Role_ID);
{
PreparedStatement pstmt = DB.prepareStatement(m_requestSQL, null);
pstmt.setInt(1, m_AD_User_ID);
pstmt.setInt(2, m_AD_Role_ID);
ResultSet rs = pstmt.executeQuery();
if (rs.next())
retValue = rs.getInt(1);
rs.close();
pstmt.close();
}
catch (SQLException e)
{
log.log(Level.SEVERE, m_requestSQL, e);
}
return retValue; return retValue;
} // getRequests } // getRequests
@ -748,19 +753,15 @@ public final class AMenu extends CFrame
*/ */
public static void main(String[] args) public static void main(String[] args)
{ {
Splash splash = Splash.getSplash(); Splash.getSplash();
Adempiere.startup(true); // needs to be here for UI Adempiere.startup(true); // needs to be here for UI
AMenu menu = new AMenu(); new AMenu();
} // main } // main
class InfoUpdater implements Runnable class InfoUpdater implements Runnable
{ {
boolean stop = false; boolean stop = false;
public void InfoUpdater()
{
}
public void run() public void run()
{ {
while(stop == false) while(stop == false)
@ -768,7 +769,7 @@ public final class AMenu extends CFrame
updateInfo(); updateInfo();
try { try {
Thread.currentThread().sleep(60000); Thread.sleep(60000);
} catch(InterruptedException ire) { } } catch(InterruptedException ire) { }
} }
} }