413 |
413 |
414 def CloseProject(self): |
414 def CloseProject(self): |
415 self.ClearChildren() |
415 self.ClearChildren() |
416 self.ResetAppFrame(None) |
416 self.ResetAppFrame(None) |
417 |
417 |
|
418 def CheckNewProjectPath(self, old_project_path, new_project_path): |
|
419 if old_project_path == new_project_path: |
|
420 message = (_("Save path is the same as path of a project! \n")) |
|
421 dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.OK | wx.ICON_ERROR) |
|
422 dialog.ShowModal() |
|
423 return False |
|
424 else: |
|
425 plc_file = os.path.join(new_project_path, "plc.xml") |
|
426 if os.path.isfile(plc_file): |
|
427 message = (_("Selected directory already contains another project. Overwrite? \n")) |
|
428 dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.YES_NO | wx.ICON_ERROR) |
|
429 answer = dialog.ShowModal() |
|
430 return answer == wx.ID_YES |
|
431 return True |
|
432 |
418 def SaveProject(self, from_project_path=None): |
433 def SaveProject(self, from_project_path=None): |
419 if self.CheckProjectPathPerm(False): |
434 if self.CheckProjectPathPerm(False): |
420 if from_project_path is not None: |
435 if from_project_path is not None: |
421 old_projectfiles_path = self._getProjectFilesPath(from_project_path) |
436 old_projectfiles_path = self._getProjectFilesPath(from_project_path) |
422 if os.path.isdir(old_projectfiles_path): |
437 if os.path.isdir(old_projectfiles_path): |
437 answer = dirdialog.ShowModal() |
452 answer = dirdialog.ShowModal() |
438 dirdialog.Destroy() |
453 dirdialog.Destroy() |
439 if answer == wx.ID_OK: |
454 if answer == wx.ID_OK: |
440 newprojectpath = dirdialog.GetPath() |
455 newprojectpath = dirdialog.GetPath() |
441 if os.path.isdir(newprojectpath): |
456 if os.path.isdir(newprojectpath): |
442 self.ProjectPath, old_project_path = newprojectpath, self.ProjectPath |
457 if self.CheckNewProjectPath(self.ProjectPath, newprojectpath): |
443 self.SaveProject(old_project_path) |
458 self.ProjectPath, old_project_path = newprojectpath, self.ProjectPath |
444 self._setBuildPath(self.BuildPath) |
459 self.SaveProject(old_project_path) |
|
460 self._setBuildPath(self.BuildPath) |
445 return True |
461 return True |
446 return False |
462 return False |
447 |
463 |
448 def GetLibrariesTypes(self): |
464 def GetLibrariesTypes(self): |
449 self.LoadLibraries() |
465 self.LoadLibraries() |