projectFile.setApproveButtonText(Resources.getString("importProject"));
ExtensionFileFilter filter = new ExtensionFileFilter(Common.PROJECT_FILE_SUFFIX,"Project files");
projectFile.addChoosableFileFilter(filter);
projectFile.setFileFilter(filter);
if (projectFile.showSaveDialog(this)==JFileChooser.APPROVE_OPTION) {
StatusWindow waitWindow = new StatusWindow(this,Resources.getString("pleaseWait"),"");
try {
String importProjectName = Utils.removeSuffix(Utils.extractFileName(projectFile.getSelectedFile().getCanonicalPath()));
String importProjectPath = Utils.extractPath(projectFile.getSelectedFile().getCanonicalPath());
String importResultsDirectory = importProjectPath+File.separator+Common.RESULTS_DIR_NAME+File.separator+importProjectName;
String src, dest;
waitWindow.setMessage("Project file");
// copy the prj file to our .qat directory
src=projectFile.getSelectedFile().getCanonicalPath();
dest=Common.getHarnessBaseDirectory();
//System.out.println("Copying :"+src+" to :"+dest);
SwingUtils.copy(src,dest,waitWindow);
waitWindow.setMessage("Serialiased file");
// copy the ser file to out .qat directory
src = Utils.ensureSuffix(projectFile.getSelectedFile().getCanonicalPath(),Common.SERIALIZED_TREE_EXTENSION);
dest = Common.getHarnessBaseDirectory();
//System.out.println("Copying :"+src+" to :"+dest);
SwingUtils.copy(src,dest,waitWindow);
// copy the results directory to out .qat/harness/results directory
try {
waitWindow.setMessage("Results");
src = importResultsDirectory;
dest = Common.getHarnessBaseDirectory()+File.separator+Common.RESULTS_DIR_NAME+File.separator+importProjectName;
//System.out.println("Copying :"+src+" to :"+dest);
SwingUtils.copy(src,dest,waitWindow);
}
catch (IOException e) {
// don't report, it only means no results directory was found to be copied.
}
// load this project
loadProject(Common.getHarnessBaseDirectory()+File.separator+Utils.ensureSuffix(importProjectName,Common.PROJECT_FILE_SUFFIX));
}
catch (Exception e) {
e.printStackTrace();
}
finally {
waitWindow.setVisible(false);
}
projectPropertiesChanged();
}
}