added clear button to the ShowAllPanel.java
fixed the export save dialog to automatically handle extensions added new order stats to the order pane
This commit is contained in:
BIN
Order Processor/images/page.png
Normal file
BIN
Order Processor/images/page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Order Processor/images/page_process.png
Normal file
BIN
Order Processor/images/page_process.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
@@ -54,7 +54,9 @@ public class OrderPane extends JScrollPane {
|
||||
mOutput.setText(null);
|
||||
BigDecimal possible = new BigDecimal(0);
|
||||
BigDecimal actual = new BigDecimal(0);
|
||||
BigDecimal possibleNew = new BigDecimal(0);
|
||||
int total = 0;
|
||||
int newOrders = 0;
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if(mListener != null)
|
||||
@@ -67,6 +69,8 @@ public class OrderPane extends JScrollPane {
|
||||
break;
|
||||
case NEW:
|
||||
styles.add(TextStyle.BLUE.toString());
|
||||
newOrders++;
|
||||
possibleNew = possibleNew.add(new BigDecimal(list.get(i).getOrderAmount()));
|
||||
break;
|
||||
default:
|
||||
styles.add(TextStyle.REGULAR.toString());
|
||||
@@ -82,7 +86,12 @@ public class OrderPane extends JScrollPane {
|
||||
}
|
||||
|
||||
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)
|
||||
+ "\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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
||||
private JCheckBox mExclusiveCheckBox;
|
||||
private JButton mExportButton;
|
||||
private JFileChooser fc;
|
||||
private JCheckBox fcCheckBox;
|
||||
// private JCheckBox fcCheckBox;
|
||||
private JFrame mFrame;
|
||||
|
||||
/**
|
||||
@@ -120,9 +120,6 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
||||
//file chooser
|
||||
fc = new JFileChooser();
|
||||
fc.setFileFilter(new FileFilter());
|
||||
fcCheckBox = new JCheckBox("Automatically append extention");
|
||||
fcCheckBox.setSelected(true);
|
||||
fc.setAccessory(fcCheckBox);
|
||||
|
||||
setVisible(true);
|
||||
}
|
||||
@@ -161,15 +158,21 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
||||
private boolean exportToCSV() {
|
||||
if(fc.showDialog(SearchPanel.this, "Export") == JFileChooser.APPROVE_OPTION){
|
||||
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
|
||||
if(fc.getSelectedFile().exists()){
|
||||
if(new File(filename + (( ! hasExtention ) ? ".csv" : "") ).exists()){
|
||||
//default icon, custom title
|
||||
write = JOptionPane.showConfirmDialog(
|
||||
mFrame,
|
||||
"Do you want to overwrite"+ fc.getSelectedFile().toString(),
|
||||
mFrame, "Do you want to overwrite"+ filename + ((! hasExtention ) ? ".csv" : ""),
|
||||
"Overwrite?",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
System.out.print(write);
|
||||
}
|
||||
|
||||
if(write == 0){
|
||||
@@ -189,11 +192,7 @@ public class SearchPanel extends JPanel implements ActionListener, ProgressListe
|
||||
}
|
||||
//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());
|
||||
FileOutputStream theFile = new FileOutputStream(filename + (( ! hasExtention ) ? ".csv" : ""));
|
||||
theFile.write(sb.toString().getBytes());
|
||||
theFile.flush();
|
||||
theFile.close();
|
||||
|
||||
@@ -53,36 +53,42 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
||||
|
||||
JLabel lblMysqlServerLocation = new JLabel("MYsql server location:");
|
||||
|
||||
//mql database location
|
||||
mServerLocation = new JTextField();
|
||||
mServerLocation.setColumns(10);
|
||||
|
||||
//use remote database checkbox
|
||||
mUseRemoteDatabase = new JCheckBox("Use Remote Database?");
|
||||
mUseRemoteDatabase.addActionListener(this);
|
||||
|
||||
JLabel lblMysqlServerPort = new JLabel("MYsql server port:");
|
||||
|
||||
//server port number
|
||||
mPortNumber = new JTextField();
|
||||
mPortNumber.setColumns(10);
|
||||
mPortNumber.setText("3306");
|
||||
|
||||
JLabel lblMysql = new JLabel("MYsql serevr username:");
|
||||
|
||||
JLabel lblMysqlServerPassword = new JLabel("MYsql server password:");
|
||||
|
||||
//username
|
||||
mUserName = new JTextField();
|
||||
mUserName.setColumns(10);
|
||||
|
||||
//user password
|
||||
mUserPassword = new JPasswordField();
|
||||
mUserPassword.setColumns(10);
|
||||
|
||||
//disable everything
|
||||
mServerLocation.setEnabled(false);
|
||||
mPortNumber.setEnabled(false);
|
||||
mUserName.setEnabled(false);
|
||||
mUserPassword.setEnabled(false);
|
||||
|
||||
//save button
|
||||
mSaveButton = new JButton("Save");
|
||||
mSaveButton.addActionListener(this);
|
||||
|
||||
//group layout bullshit
|
||||
GroupLayout groupLayout = new GroupLayout(this);
|
||||
groupLayout.setHorizontalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
@@ -137,9 +143,6 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
||||
// create and load default properties
|
||||
mProps = new Properties();
|
||||
|
||||
|
||||
|
||||
mProps = new java.util.Properties();
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(".settings.propertys");
|
||||
mProps.load(in);
|
||||
@@ -164,8 +167,16 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
//save button
|
||||
if(e.getSource() == mSaveButton){
|
||||
mProps.put(SERVER_LOCATION, mServerLocation.getText());
|
||||
mProps.put(SERVER_PORT_NUMBER, mPortNumber.getText());
|
||||
@@ -185,6 +196,7 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
||||
|
||||
}
|
||||
|
||||
//use remote database checkbox
|
||||
if(e.getSource() == mUseRemoteDatabase){
|
||||
mProps.put(IS_USING_REMOTE_SERVER, Boolean.toString(mUseRemoteDatabase.isSelected()));
|
||||
try {
|
||||
@@ -192,10 +204,8 @@ public class SettingsPanel extends JPanel implements ActionListener {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import javax.swing.JProgressBar;
|
||||
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 {
|
||||
|
||||
@@ -29,6 +29,8 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
|
||||
private JProgressBar mProgressBar;
|
||||
private OrderPane mOutput;
|
||||
private JFrame mFrame;
|
||||
private JButton ok;
|
||||
private JButton clear;
|
||||
|
||||
/**
|
||||
* Creates a new ShowAllDialog
|
||||
@@ -37,41 +39,73 @@ public class ShowAllPanel extends JPanel implements ActionListener, ProgressList
|
||||
super(new BorderLayout());
|
||||
mFrame = frame;
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
|
||||
// setTitle("Show All Orders");
|
||||
// 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);
|
||||
panel.add(ok);
|
||||
|
||||
//clear button
|
||||
clear = new JButton("Clear", new ImageIcon(getClass().getResource("/page.png")));
|
||||
clear.addActionListener(this);
|
||||
panel.add(clear);
|
||||
|
||||
mOutput = new OrderPane();
|
||||
mProgressBar = new JProgressBar();
|
||||
add(mProgressBar, BorderLayout.SOUTH);
|
||||
add(mOutput, BorderLayout.CENTER);
|
||||
add(ok, BorderLayout.NORTH);
|
||||
mProgressBar.setString("Loading from Database");
|
||||
add(panel, BorderLayout.NORTH);
|
||||
mProgressBar.setStringPainted(true);
|
||||
frame.pack();
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* called when the buttons are clicked
|
||||
* (non-Javadoc)
|
||||
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||||
* @author ricky barrette
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
MainWindow.db.setOnProgressListerner(this);
|
||||
java.util.concurrent.Executors.newSingleThreadExecutor().submit(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
mOutput.displayOrders(MainWindow.db.getAllOrders());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
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() {
|
||||
public void run() {
|
||||
try {
|
||||
mOutput.displayOrders(MainWindow.db.getAllOrders());
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mFrame.pack();
|
||||
}
|
||||
mFrame.pack();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//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
|
||||
public void onProgressUpdate(String string, boolean isIndeterminate, int progress, int max) {
|
||||
mProgressBar.setMaximum(max);
|
||||
|
||||
@@ -33,3 +33,8 @@ 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 @@
|
||||
1.1.0 b 35
|
||||
1.1.2 b 47
|
||||
Reference in New Issue
Block a user