editors/ResourceEditor.py
changeset 879 55b8a16ead2b
parent 831 dec885ba1f2b
child 899 64aa66d481c5
equal deleted inserted replaced
878:37256069baed 879:55b8a16ead2b
   131         for row in range(self.GetNumberRows()):
   131         for row in range(self.GetNumberRows()):
   132             row_highlights = self.Highlights.get(row, {})
   132             row_highlights = self.Highlights.get(row, {})
   133             for col in range(self.GetNumberCols()):
   133             for col in range(self.GetNumberCols()):
   134                 editor = None
   134                 editor = None
   135                 renderer = None
   135                 renderer = None
       
   136                 error = False
   136                 colname = self.GetColLabelValue(col, False)
   137                 colname = self.GetColLabelValue(col, False)
   137                 grid.SetReadOnly(row, col, False)
   138                 grid.SetReadOnly(row, col, False)
   138                 if colname == "Name":
   139                 if colname == "Name":
   139                     editor = wx.grid.GridCellTextEditor()
   140                     editor = wx.grid.GridCellTextEditor()
   140                     renderer = wx.grid.GridCellStringRenderer()
   141                     renderer = wx.grid.GridCellStringRenderer()
   141                 elif colname == "Interval":
   142                 elif colname == "Interval":
   142                     editor = DurationCellEditor(self)
   143                     editor = DurationCellEditor(self)
   143                     renderer = wx.grid.GridCellStringRenderer()
   144                     renderer = wx.grid.GridCellStringRenderer()
   144                     if self.GetValueByName(row, "Triggering") != "Cyclic":
   145                     if self.GetValueByName(row, "Triggering") != "Cyclic":
   145                         grid.SetReadOnly(row, col, True)
   146                         grid.SetReadOnly(row, col, True)
       
   147                     interval = self.GetValueByName(row, colname)
       
   148                     if interval != "" and IEC_TIME_MODEL.match(interval.upper()) is None:
       
   149                         error = True
   146                 elif colname == "Single":
   150                 elif colname == "Single":
   147                     editor = wx.grid.GridCellChoiceEditor()
   151                     editor = wx.grid.GridCellChoiceEditor()
   148                     editor.SetParameters(self.Parent.VariableList)
   152                     editor.SetParameters(self.Parent.VariableList)
   149                     if self.GetValueByName(row, "Triggering") != "Interrupt":
   153                     if self.GetValueByName(row, "Triggering") != "Interrupt":
   150                         grid.SetReadOnly(row, col, True)
   154                         grid.SetReadOnly(row, col, True)
   162                     editor.SetParameters(self.Parent.TaskList)
   166                     editor.SetParameters(self.Parent.TaskList)
   163                     
   167                     
   164                 grid.SetCellEditor(row, col, editor)
   168                 grid.SetCellEditor(row, col, editor)
   165                 grid.SetCellRenderer(row, col, renderer)
   169                 grid.SetCellRenderer(row, col, renderer)
   166                 
   170                 
   167                 if colname == "Interval" and IEC_TIME_MODEL.match(self.GetValueByName(row, colname)) is None:
   171                 if error:
   168                     highlight_colours = ERROR_HIGHLIGHT
   172                     highlight_colours = ERROR_HIGHLIGHT
   169                 else:
   173                 else:
   170                     highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
   174                     highlight_colours = row_highlights.get(colname.lower(), [(wx.WHITE, wx.BLACK)])[-1]
   171                 grid.SetCellBackgroundColour(row, col, highlight_colours[0])
   175                 grid.SetCellBackgroundColour(row, col, highlight_colours[0])
   172                 grid.SetCellTextColour(row, col, highlight_colours[1])
   176                 grid.SetCellTextColour(row, col, highlight_colours[1])