diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java new file mode 100644 index 0000000..59a4d34 --- /dev/null +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java @@ -0,0 +1,29 @@ +/** + * Main.java + * @date Jan 6, 2011 + * @author ricky barrette + * @author Twenty Codes, LLC + */ +package com.TwentyCodes.java.OrderProcessor; + +import com.TwentyCodes.java.OrderProcessor.UI.MainWindow; + +/** + * Main class + * @author ricky barrette + */ +public class Main { + + + public static final boolean DEBUG = true; + + /** + * called when the application first starts + * @param args + * @author ricky barrette + */ + public static void main(String[] args) { + new MainWindow(); + } + +} \ No newline at end of file diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java index c38ba18..4769224 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java @@ -6,7 +6,6 @@ package com.TwentyCodes.java.OrderProcessor; -import com.TwentyCodes.java.OrderProcessor.UI.MainWindow; /** * This class will represent a single order @@ -34,7 +33,7 @@ public class Order implements Comparable{ * @throws InvalidDateFormatException */ public Order(String order) throws NumberFormatException, InvalidDateFormatException{ - if(MainWindow.DEBUG) + if(Main.DEBUG) System.out.println("parsing in order: "+ order); String [] lineParts; @@ -50,7 +49,7 @@ public class Order implements Comparable{ this.mCustomerName = removeFistAndLastChar(lineParts[17]); this.mItemName = removeFistAndLastChar(lineParts[27]); - if (MainWindow.DEBUG) + if (Main.DEBUG) System.out.println(this.toString()); } diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/OrderDB.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/OrderDB.java index 8e132db..90afbe0 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/OrderDB.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/OrderDB.java @@ -13,7 +13,6 @@ import java.util.Collections; import java.util.Locale; import java.util.Scanner; -import com.TwentyCodes.java.OrderProcessor.UI.MainWindow; /** * This class will be a order database @@ -74,19 +73,19 @@ public class OrderDB { if(mListener != null) mListener.onProgressUpdate(line++); - if(MainWindow.DEBUG) + if(Main.DEBUG) System.out.println("\non line: "+ line); try { addOrder(new Order(scan.nextLine())); } catch (OrderExistsException e) { - if(MainWindow.DEBUG) + if(Main.DEBUG) e.printStackTrace(); } catch (NumberFormatException e1){ - if(MainWindow.DEBUG) + if(Main.DEBUG) e1.printStackTrace(); } catch (InvalidDateFormatException e2) { - if(MainWindow.DEBUG) + if(Main.DEBUG) e2.printStackTrace(); } } diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java index 9e4027c..40d1745 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java @@ -6,7 +6,6 @@ */ package com.TwentyCodes.java.OrderProcessor; -import com.TwentyCodes.java.OrderProcessor.UI.MainWindow; /** * This enum will represent statuses that are associated with an order @@ -48,7 +47,7 @@ public enum Status { * @author ricky barrette */ public static Status parseStatus(String s){ - if(MainWindow.DEBUG) + if(Main.DEBUG) System.out.println("parsing status: "+ s); if(s.equals("\""+ CHARGED.toString()+"\"")) diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java index 35f93ec..dcfd42d 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java @@ -23,6 +23,7 @@ import javax.swing.JProgressBar; import com.TwentyCodes.java.OrderProcessor.OrderDB; import com.TwentyCodes.java.OrderProcessor.ProgressListener; +import com.TwentyCodes.java.OrderProcessor.UncaughtExceptionHandler; /** * this is the main window and class of this application @@ -35,7 +36,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen private JFileChooser fc; public static OrderDB db; private static final long serialVersionUID = 1841715561053331517L; - public static final boolean DEBUG = true; private JProgressBar mProgressBar; private String mCurrentFile; private UncaughtExceptionHandler mExceptionReport = new UncaughtExceptionHandler(this.getClass()); @@ -75,14 +75,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen db.setOnProgressListerner(this); } - /** - * main method, called when the application starts - * @param args - */ - public static void main(String[] args){ - new MainWindow(); - } - /** * called when a button is clicked * (non-Javadoc) @@ -104,6 +96,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen if(e.getSource() == mLoadFileButton){ try { if(fc.showOpenDialog(MainWindow.this) == JFileChooser.APPROVE_OPTION){ + mLoadFileButton.setEnabled(false); db.setOnProgressListerner(this); mProgressBar.setIndeterminate(true); mCurrentFile = fc.getSelectedFile().toString(); @@ -122,6 +115,8 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen }); pack(); + } else { + mProgressBar.setIndeterminate(false); } } catch (FileNotFoundException e1) { @@ -166,6 +161,8 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen mProgressBar.setIndeterminate(false); pack(); } + if(progress >= mProgressBar.getMaximum()) + mLoadFileButton.setEnabled(true); } } \ No newline at end of file diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/SearchDialog.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/SearchDialog.java index 4c40918..c088b6f 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/SearchDialog.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/SearchDialog.java @@ -26,6 +26,7 @@ import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import javax.swing.text.StyledDocument; +import com.TwentyCodes.java.OrderProcessor.Main; import com.TwentyCodes.java.OrderProcessor.Order; import com.TwentyCodes.java.OrderProcessor.ProgressListener; import com.TwentyCodes.java.OrderProcessor.Status; @@ -198,7 +199,7 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList */ @Override public void onProgressUpdate(int progress) { - if(MainWindow.DEBUG) + if(Main.DEBUG) System.out.println("search progress = "+ progress); progress++; diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/UncaughtExceptionHandler.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UncaughtExceptionHandler.java similarity index 94% rename from Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/UncaughtExceptionHandler.java rename to Order Processor/src/com/TwentyCodes/java/OrderProcessor/UncaughtExceptionHandler.java index d89f648..07eeb4e 100644 --- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/UncaughtExceptionHandler.java +++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UncaughtExceptionHandler.java @@ -4,7 +4,9 @@ * @author ricky barrette * @author Twenty Codes, LLC */ -package com.TwentyCodes.java.OrderProcessor.UI; +package com.TwentyCodes.java.OrderProcessor; + +import com.TwentyCodes.java.OrderProcessor.UI.ShowAllDialog; /** * An exception handler used to help report bugs in our applications @@ -56,7 +58,7 @@ public class UncaughtExceptionHandler implements java.lang.Thread.UncaughtExcept report.append("--------- Application ---------\n\n"); - report.append(mApp.getName()); + report.append(mApp.getPackage()); report.append(" generated the following exception:\n\n");