re-added the show all dialog.

MainWinod.java, reorganized the constructor so the progress bar will be indeterminate when connecting to the database
This commit is contained in:
2011-01-23 02:51:58 +00:00
parent f9a805803c
commit 7d1fe95e5a
5 changed files with 43 additions and 45 deletions

View File

@@ -1,7 +1,7 @@
#---No Comment--- #---No Comment---
#Sat Jan 22 14:59:35 EST 2011 #Sat Jan 22 21:42:25 EST 2011
server_parrword=S35-2n6t 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=ricky.barrette server_user_name=ricky.barrette

View File

@@ -37,7 +37,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
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 static JProgressBar mProgressBar;
private String mCurrentFile; private String mCurrentFile;
private UncaughtExceptionHandler mExceptionReport = new UncaughtExceptionHandler(this.getClass()); private UncaughtExceptionHandler mExceptionReport = new UncaughtExceptionHandler(this.getClass());
private static JLabel orderCountLabel; private static JLabel orderCountLabel;
@@ -59,14 +59,17 @@ 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());
mProgressBar.setString(null);
mProgressBar.setIndeterminate(false);
this.getContentPane().add(tabbedPane, BorderLayout.CENTER); this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
this.setVisible(true); this.setVisible(true);
this.pack(); this.pack();
loadDatabase();
} }
/** /**
@@ -82,20 +85,16 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
JPanel panel = new JPanel(); JPanel panel = new JPanel();
mainPanel.add(panel); mainPanel.add(panel);
//load button //load button
mLoadFileButton = new JButton("Load File", new ImageIcon(getClass().getResource("/database_add.png"))); mLoadFileButton = new JButton("Load File", new ImageIcon(getClass().getResource("/database_add.png")));
mLoadFileButton.addActionListener(this); mLoadFileButton.addActionListener(this);
mWarningLabel = new JLabel(""); mWarningLabel = new JLabel("");
orderCountLabel = new JLabel(""); orderCountLabel = new JLabel("");
panel.add(new JLabel("Total Orders in the database:")); panel.add(new JLabel("Total Orders in the database:"));
panel.add(orderCountLabel); panel.add(orderCountLabel);
loadDatabase();
panel.add(mLoadFileButton); panel.add(mLoadFileButton);
panel.add(mWarningLabel); panel.add(mWarningLabel);
@@ -103,32 +102,39 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
//progress bar //progress bar
mProgressBar = new JProgressBar(); mProgressBar = new JProgressBar();
mProgressBar.setStringPainted(true); mProgressBar.setStringPainted(true);
mainPanel.add(mProgressBar, BorderLayout.SOUTH); mainPanel.add(mProgressBar, BorderLayout.SOUTH);
return mainPanel; return mainPanel;
} }
public static void loadDatabase() { public static void loadDatabase() {
//order count labels mProgressBar.setString("Connecting to database");
try { mProgressBar.setIndeterminate(true);
db = new OrderDB(); java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
orderCountLabel.setText(db.getCount()+""); public void run() {
mWarningLabel.setText("");
} catch (SQLException e) { //order count labels
e.printStackTrace(); try {
mWarningLabel.setText(e.getMessage()); db = new OrderDB();
mWarningLabel.setVisible(true); orderCountLabel.setText(db.getCount()+"");
} catch (SocketException e) { mWarningLabel.setText(null);
mWarningLabel.setText(e.getMessage()); } catch (SQLException e) {
mWarningLabel.setVisible(true); e.printStackTrace();
} catch (NullPointerException e){ mWarningLabel.setText(e.getMessage());
mWarningLabel.setText("Database not avilable"); mWarningLabel.setVisible(true);
mWarningLabel.setVisible(true); } catch (SocketException e) {
} catch (ClassNotFoundException e) { mWarningLabel.setText(e.getMessage());
// TODO Auto-generated catch block mWarningLabel.setVisible(true);
e.printStackTrace(); } catch (NullPointerException e){
} mWarningLabel.setText("Database not avilable");
mWarningLabel.setVisible(true);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
mProgressBar.setString(null);
mProgressBar.setIndeterminate(false);
}
});
} }
@@ -155,7 +161,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
public void run() { public void run() {
try { try {
db.load(fc.getSelectedFile()); db.load(fc.getSelectedFile());
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} catch (SQLException e) { } catch (SQLException e) {

View File

@@ -58,7 +58,7 @@ public class OrderPane extends JScrollPane {
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {
if(mListener != null) if(mListener != null)
mListener.onProgressUpdate("Processing Order: "+ (i+1) +" of "+ list.size(), false, i, list.size()); mListener.onProgressUpdate("Processing Order: "+ (i+1) +" of "+ list.size(), false, (i+1), list.size());
try { try {
switch (list.get(i).getFulfillmentStatus()) { switch (list.get(i).getFulfillmentStatus()) {

View File

@@ -49,33 +49,22 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
add(ok, BorderLayout.NORTH); add(ok, BorderLayout.NORTH);
mProgressBar.setString("Loading from Database"); mProgressBar.setString("Loading from Database");
mProgressBar.setStringPainted(true); mProgressBar.setStringPainted(true);
try {
MainWindow.db.setOnProgressListerner(this);
} catch (NullPointerException e) {
e.printStackTrace();
mOutput.setText("Database not initialized");
}
frame.pack(); frame.pack();
setVisible(true); setVisible(true);
} }
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
MainWindow.db.setOnProgressListerner(this);
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() { java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
public void run() { public void run() {
try { try {
mOutput.displayOrders(MainWindow.db.getAllOrders()); mOutput.displayOrders(MainWindow.db.getAllOrders());
} catch (SQLException e) { } catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
mFrame.pack(); mFrame.pack();

View File

@@ -28,4 +28,8 @@ created statuss for NEW and CHARGABLE, and added the options to the order pane.
added the ability to remove existing orders if they are new, so they can be replaced added the ability to remove existing orders if they are new, so they can be replaced
added the ability to print all new order in blue added the ability to print all new order in blue
improved order pane processing improved order pane processing
modified the date picker to be easier to use modified the date picker to be easier to use
1.1.1 b 46
re-added the show all dialog.
MainWinod.java, reorganized the constructor so the progress bar will be indeterminate when connecting to the database