* @param project
* @param projectLocation
*/
public void saveProjectFile(Project project, ProjectLocation projectLocation) {
String projectFile = "";
SSHDataHandler handler = null;
String remotePath = "";
if (projectLocation == ProjectLocation.LOCALE) {
projectFile = workspaceDir + project.getPathName()
+ JSimConstants.PROJECTCONFFILE;
} else {
RemoteProject rmProject = (RemoteProject) project;
handler = (SSHDataHandler) rmProject.getDataHandler();
remotePath = rmProject.getPath() + rmProject.getName() + "/"
+ JSimConstants.PROJECTCONFFILE;
projectFile = handler
.createTempPath(rmProject.getPath() + rmProject.getName()
+ "/" + JSimConstants.PROJECTCONFFILE);
projectFile += JSimConstants.PROJECTCONFFILE;
}
IXMLWriter projectWriter = new ProjectSAXWriter(project);
try {
projectWriter.writeXML(projectFile);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, e.getMessage(), "Save error",
JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
if (projectLocation == ProjectLocation.SSH) {
try {
boolean copy = true;
try {
handler.getDirectoryEntry(remotePath);
copy = false;
} catch (IOException e) {
copy = true;
}
if (copy)
handler.copyToServer(new File(projectFile));
} catch (IOException e) {
JOptionPane.showMessageDialog(frame, e.getMessage(),
"Save error", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}