Compare commits
10 Commits
a25fab8882
...
8749006ea5
| Author | SHA1 | Date | |
|---|---|---|---|
| 8749006ea5 | |||
| d5d2221fb2 | |||
| f58c2219c5 | |||
| 866505868e | |||
| 4ebe4a9910 | |||
| 4be7476de7 | |||
| c85e599530 | |||
| 21c7d0642b | |||
| 7d1fe95e5a | |||
| f9a805803c |
@@ -1,7 +0,0 @@
|
|||||||
#---No Comment---
|
|
||||||
#Thu Jan 20 12:15:15 EST 2011
|
|
||||||
server_parrword=S35-2n6t
|
|
||||||
use_remote_server=true
|
|
||||||
server_location=tcdevsvn1
|
|
||||||
server_port_number=3306
|
|
||||||
server_user_name=ricky.barrette
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
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.0.2 b 30
|
|
||||||
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
|
|
||||||
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 modified OrderDB to use the .property file
|
|
||||||
|
|
||||||
1.0.6 b 34
|
|
||||||
created the static method MainWindow.loadDatabase() for easy database reloading
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
1.0.6 b 34
|
|
||||||
@@ -8,5 +8,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.14-bin.jar"/>
|
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.14-bin.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/sqlitejdbc-v056.jar"/>
|
<classpathentry kind="lib" path="lib/sqlitejdbc-v056.jar"/>
|
||||||
|
<classpathentry kind="lib" path="lib/jasypt-1.7.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
9
OrderProcessor/.orderprocessor.properties
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#---Order Processor Settings---
|
||||||
|
#Wed Feb 09 13:48:50 EST 2011
|
||||||
|
database_name=Orders
|
||||||
|
server_parrword=Ekf4syi+03SEjxLksxRbuuxV4qpKog5G
|
||||||
|
save_password=true
|
||||||
|
use_remote_server=true
|
||||||
|
server_location=tcdevsvn1
|
||||||
|
server_port_number=3306
|
||||||
|
server_user_name=ricky.barrette
|
||||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
OrderProcessor/images/page.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
OrderProcessor/images/page_process.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
BIN
OrderProcessor/images/remove.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
OrderProcessor/images/repeat.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
OrderProcessor/lib/jasypt-1.7.jar
Normal file
@@ -25,6 +25,8 @@ import java.util.Collections;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jasypt.util.text.BasicTextEncryptor;
|
||||||
|
|
||||||
import com.Ostermiller.util.CSVParser;
|
import com.Ostermiller.util.CSVParser;
|
||||||
import com.TwentyCodes.java.OrderProcessor.Date;
|
import com.TwentyCodes.java.OrderProcessor.Date;
|
||||||
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
||||||
@@ -32,6 +34,8 @@ import com.TwentyCodes.java.OrderProcessor.Main;
|
|||||||
import com.TwentyCodes.java.OrderProcessor.Order;
|
import com.TwentyCodes.java.OrderProcessor.Order;
|
||||||
import com.TwentyCodes.java.OrderProcessor.OrderExistsException;
|
import com.TwentyCodes.java.OrderProcessor.OrderExistsException;
|
||||||
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
||||||
|
import com.TwentyCodes.java.OrderProcessor.Status;
|
||||||
|
import com.TwentyCodes.java.OrderProcessor.UI.MainWindow;
|
||||||
import com.TwentyCodes.java.OrderProcessor.UI.SettingsPanel;
|
import com.TwentyCodes.java.OrderProcessor.UI.SettingsPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +44,7 @@ import com.TwentyCodes.java.OrderProcessor.UI.SettingsPanel;
|
|||||||
*/
|
*/
|
||||||
public class OrderDB {
|
public class OrderDB {
|
||||||
|
|
||||||
|
public final static String PASSWORD = "askjdhfui2ywpordhewpfiy2390uriyfu230rhuiyhew8fu293hro9yqewrfup9u34bh0yf3-eqwjf9834-fjud9i-he9-fhuj830uewfh";
|
||||||
private final String CREATE_TABLE = "CREATE TABLE Orders (id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, item blob);";
|
private final String CREATE_TABLE = "CREATE TABLE Orders (id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, item blob);";
|
||||||
private final String CREATE_TABLE_LOCAL = "CREATE TABLE Orders (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'item' blob);";
|
private final String CREATE_TABLE_LOCAL = "CREATE TABLE Orders (id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'item' blob);";
|
||||||
private final String INSERT = "insert into Orders (item) values (?);";
|
private final String INSERT = "insert into Orders (item) values (?);";
|
||||||
@@ -47,16 +52,15 @@ public class OrderDB {
|
|||||||
private PreparedStatement prep;
|
private PreparedStatement prep;
|
||||||
private String dbLocation;
|
private String dbLocation;
|
||||||
private boolean isLoadingFile = false;
|
private boolean isLoadingFile = false;
|
||||||
private ArrayList<Order> list;
|
private ArrayList<Order> mList;
|
||||||
private boolean isUsingRemoteDatabase;
|
private boolean isUsingRemoteDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new OrderDB
|
* Creates a new OrderDB
|
||||||
* @author ricky barrette
|
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException
|
||||||
* @throws SQLException
|
* @throws SQLException
|
||||||
* @throws SocketException
|
* @throws SocketException
|
||||||
* @throws Exception
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public OrderDB() throws ClassNotFoundException, SQLException, SocketException {
|
public OrderDB() throws ClassNotFoundException, SQLException, SocketException {
|
||||||
|
|
||||||
@@ -73,6 +77,7 @@ public class OrderDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
|
|
||||||
Statement stat = conn.createStatement();
|
Statement stat = conn.createStatement();
|
||||||
|
|
||||||
// stat.executeUpdate("drop table if exists Orders;");
|
// stat.executeUpdate("drop table if exists Orders;");
|
||||||
@@ -89,40 +94,42 @@ public class OrderDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the properties from the properties file
|
* Creates a new OrderDB
|
||||||
* @return properties
|
* @param password for the database
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws SocketException
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private Properties getProperties() {
|
public OrderDB(String password) throws ClassNotFoundException, SQLException, SocketException {
|
||||||
Properties props = new java.util.Properties();
|
|
||||||
try {
|
Properties props = getProperties();
|
||||||
FileInputStream in = new FileInputStream(".settings.propertys");
|
|
||||||
props.load(in);
|
isUsingRemoteDatabase = Boolean.parseBoolean(props.getProperty(SettingsPanel.IS_USING_REMOTE_SERVER, "false"));
|
||||||
in.close();
|
|
||||||
return props;
|
if(isUsingRemoteDatabase) {
|
||||||
} catch (IOException e1) {
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return props;
|
else {
|
||||||
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
dbLocation = System.getProperty("user.home") +"/.TwentyCodesOrders";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
Connection conn = getConnection(password);
|
||||||
* counts the number of lines in a csv file
|
|
||||||
* @param file to be read
|
Statement stat = conn.createStatement();
|
||||||
* @return number of lines in a file
|
|
||||||
* @throws IOException
|
// stat.executeUpdate("drop table if exists Orders;");
|
||||||
* @author ricky barrette
|
try {
|
||||||
*/
|
if(isUsingRemoteDatabase)
|
||||||
public int countLines(File file) throws IOException {
|
stat.executeUpdate(CREATE_TABLE);
|
||||||
// LineNumberReader reader = new LineNumberReader(new FileReader(file));
|
else
|
||||||
int cnt = 1;
|
stat.executeUpdate(CREATE_TABLE_LOCAL);
|
||||||
// while ((reader.readLine()) != null) ;
|
} catch (SQLException e) {
|
||||||
// cnt = reader.getLineNumber();
|
//most likely the table already exist
|
||||||
// reader.close();
|
e.printStackTrace();
|
||||||
CSVParser csvParser = new CSVParser(new FileInputStream(file));
|
}
|
||||||
while(csvParser.getLine() != null)
|
conn.close();
|
||||||
cnt++;
|
|
||||||
return cnt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,15 +145,127 @@ public class OrderDB {
|
|||||||
/*
|
/*
|
||||||
* check the current database for an orders with a matching order number
|
* check the current database for an orders with a matching order number
|
||||||
*/
|
*/
|
||||||
for(Order item : list)
|
for(Order item : mList)
|
||||||
|
|
||||||
if(item.getGoogleOrderNumber() == order.getGoogleOrderNumber())
|
if(item.getGoogleOrderNumber() == order.getGoogleOrderNumber())
|
||||||
|
if(item.getFulfillmentStatus() == Status.NEW )
|
||||||
|
deleteOrder(item);
|
||||||
|
else
|
||||||
throw new OrderExistsException(order.toString());
|
throw new OrderExistsException(order.toString());
|
||||||
|
|
||||||
list.add(order);
|
mList.add(order);
|
||||||
|
|
||||||
saveOrder(order);
|
saveOrder(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* copies remote database to local DB
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public void checkoutDatabase() throws SQLException, IOException, ClassNotFoundException{
|
||||||
|
//get all from remote DB
|
||||||
|
ArrayList<Order> list = this.getAllOrders();
|
||||||
|
//switch over to local DB
|
||||||
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
dbLocation = System.getProperty("user.home") +"/.TwentyCodesOrders";
|
||||||
|
|
||||||
|
isUsingRemoteDatabase = false;
|
||||||
|
|
||||||
|
//connect to local DB
|
||||||
|
Connection conn = this.getConnection();
|
||||||
|
Statement stat = conn.createStatement();
|
||||||
|
|
||||||
|
// //remove old table
|
||||||
|
// stat.executeUpdate("drop table if exists Orders;");
|
||||||
|
|
||||||
|
//create tabe if it needs to be created
|
||||||
|
try {
|
||||||
|
stat.executeUpdate(CREATE_TABLE_LOCAL);
|
||||||
|
} catch (Exception e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
mList = this.getAllOrders();
|
||||||
|
|
||||||
|
//the insert statement
|
||||||
|
prep = conn.prepareStatement(INSERT);
|
||||||
|
conn.setAutoCommit(true);
|
||||||
|
|
||||||
|
//copy the orders over
|
||||||
|
int i = 1;
|
||||||
|
for(Order item : list) {
|
||||||
|
if(mListener != null)
|
||||||
|
mListener.onProgressUpdate("Checking out order "+ i++ +" of "+ list.size(), false, i, list.size());
|
||||||
|
try {
|
||||||
|
addOrder(item);
|
||||||
|
} catch (OrderExistsException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//reload the remote DB
|
||||||
|
MainWindow.loadDatabase();
|
||||||
|
|
||||||
|
mList = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* counts the number of lines in a csv file
|
||||||
|
* @param file to be read
|
||||||
|
* @return number of lines in a file
|
||||||
|
* @throws IOException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
public int countLines(File file) throws IOException {
|
||||||
|
int cnt = 1;
|
||||||
|
CSVParser csvParser = new CSVParser(new FileInputStream(file));
|
||||||
|
while(csvParser.getLine() != null)
|
||||||
|
cnt++;
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* deletes the old order that IS BEING replaced
|
||||||
|
* @throws SQLException
|
||||||
|
* @throws IOException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private void deleteOrder(Order order) throws SQLException, IOException, ClassNotFoundException{
|
||||||
|
int row = 1;
|
||||||
|
int count = getCount();
|
||||||
|
|
||||||
|
Connection conn = getConnection();
|
||||||
|
ResultSet rs = getOrders(conn);
|
||||||
|
|
||||||
|
ByteArrayInputStream bais;
|
||||||
|
ObjectInputStream ins;
|
||||||
|
Order item;
|
||||||
|
while (rs.next()) {
|
||||||
|
|
||||||
|
if(mListener != null)
|
||||||
|
mListener.onProgressUpdate("Deleting old Order", false, row++, count);
|
||||||
|
bais = new ByteArrayInputStream(rs.getBytes("item"));
|
||||||
|
ins = new ObjectInputStream(bais);
|
||||||
|
item = (Order) ins.readObject();
|
||||||
|
|
||||||
|
if (order.getGoogleOrderNumber() == item.getGoogleOrderNumber()){
|
||||||
|
conn.createStatement().execute("DELETE FROM Orders WHERE id="+rs.getInt("id")+";");
|
||||||
|
System.out.println("deleting "+ item.toString());
|
||||||
|
}
|
||||||
|
ins.close();
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
conn.close();
|
||||||
|
|
||||||
|
if(mListener != null)
|
||||||
|
mListener.onProgressUpdate("Done", false, 1, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets all orders from the database
|
* gets all orders from the database
|
||||||
* @return a list of orders
|
* @return a list of orders
|
||||||
@@ -159,9 +278,10 @@ public class OrderDB {
|
|||||||
|
|
||||||
int row = 1;
|
int row = 1;
|
||||||
int count = getCount();
|
int count = getCount();
|
||||||
|
|
||||||
Connection conn = getConnection();
|
Connection conn = getConnection();
|
||||||
Statement stat = conn.createStatement();
|
ResultSet rs = getOrders(conn);
|
||||||
ResultSet rs = stat.executeQuery("select * from Orders;");
|
|
||||||
ArrayList<Order> list = new ArrayList<Order>();
|
ArrayList<Order> list = new ArrayList<Order>();
|
||||||
|
|
||||||
ByteArrayInputStream bais;
|
ByteArrayInputStream bais;
|
||||||
@@ -188,21 +308,34 @@ public class OrderDB {
|
|||||||
*/
|
*/
|
||||||
private Connection getConnection() throws SQLException, SocketException{
|
private Connection getConnection() throws SQLException, SocketException{
|
||||||
Properties props = getProperties();
|
Properties props = getProperties();
|
||||||
|
BasicTextEncryptor passwordEncryptor = new BasicTextEncryptor();
|
||||||
|
passwordEncryptor.setPassword(PASSWORD);
|
||||||
|
|
||||||
if(isUsingRemoteDatabase){
|
if(isUsingRemoteDatabase)
|
||||||
String url = "jdbc:mysql://"+props.getProperty(SettingsPanel.SERVER_LOCATION)+":"+props.getProperty(SettingsPanel.SERVER_PORT_NUMBER, "3306")+"/Orders";
|
return getConnection(passwordEncryptor.decrypt(props.getProperty(SettingsPanel.SERVER_PASSWORD)));
|
||||||
|
else
|
||||||
|
return DriverManager.getConnection("jdbc:sqlite:"+ dbLocation+".db");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the connection to the database
|
||||||
|
* @param password users password for the database
|
||||||
|
* @return connection
|
||||||
|
* @throws SQLException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private Connection getConnection(String password) throws SQLException {
|
||||||
|
Properties props = getProperties();
|
||||||
|
|
||||||
|
String url = "jdbc:mysql://"+props.getProperty(SettingsPanel.SERVER_LOCATION)+":"+props.getProperty(SettingsPanel.SERVER_PORT_NUMBER, "3306")+"/"+props.getProperty(SettingsPanel.DATABASE_NAME,"Orders");
|
||||||
|
|
||||||
if(props.getProperty(SettingsPanel.SERVER_USERNAME).length() > 0)
|
if(props.getProperty(SettingsPanel.SERVER_USERNAME).length() > 0)
|
||||||
url += "?user="+ props.getProperty(SettingsPanel.SERVER_USERNAME);
|
url += "?user="+ props.getProperty(SettingsPanel.SERVER_USERNAME);
|
||||||
|
|
||||||
if(props.getProperty(SettingsPanel.SERVER_PASSWORD).length() > 0)
|
if(password.length() > 0)
|
||||||
url += "&password="+ props.getProperty(SettingsPanel.SERVER_PASSWORD);
|
url += "&password="+ password;
|
||||||
|
|
||||||
return DriverManager.getConnection(url);
|
return DriverManager.getConnection(url);
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return DriverManager.getConnection("jdbc:sqlite:"+ dbLocation+".db");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -223,6 +356,37 @@ public class OrderDB {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all orders from the database
|
||||||
|
* @param conn to database
|
||||||
|
* @return ResultSet containing all orders
|
||||||
|
* @throws SocketException
|
||||||
|
* @throws SQLException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private ResultSet getOrders(Connection conn) throws SocketException, SQLException {
|
||||||
|
Statement stat = conn.createStatement();
|
||||||
|
return stat.executeQuery("select * from Orders;");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the properties from the properties file
|
||||||
|
* @return properties
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private Properties getProperties() {
|
||||||
|
Properties props = new java.util.Properties();
|
||||||
|
try {
|
||||||
|
FileInputStream in = new FileInputStream(SettingsPanel.PROPERTIES_FILE_NAME);
|
||||||
|
props.load(in);
|
||||||
|
in.close();
|
||||||
|
return props;
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loads the orders from the specified *.CSV file
|
* loads the orders from the specified *.CSV file
|
||||||
* @param file to be parsed
|
* @param file to be parsed
|
||||||
@@ -234,12 +398,11 @@ public class OrderDB {
|
|||||||
*/
|
*/
|
||||||
public void load(File file) throws SQLException, IOException, ClassNotFoundException{
|
public void load(File file) throws SQLException, IOException, ClassNotFoundException{
|
||||||
|
|
||||||
// Scanner scan = new Scanner(file);
|
|
||||||
prep = null;
|
prep = null;
|
||||||
list = null;
|
mList = null;
|
||||||
|
|
||||||
CSVParser csvParser = new CSVParser(new FileInputStream(file));
|
CSVParser csvParser = new CSVParser(new FileInputStream(file));
|
||||||
list = new ArrayList<Order>(getAllOrders());
|
mList = new ArrayList<Order>(getAllOrders());
|
||||||
|
|
||||||
int line = 1;
|
int line = 1;
|
||||||
int lineCount = countLines(file);
|
int lineCount = countLines(file);
|
||||||
@@ -267,7 +430,6 @@ public class OrderDB {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -276,8 +438,8 @@ public class OrderDB {
|
|||||||
prep.close();
|
prep.close();
|
||||||
conn.close();
|
conn.close();
|
||||||
isLoadingFile = false;
|
isLoadingFile = false;
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves an order to the database
|
* saves an order to the database
|
||||||
@@ -297,7 +459,6 @@ public class OrderDB {
|
|||||||
|
|
||||||
prep.setBytes(1, bos.toByteArray());
|
prep.setBytes(1, bos.toByteArray());
|
||||||
prep.executeUpdate();
|
prep.executeUpdate();
|
||||||
// prep.addBatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -16,7 +16,6 @@ public class Main {
|
|||||||
|
|
||||||
|
|
||||||
public static final boolean DEBUG = true;
|
public static final boolean DEBUG = true;
|
||||||
public static final boolean USE_REMOTE_DB = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called when the application first starts
|
* called when the application first starts
|
||||||
@@ -37,7 +37,25 @@ public enum Status {
|
|||||||
/**
|
/**
|
||||||
* A fulfillment status representing that the order has been canceled, and will not be delivered to the customer
|
* A fulfillment status representing that the order has been canceled, and will not be delivered to the customer
|
||||||
*/
|
*/
|
||||||
WILL_NOT_DELIVER;
|
WILL_NOT_DELIVER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A financial status representing that the order is chargeable
|
||||||
|
*/
|
||||||
|
CHARGEABLE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A fulfillment status representing that the order is new
|
||||||
|
*/
|
||||||
|
NEW,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A financial status representing that the authorization of the customer's credit card failed.
|
||||||
|
* Google has sent an email instructing the customer to update their card.
|
||||||
|
* If they fail to provide a valid card within 7 days, this order will be automatically canceled by Google.
|
||||||
|
*/
|
||||||
|
PAYMENT_DECLINED
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +83,15 @@ public enum Status {
|
|||||||
if(s.equals(WILL_NOT_DELIVER.toString()))
|
if(s.equals(WILL_NOT_DELIVER.toString()))
|
||||||
return WILL_NOT_DELIVER;
|
return WILL_NOT_DELIVER;
|
||||||
|
|
||||||
|
if(s.equals(CHARGEABLE.toString()))
|
||||||
|
return CHARGEABLE;
|
||||||
|
|
||||||
|
if(s.equals(NEW.toString()))
|
||||||
|
return NEW;
|
||||||
|
|
||||||
|
if(s.equals(PAYMENT_DECLINED.toString()))
|
||||||
|
return PAYMENT_DECLINED;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,6 @@ package com.TwentyCodes.java.OrderProcessor;
|
|||||||
*/
|
*/
|
||||||
public enum TextStyle {
|
public enum TextStyle {
|
||||||
|
|
||||||
BOLD, ITALIC, REGULAR, RED, GREEN
|
BOLD, ITALIC, REGULAR, RED, BLUE
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,12 +16,12 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
|
||||||
|
|
||||||
import com.TwentyCodes.java.OrderProcessor.Date;
|
import com.TwentyCodes.java.OrderProcessor.Date;
|
||||||
import com.TwentyCodes.java.OrderProcessor.DatePickerListener;
|
import com.TwentyCodes.java.OrderProcessor.DatePickerListener;
|
||||||
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
||||||
import com.toedter.calendar.JCalendar;
|
import com.toedter.calendar.JCalendar;
|
||||||
|
import com.toedter.components.JSpinField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* a simple date picker window that allows the user to easily pick a date
|
* a simple date picker window that allows the user to easily pick a date
|
||||||
@@ -30,11 +30,13 @@ import com.toedter.calendar.JCalendar;
|
|||||||
public class DatePicker extends JFrame implements ActionListener {
|
public class DatePicker extends JFrame implements ActionListener {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8460535573336456875L;
|
private static final long serialVersionUID = -8460535573336456875L;
|
||||||
|
public static final int END_DATE_RESULT = 1;
|
||||||
|
public static final int START_DATE_RESULT = 0;
|
||||||
private JCalendar mCalendar;
|
private JCalendar mCalendar;
|
||||||
private JButton mOkButton;
|
private JButton mOkButton;
|
||||||
private JTextField mHours;
|
private JSpinField mHours;
|
||||||
private JTextField mSeconds;
|
private JSpinField mSeconds;
|
||||||
private JTextField mMinutes;
|
private JSpinField mMinutes;
|
||||||
private DatePickerListener mListener;
|
private DatePickerListener mListener;
|
||||||
private JLabel mFailLabel;
|
private JLabel mFailLabel;
|
||||||
private int mResultCode;
|
private int mResultCode;
|
||||||
@@ -54,16 +56,22 @@ public class DatePicker extends JFrame implements ActionListener {
|
|||||||
//Time fields
|
//Time fields
|
||||||
JPanel p = new JPanel();
|
JPanel p = new JPanel();
|
||||||
p.add(new JLabel("Hours:"));
|
p.add(new JLabel("Hours:"));
|
||||||
mHours = new JTextField();
|
mHours = new JSpinField();
|
||||||
mHours.setColumns(10);
|
mHours.setMinimum(0);
|
||||||
|
mHours.setMaximum(23);
|
||||||
|
mHours.adjustWidthToMaximumValue();
|
||||||
p.add(mHours);
|
p.add(mHours);
|
||||||
p.add(new JLabel("Minutes:"));
|
p.add(new JLabel("Minutes:"));
|
||||||
mMinutes = new JTextField();
|
mMinutes = new JSpinField();
|
||||||
mMinutes.setColumns(10);
|
mMinutes.setMinimum(0);
|
||||||
|
mMinutes.setMaximum(59);
|
||||||
|
mMinutes.adjustWidthToMaximumValue();
|
||||||
p.add(mMinutes);
|
p.add(mMinutes);
|
||||||
p.add(new JLabel("Seconds:"));
|
p.add(new JLabel("Seconds:"));
|
||||||
mSeconds = new JTextField();
|
mSeconds = new JSpinField();
|
||||||
mSeconds.setColumns(10);
|
mSeconds.setMinimum(0);
|
||||||
|
mSeconds.setMaximum(59);
|
||||||
|
mSeconds.adjustWidthToMaximumValue();
|
||||||
p.add(mSeconds);
|
p.add(mSeconds);
|
||||||
this.getContentPane().add(p, BorderLayout.NORTH);
|
this.getContentPane().add(p, BorderLayout.NORTH);
|
||||||
|
|
||||||
@@ -81,6 +89,13 @@ public class DatePicker extends JFrame implements ActionListener {
|
|||||||
mFailLabel.setVisible(false);
|
mFailLabel.setVisible(false);
|
||||||
p.add(mFailLabel);
|
p.add(mFailLabel);
|
||||||
|
|
||||||
|
//if this is an end date, then set the time to the latest possible
|
||||||
|
if(resultCode == END_DATE_RESULT){
|
||||||
|
mHours.setValue(23);
|
||||||
|
mMinutes.setValue(59);
|
||||||
|
mSeconds.setValue(59);
|
||||||
|
}
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
}
|
}
|
||||||
@@ -90,7 +105,7 @@ public class DatePicker extends JFrame implements ActionListener {
|
|||||||
try {
|
try {
|
||||||
mListener.onDatePicked(mResultCode, new Date(
|
mListener.onDatePicked(mResultCode, new Date(
|
||||||
mCalendar.getYearChooser().getYear()+"-"+ (mCalendar.getMonthChooser().getMonth()+1) +"-"+ mCalendar.getDayChooser().getDay() +
|
mCalendar.getYearChooser().getYear()+"-"+ (mCalendar.getMonthChooser().getMonth()+1) +"-"+ mCalendar.getDayChooser().getDay() +
|
||||||
" "+ Integer.parseInt(mHours.getText())+":"+ Integer.parseInt(mMinutes.getText())+":"+ Integer.parseInt(mSeconds.getText())));
|
" "+ mHours.getValue()+":"+ mMinutes.getValue()+":"+ mSeconds.getValue()));
|
||||||
this.dispose();
|
this.dispose();
|
||||||
} catch (NumberFormatException e1) {
|
} catch (NumberFormatException e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
@@ -9,10 +9,12 @@ package com.TwentyCodes.java.OrderProcessor.UI;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
@@ -27,6 +29,9 @@ import com.TwentyCodes.java.OrderProcessor.FileFilter;
|
|||||||
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
||||||
import com.TwentyCodes.java.OrderProcessor.UncaughtExceptionHandler;
|
import com.TwentyCodes.java.OrderProcessor.UncaughtExceptionHandler;
|
||||||
import com.TwentyCodes.java.OrderProcessor.DB.OrderDB;
|
import com.TwentyCodes.java.OrderProcessor.DB.OrderDB;
|
||||||
|
import javax.swing.JPasswordField;
|
||||||
|
|
||||||
|
import org.jasypt.util.text.BasicTextEncryptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is the main window and class of this application
|
* this is the main window and class of this application
|
||||||
@@ -37,11 +42,16 @@ 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;
|
||||||
private static JLabel mWarningLabel;
|
// private static JLabel mWarningLabel;
|
||||||
|
private static JButton mConnectButton;
|
||||||
|
private static JPasswordField mPassWord;
|
||||||
|
private static boolean isUsingRemoteServer;
|
||||||
|
private JLabel lblDatabasePassword;
|
||||||
|
private static JButton mCheckout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new MainWindow
|
* Creates a new MainWindow
|
||||||
@@ -59,14 +69,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,53 +95,100 @@ 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);
|
lblDatabasePassword = new JLabel("Database Password");
|
||||||
|
panel.add(lblDatabasePassword);
|
||||||
|
|
||||||
|
mPassWord = new JPasswordField();
|
||||||
|
mPassWord.setColumns(10);
|
||||||
|
mPassWord.setEnabled(false);
|
||||||
|
panel.add(mPassWord);
|
||||||
|
|
||||||
|
mConnectButton = new JButton("Connect", new ImageIcon(getClass().getResource("/repeat.png")));
|
||||||
|
mConnectButton.addActionListener(this);
|
||||||
|
panel.add(mConnectButton);
|
||||||
|
|
||||||
|
mCheckout = new JButton("Checkout Remote Database", new ImageIcon(getClass().getResource("/database_down.png")));
|
||||||
|
mCheckout.addActionListener(this);
|
||||||
|
mCheckout.setEnabled(false);
|
||||||
|
panel.add(mCheckout);
|
||||||
|
|
||||||
|
// panel.add(mWarningLabel);
|
||||||
|
|
||||||
//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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* loads an instance of the order database using the most current settings
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
public static void loadDatabase() {
|
public static void loadDatabase() {
|
||||||
//order count labels
|
BasicTextEncryptor passwordEncryptor = new BasicTextEncryptor();
|
||||||
|
passwordEncryptor.setPassword(OrderDB.PASSWORD);
|
||||||
|
|
||||||
|
isUsingRemoteServer = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
db = new OrderDB();
|
Properties p = getProperties();
|
||||||
orderCountLabel.setText(db.getCount()+"");
|
|
||||||
mWarningLabel.setText("");
|
isUsingRemoteServer = Boolean.parseBoolean(p.getProperty(SettingsPanel.IS_USING_REMOTE_SERVER, "false"));
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
mPassWord.setEnabled((! Boolean.parseBoolean(p.getProperty(SettingsPanel.SAVE_PASSWORD, "false"))) && (isUsingRemoteServer));
|
||||||
mWarningLabel.setText(e.getMessage());
|
if(! mPassWord.isEnabled())
|
||||||
mWarningLabel.setVisible(true);
|
mPassWord.setText(passwordEncryptor.decrypt(p.getProperty(SettingsPanel.SERVER_PASSWORD)));
|
||||||
} catch (SocketException e) {
|
} catch (IOException e) {
|
||||||
mWarningLabel.setText(e.getMessage());
|
|
||||||
mWarningLabel.setVisible(true);
|
|
||||||
} catch (NullPointerException e){
|
|
||||||
mWarningLabel.setText("Database not avilable");
|
|
||||||
mWarningLabel.setVisible(true);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mConnectButton.setEnabled(false);
|
||||||
|
mProgressBar.setString("Connecting to database");
|
||||||
|
mProgressBar.setIndeterminate(true);
|
||||||
|
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
//order count labels
|
||||||
|
try {
|
||||||
|
db = isUsingRemoteServer ? new OrderDB(new String(mPassWord.getPassword())) : new OrderDB();
|
||||||
|
orderCountLabel.setText(db.getCount()+"");
|
||||||
|
mProgressBar.setString("Connected");
|
||||||
|
mPassWord.setEnabled(false);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
mProgressBar.setString(e.getMessage());
|
||||||
|
mConnectButton.setEnabled(true);
|
||||||
|
orderCountLabel.setText("");
|
||||||
|
} catch (SocketException e) {
|
||||||
|
mProgressBar.setString(e.getMessage());
|
||||||
|
mConnectButton.setEnabled(true);
|
||||||
|
orderCountLabel.setText("");
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
mProgressBar.setString("Database not avilable");
|
||||||
|
mConnectButton.setEnabled(true);
|
||||||
|
orderCountLabel.setText("");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
mCheckout.setEnabled( (isUsingRemoteServer && ! mConnectButton.isEnabled()) );
|
||||||
|
mProgressBar.setIndeterminate(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +215,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) {
|
||||||
@@ -173,6 +232,29 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
mProgressBar.setIndeterminate(false);
|
mProgressBar.setIndeterminate(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(e.getSource() == mConnectButton){
|
||||||
|
loadDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e.getSource() == mCheckout)
|
||||||
|
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
db.setOnProgressListerner(MainWindow.this);
|
||||||
|
try {
|
||||||
|
db.checkoutDatabase();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -197,9 +279,24 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
mWarningLabel.setText(e.getMessage());
|
mProgressBar.setString(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gets the properties from the save file
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private static Properties getProperties() throws IOException{
|
||||||
|
// create and load default properties
|
||||||
|
Properties props = new Properties();
|
||||||
|
FileInputStream in = new FileInputStream(SettingsPanel.PROPERTIES_FILE_NAME);
|
||||||
|
props.load(in);
|
||||||
|
in.close();
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,36 +44,51 @@ public class OrderPane extends JScrollPane {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* displays orders
|
* displays orders
|
||||||
*
|
* @param list of orders to display
|
||||||
* @param list
|
|
||||||
* of orders to display
|
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
public void displayOrders(ArrayList<Order> list) {
|
public void displayOrders(ArrayList<Order> list) {
|
||||||
ArrayList<String> styles = new ArrayList<String>();
|
ArrayList<TextStyle> styles = new ArrayList<TextStyle>();
|
||||||
mOutput.setText(null);
|
mOutput.setText(null);
|
||||||
BigDecimal possible = new BigDecimal(0);
|
BigDecimal possible = new BigDecimal(0);
|
||||||
BigDecimal actual = new BigDecimal(0);
|
BigDecimal actual = new BigDecimal(0);
|
||||||
|
BigDecimal possibleNew = new BigDecimal(0);
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for (Order item : list) {
|
int newOrders = 0;
|
||||||
if(mListener != null)
|
|
||||||
mListener.onProgressUpdate("Processing Order: "+ (total+1) +" of "+ list.size(), false, total, list.size());
|
|
||||||
|
|
||||||
switch (item.getFulfillmentStatus()) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
if(mListener != null)
|
||||||
|
mListener.onProgressUpdate("Processing Order: "+ (i+1) +" of "+ list.size(), false, (i+1), list.size());
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (list.get(i).getFulfillmentStatus()) {
|
||||||
case WILL_NOT_DELIVER:
|
case WILL_NOT_DELIVER:
|
||||||
styles.add(TextStyle.RED.toString());
|
styles.add(TextStyle.RED);
|
||||||
|
break;
|
||||||
|
case NEW:
|
||||||
|
styles.add(TextStyle.BLUE);
|
||||||
|
newOrders++;
|
||||||
|
possibleNew = possibleNew.add(new BigDecimal(list.get(i).getOrderAmount()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
styles.add(TextStyle.REGULAR.toString());
|
styles.add(TextStyle.REGULAR);
|
||||||
total++;
|
total++;
|
||||||
|
actual = actual.add(new BigDecimal((list.get(i).getAmountCharged())));
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
possible = possible.add(new BigDecimal(item.getOrderAmount()));
|
//This is just in case I missed a order status again
|
||||||
actual = actual.add(new BigDecimal(item.getAmountCharged()));
|
styles.add(TextStyle.ITALIC);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
possible = possible.add(new BigDecimal((list.get(i).getOrderAmount())));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTextPane(list, styles);
|
updateTextPane(list, styles);
|
||||||
updateTextPane("\nPossible sales: $" + possible.setScale(2, BigDecimal.ROUND_DOWN) + "\nActual sales: $" + actual.setScale(2, BigDecimal.ROUND_DOWN) + "\nPossible sold:" + list.size() + "\nTotal sold: " + total, TextStyle.BOLD);
|
updateTextPane("\nPossible sold: " + list.size()
|
||||||
|
+"\nPossible sales: $" + possible.setScale(2, BigDecimal.ROUND_DOWN)
|
||||||
|
+ ( (newOrders > 0) ? "\n\nTotal new sales: "+ newOrders + "\nPossible new sales: $"+ possibleNew.setScale(2, BigDecimal.ROUND_DOWN) : "")
|
||||||
|
+ "\n\nTotal sold: " + total
|
||||||
|
+ "\nActual sales: $" + actual.setScale(2, BigDecimal.ROUND_DOWN) , TextStyle.BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,14 +97,14 @@ public class OrderPane extends JScrollPane {
|
|||||||
* @param styles for the orders
|
* @param styles for the orders
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void updateTextPane(ArrayList<Order> list, ArrayList<String> styles) {
|
private void updateTextPane(ArrayList<Order> list, ArrayList<TextStyle> styles) {
|
||||||
StyledDocument doc = mOutput.getStyledDocument();
|
StyledDocument doc = mOutput.getStyledDocument();
|
||||||
addStylesToDocument(doc);
|
addStylesToDocument(doc);
|
||||||
// Load the text pane with styled text.
|
// Load the text pane with styled text.
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
doc.insertString(doc.getLength(), "\n"+list.get(i).toString(),
|
doc.insertString(doc.getLength(), "\n"+list.get(i).toString(),
|
||||||
doc.getStyle(styles.get(i)));
|
doc.getStyle(styles.get(i).toString()));
|
||||||
}
|
}
|
||||||
} catch (BadLocationException ble) {
|
} catch (BadLocationException ble) {
|
||||||
System.err.println("Couldn't insert initial text into text pane.");
|
System.err.println("Couldn't insert initial text into text pane.");
|
||||||
@@ -97,29 +112,26 @@ public class OrderPane extends JScrollPane {
|
|||||||
mOutput.setDocument(doc);
|
mOutput.setDocument(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the text contained by this order pane
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
public String getText(){
|
public String getText(){
|
||||||
return mOutput.getText();
|
return mOutput.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds the following string to the textpane
|
* adds the following string to the order pane
|
||||||
*
|
|
||||||
* @param string
|
* @param string
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
private void updateTextPane(String string, TextStyle style) {
|
private void updateTextPane(String string, TextStyle style) {
|
||||||
String[] initString = { "\n" + string };
|
|
||||||
String[] initStyles = { style.toString() };
|
|
||||||
|
|
||||||
StyledDocument doc = mOutput.getStyledDocument();
|
StyledDocument doc = mOutput.getStyledDocument();
|
||||||
addStylesToDocument(doc);
|
addStylesToDocument(doc);
|
||||||
|
|
||||||
// Load the text pane with styled text.
|
// Load the text pane with styled text.
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < initString.length; i++) {
|
doc.insertString(doc.getLength(), string, doc.getStyle(style.toString()));
|
||||||
doc.insertString(doc.getLength(), initString[i],
|
|
||||||
doc.getStyle(initStyles[i]));
|
|
||||||
}
|
|
||||||
} catch (BadLocationException ble) {
|
} catch (BadLocationException ble) {
|
||||||
System.err.println("Couldn't insert initial text into text pane.");
|
System.err.println("Couldn't insert initial text into text pane.");
|
||||||
}
|
}
|
||||||
@@ -129,7 +141,6 @@ public class OrderPane extends JScrollPane {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* adds supported styles to the document
|
* adds supported styles to the document
|
||||||
*
|
|
||||||
* @param doc
|
* @param doc
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -143,6 +154,7 @@ public class OrderPane extends JScrollPane {
|
|||||||
|
|
||||||
Style s = doc.addStyle("ITALIC", regular);
|
Style s = doc.addStyle("ITALIC", regular);
|
||||||
StyleConstants.setItalic(s, true);
|
StyleConstants.setItalic(s, true);
|
||||||
|
StyleConstants.setBackground(s, Color.YELLOW);
|
||||||
|
|
||||||
s = doc.addStyle("BOLD", regular);
|
s = doc.addStyle("BOLD", regular);
|
||||||
StyleConstants.setBold(s, true);
|
StyleConstants.setBold(s, true);
|
||||||
@@ -151,13 +163,13 @@ public class OrderPane extends JScrollPane {
|
|||||||
StyleConstants.setForeground(s, Color.RED);
|
StyleConstants.setForeground(s, Color.RED);
|
||||||
StyleConstants.setBold(s, true);
|
StyleConstants.setBold(s, true);
|
||||||
|
|
||||||
s = doc.addStyle("GREEN", regular);
|
s = doc.addStyle("BLUE", regular);
|
||||||
StyleConstants.setForeground(s, Color.GREEN);
|
StyleConstants.setForeground(s, Color.BLUE);
|
||||||
|
StyleConstants.setBold(s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sets a listener for db progress updates
|
* sets a listener for db progress updates
|
||||||
*
|
|
||||||
* @param listener
|
* @param listener
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
*/
|
*/
|
||||||
@@ -14,7 +14,6 @@ import java.awt.event.MouseListener;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.SocketException;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
@@ -34,7 +33,6 @@ import com.TwentyCodes.java.OrderProcessor.Date;
|
|||||||
import com.TwentyCodes.java.OrderProcessor.DatePickerListener;
|
import com.TwentyCodes.java.OrderProcessor.DatePickerListener;
|
||||||
import com.TwentyCodes.java.OrderProcessor.FileFilter;
|
import com.TwentyCodes.java.OrderProcessor.FileFilter;
|
||||||
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
|
||||||
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;
|
||||||
|
|
||||||
@@ -45,20 +43,17 @@ import com.TwentyCodes.java.OrderProcessor.ProgressListener;
|
|||||||
public class SearchPanel extends JPanel 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 START_DATE_RESULT = 0;
|
|
||||||
private JButton mOkButton;
|
private JButton mOkButton;
|
||||||
private JTextField mTextField;
|
private JTextField mTextField;
|
||||||
private JProgressBar mProgressBar;
|
private JProgressBar mProgressBar;
|
||||||
private boolean isProcessing = false;
|
|
||||||
private int mListSize;
|
|
||||||
private OrderPane mOrderPanel;
|
private OrderPane mOrderPanel;
|
||||||
private JTextField mStartDateField;
|
private JTextField mStartDateField;
|
||||||
private JTextField mEndDateField;
|
private JTextField mEndDateField;
|
||||||
private JCheckBox mExclusiveCheckBox;
|
private JCheckBox mExclusiveCheckBox;
|
||||||
private JButton mExportButton;
|
private JButton mExportButton;
|
||||||
private JFileChooser fc;
|
private JFileChooser fc;
|
||||||
private JCheckBox fcCheckBox;
|
// private JCheckBox fcCheckBox;
|
||||||
private JFrame mFrame;
|
private JFrame mFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -120,12 +115,11 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
//progress bar
|
//progress bar
|
||||||
mProgressBar = new JProgressBar();
|
mProgressBar = new JProgressBar();
|
||||||
add(mProgressBar, BorderLayout.SOUTH);
|
add(mProgressBar, BorderLayout.SOUTH);
|
||||||
|
mProgressBar.setStringPainted(true);
|
||||||
|
|
||||||
//file chooser
|
//file chooser
|
||||||
fc = new JFileChooser();
|
fc = new JFileChooser();
|
||||||
fc.setFileFilter(new FileFilter());
|
fc.setFileFilter(new FileFilter());
|
||||||
fcCheckBox = new JCheckBox("Automatically append extention");
|
|
||||||
fcCheckBox.setSelected(true);
|
|
||||||
fc.setAccessory(fcCheckBox);
|
|
||||||
|
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
@@ -164,15 +158,21 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
private boolean exportToCSV() {
|
private boolean exportToCSV() {
|
||||||
if(fc.showDialog(SearchPanel.this, "Export") == JFileChooser.APPROVE_OPTION){
|
if(fc.showDialog(SearchPanel.this, "Export") == JFileChooser.APPROVE_OPTION){
|
||||||
int write = 0;
|
int write = 0;
|
||||||
|
boolean hasExtention;
|
||||||
|
|
||||||
|
String filename = fc.getSelectedFile().toString();
|
||||||
|
String ext =filename.substring((filename.lastIndexOf(".")+1),filename.length());
|
||||||
|
|
||||||
|
hasExtention = ext.equalsIgnoreCase("csv");
|
||||||
|
|
||||||
//file exists dialog
|
//file exists dialog
|
||||||
if(fc.getSelectedFile().exists()){
|
if(new File(filename + (( ! hasExtention ) ? ".csv" : "") ).exists()){
|
||||||
//default icon, custom title
|
//default icon, custom title
|
||||||
write = JOptionPane.showConfirmDialog(
|
write = JOptionPane.showConfirmDialog(
|
||||||
mFrame,
|
mFrame, "Do you want to overwrite"+ filename + ((! hasExtention ) ? ".csv" : ""),
|
||||||
"Do you want to overwrite"+ fc.getSelectedFile().toString(),
|
|
||||||
"Overwrite?",
|
"Overwrite?",
|
||||||
JOptionPane.YES_NO_OPTION);
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
System.out.print(write);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(write == 0){
|
if(write == 0){
|
||||||
@@ -192,11 +192,7 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
}
|
}
|
||||||
//write to the selceted file
|
//write to the selceted file
|
||||||
try {
|
try {
|
||||||
FileOutputStream theFile;
|
FileOutputStream theFile = new FileOutputStream(filename + (( ! hasExtention ) ? ".csv" : ""));
|
||||||
if (fcCheckBox.isSelected())
|
|
||||||
theFile = new FileOutputStream(new File(fc.getSelectedFile().toString()+".csv"));
|
|
||||||
else
|
|
||||||
theFile = new FileOutputStream(fc.getSelectedFile());
|
|
||||||
theFile.write(sb.toString().getBytes());
|
theFile.write(sb.toString().getBytes());
|
||||||
theFile.flush();
|
theFile.flush();
|
||||||
theFile.close();
|
theFile.close();
|
||||||
@@ -220,8 +216,6 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
private void preformSearch(final String search, final Date start, final Date end) {
|
private void preformSearch(final String search, final Date start, final Date end) {
|
||||||
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
mProgressBar.setString("Searching for: "+search);
|
|
||||||
mProgressBar.setStringPainted(true);
|
|
||||||
MainWindow.db.setOnProgressListerner(SearchPanel.this);
|
MainWindow.db.setOnProgressListerner(SearchPanel.this);
|
||||||
|
|
||||||
ArrayList<Order> list = null;
|
ArrayList<Order> list = null;
|
||||||
@@ -239,18 +233,10 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
mListSize = list.size();
|
|
||||||
|
|
||||||
mProgressBar.setMaximum(mProgressBar.getMaximum() + mListSize);
|
|
||||||
isProcessing = true;
|
|
||||||
mProgressBar.setString("Processing Order: "+ 1 +" of "+ mListSize);
|
|
||||||
mFrame.pack();
|
|
||||||
|
|
||||||
mOrderPanel.setOnProgressListerner(SearchPanel.this);
|
mOrderPanel.setOnProgressListerner(SearchPanel.this);
|
||||||
mOrderPanel.displayOrders(list);
|
mOrderPanel.displayOrders(list);
|
||||||
|
|
||||||
isProcessing = false;
|
|
||||||
|
|
||||||
mFrame.pack();
|
mFrame.pack();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -268,24 +254,6 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
mProgressBar.setValue(progress);
|
mProgressBar.setValue(progress);
|
||||||
mProgressBar.setIndeterminate(isIndeterminate);
|
mProgressBar.setIndeterminate(isIndeterminate);
|
||||||
mProgressBar.setString(string);
|
mProgressBar.setString(string);
|
||||||
|
|
||||||
if(Main.DEBUG)
|
|
||||||
System.out.println("search progress = "+ progress);
|
|
||||||
|
|
||||||
progress++;
|
|
||||||
|
|
||||||
if(isProcessing){
|
|
||||||
try {
|
|
||||||
mProgressBar.setValue(progress + MainWindow.db.getCount());
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SocketException e) {
|
|
||||||
mOrderPanel.setText(e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mProgressBar.setValue(progress);
|
|
||||||
mProgressBar.setMaximum(max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -297,11 +265,11 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent e) {
|
public void mouseClicked(MouseEvent e) {
|
||||||
if(e.getSource() == mEndDateField){
|
if(e.getSource() == mEndDateField){
|
||||||
new DatePicker(END_DATE_RESULT, this);
|
new DatePicker(DatePicker.END_DATE_RESULT, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.getSource() == mStartDateField){
|
if(e.getSource() == mStartDateField){
|
||||||
new DatePicker(START_DATE_RESULT, this);
|
new DatePicker(DatePicker.START_DATE_RESULT, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,10 +310,10 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
|||||||
@Override
|
@Override
|
||||||
public void onDatePicked(int resultCode, Date date) {
|
public void onDatePicked(int resultCode, Date date) {
|
||||||
switch(resultCode){
|
switch(resultCode){
|
||||||
case START_DATE_RESULT:
|
case DatePicker.START_DATE_RESULT:
|
||||||
mStartDateField.setText(date.getYear()+"-"+date.getMonth()+"-"+date.getDay()+" "+date.getHour()+":"+date.getMinute()+":"+date.getSecond());
|
mStartDateField.setText(date.getYear()+"-"+date.getMonth()+"-"+date.getDay()+" "+date.getHour()+":"+date.getMinute()+":"+date.getSecond());
|
||||||
break;
|
break;
|
||||||
case END_DATE_RESULT:
|
case DatePicker.END_DATE_RESULT:
|
||||||
mEndDateField.setText(date.getYear()+"-"+date.getMonth()+"-"+date.getDay()+" "+date.getHour()+":"+date.getMinute()+":"+date.getSecond());
|
mEndDateField.setText(date.getYear()+"-"+date.getMonth()+"-"+date.getDay()+" "+date.getHour()+":"+date.getMinute()+":"+date.getSecond());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import javax.swing.GroupLayout;
|
import javax.swing.GroupLayout;
|
||||||
import javax.swing.GroupLayout.Alignment;
|
import javax.swing.GroupLayout.Alignment;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@@ -24,6 +25,10 @@ import javax.swing.JPasswordField;
|
|||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||||
|
|
||||||
|
import org.jasypt.util.text.BasicTextEncryptor;
|
||||||
|
|
||||||
|
import com.TwentyCodes.java.OrderProcessor.DB.OrderDB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this panel will be used to display and handle application settings
|
* this panel will be used to display and handle application settings
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
@@ -36,6 +41,9 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
|||||||
public static final String SERVER_PORT_NUMBER = "server_port_number";
|
public static final String SERVER_PORT_NUMBER = "server_port_number";
|
||||||
public static final String SERVER_USERNAME = "server_user_name";
|
public static final String SERVER_USERNAME = "server_user_name";
|
||||||
public static final String SERVER_PASSWORD = "server_parrword";
|
public static final String SERVER_PASSWORD = "server_parrword";
|
||||||
|
public static final String SAVE_PASSWORD = "save_password";
|
||||||
|
public static final String DATABASE_NAME = "database_name";
|
||||||
|
public static final String PROPERTIES_FILE_NAME = ".orderprocessor.properties";
|
||||||
private JTextField mServerLocation;
|
private JTextField mServerLocation;
|
||||||
private JTextField mPortNumber;
|
private JTextField mPortNumber;
|
||||||
private JTextField mUserName;
|
private JTextField mUserName;
|
||||||
@@ -44,6 +52,8 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JCheckBox mUseRemoteDatabase;
|
private JCheckBox mUseRemoteDatabase;
|
||||||
private Properties mProps;
|
private Properties mProps;
|
||||||
|
private JTextField mDatabaseName;
|
||||||
|
private JCheckBox mSavePassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new SettingsPanel
|
* Creates a new SettingsPanel
|
||||||
@@ -53,59 +63,85 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
|||||||
|
|
||||||
JLabel lblMysqlServerLocation = new JLabel("MYsql server location:");
|
JLabel lblMysqlServerLocation = new JLabel("MYsql server location:");
|
||||||
|
|
||||||
|
//mql database location
|
||||||
mServerLocation = new JTextField();
|
mServerLocation = new JTextField();
|
||||||
mServerLocation.setColumns(10);
|
mServerLocation.setColumns(10);
|
||||||
|
|
||||||
|
//use remote database checkbox
|
||||||
mUseRemoteDatabase = new JCheckBox("Use Remote Database?");
|
mUseRemoteDatabase = new JCheckBox("Use Remote Database?");
|
||||||
mUseRemoteDatabase.addActionListener(this);
|
mUseRemoteDatabase.addActionListener(this);
|
||||||
|
|
||||||
JLabel lblMysqlServerPort = new JLabel("MYsql server port:");
|
JLabel lblMysqlServerPort = new JLabel("MYsql server port:");
|
||||||
|
|
||||||
|
//server port number
|
||||||
mPortNumber = new JTextField();
|
mPortNumber = new JTextField();
|
||||||
|
mPortNumber.setEnabled(false);
|
||||||
mPortNumber.setColumns(10);
|
mPortNumber.setColumns(10);
|
||||||
mPortNumber.setText("3306");
|
|
||||||
|
|
||||||
JLabel lblMysql = new JLabel("MYsql serevr username:");
|
|
||||||
|
|
||||||
|
JLabel lblMysql = new JLabel("MYsql server user name:");
|
||||||
JLabel lblMysqlServerPassword = new JLabel("MYsql server password:");
|
JLabel lblMysqlServerPassword = new JLabel("MYsql server password:");
|
||||||
|
//username
|
||||||
mUserName = new JTextField();
|
mUserName = new JTextField();
|
||||||
mUserName.setColumns(10);
|
mUserName.setColumns(10);
|
||||||
|
|
||||||
|
//user password
|
||||||
mUserPassword = new JPasswordField();
|
mUserPassword = new JPasswordField();
|
||||||
mUserPassword.setColumns(10);
|
mUserPassword.setColumns(10);
|
||||||
|
|
||||||
|
//disable everything
|
||||||
mServerLocation.setEnabled(false);
|
mServerLocation.setEnabled(false);
|
||||||
mPortNumber.setEnabled(false);
|
|
||||||
mUserName.setEnabled(false);
|
mUserName.setEnabled(false);
|
||||||
mUserPassword.setEnabled(false);
|
mUserPassword.setEnabled(false);
|
||||||
|
|
||||||
mSaveButton = new JButton("Save");
|
//save button
|
||||||
|
mSaveButton = new JButton("Save", new ImageIcon(getClass().getResource("/floppy_disc.png")));
|
||||||
mSaveButton.addActionListener(this);
|
mSaveButton.addActionListener(this);
|
||||||
|
|
||||||
|
mSavePassword = new JCheckBox("Save Password?");
|
||||||
|
mSavePassword.addActionListener(this);
|
||||||
|
|
||||||
|
JLabel lblDatabaseName = new JLabel("Database Name:");
|
||||||
|
|
||||||
|
mDatabaseName = new JTextField();
|
||||||
|
mDatabaseName.setEnabled(false);
|
||||||
|
|
||||||
|
mDatabaseName.setColumns(10);
|
||||||
|
|
||||||
|
//group layout bullshit
|
||||||
GroupLayout groupLayout = new GroupLayout(this);
|
GroupLayout groupLayout = new GroupLayout(this);
|
||||||
groupLayout.setHorizontalGroup(
|
groupLayout.setHorizontalGroup(
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(mUseRemoteDatabase)
|
||||||
|
.addContainerGap(1087, Short.MAX_VALUE))
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addComponent(mUseRemoteDatabase)
|
.addComponent(mSavePassword)
|
||||||
.addContainerGap())
|
.addContainerGap())
|
||||||
.addGroup(groupLayout.createSequentialGroup()
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
.addComponent(lblMysqlServerLocation)
|
.addComponent(lblMysqlServerLocation)
|
||||||
.addComponent(lblMysqlServerPort)
|
.addComponent(lblMysqlServerPort)
|
||||||
.addComponent(lblMysql)
|
.addComponent(lblDatabaseName)
|
||||||
.addComponent(lblMysqlServerPassword))
|
.addComponent(lblMysql))
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
|
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
|
||||||
.addComponent(mServerLocation)
|
.addComponent(mPortNumber, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1079, Short.MAX_VALUE)
|
||||||
.addComponent(mSaveButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(mServerLocation, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1079, Short.MAX_VALUE)
|
||||||
.addComponent(mUserPassword)
|
.addComponent(mDatabaseName, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1079, Short.MAX_VALUE)
|
||||||
.addComponent(mUserName)
|
.addComponent(mUserName, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 1079, Short.MAX_VALUE))
|
||||||
.addComponent(mPortNumber))
|
.addContainerGap())))
|
||||||
.addContainerGap(139, Short.MAX_VALUE))))
|
.addGroup(groupLayout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(lblMysqlServerPassword)
|
||||||
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
|
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
|
.addComponent(mUserPassword, GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
|
||||||
|
.addComponent(mSaveButton, GroupLayout.DEFAULT_SIZE, 949, Short.MAX_VALUE))
|
||||||
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
groupLayout.setVerticalGroup(
|
groupLayout.setVerticalGroup(
|
||||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||||
@@ -121,27 +157,30 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
|||||||
.addComponent(lblMysqlServerPort)
|
.addComponent(lblMysqlServerPort)
|
||||||
.addComponent(mPortNumber, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(mPortNumber, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
|
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
|
||||||
|
.addComponent(lblDatabaseName)
|
||||||
|
.addComponent(mDatabaseName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
|
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
|
||||||
.addComponent(lblMysql)
|
.addComponent(mUserName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||||
.addComponent(mUserName, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(lblMysql))
|
||||||
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
|
.addComponent(mSavePassword)
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
|
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
|
||||||
.addComponent(lblMysqlServerPassword)
|
.addComponent(lblMysqlServerPassword)
|
||||||
.addComponent(mUserPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
.addComponent(mUserPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
.addPreferredGap(ComponentPlacement.RELATED)
|
||||||
.addComponent(mSaveButton)
|
.addComponent(mSaveButton)
|
||||||
.addContainerGap(142, Short.MAX_VALUE))
|
.addContainerGap(264, Short.MAX_VALUE))
|
||||||
);
|
);
|
||||||
setLayout(groupLayout);
|
setLayout(groupLayout);
|
||||||
|
|
||||||
// create and load default properties
|
// create and load default properties
|
||||||
mProps = new Properties();
|
mProps = new Properties();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mProps = new java.util.Properties();
|
|
||||||
try {
|
try {
|
||||||
FileInputStream in = new FileInputStream(".settings.propertys");
|
FileInputStream in = new FileInputStream(PROPERTIES_FILE_NAME);
|
||||||
mProps.load(in);
|
mProps.load(in);
|
||||||
in.close();
|
in.close();
|
||||||
isUsingRemoteServer = Boolean.parseBoolean(mProps.getProperty(IS_USING_REMOTE_SERVER, "false"));
|
isUsingRemoteServer = Boolean.parseBoolean(mProps.getProperty(IS_USING_REMOTE_SERVER, "false"));
|
||||||
@@ -150,70 +189,102 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
|||||||
mServerLocation.setEnabled(true);
|
mServerLocation.setEnabled(true);
|
||||||
mPortNumber.setEnabled(true);
|
mPortNumber.setEnabled(true);
|
||||||
mUserName.setEnabled(true);
|
mUserName.setEnabled(true);
|
||||||
mUserPassword.setEnabled(true);
|
mUserPassword.setEnabled( Boolean.parseBoolean(mProps.getProperty(SAVE_PASSWORD, "false")));
|
||||||
mUseRemoteDatabase.setSelected(true);
|
mUseRemoteDatabase.setSelected(true);
|
||||||
|
mDatabaseName.setEnabled(true);
|
||||||
|
mSavePassword.setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mDatabaseName.setText(mProps.getProperty(DATABASE_NAME, "Orders"));
|
||||||
mServerLocation.setText(mProps.getProperty(SERVER_LOCATION));
|
mServerLocation.setText(mProps.getProperty(SERVER_LOCATION));
|
||||||
mPortNumber.setText(mProps.getProperty(SERVER_PORT_NUMBER));;
|
mPortNumber.setText(mProps.getProperty(SERVER_PORT_NUMBER, "3306"));
|
||||||
mUserName.setText(mProps.getProperty(SERVER_USERNAME));;
|
mUserName.setText(mProps.getProperty(SERVER_USERNAME));
|
||||||
|
mSavePassword.setSelected(Boolean.parseBoolean(mProps.getProperty(SAVE_PASSWORD, "false")));
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
mDatabaseName.setText("Orders");
|
||||||
|
mPortNumber.setText("3306");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when the save button is clicked, or the use remote database check box is clicked
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
//save button
|
||||||
if(e.getSource() == mSaveButton){
|
if(e.getSource() == mSaveButton){
|
||||||
|
BasicTextEncryptor passwordEncryptor = new BasicTextEncryptor();
|
||||||
|
passwordEncryptor.setPassword(OrderDB.PASSWORD);
|
||||||
mProps.put(SERVER_LOCATION, mServerLocation.getText());
|
mProps.put(SERVER_LOCATION, mServerLocation.getText());
|
||||||
mProps.put(SERVER_PORT_NUMBER, mPortNumber.getText());
|
mProps.put(SERVER_PORT_NUMBER, mPortNumber.getText());
|
||||||
mProps.put(SERVER_USERNAME, mUserName.getText());
|
mProps.put(SERVER_USERNAME, mUserName.getText());
|
||||||
mProps.put(SERVER_PASSWORD, new String(mUserPassword.getPassword()));
|
mProps.put(DATABASE_NAME, mDatabaseName.getText());
|
||||||
try {
|
|
||||||
FileOutputStream out = new FileOutputStream(".settings.propertys");
|
if(mSavePassword.isSelected())
|
||||||
mProps.store(out, "---No Comment---");
|
mProps.put(SERVER_PASSWORD, new String(passwordEncryptor.encrypt(new String(mUserPassword.getPassword()))));
|
||||||
out.close();
|
|
||||||
} catch (FileNotFoundException e1) {
|
writeProperties(mProps);
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-gene1rated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//use remote database checkbox
|
||||||
if(e.getSource() == mUseRemoteDatabase){
|
if(e.getSource() == mUseRemoteDatabase){
|
||||||
mProps.put(IS_USING_REMOTE_SERVER, Boolean.toString(mUseRemoteDatabase.isSelected()));
|
mProps.put(IS_USING_REMOTE_SERVER, Boolean.toString(mUseRemoteDatabase.isSelected()));
|
||||||
try {
|
writeProperties(mProps);
|
||||||
FileOutputStream out = new FileOutputStream(".settings.propertys");
|
|
||||||
mProps.store(out, "---No Comment---");
|
|
||||||
out.close();
|
|
||||||
} catch (FileNotFoundException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
} catch (IOException e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(mUseRemoteDatabase.isSelected()){
|
if(mUseRemoteDatabase.isSelected()){
|
||||||
mServerLocation.setEnabled(true);
|
mServerLocation.setEnabled(true);
|
||||||
mPortNumber.setEnabled(true);
|
mPortNumber.setEnabled(true);
|
||||||
mUserName.setEnabled(true);
|
mUserName.setEnabled(true);
|
||||||
mUserPassword.setEnabled(true);
|
mUserPassword.setEnabled(true);
|
||||||
|
mDatabaseName.setEnabled(true);
|
||||||
|
mSavePassword.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
mServerLocation.setEnabled(false);
|
mServerLocation.setEnabled(false);
|
||||||
mPortNumber.setEnabled(false);
|
mPortNumber.setEnabled(false);
|
||||||
mUserName.setEnabled(false);
|
mUserName.setEnabled(false);
|
||||||
mUserPassword.setEnabled(false);
|
mUserPassword.setEnabled(false);
|
||||||
|
mDatabaseName.setEnabled(false);
|
||||||
|
mSavePassword.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e.getSource() == mSavePassword){
|
||||||
|
mProps.setProperty(SAVE_PASSWORD, Boolean.toString(mSavePassword.isSelected()));
|
||||||
|
writeProperties(mProps);
|
||||||
|
if(mSavePassword.isSelected()){
|
||||||
|
mUserPassword.setEnabled(true);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mUserPassword.setEnabled(false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow.loadDatabase();
|
MainWindow.loadDatabase();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* writes the Properties to a persitent file
|
||||||
|
* @param p
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private void writeProperties(Properties p){
|
||||||
|
try {
|
||||||
|
FileOutputStream out = new FileOutputStream(PROPERTIES_FILE_NAME);
|
||||||
|
p.store(out, "---Order Processor Settings---");
|
||||||
|
out.close();
|
||||||
|
} catch (FileNotFoundException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ import javax.swing.JProgressBar;
|
|||||||
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 orders in the order database
|
||||||
*/
|
*/
|
||||||
public class ShowAllPanel extends JPanel implements ActionListener, ProgressListener {
|
public class ShowAllPanel extends JPanel implements ActionListener, ProgressListener {
|
||||||
|
|
||||||
@@ -29,6 +29,8 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
|
|||||||
private JProgressBar mProgressBar;
|
private JProgressBar mProgressBar;
|
||||||
private OrderPane mOutput;
|
private OrderPane mOutput;
|
||||||
private JFrame mFrame;
|
private JFrame mFrame;
|
||||||
|
private JButton ok;
|
||||||
|
private JButton clear;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ShowAllDialog
|
* Creates a new ShowAllDialog
|
||||||
@@ -37,45 +39,52 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
|
|||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
mFrame = frame;
|
mFrame = frame;
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
|
||||||
// setTitle("Show All Orders");
|
// setTitle("Show All Orders");
|
||||||
// setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
// setIconImage(new ImageIcon(getClass().getResource("/database.png")).getImage());
|
||||||
|
|
||||||
JButton ok = new JButton("Refresh", new ImageIcon(getClass().getResource("/process.png")));
|
//ok button
|
||||||
|
ok = new JButton("Refresh", new ImageIcon(getClass().getResource("/page_process.png")));
|
||||||
ok.addActionListener(this);
|
ok.addActionListener(this);
|
||||||
|
panel.add(ok);
|
||||||
|
|
||||||
|
//clear button
|
||||||
|
clear = new JButton("Clear", new ImageIcon(getClass().getResource("/page.png")));
|
||||||
|
clear.addActionListener(this);
|
||||||
|
panel.add(clear);
|
||||||
|
|
||||||
mOutput = new OrderPane();
|
mOutput = new OrderPane();
|
||||||
mProgressBar = new JProgressBar();
|
mProgressBar = new JProgressBar();
|
||||||
add(mProgressBar, BorderLayout.SOUTH);
|
add(mProgressBar, BorderLayout.SOUTH);
|
||||||
add(mOutput, BorderLayout.CENTER);
|
add(mOutput, BorderLayout.CENTER);
|
||||||
add(ok, BorderLayout.NORTH);
|
add(panel, BorderLayout.NORTH);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when the buttons are clicked
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
//display all the orders
|
||||||
|
if(e.getSource() == ok){
|
||||||
|
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();
|
||||||
@@ -83,6 +92,20 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//clear the output
|
||||||
|
if(e.getSource() == clear){
|
||||||
|
mOutput.setText(null);
|
||||||
|
onProgressUpdate(null, false, 0, 1);
|
||||||
|
mFrame.pack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called when there is a progress update
|
||||||
|
* (non-Javadoc)
|
||||||
|
* @see com.TwentyCodes.java.OrderProcessor.ProgressListener#onProgressUpdate(java.lang.String, boolean, int, int)
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onProgressUpdate(String string, boolean isIndeterminate, int progress, int max) {
|
public void onProgressUpdate(String string, boolean isIndeterminate, int progress, int max) {
|
||||||
mProgressBar.setMaximum(max);
|
mProgressBar.setMaximum(max);
|
||||||
63
OrderProcessor/version infomation/changelog
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
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.0.2 b 30
|
||||||
|
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
|
||||||
|
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 modified OrderDB to use the .property file
|
||||||
|
|
||||||
|
1.0.6 b 34
|
||||||
|
created the static method MainWindow.loadDatabase() for easy database reloading
|
||||||
|
|
||||||
|
1.1.0 B 45
|
||||||
|
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 print all new order in blue
|
||||||
|
improved order pane processing
|
||||||
|
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
|
||||||
|
|
||||||
|
1.1.2 b 47
|
||||||
|
added clear button to the ShowAllPanel.java
|
||||||
|
fixed the export save dialog to automatically handle extensions
|
||||||
|
added new order stats to the order pane
|
||||||
|
|
||||||
|
1.1.3 b 48
|
||||||
|
fixed processed order stats to only display new order stats when theres new orders
|
||||||
|
added password encryption using jasypt
|
||||||
|
|
||||||
|
1.1.4 b 49
|
||||||
|
added more options in settings allowing user to pick the database name.
|
||||||
|
added an option to allow the user to save their password
|
||||||
|
added a password field to the main panel to allow for easy password entry
|
||||||
|
added a connect button to the main panel
|
||||||
|
|
||||||
|
1.1.5 b 50
|
||||||
|
used similar code to remove redundant code
|
||||||
|
created a static variable for PROPERTIES_FILE_NAME
|
||||||
|
added a case to the order pane to highlight any orders with null statuses
|
||||||
|
slight modification to order pane updateTextPane() s
|
||||||
|
|
||||||
|
1.1.6 b 51
|
||||||
|
added status PAYMENT_DECLINED
|
||||||
|
|
||||||
|
1.1.7 b 52
|
||||||
|
added a checkout button to the Main Panel. It allows the user to "checkout" a remote database to a local database
|
||||||
|
removed the warning label from main panel, and moved all messages to the progress bar
|
||||||
1
OrderProcessor/version infomation/version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
1.1.7 b 52
|
||||||