Fix resource task interval error highlighting
authorLaurent Bessard
Thu, 08 Nov 2012 18:54:34 +0100
changeset 879 55b8a16ead2b
parent 878 37256069baed
child 880 781ced3c0aef
Fix resource task interval error highlighting
dialogs/DurationEditorDialog.py
editors/ResourceEditor.py
--- a/dialogs/DurationEditorDialog.py	Thu Nov 08 18:23:32 2012 +0100
+++ b/dialogs/DurationEditorDialog.py	Thu Nov 08 18:54:34 2012 +0100
@@ -37,7 +37,7 @@
 HOUR = 60 * MINUTE
 DAY = 24 * HOUR
 
-IEC_TIME_MODEL = re.compile("(?:T|TIME)#(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?" % {"float": "[0-9]+(?:\.[0-9]+)?"})
+IEC_TIME_MODEL = re.compile("(?:T|TIME)#(-)?(?:(%(float)s)D_?)?(?:(%(float)s)H_?)?(?:(%(float)s)M(?!S)_?)?(?:(%(float)s)S_?)?(?:(%(float)s)MS)?$" % {"float": "[0-9]+(?:\.[0-9]+)?"})
 
 CONTROLS = [
     ("Days", _('Days:')),
--- a/editors/ResourceEditor.py	Thu Nov 08 18:23:32 2012 +0100
+++ b/editors/ResourceEditor.py	Thu Nov 08 18:54:34 2012 +0100
@@ -133,6 +133,7 @@
             for col in range(self.GetNumberCols()):
                 editor = None
                 renderer = None
+                error = False
                 colname = self.GetColLabelValue(col, False)
                 grid.SetReadOnly(row, col, False)
                 if colname == "Name":
@@ -143,6 +144,9 @@
                     renderer = wx.grid.GridCellStringRenderer()
                     if self.GetValueByName(row, "Triggering") != "Cyclic":
                         grid.SetReadOnly(row, col, True)
+                    interval = self.GetValueByName(row, colname)
+                    if interval != "" and IEC_TIME_MODEL.match(interval.upper()) is None:
+                        error = True
                 elif colname == "Single":
                     editor = wx.grid.GridCellChoiceEditor()
                     editor.SetParameters(self.Parent.VariableList)
@@ -164,7 +168,7 @@
                 grid.SetCellEditor(row, col, editor)
                 grid.SetCellRenderer(row, col, renderer)
                 
-                if colname == "Interval" and IEC_TIME_MODEL.match(self.GetValueByName(row, colname)) is None:
+                if error:
                     highlight_colours = ERROR_HIGHLIGHT
                 else:
                     highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]