def __init__(self,modCombo,envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'requirement' self.colLabels = ['Name','Description','Priority','Rationale','Fit Criterion','Originator','Type'] if (modCombo.GetValue() != ''): self.om = RequirementManager(modCombo) else: self.om = RequirementManager(envCombo,False)
def __init__(self, modCombo, envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'requirement' self.colLabels = [ 'Name', 'Description', 'Priority', 'Rationale', 'Fit Criterion', 'Originator', 'Type' ] if (modCombo.GetValue() != ''): self.om = RequirementManager(modCombo) else: self.om = RequirementManager(envCombo, False)
class RequirementsTable(wx.grid.PyGridTableBase): def __init__(self, modCombo, envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'requirement' self.colLabels = [ 'Name', 'Description', 'Priority', 'Rationale', 'Fit Criterion', 'Originator', 'Type' ] if (modCombo.GetValue() != ''): self.om = RequirementManager(modCombo) else: self.om = RequirementManager(envCombo, False) def GetNumberRows(self): return self.om.size() def GetNumberCols(self): return len(self.colLabels) def GetColLabelValue(self, col): return self.colLabels[col] def GetRowLabelValue(self, row): return self.om.reqs[row].label() def IsEmptyCell(self, row, col): return False def GetValue(self, row, col): if (col == NAME_POS): return self.om.reqs[row].name() elif (col == DESCRIPTION_POS): return self.om.reqs[row].description() elif (col == PRIORITY_POS): return self.om.reqs[row].priority() elif (col == RATIONALE_POS): return self.om.reqs[row].rationale() elif (col == FITCRITERION_POS): return self.om.reqs[row].fitCriterion() elif (col == ORIGINATOR_POS): return self.om.reqs[row].originator() elif (col == TYPE_POS): return self.om.reqs[row].type() def SetValue(self, row, col, value): label = self.GetRowLabelValue(row) if (col == NAME_POS): self.om.update(label, 'name', value) elif (col == DESCRIPTION_POS): self.om.update(label, 'description', value) elif (col == PRIORITY_POS): self.om.update(label, 'priority', value) elif (col == RATIONALE_POS): self.om.update(label, 'rationale', value) elif (col == FITCRITERION_POS): self.om.update(label, 'fitCriterion', value) elif (col == ORIGINATOR_POS): self.om.update(label, 'originator', value) elif (col == TYPE_POS): self.om.update(label, 'type', value) def AppendRows(self, numRows=1): pos = self.om.size() - 1 self.InsertRows(pos, numRows) def InsertRows(self, pos, numRows=1): try: if (pos == -1): pos = 0 newPos = pos + 1 if (self.om.size() == 0): lastLabel = 0 else: lastGridLabel = self.om.reqs[pos].label() if (len(str(lastGridLabel).split('-')) > 1): raise ARMException( 'Asset or Environment must be specified') lastLabel = int(lastGridLabel) newLabel = lastLabel + 1 self.om.add(newLabel, newPos) except ARMException, errorText: dlg = wx.MessageDialog(self.GetView(), str(errorText), 'Add Requirement', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return newReqPos, newReq = self.om.requirementByLabel(newLabel) self.addToView(newReqPos) grid = self.GetView() grid.SetCellEditor(newPos, NAME_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, NAME_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, DESCRIPTION_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, DESCRIPTION_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, PRIORITY_POS, wx.grid.GridCellChoiceEditor(priorityChoices)) grid.SetCellEditor(newPos, RATIONALE_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, RATIONALE_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, FITCRITERION_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, FITCRITERION_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, ORIGINATOR_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, ORIGINATOR_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, TYPE_POS, wx.grid.GridCellChoiceEditor(typeChoices)) return True
class RequirementsTable(wx.grid.PyGridTableBase): def __init__(self,modCombo,envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'requirement' self.colLabels = ['Name','Description','Priority','Rationale','Fit Criterion','Originator','Type'] if (modCombo.GetValue() != ''): self.om = RequirementManager(modCombo) else: self.om = RequirementManager(envCombo,False) def GetNumberRows(self): return self.om.size() def GetNumberCols(self): return len(self.colLabels) def GetColLabelValue(self,col): return self.colLabels[col] def GetRowLabelValue(self,row): return self.om.reqs[row].label() def IsEmptyCell(self,row,col): return False def GetValue(self,row,col): if (col == NAME_POS): return self.om.reqs[row].name() elif (col == DESCRIPTION_POS): return self.om.reqs[row].description() elif (col == PRIORITY_POS): return self.om.reqs[row].priority() elif (col == RATIONALE_POS): return self.om.reqs[row].rationale() elif (col == FITCRITERION_POS): return self.om.reqs[row].fitCriterion() elif (col == ORIGINATOR_POS): return self.om.reqs[row].originator() elif (col == TYPE_POS): return self.om.reqs[row].type() def SetValue(self,row,col,value): label = self.GetRowLabelValue(row) if (col == NAME_POS): self.om.update(label,'name',value) elif (col == DESCRIPTION_POS): self.om.update(label,'description',value) elif (col == PRIORITY_POS): self.om.update(label,'priority',value) elif (col == RATIONALE_POS): self.om.update(label,'rationale',value) elif (col == FITCRITERION_POS): self.om.update(label,'fitCriterion',value) elif (col == ORIGINATOR_POS): self.om.update(label,'originator',value) elif (col == TYPE_POS): self.om.update(label,'type',value) def AppendRows(self,numRows=1): pos = self.om.size() - 1 self.InsertRows(pos,numRows) def InsertRows(self,pos,numRows=1): try: if (pos == -1): pos = 0 newPos = pos + 1 if (self.om.size() == 0): lastLabel = 0 else: lastGridLabel = self.om.reqs[pos].label() if (len(str(lastGridLabel).split('-')) > 1): raise ARMException('Asset or Environment must be specified') lastLabel = int(lastGridLabel) newLabel = lastLabel + 1 self.om.add(newLabel,newPos) except ARMException,errorText: dlg = wx.MessageDialog(self.GetView(),str(errorText),'Add Requirement',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return newReqPos,newReq = self.om.requirementByLabel(newLabel) self.addToView(newReqPos) grid = self.GetView() grid.SetCellEditor(newPos,NAME_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,NAME_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,DESCRIPTION_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,DESCRIPTION_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,PRIORITY_POS,wx.grid.GridCellChoiceEditor(priorityChoices)) grid.SetCellEditor(newPos,RATIONALE_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,RATIONALE_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,FITCRITERION_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,FITCRITERION_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,ORIGINATOR_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,ORIGINATOR_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,TYPE_POS,wx.grid.GridCellChoiceEditor(typeChoices)) return True