created the static method MainWindow.loadDatabase() for easy database reloading

This commit is contained in:
2011-01-21 17:18:30 +00:00
parent a3e2c7872f
commit a25fab8882
5 changed files with 46 additions and 32 deletions

View File

@@ -1,7 +1,7 @@
#---No Comment--- #---No Comment---
#Wed Jan 19 13:29:12 EST 2011 #Thu Jan 20 12:15:15 EST 2011
server_parrword= server_parrword=S35-2n6t
server_location=tcdevsvn1
use_remote_server=true use_remote_server=true
server_location=tcdevsvn1
server_port_number=3306 server_port_number=3306
server_user_name= server_user_name=ricky.barrette

View File

@@ -33,15 +33,15 @@ import com.TwentyCodes.java.OrderProcessor.DB.OrderDB;
*/ */
public class MainWindow extends JFrame implements ActionListener, ProgressListener{ public class MainWindow extends JFrame implements ActionListener, ProgressListener{
private JButton mLoadFileButton; private static JButton mLoadFileButton;
private JFileChooser fc; private JFileChooser fc;
public static OrderDB db; public static OrderDB db;
private static final long serialVersionUID = 1841715561053331517L; private static final long serialVersionUID = 1841715561053331517L;
private JProgressBar mProgressBar; private JProgressBar mProgressBar;
private String mCurrentFile; private String mCurrentFile;
private UncaughtExceptionHandler mExceptionReport = new UncaughtExceptionHandler(this.getClass()); private UncaughtExceptionHandler mExceptionReport = new UncaughtExceptionHandler(this.getClass());
private JLabel orderCountLabel; private static JLabel orderCountLabel;
private JLabel mWarningLabel; private static JLabel mWarningLabel;
/** /**
* Creates a new MainWindow * Creates a new MainWindow
@@ -52,12 +52,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
Thread.setDefaultUncaughtExceptionHandler(mExceptionReport); Thread.setDefaultUncaughtExceptionHandler(mExceptionReport);
this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.setDefaultCloseOperation(EXIT_ON_CLOSE);
try {
db = new OrderDB();
} catch (Exception e) {
e.printStackTrace();
}
fc = new JFileChooser(); fc = new JFileChooser();
fc.setFileFilter(new FileFilter()); fc.setFileFilter(new FileFilter());
@@ -65,7 +59,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
tabbedPane.addTab("Main", initializeMainPanel()); tabbedPane.addTab("Main", initializeMainPanel());
tabbedPane.addTab("Search Orders", new SearchPanel(this)); tabbedPane.addTab("Search Orders", new SearchPanel(this));
tabbedPane.addTab("Show All Orders", new ShowAllPanel(this)); // tabbedPane.addTab("Show All Orders", new ShowAllPanel(this));
tabbedPane.addTab("Settings", new SettingsPanel()); tabbedPane.addTab("Settings", new SettingsPanel());
@@ -95,12 +89,31 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
mWarningLabel = new JLabel(""); mWarningLabel = new JLabel("");
orderCountLabel = new JLabel("");
panel.add(new JLabel("Total Orders in the database:"));
panel.add(orderCountLabel);
loadDatabase();
panel.add(mLoadFileButton);
panel.add(mWarningLabel);
//progress bar
mProgressBar = new JProgressBar();
mProgressBar.setStringPainted(true);
mainPanel.add(mProgressBar, BorderLayout.SOUTH);
return mainPanel;
}
public static void loadDatabase() {
//order count labels //order count labels
try { try {
panel.add(new JLabel("Total Orders in the database:")); db = new OrderDB();
orderCountLabel = new JLabel(db.getCount()+""); orderCountLabel.setText(db.getCount()+"");
panel.add(orderCountLabel); mWarningLabel.setText("");
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
mWarningLabel.setText(e.getMessage()); mWarningLabel.setText(e.getMessage());
@@ -111,19 +124,12 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
} catch (NullPointerException e){ } catch (NullPointerException e){
mWarningLabel.setText("Database not avilable"); mWarningLabel.setText("Database not avilable");
mWarningLabel.setVisible(true); mWarningLabel.setVisible(true);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
panel.add(mLoadFileButton);
panel.add(mWarningLabel);
//progress bar
mProgressBar = new JProgressBar();
mProgressBar.setStringPainted(true);
mainPanel.add(mProgressBar, BorderLayout.SOUTH);
return mainPanel;
} }
/** /**

View File

@@ -182,6 +182,7 @@ public class SettingsPanel extends JPanel implements ActionListener {
// TODO Auto-gene1rated catch block // TODO Auto-gene1rated catch block
e1.printStackTrace(); e1.printStackTrace();
} }
} }
if(e.getSource() == mUseRemoteDatabase){ if(e.getSource() == mUseRemoteDatabase){
@@ -212,5 +213,7 @@ public class SettingsPanel extends JPanel implements ActionListener {
} }
} }
MainWindow.loadDatabase();
} }
} }

View File

@@ -1,19 +1,24 @@
1.0.0 b 28 1.0.0 b 28
fixed the .CSV file parsing with an external lib. fixed the .CSV file parsing with an external lib.
1.0.1 b 29 1.0.1 b 29
created a single window with a tabbed layout for a more fluid experience. created a single window with a tabbed layout for a more fluid experience.
added an overwrite file dialog. added an overwrite file dialog.
added the customer country to the order object. added the customer country to the order object.
updated .CSV export updated .CSV export
1.0.2 b 30 1.0.2 b 30
i replaced the old sqlite driver (for local databases) with the mySQL driver to interface with TCDEVSVN1's order database i replaced the old sqlite driver (for local databases) with the mySQL driver to interface with TCDEVSVN1's order database
1.0.3 b 31 1.0.3 b 31
i improved the speed of file parsing, be making less database hits
1.0.4 b 32
fixed order processing to be more efficient, and i now use BigDecimal to cal money
1.0.5 b 33
i created a settings panel that uses a .property file to save settings. i created a settings panel that uses a .property file to save settings.
i modified OrderDB to use the .property file i modified OrderDB to use the .property file
1.0.6 b 34
created the static method MainWindow.loadDatabase() for easy database reloading

View File

@@ -1 +1 @@
1.0.3 b 31 1.0.6 b 34