created a single window with a tabbed layout for a more fluid experience.
added an overwrite file dialog. added the customer country to the order object. updated .CSV export
This commit is contained in:
BIN
Order Processor/images/process.png
Normal file
BIN
Order Processor/images/process.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
@@ -277,8 +277,8 @@ public class OrderDB {
|
|||||||
} else if (order.getItemName().equalsIgnoreCase(parts[i])
|
} else if (order.getItemName().equalsIgnoreCase(parts[i])
|
||||||
|| (orderNumber > 0)
|
|| (orderNumber > 0)
|
||||||
&& (order.getGoogleOrderNumber() == orderNumber)
|
&& (order.getGoogleOrderNumber() == orderNumber)
|
||||||
|| order.getCustomerName().toLowerCase(Locale.ENGLISH)
|
|| order.getCustomerName().toLowerCase(Locale.ENGLISH).contains(parts[i].toLowerCase(Locale.ENGLISH))
|
||||||
.contains(parts[i].toLowerCase(Locale.ENGLISH)))
|
|| order.getCustomerContry().toLowerCase(Locale.ENGLISH).contains(parts[i].toLowerCase(Locale.ENGLISH)))
|
||||||
list.add(order);
|
list.add(order);
|
||||||
}
|
}
|
||||||
ins.close();
|
ins.close();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class Main {
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
new MainWindow();
|
new MainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,7 @@
|
|||||||
|
|
||||||
package com.TwentyCodes.java.OrderProcessor;
|
package com.TwentyCodes.java.OrderProcessor;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.StringReader;
|
|
||||||
|
|
||||||
import com.Ostermiller.util.CSVParser;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,35 +25,36 @@ public class Order implements Comparable<Order>, Serializable{
|
|||||||
private Status mFulfillmentStatus;
|
private Status mFulfillmentStatus;
|
||||||
private String mCustomerEmail;
|
private String mCustomerEmail;
|
||||||
private String mCustomerName;
|
private String mCustomerName;
|
||||||
|
private String mCustomerContry;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Creates a new Order from a comma separated line from a *.csv file.
|
// * Creates a new Order from a comma separated line from a *.csv file.
|
||||||
*
|
// *
|
||||||
* Order ID,Merchant Order Number,Order Creation Date,Currency of Transaction,Order Amount,Amount Charged,Financial Status,Fulfillment Status,Link to Order,Total Tax,Total Shipping,Amount Refunded,Amount Charged Back,Chargeback Protection,Shipping Method,Email Marketing,Buyer Email Address,Buyer Name,Buyer Address 1,Buyer Address 2,Buyer City,Buyer State,Buyer Postal Code,Buyer Country,Buyer Phone Number,Tracking Data,Item 1 ID,Item 1 Name,Item 1 Description,Item 1 Price,Item 1 Quantity
|
// * Order ID,Merchant Order Number,Order Creation Date,Currency of Transaction,Order Amount,Amount Charged,Financial Status,Fulfillment Status,Link to Order,Total Tax,Total Shipping,Amount Refunded,Amount Charged Back,Chargeback Protection,Shipping Method,Email Marketing,Buyer Email Address,Buyer Name,Buyer Address 1,Buyer Address 2,Buyer City,Buyer State,Buyer Postal Code,Buyer Country,Buyer Phone Number,Tracking Data,Item 1 ID,Item 1 Name,Item 1 Description,Item 1 Price,Item 1 Quantity
|
||||||
*
|
// *
|
||||||
* @param order
|
// * @param order
|
||||||
* @author ricky barrette
|
// * @author ricky barrette
|
||||||
* @throws InvalidDateFormatException
|
// * @throws InvalidDateFormatException
|
||||||
* @throws IOException
|
// * @throws IOException
|
||||||
*/
|
// */
|
||||||
public Order(String order) throws NumberFormatException, InvalidDateFormatException, IOException{
|
// public Order(String order) throws NumberFormatException, InvalidDateFormatException, IOException{
|
||||||
if(Main.DEBUG)
|
// if(Main.DEBUG)
|
||||||
System.out.println("parsing in order: "+ order);
|
// System.out.println("parsing in order: "+ order);
|
||||||
|
//
|
||||||
CSVParser parsedOrder = new CSVParser(new StringReader(order));
|
// CSVParser parsedOrder = new CSVParser(new StringReader(order));
|
||||||
String[] lineParts = parsedOrder.getLine();
|
// String[] lineParts = parsedOrder.getLine();
|
||||||
parsedOrder.close();
|
// parsedOrder.close();
|
||||||
|
//
|
||||||
this.mGoogleOrderNumber = Long.parseLong(lineParts[0].split(" ")[1]);
|
// this.mGoogleOrderNumber = Long.parseLong(lineParts[0].split(" ")[1]);
|
||||||
this.mOrderCreationDate = new Date(lineParts[2]);
|
// this.mOrderCreationDate = new Date(lineParts[2]);
|
||||||
this.mOrderAmount = Float.parseFloat(lineParts[4]);
|
// this.mOrderAmount = Float.parseFloat(lineParts[4]);
|
||||||
this.mAmountCharged = Float.parseFloat(lineParts[5]);
|
// this.mAmountCharged = Float.parseFloat(lineParts[5]);
|
||||||
this.mFinancialStatus = Status.parseStatus(lineParts[6]);
|
// this.mFinancialStatus = Status.parseStatus(lineParts[6]);
|
||||||
this.mFulfillmentStatus = Status.parseStatus(lineParts[7]);
|
// this.mFulfillmentStatus = Status.parseStatus(lineParts[7]);
|
||||||
this.mCustomerEmail = lineParts[16];
|
// this.mCustomerEmail = lineParts[16];
|
||||||
this.mCustomerName = lineParts[17];
|
// this.mCustomerName = lineParts[17];
|
||||||
this.mItemName = lineParts[27];
|
// this.mItemName = lineParts[27];
|
||||||
|
//
|
||||||
// String [] lineParts;
|
// String [] lineParts;
|
||||||
// lineParts = order.split(",");
|
// lineParts = order.split(",");
|
||||||
// System.out.println(lineParts[0].split(" ")[1]);
|
// System.out.println(lineParts[0].split(" ")[1]);
|
||||||
@@ -70,10 +67,10 @@ public class Order implements Comparable<Order>, Serializable{
|
|||||||
// this.mCustomerEmail = removeFistAndLastChar(lineParts[16]);
|
// this.mCustomerEmail = removeFistAndLastChar(lineParts[16]);
|
||||||
// this.mCustomerName = removeFistAndLastChar(lineParts[17]);
|
// this.mCustomerName = removeFistAndLastChar(lineParts[17]);
|
||||||
// this.mItemName = removeFistAndLastChar(lineParts[27]);
|
// this.mItemName = removeFistAndLastChar(lineParts[27]);
|
||||||
|
//
|
||||||
if (Main.DEBUG)
|
// if (Main.DEBUG)
|
||||||
System.out.println(this.toString());
|
// System.out.println(this.toString());
|
||||||
}
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * removes the last char from a string
|
// * removes the last char from a string
|
||||||
@@ -106,6 +103,7 @@ public class Order implements Comparable<Order>, Serializable{
|
|||||||
this.mCustomerEmail = lineParts[16];
|
this.mCustomerEmail = lineParts[16];
|
||||||
this.mCustomerName = lineParts[17];
|
this.mCustomerName = lineParts[17];
|
||||||
this.mItemName = lineParts[27];
|
this.mItemName = lineParts[27];
|
||||||
|
this.mCustomerContry = lineParts[23];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -116,7 +114,7 @@ public class Order implements Comparable<Order>, Serializable{
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return this.mGoogleOrderNumber +", "+ this.mOrderCreationDate.toString() +", "+ this.mItemName +", "+ this.mOrderAmount +", "+ this.mAmountCharged +", "+ this.mFinancialStatus +", "+ this.mFulfillmentStatus +", "+ this.mCustomerName +", "+ this.mCustomerEmail;
|
return this.mGoogleOrderNumber +", "+ this.mOrderCreationDate.toString() +", "+ this.mItemName +", "+ this.mOrderAmount +", "+ this.mAmountCharged +", "+ this.mFinancialStatus +", "+ this.mFulfillmentStatus +", "+ this.mCustomerName +", "+ this.mCustomerEmail +", "+ this.mCustomerContry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -292,4 +290,20 @@ public class Order implements Comparable<Order>, Serializable{
|
|||||||
return mCustomerName;
|
return mCustomerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param customerContry the mCustomerContry to set
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public void setCustomerContry(String customerContry) {
|
||||||
|
this.mCustomerContry = customerContry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mCustomerContry
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public String getCustomerContry() {
|
||||||
|
return mCustomerContry;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* ExceptionReportGUI.java
|
||||||
|
* @date Jan 15, 2011
|
||||||
|
* @author ricky barrette
|
||||||
|
* @author Twenty Codes, LLC
|
||||||
|
*/
|
||||||
|
package com.TwentyCodes.java.OrderProcessor.UI;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.HeadlessException;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this simple frame will be used to display exception reports to the user
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public class ExceptionReportGUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -4203182071311606914L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ExceptionReportGUI
|
||||||
|
* @throws HeadlessException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public ExceptionReportGUI(String report) {
|
||||||
|
super();
|
||||||
|
setTitle("We're Sorry....");
|
||||||
|
setIconImage(new ImageIcon(getClass().getResource("/info.png")).getImage());
|
||||||
|
|
||||||
|
JButton ok = new JButton("Ok", new ImageIcon(getClass().getResource("/accept.png")));
|
||||||
|
ok.addActionListener(this);
|
||||||
|
|
||||||
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
|
|
||||||
|
final JTextArea results = new JTextArea();
|
||||||
|
scrollPane.setViewportView(results);
|
||||||
|
|
||||||
|
results.setEditable(false);
|
||||||
|
results.setText(report);
|
||||||
|
|
||||||
|
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
|
||||||
|
this.getContentPane().add(ok, BorderLayout.SOUTH);
|
||||||
|
pack();
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
this.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @author Twenty Codes, LLC
|
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
* @date Dec 18, 2010
|
* @date Dec 18, 2010
|
||||||
*/
|
*/
|
||||||
@@ -17,8 +17,10 @@ import javax.swing.ImageIcon;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
|
||||||
import com.TwentyCodes.java.OrderProcessor.FileFilter;
|
import com.TwentyCodes.java.OrderProcessor.FileFilter;
|
||||||
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
||||||
@@ -30,8 +32,6 @@ 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 mSearchButton;
|
|
||||||
private JButton mShowAllButton;
|
|
||||||
private JButton mLoadFileButton;
|
private JButton mLoadFileButton;
|
||||||
private JFileChooser fc;
|
private JFileChooser fc;
|
||||||
public static OrderDB db;
|
public static OrderDB db;
|
||||||
@@ -39,6 +39,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MainWindow
|
* Creates a new MainWindow
|
||||||
@@ -49,48 +50,64 @@ 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.setFileFilter(new FileFilter());
|
||||||
|
|
||||||
|
JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
|
||||||
|
tabbedPane.addTab("Main", initializeMainPanel());
|
||||||
|
tabbedPane.addTab("Search Orders", new SearchPanel(this));
|
||||||
|
tabbedPane.addTab("Show All Orders", new ShowAllPanel(this));
|
||||||
|
|
||||||
|
this.getContentPane().add(tabbedPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
this.setVisible(true);
|
||||||
|
this.pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initializes the main layout
|
||||||
|
*
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private JPanel initializeMainPanel() {
|
||||||
setTitle("Twenty Codes, LLC Order Database");
|
setTitle("Twenty Codes, LLC Order Database");
|
||||||
setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
||||||
|
|
||||||
|
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
|
mainPanel.add(panel);
|
||||||
|
|
||||||
getContentPane().add(panel);
|
|
||||||
|
|
||||||
//Search buttom
|
|
||||||
mSearchButton = new JButton("Search", new ImageIcon(getClass().getResource("/database_search.png")));
|
|
||||||
mSearchButton.addActionListener(this);
|
|
||||||
panel.add(mSearchButton);
|
|
||||||
|
|
||||||
//show all button
|
|
||||||
mShowAllButton = new JButton("Show All Orders", new ImageIcon(getClass().getResource("/database.png")));
|
|
||||||
mShowAllButton.addActionListener(this);
|
|
||||||
panel.add(mShowAllButton);
|
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
|
//order count labels
|
||||||
|
try {
|
||||||
|
panel.add(new JLabel("Total Orders in the database:"));
|
||||||
|
orderCountLabel = new JLabel(db.getCount()+"");
|
||||||
|
panel.add(orderCountLabel);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
panel.add(mLoadFileButton);
|
panel.add(mLoadFileButton);
|
||||||
|
|
||||||
//progress bar
|
//progress bar
|
||||||
mProgressBar = new JProgressBar();
|
mProgressBar = new JProgressBar();
|
||||||
mProgressBar.setStringPainted(true);
|
mProgressBar.setStringPainted(true);
|
||||||
getContentPane().add(mProgressBar, BorderLayout.SOUTH);
|
mainPanel.add(mProgressBar, BorderLayout.SOUTH);
|
||||||
|
|
||||||
setVisible(true);
|
return mainPanel;
|
||||||
pack();
|
|
||||||
|
|
||||||
try {
|
|
||||||
db = new OrderDB();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fc = new JFileChooser();
|
|
||||||
fc.setFileFilter(new FileFilter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when a button is clicked
|
* called when a button is clicked
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -98,13 +115,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if(e.getSource() == mShowAllButton){
|
|
||||||
new ShowAllDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.getSource() == mSearchButton) {
|
|
||||||
new SearchDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares the progress bar, and loads the file using an executer to prevent UI hangups
|
* Prepares the progress bar, and loads the file using an executer to prevent UI hangups
|
||||||
@@ -121,6 +131,7 @@ 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) {
|
||||||
@@ -129,7 +140,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -140,9 +151,6 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called then the progress of the order db is updated
|
* called then the progress of the order db is updated
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
@@ -151,16 +159,21 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onProgressUpdate(int progress, int max) {
|
public void onProgressUpdate(int progress, int max) {
|
||||||
// progress++;
|
|
||||||
mProgressBar.setMaximum(max);
|
mProgressBar.setMaximum(max);
|
||||||
mProgressBar.setValue(progress);
|
mProgressBar.setValue(progress);
|
||||||
mProgressBar.setString(" "+mCurrentFile + " ~ Parsing Order: "+ progress +" of "+mProgressBar.getMaximum()+" ");
|
mProgressBar.setString(mCurrentFile + " ~ Parsing Order: "+ progress +" of "+mProgressBar.getMaximum());
|
||||||
if(mProgressBar.isIndeterminate()) {
|
if(mProgressBar.isIndeterminate()) {
|
||||||
mProgressBar.setIndeterminate(false);
|
mProgressBar.setIndeterminate(false);
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
if(progress >= mProgressBar.getMaximum())
|
if(progress >= mProgressBar.getMaximum()){
|
||||||
mLoadFileButton.setEnabled(true);
|
mLoadFileButton.setEnabled(true);
|
||||||
|
try {
|
||||||
|
orderCountLabel.setText(db.getCount()+"");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ import javax.swing.JCheckBox;
|
|||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
@@ -40,7 +41,7 @@ import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
|||||||
* This class will be the dialog that will ask the user for a specific make to show
|
* This class will be the dialog that will ask the user for a specific make to show
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public class SearchDialog extends JFrame implements ActionListener, ProgressListener, MouseListener, DatePickerListener {
|
public class SearchPanel extends JPanel implements ActionListener, ProgressListener, MouseListener, DatePickerListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1750326106927701404L;
|
private static final long serialVersionUID = 1750326106927701404L;
|
||||||
private static final int END_DATE_RESULT = 1;
|
private static final int END_DATE_RESULT = 1;
|
||||||
@@ -57,21 +58,24 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
private JButton mExportButton;
|
private JButton mExportButton;
|
||||||
private JFileChooser fc;
|
private JFileChooser fc;
|
||||||
private JCheckBox fcCheckBox;
|
private JCheckBox fcCheckBox;
|
||||||
|
private JFrame mFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ShowAllMakeDialog
|
* Creates a new ShowAllMakeDialog
|
||||||
|
* @param frame
|
||||||
*/
|
*/
|
||||||
public SearchDialog() {
|
public SearchPanel(JFrame frame) {
|
||||||
super();
|
super(new BorderLayout());
|
||||||
|
mFrame = frame;
|
||||||
|
|
||||||
setTitle("Search");
|
// mFrame.setTitle("Search");
|
||||||
setIconImage(new ImageIcon(getClass().getResource("/database_search.png")).getImage());
|
// mFrame.setIconImage(new ImageIcon(getClass().getResource("/database_search.png")).getImage());
|
||||||
|
|
||||||
//create a JPanel to hold the text area and button
|
//create a JPanel to hold the text area and button
|
||||||
JPanel panel = new JPanel();
|
JPanel panel = new JPanel();
|
||||||
|
|
||||||
//add the JPanel to the frame, and display
|
//add the JPanel to the frame, and display
|
||||||
getContentPane().add(panel, BorderLayout.NORTH);
|
add(panel, BorderLayout.NORTH);
|
||||||
|
|
||||||
//search string
|
//search string
|
||||||
panel.add(new JLabel("Enter a Product name, Customer Name, or Google Order Number:"));
|
panel.add(new JLabel("Enter a Product name, Customer Name, or Google Order Number:"));
|
||||||
@@ -108,14 +112,13 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
panel.add(mExportButton);
|
panel.add(mExportButton);
|
||||||
mExportButton.addActionListener(this);
|
mExportButton.addActionListener(this);
|
||||||
|
|
||||||
//progress bar
|
|
||||||
mProgressBar = new JProgressBar();
|
|
||||||
getContentPane().add(mProgressBar, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
//output orderpane
|
//output orderpane
|
||||||
mOrderPanel = new OrderPane();
|
mOrderPanel = new OrderPane();
|
||||||
this.getContentPane().add(mOrderPanel, BorderLayout.CENTER);
|
add(mOrderPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
//progress bar
|
||||||
|
mProgressBar = new JProgressBar();
|
||||||
|
add(mProgressBar, BorderLayout.SOUTH);
|
||||||
//file chooser
|
//file chooser
|
||||||
fc = new JFileChooser();
|
fc = new JFileChooser();
|
||||||
fc.setFileFilter(new FileFilter());
|
fc.setFileFilter(new FileFilter());
|
||||||
@@ -123,7 +126,6 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
fcCheckBox.setSelected(true);
|
fcCheckBox.setSelected(true);
|
||||||
fc.setAccessory(fcCheckBox);
|
fc.setAccessory(fcCheckBox);
|
||||||
|
|
||||||
pack();
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,36 +156,50 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private boolean exportToCSV() {
|
private boolean exportToCSV() {
|
||||||
if(fc.showDialog(SearchDialog.this, "Export") == JFileChooser.APPROVE_OPTION){
|
if(fc.showDialog(SearchPanel.this, "Export") == JFileChooser.APPROVE_OPTION){
|
||||||
//prep the data for proper csv format
|
int write = 0;
|
||||||
StringBuffer sb = new StringBuffer("Order Number,Time & date,Product Name,Order Amount,Amount Charged,Financial Status,Fulfillment Status,Customer Name,Customer Email");
|
|
||||||
Scanner scan = new Scanner(mOrderPanel.getText());
|
//file exists dialog
|
||||||
String[] parts;
|
if(fc.getSelectedFile().exists()){
|
||||||
String line;
|
//default icon, custom title
|
||||||
while(scan.hasNext()){
|
write = JOptionPane.showConfirmDialog(
|
||||||
line = scan.nextLine();
|
mFrame,
|
||||||
parts = line.split(", ");
|
"Do you want to overwrite"+ fc.getSelectedFile().toString(),
|
||||||
try {
|
"Overwrite?",
|
||||||
sb.append(parts[0]+","+parts[1]+","+parts[2]+","+parts[3]+","+parts[4]+","+parts[5]+","+parts[6]+","+parts[7]+","+parts[8]+"\n");
|
JOptionPane.YES_NO_OPTION);
|
||||||
} catch (Exception e) {
|
}
|
||||||
sb.append(line+"\n");
|
|
||||||
|
if(write == 0){
|
||||||
|
//prep the data for proper csv format
|
||||||
|
StringBuffer sb = new StringBuffer("Order Number,Time & date,Product Name,Order Amount,Amount Charged,Financial Status,Fulfillment Status,Customer Name,Customer Email,Customer Country");
|
||||||
|
Scanner scan = new Scanner(mOrderPanel.getText());
|
||||||
|
String[] parts;
|
||||||
|
String line;
|
||||||
|
while(scan.hasNext()){
|
||||||
|
line = scan.nextLine();
|
||||||
|
parts = line.split(", ");
|
||||||
|
try {
|
||||||
|
sb.append(parts[0]+","+parts[1]+","+parts[2]+","+parts[3]+","+parts[4]+","+parts[5]+","+parts[6]+","+parts[7]+","+parts[8]+","+parts[9]+"\n");
|
||||||
|
} catch (Exception e) {
|
||||||
|
sb.append(line+"\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//write to the selceted file
|
||||||
|
try {
|
||||||
|
FileOutputStream theFile;
|
||||||
|
if (fcCheckBox.isSelected())
|
||||||
|
theFile = new FileOutputStream(new File(fc.getSelectedFile().toString()+".csv"));
|
||||||
|
else
|
||||||
|
theFile = new FileOutputStream(fc.getSelectedFile());
|
||||||
|
theFile.write(sb.toString().getBytes());
|
||||||
|
theFile.flush();
|
||||||
|
theFile.close();
|
||||||
|
} catch(IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
//write to the selceted file
|
|
||||||
try {
|
|
||||||
FileOutputStream theFile;
|
|
||||||
if (fcCheckBox.isSelected())
|
|
||||||
theFile = new FileOutputStream(new File(fc.getSelectedFile().toString()+".csv"));
|
|
||||||
else
|
|
||||||
theFile = new FileOutputStream(fc.getSelectedFile());
|
|
||||||
theFile.write(sb.toString().getBytes());
|
|
||||||
theFile.flush();
|
|
||||||
theFile.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -200,7 +216,7 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
public void run() {
|
public void run() {
|
||||||
mProgressBar.setString("Searching for: "+search);
|
mProgressBar.setString("Searching for: "+search);
|
||||||
mProgressBar.setStringPainted(true);
|
mProgressBar.setStringPainted(true);
|
||||||
MainWindow.db.setOnProgressListerner(SearchDialog.this);
|
MainWindow.db.setOnProgressListerner(SearchPanel.this);
|
||||||
|
|
||||||
ArrayList<Order> list = null;
|
ArrayList<Order> list = null;
|
||||||
try {
|
try {
|
||||||
@@ -222,14 +238,14 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
mProgressBar.setMaximum(mProgressBar.getMaximum() + mListSize);
|
mProgressBar.setMaximum(mProgressBar.getMaximum() + mListSize);
|
||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
mProgressBar.setString("Processing Order: "+ 1 +" of "+ mListSize);
|
mProgressBar.setString("Processing Order: "+ 1 +" of "+ mListSize);
|
||||||
pack();
|
mFrame.pack();
|
||||||
|
|
||||||
mOrderPanel.setOnProgressListerner(SearchDialog.this);
|
mOrderPanel.setOnProgressListerner(SearchPanel.this);
|
||||||
mOrderPanel.displayOrders(list);
|
mOrderPanel.displayOrders(list);
|
||||||
|
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
|
|
||||||
pack();
|
mFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -248,7 +264,7 @@ public class SearchDialog extends JFrame implements ActionListener, ProgressList
|
|||||||
progress++;
|
progress++;
|
||||||
if(mProgressBar.isIndeterminate()) {
|
if(mProgressBar.isIndeterminate()) {
|
||||||
mProgressBar.setIndeterminate(false);
|
mProgressBar.setIndeterminate(false);
|
||||||
pack();
|
mFrame.pack();
|
||||||
}
|
}
|
||||||
if(isProcessing){
|
if(isProcessing){
|
||||||
mProgressBar.setString("Processing Order: "+ mListSize +" of "+ progress);
|
mProgressBar.setString("Processing Order: "+ mListSize +" of "+ progress);
|
||||||
@@ -15,41 +15,50 @@ import java.sql.SQLException;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This panel will be used to display all Vehicles in the VechicleDB
|
* This panel will be used to display all Vehicles in the VechicleDB
|
||||||
*/
|
*/
|
||||||
public class ShowAllDialog extends JFrame implements ActionListener, ProgressListener {
|
public class ShowAllPanel extends JPanel implements ActionListener, ProgressListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8416144493079733535L;
|
private static final long serialVersionUID = -8416144493079733535L;
|
||||||
private JProgressBar mProgressBar;
|
private JProgressBar mProgressBar;
|
||||||
private OrderPane mOutput;
|
private OrderPane mOutput;
|
||||||
|
private JFrame mFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ShowAllDialog
|
* Creates a new ShowAllDialog
|
||||||
*/
|
*/
|
||||||
public ShowAllDialog(){
|
public ShowAllPanel(final JFrame frame){
|
||||||
super();
|
super(new BorderLayout());
|
||||||
setTitle("Show All Orders");
|
mFrame = frame;
|
||||||
setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
|
||||||
|
|
||||||
JButton ok = new JButton("Ok", new ImageIcon(getClass().getResource("/accept.png")));
|
// setTitle("Show All Orders");
|
||||||
|
// setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
||||||
|
|
||||||
|
JButton ok = new JButton("Refresh", new ImageIcon(getClass().getResource("/process.png")));
|
||||||
ok.addActionListener(this);
|
ok.addActionListener(this);
|
||||||
mOutput = new OrderPane();
|
mOutput = new OrderPane();
|
||||||
mProgressBar = new JProgressBar();
|
mProgressBar = new JProgressBar();
|
||||||
getContentPane().add(mProgressBar, BorderLayout.SOUTH);
|
add(mProgressBar, BorderLayout.SOUTH);
|
||||||
this.getContentPane().add(mOutput, BorderLayout.CENTER);
|
add(mOutput, BorderLayout.CENTER);
|
||||||
this.getContentPane().add(ok, BorderLayout.NORTH);
|
add(ok, BorderLayout.NORTH);
|
||||||
mProgressBar.setString("Loading from Database");
|
mProgressBar.setString("Loading from Database");
|
||||||
mProgressBar.setStringPainted(true);
|
mProgressBar.setStringPainted(true);
|
||||||
MainWindow.db.setOnProgressListerner(this);
|
MainWindow.db.setOnProgressListerner(this);
|
||||||
pack();
|
frame.pack();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -64,42 +73,9 @@ public class ShowAllDialog extends JFrame implements ActionListener, ProgressLis
|
|||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
pack();
|
mFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new ShowAllDialog
|
|
||||||
*/
|
|
||||||
public ShowAllDialog(String title, String body){
|
|
||||||
super();
|
|
||||||
setTitle(title);
|
|
||||||
setIconImage(new ImageIcon(getClass().getResource("/info.png")).getImage());
|
|
||||||
|
|
||||||
JButton ok = new JButton("Ok", new ImageIcon(getClass().getResource("/accept.png")));
|
|
||||||
ok.addActionListener(this);
|
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
|
||||||
|
|
||||||
final JTextArea results = new JTextArea();
|
|
||||||
scrollPane.setViewportView(results);
|
|
||||||
|
|
||||||
results.setEditable(false);
|
|
||||||
results.setText(body);
|
|
||||||
|
|
||||||
this.getContentPane().add(scrollPane, BorderLayout.CENTER);
|
|
||||||
this.getContentPane().add(ok, BorderLayout.SOUTH);
|
|
||||||
pack();
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
this.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -107,7 +83,7 @@ public class ShowAllDialog extends JFrame implements ActionListener, ProgressLis
|
|||||||
mProgressBar.setMaximum(max);
|
mProgressBar.setMaximum(max);
|
||||||
mProgressBar.setValue(progress);
|
mProgressBar.setValue(progress);
|
||||||
if(progress >= mProgressBar.getMaximum()){
|
if(progress >= mProgressBar.getMaximum()){
|
||||||
this.pack();
|
mFrame.pack();
|
||||||
mProgressBar.setString("Done");
|
mProgressBar.setString("Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.TwentyCodes.java.OrderProcessor;
|
package com.TwentyCodes.java.OrderProcessor;
|
||||||
|
|
||||||
import com.TwentyCodes.java.OrderProcessor.UI.ShowAllDialog;
|
import com.TwentyCodes.java.OrderProcessor.UI.ExceptionReportGUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An exception handler used to help report bugs in our applications
|
* An exception handler used to help report bugs in our applications
|
||||||
@@ -37,7 +37,7 @@ public class UncaughtExceptionHandler implements java.lang.Thread.UncaughtExcept
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void uncaughtException(Thread t, Throwable e) {
|
public void uncaughtException(Thread t, Throwable e) {
|
||||||
new ShowAllDialog("We're Sorry....", getDebugReport(e));
|
new ExceptionReportGUI(getDebugReport(e));
|
||||||
mDefaultUEH.uncaughtException(t,e);
|
mDefaultUEH.uncaughtException(t,e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
1.0.0 b 28
|
||||||
|
|
||||||
|
fixed the .CSV file parsing with an external lib.
|
||||||
|
|
||||||
|
1.0.1 b 29
|
||||||
|
|
||||||
|
created a single window with a tabbed layout for a more fluid experience.
|
||||||
|
added an overwrite file dialog.
|
||||||
|
added the customer country to the order object.
|
||||||
|
updated .CSV export
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
0.12.0 b 27
|
1.0.0 b 29
|
||||||
Reference in New Issue
Block a user