reorg of files and variables

This commit is contained in:
2011-01-06 17:44:03 +00:00
parent 0af0c1007d
commit 13c1c5dae7
7 changed files with 48 additions and 22 deletions

View File

@@ -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();
}
}

View File

@@ -6,7 +6,6 @@
package com.TwentyCodes.java.OrderProcessor; package com.TwentyCodes.java.OrderProcessor;
import com.TwentyCodes.java.OrderProcessor.UI.MainWindow;
/** /**
* This class will represent a single order * This class will represent a single order
@@ -34,7 +33,7 @@ public class Order implements Comparable<Order>{
* @throws InvalidDateFormatException * @throws InvalidDateFormatException
*/ */
public Order(String order) throws NumberFormatException, InvalidDateFormatException{ public Order(String order) throws NumberFormatException, InvalidDateFormatException{
if(MainWindow.DEBUG) if(Main.DEBUG)
System.out.println("parsing in order: "+ order); System.out.println("parsing in order: "+ order);
String [] lineParts; String [] lineParts;
@@ -50,7 +49,7 @@ public class Order implements Comparable<Order>{
this.mCustomerName = removeFistAndLastChar(lineParts[17]); this.mCustomerName = removeFistAndLastChar(lineParts[17]);
this.mItemName = removeFistAndLastChar(lineParts[27]); this.mItemName = removeFistAndLastChar(lineParts[27]);
if (MainWindow.DEBUG) if (Main.DEBUG)
System.out.println(this.toString()); System.out.println(this.toString());
} }

View File

@@ -13,7 +13,6 @@ import java.util.Collections;
import java.util.Locale; import java.util.Locale;
import java.util.Scanner; import java.util.Scanner;
import com.TwentyCodes.java.OrderProcessor.UI.MainWindow;
/** /**
* This class will be a order database * This class will be a order database
@@ -74,19 +73,19 @@ public class OrderDB {
if(mListener != null) if(mListener != null)
mListener.onProgressUpdate(line++); mListener.onProgressUpdate(line++);
if(MainWindow.DEBUG) if(Main.DEBUG)
System.out.println("\non line: "+ line); System.out.println("\non line: "+ line);
try { try {
addOrder(new Order(scan.nextLine())); addOrder(new Order(scan.nextLine()));
} catch (OrderExistsException e) { } catch (OrderExistsException e) {
if(MainWindow.DEBUG) if(Main.DEBUG)
e.printStackTrace(); e.printStackTrace();
} catch (NumberFormatException e1){ } catch (NumberFormatException e1){
if(MainWindow.DEBUG) if(Main.DEBUG)
e1.printStackTrace(); e1.printStackTrace();
} catch (InvalidDateFormatException e2) { } catch (InvalidDateFormatException e2) {
if(MainWindow.DEBUG) if(Main.DEBUG)
e2.printStackTrace(); e2.printStackTrace();
} }
} }

View File

@@ -6,7 +6,6 @@
*/ */
package com.TwentyCodes.java.OrderProcessor; package com.TwentyCodes.java.OrderProcessor;
import com.TwentyCodes.java.OrderProcessor.UI.MainWindow;
/** /**
* This enum will represent statuses that are associated with an order * This enum will represent statuses that are associated with an order
@@ -48,7 +47,7 @@ public enum Status {
* @author ricky barrette * @author ricky barrette
*/ */
public static Status parseStatus(String s){ public static Status parseStatus(String s){
if(MainWindow.DEBUG) if(Main.DEBUG)
System.out.println("parsing status: "+ s); System.out.println("parsing status: "+ s);
if(s.equals("\""+ CHARGED.toString()+"\"")) if(s.equals("\""+ CHARGED.toString()+"\""))

View File

@@ -23,6 +23,7 @@ import javax.swing.JProgressBar;
import com.TwentyCodes.java.OrderProcessor.OrderDB; import com.TwentyCodes.java.OrderProcessor.OrderDB;
import com.TwentyCodes.java.OrderProcessor.ProgressListener; import com.TwentyCodes.java.OrderProcessor.ProgressListener;
import com.TwentyCodes.java.OrderProcessor.UncaughtExceptionHandler;
/** /**
* this is the main window and class of this application * 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; private JFileChooser fc;
public static OrderDB db; public static OrderDB db;
private static final long serialVersionUID = 1841715561053331517L; private static final long serialVersionUID = 1841715561053331517L;
public static final boolean DEBUG = true;
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());
@@ -75,14 +75,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
db.setOnProgressListerner(this); 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 * called when a button is clicked
* (non-Javadoc) * (non-Javadoc)
@@ -104,6 +96,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
if(e.getSource() == mLoadFileButton){ if(e.getSource() == mLoadFileButton){
try { try {
if(fc.showOpenDialog(MainWindow.this) == JFileChooser.APPROVE_OPTION){ if(fc.showOpenDialog(MainWindow.this) == JFileChooser.APPROVE_OPTION){
mLoadFileButton.setEnabled(false);
db.setOnProgressListerner(this); db.setOnProgressListerner(this);
mProgressBar.setIndeterminate(true); mProgressBar.setIndeterminate(true);
mCurrentFile = fc.getSelectedFile().toString(); mCurrentFile = fc.getSelectedFile().toString();
@@ -122,6 +115,8 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
}); });
pack(); pack();
} else {
mProgressBar.setIndeterminate(false);
} }
} catch (FileNotFoundException e1) { } catch (FileNotFoundException e1) {
@@ -166,6 +161,8 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
mProgressBar.setIndeterminate(false); mProgressBar.setIndeterminate(false);
pack(); pack();
} }
if(progress >= mProgressBar.getMaximum())
mLoadFileButton.setEnabled(true);
} }
} }

View File

@@ -26,6 +26,7 @@ import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext; import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument; import javax.swing.text.StyledDocument;
import com.TwentyCodes.java.OrderProcessor.Main;
import com.TwentyCodes.java.OrderProcessor.Order; import com.TwentyCodes.java.OrderProcessor.Order;
import com.TwentyCodes.java.OrderProcessor.ProgressListener; import com.TwentyCodes.java.OrderProcessor.ProgressListener;
import com.TwentyCodes.java.OrderProcessor.Status; import com.TwentyCodes.java.OrderProcessor.Status;
@@ -198,7 +199,7 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
*/ */
@Override @Override
public void onProgressUpdate(int progress) { public void onProgressUpdate(int progress) {
if(MainWindow.DEBUG) if(Main.DEBUG)
System.out.println("search progress = "+ progress); System.out.println("search progress = "+ progress);
progress++; progress++;

View File

@@ -4,7 +4,9 @@
* @author ricky barrette * @author ricky barrette
* @author Twenty Codes, LLC * @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 * 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("--------- Application ---------\n\n");
report.append(mApp.getName()); report.append(mApp.getPackage());
report.append(" generated the following exception:\n\n"); report.append(" generated the following exception:\n\n");