Adding support for adding default configuration on opened project without any
authorLaurent Bessard
Sat, 22 Sep 2012 12:33:39 +0200
changeset 839 25ba9d74afb1
parent 838 06db7d4edbe6
child 840 980863738cf6
Adding support for adding default configuration on opened project without any
ProjectController.py
--- a/ProjectController.py	Sat Sep 22 12:23:58 2012 +0200
+++ b/ProjectController.py	Sat Sep 22 12:33:39 2012 +0200
@@ -237,6 +237,10 @@
             os.mkdir(projectfiles_path)
         return projectfiles_path
     
+    def AddProjectDefaultConfiguration(self, config_name="config", res_name="resource1"):
+        self.ProjectAddConfiguration(config_name)
+        self.ProjectAddConfigurationResource(config_name, res_name)
+
     def NewProject(self, ProjectPath, BuildPath=None):
         """
         Create a new project in an empty folder
@@ -254,8 +258,7 @@
              "productVersion": "1",
              "companyName": _("Unknown"),
              "creationDateTime": datetime(*localtime()[:6])})
-        self.ProjectAddConfiguration("config")
-        self.ProjectAddConfigurationResource("config", "resource1")
+        self.AddProjectDefaultConfiguration()
         
         # Change XSD into class members
         self._AddParamsMembers()
@@ -284,6 +287,8 @@
         result = self.OpenXMLFile(plc_file)
         if result:
             return result
+        if len(self.GetProjectConfigNames()) == 0:
+            self.AddProjectDefaultConfiguration()
         # Change XSD into class members
         self._AddParamsMembers()
         self.Children = {}