JFileChooser fdCreate=new JFileChooser(strDirrectory);
fdCreate.addChoosableFileFilter(new FileFilterImpl("vcd", "Virtual cache database"));
int intResult=fdCreate.showSaveDialog(fdCreate);
if(intResult==JFileChooser.APPROVE_OPTION)
{
Password pcPass=new Password(mwcMain);
//pcPass.setCheckPasswordStrenght(true);
pcPass.setVisible(true);
if(pcPass.getPassword()!=null)
{
InputBox inProfile=new InputBox(mwcMain, "Enter the name of this profile:", "The profile name could not be empty!");
inProfile.setCheckEmpty(true);
inProfile.setVisible(true);
if(inProfile.getResult()==null)
return;
Profile prfMain=new Profile(inProfile.getResult());
inProfile=null;
FileWriter fwDBWriter;
if(!fdCreate.getSelectedFile().exists())
{
if((!fdCreate.getSelectedFile().getName().toLowerCase().endsWith(".vcd"))&&(!(new File(fdCreate.getSelectedFile().getName()+".vcd")).exists()))
fwDBWriter=new FileWriter(fdCreate.getSelectedFile()+".vcd", prfMain);
else
fwDBWriter=new FileWriter(fdCreate.getSelectedFile(), prfMain);
}
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;
fdCreate=null;
return;
}
fwDBWriter=new FileWriter(fdCreate.getSelectedFile(), prfMain);
}
if(!fwDBWriter.write(pcPass.getPassword()))
{
OKMessage okError=new OKMessage(mwcMain, "The error occured while writing the file!");
okError.setVisible(true);
okError=null;
}
else
{
mwcMain.setPassword(pcPass.getPassword());
mwcMain.setProfile(prfMain);
mwcMain.setOpenedFile(fdCreate.getSelectedFile());
IniHolder.WriteValue("DataWorkDir", fdCreate.getSelectedFile().getAbsolutePath());
}
fwDBWriter=null;
}
pcPass.erasePass();
pcPass=null;
}
fdCreate=null;
strDirrectory=null;
}