if(!blnEquals)
break;
}
if(!blnEquals)
{
OKMessage okm=new OKMessage(mwcMain, "IncorrectPassword!");
okm.setVisible(true);
okm=null;
return;
}
pswPass=null;
String strDirrectory=IniHolder.ReadValue("ExportWorkDir");
if(strDirrectory==null)
{
if(System.getenv("HOMEPATH")!=null)
strDirrectory=new String(System.getenv("HOMEPATH")+"\\My Documents");
else
strDirrectory=new String(System.getenv("HOME"));
}
JFileChooser jfcExport=new JFileChooser(strDirrectory);
jfcExport.addChoosableFileFilter(new FileFilterImpl("csv", "Text file"));
//jfcExport.addChoosableFileFilter(new FileFilterImpl("txt", "Text file"));
int intResult=jfcExport.showSaveDialog(mwcMain);
if(intResult!=JFileChooser.APPROVE_OPTION)
return;
IniHolder.WriteValue("ExportWorkDir", jfcExport.getSelectedFile().getAbsolutePath().substring(0, jfcExport.getSelectedFile().getAbsolutePath().lastIndexOf((int)File.separatorChar)));
File fleOutput=jfcExport.getSelectedFile();
if(!jfcExport.getSelectedFile().exists())
{
if((!jfcExport.getSelectedFile().getName().toLowerCase().endsWith(".csv"))&&(!(new File(jfcExport.getSelectedFile().getName()+".csv")).exists()))
fleOutput=new File(jfcExport.getSelectedFile().getAbsolutePath()+".csv");
}
else
{
YesNoCancelMessage ynmDelete=new YesNoCancelMessage(mwcMain, mwcMain.getTitle(), "The file already exists would you like to replace it?", false);
ynmDelete.setVisible(true);
if(ynmDelete.getResult()==YesNoCancelMessage.NO)
{
ynmDelete=null;
jfcExport=null;
return;
}
}
FileOutputStream fosWriter;
StringBuffer sbString=new StringBuffer();
try
{
fosWriter=new FileOutputStream(fleOutput);
DefaultTableModel dtmTrans=(DefaultTableModel)mwcMain.getCurrentTransactionTable().getModel();
for(int i=0; i<dtmTrans.getRowCount(); i++)
{
for(int j=0; j<dtmTrans.getColumnCount(); j++)
{
if(j==0)
continue;
if(j!=1)
sbString.append("\"");
if(j==2)
sbString.append(-Double.parseDouble(dtmTrans.getValueAt(i, j).toString()));
else
sbString.append(dtmTrans.getValueAt(i, j));
if(j!=1)
sbString.append("\"");
if(j!=dtmTrans.getColumnCount()-1)
sbString.append(',');
}
sbString.append('\n');
fosWriter.write(sbString.toString().getBytes());
sbString.delete(0, sbString.length());
}
}
catch(IOException ex)
{
OKMessage okm=new OKMessage(mwcMain, "Unable to write file to disk!");
okm.setVisible(true);
okm=null;
}
finally
{
fosWriter=null;