Fixing bugs with properties panel when resetting optional value and saving project
authorLaurent Bessard
Mon, 04 Jun 2012 01:27:17 +0200
changeset 702 ece862b07321
parent 701 25fbbb005a30
child 703 1a14560e10ed
Fixing bugs with properties panel when resetting optional value and saving project
PLCControler.py
controls/ProjectPropertiesPanel.py
--- a/PLCControler.py	Sun Jun 03 23:47:56 2012 +0200
+++ b/PLCControler.py	Mon Jun 04 01:27:17 2012 +0200
@@ -2899,8 +2899,7 @@
         if not filepath and self.FilePath == "":
             return False
         else:
-            contentheader = self.Project.getcontentHeader()
-            contentheader["modificationDateTime"] = datetime.datetime(*localtime()[:6])
+            contentheader = {"modificationDateTime": datetime.datetime(*localtime()[:6])}
             self.Project.setcontentHeader(contentheader)
             
             text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
--- a/controls/ProjectPropertiesPanel.py	Sun Jun 03 23:47:56 2012 +0200
+++ b/controls/ProjectPropertiesPanel.py	Mon Jun 04 01:27:17 2012 +0200
@@ -259,10 +259,18 @@
             value = getattr(self, param).GetValue()
             if param in REQUIRED_PARAMS or value != "":
                 values[param] = value
-        if self.Language.GetStringSelection() != "":
-            values["language"] = self.Language.GetStringSelection()
-        if self.ContentDescription.GetValue() != "":
-            values["contentDescription"] = self.ContentDescription.GetValue()
+            else:
+                values[param] = None
+        language = self.Language.GetStringSelection()
+        if language != "":
+            values["language"] = language
+        else:
+            values["language"] = None
+        content_description = self.ContentDescription.GetValue()
+        if content_description != "":
+            values["contentDescription"] = content_description
+        else:
+            values["contentDescription"] = None
         values["pageSize"] = (self.PageWidth.GetValue(), self.PageHeight.GetValue())
         values["scaling"] = {}
         for language in ["FBD", "LD", "SFC"]:
@@ -278,6 +286,8 @@
                 else:
                     old_value = None
                 new_value = textctrl.GetValue()
+                if name not in REQUIRED_PARAMS and new_value == "":
+                    new_value = None
                 if old_value != new_value:
                     self.Controller.SetProjectProperties(properties={name: new_value})
                     self.ParentWindow.RefreshTitle()
@@ -341,6 +351,9 @@
             else:
                 old_value = None
             new_value = self.Language.GetStringSelection()
+            if new_value == "":
+                new_value = None
+            print old_value, new_value
             if old_value != new_value:
                 self.Controller.SetProjectProperties(properties={"language": new_value})
                 self.ParentWindow.RefreshTitle()
@@ -357,6 +370,8 @@
             else:
                 old_value = None
             new_value = self.ContentDescription.GetValue()
+            if new_value == "":
+                new_value = None
             if old_value != new_value:
                 self.Controller.SetProjectProperties(properties={"contentDescription": new_value})
                 self.ParentWindow.RefreshTitle()