当前位置: 首页>>代码示例>>Python>>正文


Python EnvironmentListCtrl.load方法代码示例

本文整理汇总了Python中EnvironmentListCtrl.EnvironmentListCtrl.load方法的典型用法代码示例。如果您正苦于以下问题:Python EnvironmentListCtrl.load方法的具体用法?Python EnvironmentListCtrl.load怎么用?Python EnvironmentListCtrl.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EnvironmentListCtrl.EnvironmentListCtrl的用法示例。


在下文中一共展示了EnvironmentListCtrl.load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ObstacleEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class ObstacleEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,OBSTACLE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theObstacleId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,OBSTACLE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = ObstacleEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.labelCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTLABEL_ID)
    self.probCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTPROBABILITY_ID)
    self.categoryCtrl = self.notebook.FindWindowById(OBSTACLE_COMBOCATEGORY_ID)
    self.definitionCtrl = self.notebook.FindWindowById(OBSTACLE_TEXTDEFINITION_ID)
    self.goalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTGOALS_ID)
    self.subGoalAssociationCtrl = self.notebook.FindWindowById(OBSTACLE_LISTSUBGOALS_ID)
    self.concernsCtrl = self.notebook.FindWindowById(OBSTACLE_LISTCONCERNS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.categoryCtrl.Disable()
    self.definitionCtrl.Disable()
    self.goalAssociationCtrl.Disable()
    self.subGoalAssociationCtrl.Disable()
    self.concernsCtrl.Disable()


  def loadControls(self,obstacle):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theObstacleId = obstacle.id()
    environmentNames = []
    for cp in obstacle.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in obstacle.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    self.labelCtrl.SetValue(p.label())
    self.probCtrl.SetValue(str(p.probability()))
    self.categoryCtrl.SetValue(p.category())
    self.definitionCtrl.SetValue(p.definition())
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.load(p.goalRefinements())
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.concernsCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.load(p.subGoalRefinements())
    self.concernsCtrl.load(p.concerns())

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.categoryCtrl.Enable()
    self.definitionCtrl.Enable()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
    self.concernsCtrl.Enable()
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    self.labelCtrl.SetValue(p.label())
    self.probCtrl.SetValue(str(p.probability()))
    self.categoryCtrl.SetValue(p.category())
    self.definitionCtrl.SetValue(p.definition())
    self.goalAssociationCtrl.setEnvironment(environmentName)
    self.goalAssociationCtrl.load(p.goalRefinements())
    self.subGoalAssociationCtrl.setEnvironment(environmentName)
    self.concernsCtrl.setEnvironment(environmentName)
    self.subGoalAssociationCtrl.load(p.subGoalRefinements())
    self.concernsCtrl.load(p.concerns())

    self.categoryCtrl.Enable()
    self.definitionCtrl.Enable()
    self.goalAssociationCtrl.Enable()
    self.subGoalAssociationCtrl.Enable()
#.........这里部分代码省略.........
开发者ID:AntonP1337,项目名称:cairis,代码行数:103,代码来源:ObstacleEnvironmentPanel.py

示例2: ThreatEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class ThreatEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,THREAT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theThreatId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,THREATENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    lhoodBox = wx.StaticBox(self)
    lhoodSizer = wx.StaticBoxSizer(lhoodBox,wx.HORIZONTAL)
    environmentDimSizer.Add(lhoodSizer,0,wx.EXPAND)
    lhoodSizer.Add(wx.StaticText(self,-1,'Likelihood'))
    lhoodList = ['Incredible','Improbable','Remote','Occasional','Probable','Frequent']
    self.lhoodCtrl = wx.ComboBox(self,THREATENVIRONMENT_COMBOLIKELIHOOD_ID,choices=lhoodList,size=wx.DefaultSize,style=wx.CB_READONLY)
    lhoodSizer.Add(self.lhoodCtrl,1,wx.EXPAND) 

    aaSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aaSizer,1,wx.EXPAND)
    self.attackerList = DimensionListCtrl(self,THREATENVIRONMENT_LISTATTACKERS_ID,wx.DefaultSize,'Attacker','attacker',self.dbProxy)
    attackerBox = wx.StaticBox(self)
    attackerSizer = wx.StaticBoxSizer(attackerBox,wx.HORIZONTAL)
    attackerSizer.Add(self.attackerList,1,wx.EXPAND)
    aaSizer.Add(attackerSizer,1,wx.EXPAND)

    self.assetList = DimensionListCtrl(self,THREATENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aaSizer.Add(assetSizer,1,wx.EXPAND)

    propertiesBox = wx.StaticBox(self)
    propertiesSizer = wx.StaticBoxSizer(propertiesBox,wx.HORIZONTAL)
    environmentDimSizer.Add(propertiesSizer,1,wx.EXPAND)
    values = self.dbProxy.getDimensionNames('threat_value')
    valueLookup = ValueDictionary(values)
    self.propertiesList = PropertiesListCtrl(self,THREATENVIRONMENT_LISTPROPERTIES_ID,valueLookup)
    propertiesSizer.Add(self.propertiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,threat):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theThreatId = threat.id()
# We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
    environmentNames = []
    if (len(threat.environmentProperties()) > 0):
      for cp in threat.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)
      for cp in threat.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.lhoodCtrl.SetStringSelection(p.likelihood())
      self.attackerList.setEnvironment(environmentName)
      self.attackerList.load(p.attackers()) 
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale())
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.lhoodCtrl.SetStringSelection(p.likelihood())
    self.attackerList.setEnvironment(environmentName)
    self.attackerList.load(p.attackers()) 
    self.assetList.setEnvironment(environmentName)
    self.assetList.load(p.assets()) 
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    syProperties,pRationale = self.propertiesList.properties()
    self.theEnvironmentDictionary[environmentName] = ThreatEnvironmentProperties(environmentName,self.lhoodCtrl.GetValue(),self.assetList.dimensions(),self.attackerList.dimensions(),syProperties,pRationale)
    self.lhoodCtrl.SetValue('')
    self.attackerList.setEnvironment('')
    self.attackerList.DeleteAllItems() 
#.........这里部分代码省略.........
开发者ID:InvalidToken,项目名称:CAIRIS,代码行数:103,代码来源:ThreatEnvironmentPanel.py

示例3: VulnerabilityEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class VulnerabilityEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.VULNERABILITY_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theVulId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)

    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    sevBox = wx.StaticBox(self)
    sevSizer = wx.StaticBoxSizer(sevBox,wx.HORIZONTAL)
    environmentDimSizer.Add(sevSizer,0,wx.EXPAND)
    sevSizer.Add(wx.StaticText(self,-1,'Severity'))
    sevList = ['Negligible','Marginal','Critical','Catastrophic']
    self.sevCtrl = wx.ComboBox(self,armid.VULNERABILITYENVIRONMENT_COMBOSEVERITY_ID,choices=sevList,size=wx.DefaultSize,style=wx.CB_READONLY)
    sevSizer.Add(self.sevCtrl,1,wx.EXPAND) 

    aSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(aSizer,1,wx.EXPAND)
    self.assetList = DimensionListCtrl(self,armid.VULNERABILITYENVIRONMENT_LISTASSETS_ID,wx.DefaultSize,'Asset','asset',self.dbProxy)
    assetBox = wx.StaticBox(self)
    assetSizer = wx.StaticBoxSizer(assetBox,wx.HORIZONTAL)
    assetSizer.Add(self.assetList,1,wx.EXPAND)
    aSizer.Add(assetSizer,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,vulnerability):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theVulId = vulnerability.id()
# We load the environment name control before anything else.  Weird stuff happens if we don't do this.  Don't ask me why!!!
    environmentNames = []
    if (len(vulnerability.environmentProperties()) > 0):
      for cp in vulnerability.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)
      for cp in vulnerability.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.sevCtrl.SetStringSelection(p.severity())
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.sevCtrl.SetStringSelection(p.severity())
    self.assetList.setEnvironment(environmentName)
    self.assetList.load(p.assets()) 
      
  

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,self.sevCtrl.GetValue(),self.assetList.dimensions())
    self.sevCtrl.SetValue('')
    self.assetList.setEnvironment('')
    self.assetList.DeleteAllItems() 
    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = VulnerabilityEnvironmentProperties(environmentName,'',[])
    self.environmentList.Select(self.theSelectedIdx)
    self.assetList.setEnvironment(environmentName)
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theVulId != None):
      p = self.dbProxy.inheritedVulnerabilityProperties(self.theVulId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.sevCtrl.SetStringSelection(p.severity())
      self.assetList.setEnvironment(environmentName)
      self.assetList.load(p.assets()) 

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
#.........这里部分代码省略.........
开发者ID:RachelLar,项目名称:CAIRIS-web,代码行数:103,代码来源:VulnerabilityEnvironmentPanel.py

示例4: CountermeasureEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class CountermeasureEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.COUNTERMEASURE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.COUNTERMEASURE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)


    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
 
    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.COUNTERMEASURE_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = CountermeasureEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.reqList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTREQUIREMENTS_ID)
    self.targetList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTTARGETS_ID)
    self.propertiesList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPROPERTIES_ID)
    self.personaList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTPERSONAS_ID)
    self.roleList = self.notebook.FindWindowById(armid.COUNTERMEASURE_LISTROLES_ID)

    self.reqList.Disable()
    self.targetList.Disable()
    self.propertiesList.Disable()
    self.costCombo.Disable()
    self.roleList.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,countermeasure):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in countermeasure.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in countermeasure.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.reqList.setEnvironment(environmentName)
    self.reqList.load(p.requirements())
    self.targetList.setEnvironment(environmentName)
    self.targetList.load(p.targets())
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.costCombo.SetStringSelection(p.cost())
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.personaList.load(p.personas())

    self.environmentList.Select(0)

    self.reqList.Enable()
    self.targetList.Enable()
    self.propertiesList.Enable()
    self.costCombo.Enable()
    self.roleList.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.reqList.setEnvironment(environmentName)
    self.reqList.load(p.requirements())
    self.targetList.setEnvironment(environmentName)
    self.targetList.load(p.targets())
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.costCombo.SetStringSelection(p.cost())
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.personaList.load(p.personas())
    self.reqList.Enable()
#.........这里部分代码省略.........
开发者ID:RachelLar,项目名称:CAIRIS-web,代码行数:103,代码来源:CountermeasureEnvironmentPanel.py

示例5: MisuseCaseEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class MisuseCaseEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,MISUSECASE_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.theSelectedRisk = ''
    self.theSelectedThreat = ''
    self.theSelectedVulnerability = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,MISUSECASE_LISTENVIRONMENTS_ID,self.dbProxy)
    self.environmentList.Unbind(wx.EVT_RIGHT_DOWN)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = MisuseCaseNotebook(self)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)

    self.objectiveCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTOBJECTIVE_ID)
    self.attackerList = self.notebook.FindWindowById(MISUSECASE_LISTATTACKERS_ID)
    self.assetList = self.notebook.FindWindowById(MISUSECASE_LISTASSETS_ID)
    self.threatCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTTHREAT_ID)
    self.lhoodCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTLIKELIHOOD_ID)
    self.vulCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTVULNERABILITY_ID)
    self.sevCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSEVERITY_ID)
    self.ratingCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTSCORE_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(MISUSECASE_TEXTNARRATIVE_ID)


    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.narrativeCtrl.Disable()



  def unloadMCComponents(self):
    self.ratingCtrl.SetValue('')
    self.threatCtrl.SetValue('')
    self.lhoodCtrl.SetValue('')
    self.vulCtrl.SetValue('')
    self.sevCtrl.SetValue('')
    self.attackerList.DeleteAllItems()
    self.assetList.DeleteAllItems()
    self.objectiveCtrl.SetValue('')
    

  def loadMCComponents(self): 
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.ratingCtrl.SetValue(self.dbProxy.riskRating(self.theSelectedThreat,self.theSelectedVulnerability,environmentName) )

    self.threatCtrl.SetValue(self.theSelectedThreat)
    threatId = self.dbProxy.getDimensionId(self.theSelectedThreat,'threat')
    environmentId = self.dbProxy.getDimensionId(environmentName,'environment')
    self.lhoodCtrl.SetValue(self.dbProxy.threatLikelihood(threatId,environmentId))

    self.vulCtrl.SetValue(self.theSelectedVulnerability)
    vulId = self.dbProxy.getDimensionId(self.theSelectedVulnerability,'vulnerability')
    self.sevCtrl.SetValue(self.dbProxy.vulnerabilitySeverity(vulId,environmentId))

    self.attackerList.DeleteAllItems()
    attackers = self.dbProxy.threatAttackers(threatId,environmentId)
    attackerSet = set(attackers)
    for atidx,attacker in enumerate(attackerSet):
      self.attackerList.InsertStringItem(atidx,attacker)

    
    threatenedAssets = self.dbProxy.threatenedAssets(threatId,environmentId)
    vulnerableAssets = self.dbProxy.vulnerableAssets(vulId,environmentId)

    objectiveText = 'Exploit vulnerabilities in '
    for idx,vulAsset in enumerate(vulnerableAssets):
      objectiveText += vulAsset
      if (idx != (len(vulnerableAssets) -1)):
        objectiveText += ','
    objectiveText += ' to threaten '
    for idx,thrAsset in enumerate(threatenedAssets):
      objectiveText += thrAsset
      if (idx != (len(threatenedAssets) -1)):
        objectiveText += ','
    objectiveText += '.'
    self.objectiveCtrl.SetValue(objectiveText)

    self.assetList.DeleteAllItems()
    assetSet = set(threatenedAssets + vulnerableAssets)
    for asidx,asset in enumerate(assetSet):
      self.assetList.InsertStringItem(asidx,asset)


  def loadMisuseCase(self,mc):
#.........这里部分代码省略.........
开发者ID:AntonP1337,项目名称:cairis,代码行数:103,代码来源:MisuseCaseEnvironmentPanel.py

示例6: AssetEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class AssetEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,ASSET_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAssetId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,ASSETENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    dimBox = wx.StaticBox(self)
    environmentDimSizer = wx.StaticBoxSizer(dimBox,wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = AssetEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.propertiesList = self.notebook.FindWindowById(ASSETENVIRONMENT_LISTPROPERTIES_ID)
    self.associationCtrl = self.notebook.FindWindowById(ASSET_LISTASSOCIATIONS_ID)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.propertiesList.Disable()
    self.associationCtrl.Disable()

  def loadControls(self,asset):
    self.theAssetId = asset.id()
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    noOfProperties = len(asset.environmentProperties())
    if (noOfProperties > 0):
      environmentNames = []
      for cp in asset.environmentProperties():
        environmentNames.append(cp.name())
      self.environmentList.load(environmentNames)

      for cp in asset.environmentProperties():
        environmentName = cp.name()
        self.theEnvironmentDictionary[environmentName] = cp
        environmentNames.append(environmentName) 
      environmentName = environmentNames[0]
      p = self.theEnvironmentDictionary[environmentName]
      self.propertiesList.setEnvironment(environmentName)
      self.propertiesList.load(p.properties(),p.rationale()) 
      self.associationCtrl.setEnvironment(environmentName)
      self.associationCtrl.load(p.associations()) 
      self.environmentList.Select(0)

    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

    self.propertiesList.Enable()
    self.associationCtrl.Enable()
    if (noOfProperties > 0):
      self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.load(p.properties(),p.rationale())
    self.associationCtrl.setEnvironment(environmentName)
    self.associationCtrl.load(p.associations()) 
    self.propertiesList.Enable()
    self.associationCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    syProperties,pRationale = self.propertiesList.properties()
    self.theEnvironmentDictionary[environmentName] = AssetEnvironmentProperties(environmentName,syProperties,pRationale,self.associationCtrl.dimensions())
    self.propertiesList.setEnvironment('')
    self.propertiesList.DeleteAllItems() 
    self.associationCtrl.setEnvironment('')
    self.associationCtrl.DeleteAllItems() 
    self.propertiesList.Disable()
    self.associationCtrl.Disable()

    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AssetEnvironmentProperties(environmentName,[0,0,0,0,0,0,0,0],['None','None','None','None','None','None','None','None'])
    self.environmentList.Select(self.theSelectedIdx)
    self.propertiesList.setEnvironment(environmentName)
    self.propertiesList.DeleteAllItems()
    self.associationCtrl.setEnvironment(environmentName)
#.........这里部分代码省略.........
开发者ID:AntonP1337,项目名称:cairis,代码行数:103,代码来源:AssetEnvironmentPanel.py

示例7: TaskEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class TaskEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,TASK_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theTaskId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,TASK_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbBoxSizer = wx.StaticBoxSizer(nbBox,wx.VERTICAL)
    environmentDimSizer.Add(nbBoxSizer,1,wx.EXPAND)
    self.notebook = TaskEnvironmentNotebook(self,self.dbProxy)
    nbBoxSizer.Add(self.notebook,1,wx.EXPAND)

    self.dependenciesCtrl = self.notebook.FindWindowById(TASK_TEXTDEPENDENCIES_ID)
    self.personaList = self.notebook.FindWindowById(TASK_LISTPERSONAS_ID)
    self.assetList = self.notebook.FindWindowById(TASK_LISTASSETS_ID)
    self.caList = self.notebook.FindWindowById(TASK_LISTCONCERNASSOCIATIONS_ID)
    self.narrativeCtrl = self.notebook.FindWindowById(TASK_TEXTNARRATIVE_ID)
    self.consequencesCtrl = self.notebook.FindWindowById(TASK_TEXTCONSEQUENCES_ID)
    self.benefitsCtrl = self.notebook.FindWindowById(TASK_TEXTBENEFITS_ID)

    self.SetSizer(mainSizer)

    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.dependenciesCtrl.Disable()
    self.personaList.Disable() 
    self.assetList.Disable() 
    self.caList.Disable()
    self.narrativeCtrl.Disable()
    self.consequencesCtrl.Disable()
    self.benefitsCtrl.Disable()

    self.theDimMenu = wx.Menu()
    self.theDimMenu.Append(DIMLIST_MENUADD_ID,'Add Goal')
    self.Bind(wx.EVT_RIGHT_DOWN,self.OnRightDown)
    wx.EVT_MENU(self.theDimMenu,DIMLIST_MENUADD_ID,self.onAddGoal)

  def OnRightDown(self,evt):
    self.PopupMenu(self.theDimMenu)

  def onAddGoal(self,evt):
    print 'goal'



  def loadControls(self,task):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theTaskId = task.id()
    environmentNames = []
    for cp in task.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in task.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    self.dependenciesCtrl.SetValue(p.dependencies())
    self.personaList.setEnvironment(environmentName)
    self.assetList.setEnvironment(environmentName)
    self.caList.setEnvironment(environmentName)   
    self.narrativeCtrl.setEnvironment(environmentName)
    self.personaList.load(p.personas()) 
    self.assetList.load(p.assets()) 
    self.caList.load(p.concernAssociations()) 
    self.narrativeCtrl.SetValue(p.narrative())
    self.consequencesCtrl.SetValue(p.consequences())
    self.benefitsCtrl.SetValue(p.benefits())
    self.narrativeCtrl.setCodes(p.codes('narrative'))
    self.consequencesCtrl.setCodes(p.codes('consequences'))
    self.benefitsCtrl.setCodes(p.codes('benefits'))

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.dependenciesCtrl.Enable()
    self.personaList.Enable() 
    self.assetList.Enable() 
    self.caList.Enable()
    self.narrativeCtrl.Enable()
    self.consequencesCtrl.Enable()
    self.benefitsCtrl.Enable()
    self.theSelectedIdx = 0
    self.narrativeCtrl.setTask(task.name())

#.........这里部分代码省略.........
开发者ID:InvalidToken,项目名称:CAIRIS,代码行数:103,代码来源:TaskEnvironmentPanel.py

示例8: PersonaEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class PersonaEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.PERSONA_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1
    self.thePersonaName = ''

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.PERSONA_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    nbBox = wx.StaticBox(self,-1)
    nbSizer = wx.StaticBoxSizer(nbBox,wx.HORIZONTAL)
    environmentDimSizer.Add(nbSizer,1,wx.EXPAND)
    self.notebook = PersonaEnvironmentNotebook(self,self.dbProxy)
    nbSizer.Add(self.notebook,1,wx.EXPAND)

    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)

    self.directCtrl = self.notebook.FindWindowById(armid.PERSONA_CHECKDIRECT_ID)
    self.roleList = self.notebook.FindWindowById(armid.PERSONA_LISTROLES_ID)
    self.descriptionCtrl = self.notebook.FindWindowById(armid.PERSONA_TEXTNARRATIVE_ID)
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 


  def loadControls(self,persona):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.thePersonaName = persona.name()
    environmentNames = []
    for cp in persona.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in persona.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]

    if (p.directFlag() == 'True'):
      self.directCtrl.SetValue(True)
    else:
      self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative',p.narrative())
    self.descriptionCtrl.setCodes(p.codes('narrative'))
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 

    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.directCtrl.Enable()
    self.descriptionCtrl.Enable()
    self.roleList.Enable() 
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]

    if (p.directFlag() == 'True'):
      self.directCtrl.SetValue(True)
    else:
      self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative',p.narrative())
    self.descriptionCtrl.setCodes(p.codes('narrative'))
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.directCtrl.Enable()
    self.descriptionCtrl.Enable()
    self.roleList.Enable() 

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    envCodebook = {'narrative':self.descriptionCtrl.codes()}
    self.theEnvironmentDictionary[environmentName] = PersonaEnvironmentProperties(environmentName,str(self.directCtrl.GetValue()),self.descriptionCtrl.GetValue(),self.roleList.dimensions())

    self.directCtrl.SetValue(False)
    self.descriptionCtrl.Set(self.thePersonaName,'Environment Narrative','')
    self.descriptionCtrl.setCodes({})
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems() 
    self.theSelectedIdx = -1
    self.directCtrl.Disable()
    self.descriptionCtrl.Disable()
    self.roleList.Disable() 
#.........这里部分代码省略.........
开发者ID:RachelLar,项目名称:CAIRIS-web,代码行数:103,代码来源:PersonaEnvironmentPanel.py

示例9: TransferEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class TransferEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.TRANSFER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.TRANSFER_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    roleBox = wx.StaticBox(self,-1)
    roleBoxSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(roleBoxSizer,0,wx.EXPAND)
    self.roleList = RoleCostListCtrl(self,armid.TRANSFER_LISTROLES_ID)
    roleBoxSizer.Add(self.roleList,1,wx.EXPAND)

    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.TRANSFER_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.roleList.Disable()
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.rationaleCtrl.SetValue(p.description()) 
    self.environmentList.Select(0)
    self.roleList.Enable()
    self.rationaleCtrl.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles())
    self.rationaleCtrl.SetValue(p.description()) 
    self.roleList.Enable() 
    self.rationaleCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = TransferEnvironmentProperties(environmentName,self.rationaleCtrl.GetValue(),self.roleList.roles())
    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems()
    self.rationaleCtrl.SetValue('') 
    self.theSelectedIdx = -1
    self.roleList.Disable() 
    self.rationaleCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = TransferEnvironmentProperties(environmentName)
    self.roleList.setEnvironment(environmentName)
    self.roleList.DeleteAllItems()
    self.rationaleCtrl.SetValue('') 
    self.environmentList.Select(self.theSelectedIdx)
    self.roleList.Enable() 
    self.rationaleCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
#.........这里部分代码省略.........
开发者ID:RobinQuetin,项目名称:CAIRIS,代码行数:103,代码来源:TransferEnvironmentPanel.py

示例10: UseCaseEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class UseCaseEnvironmentPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, USECASE_PANELENVIRONMENT_ID)
        b = Borg()
        self.dbProxy = b.dbProxy
        self.theUseCaseId = None
        self.theUseCaseName = ""
        self.theEnvironmentDictionary = {}
        self.theSelectedIdx = -1

        mainSizer = wx.BoxSizer(wx.HORIZONTAL)
        environmentBox = wx.StaticBox(self)
        environmentListSizer = wx.StaticBoxSizer(environmentBox, wx.HORIZONTAL)
        mainSizer.Add(environmentListSizer, 0, wx.EXPAND)
        self.environmentList = EnvironmentListCtrl(self, USECASE_LISTENVIRONMENTS_ID, self.dbProxy)
        environmentListSizer.Add(self.environmentList, 1, wx.EXPAND)
        environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(environmentDimSizer, 1, wx.EXPAND)

        nbBox = wx.StaticBox(self, -1)
        nbBoxSizer = wx.StaticBoxSizer(nbBox, wx.VERTICAL)
        environmentDimSizer.Add(nbBoxSizer, 1, wx.EXPAND)
        self.notebook = UseCaseEnvironmentNotebook(self, self.dbProxy)
        nbBoxSizer.Add(self.notebook, 1, wx.EXPAND)

        self.preCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPRECONDITION_ID)
        self.postCondCtrl = self.notebook.FindWindowById(USECASE_TEXTPOSTCONDITION_ID)
        self.stepsCtrl = self.notebook.FindWindowById(USECASE_PANELFLOW_ID)

        self.SetSizer(mainSizer)

        self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM, self.OnAddEnvironment)
        self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM, self.OnDeleteEnvironment)
        self.preCondCtrl.Disable()
        self.stepsCtrl.Disable()
        self.postCondCtrl.Disable()
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnEnvironmentDeselected)

    def loadControls(self, uc):
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
        self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
        self.theUseCaseId = uc.id()
        self.theUseCaseName = uc.name()
        environmentNames = []
        for cp in uc.environmentProperties():
            environmentNames.append(cp.name())
        self.environmentList.load(environmentNames)

        for cp in uc.environmentProperties():
            environmentName = cp.name()
            self.theEnvironmentDictionary[environmentName] = cp
            environmentNames.append(environmentName)
        environmentName = environmentNames[0]
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.stepsCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)

        self.environmentList.Select(0)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnEnvironmentSelected)
        self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED, self.OnEnvironmentDeselected)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()
        self.theSelectedIdx = 0

    def OnEnvironmentSelected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        p = self.theEnvironmentDictionary[environmentName]

        self.preCondCtrl.SetValue(p.preconditions())
        self.stepsCtrl.reloadSteps(p.steps())
        self.postCondCtrl.SetValue(p.postconditions())
        self.stepsCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setEnvironment(environmentName)
        self.preCondCtrl.setUseCase(self.theUseCaseName)
        self.postCondCtrl.setEnvironment(environmentName)
        self.postCondCtrl.setUseCase(self.theUseCaseName)
        self.preCondCtrl.Enable()
        self.stepsCtrl.Enable()
        self.postCondCtrl.Enable()

    def OnEnvironmentDeselected(self, evt):
        self.theSelectedIdx = evt.GetIndex()
        environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
        self.theEnvironmentDictionary[environmentName] = UseCaseEnvironmentProperties(
            environmentName, self.preCondCtrl.GetValue(), self.stepsCtrl.steps(), self.postCondCtrl.GetValue()
        )
        self.preCondCtrl.SetValue("")
        self.stepsCtrl.clear()
        self.stepsCtrl.setEnvironment("")
#.........这里部分代码省略.........
开发者ID:RachelLar,项目名称:cairis_update,代码行数:103,代码来源:UseCaseEnvironmentPanel.py

示例11: AttackerEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class AttackerEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ATTACKER_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theAttackerId = None
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ATTACKERENVIRONMENT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)
    rmSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentDimSizer.Add(rmSizer,1,wx.EXPAND)
    self.roleList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTROLES_ID,wx.DefaultSize,'Role','role',self.dbProxy)
    roleBox = wx.StaticBox(self)
    roleSizer = wx.StaticBoxSizer(roleBox,wx.HORIZONTAL)
    roleSizer.Add(self.roleList,1,wx.EXPAND)
    rmSizer.Add(roleSizer,1,wx.EXPAND)

    self.motiveList = DimensionListCtrl(self,armid.ATTACKERENVIRONMENT_LISTMOTIVES_ID,wx.DefaultSize,'Motive','motivation',self.dbProxy)
    motiveBox = wx.StaticBox(self)
    motiveSizer = wx.StaticBoxSizer(motiveBox,wx.HORIZONTAL)
    motiveSizer.Add(self.motiveList,1,wx.EXPAND)
    rmSizer.Add(motiveSizer,1,wx.EXPAND)
    capBox = wx.StaticBox(self)
    capSizer = wx.StaticBoxSizer(capBox,wx.HORIZONTAL)
    environmentDimSizer.Add(capSizer,1,wx.EXPAND)
    self.capabilitiesList = CapabilitiesListCtrl(self,armid.ATTACKERENVIRONMENT_LISTCAPABILITIES_ID,self.dbProxy)
    capSizer.Add(self.capabilitiesList,1,wx.EXPAND)
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)


  def loadControls(self,attacker):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    self.theAttackerId = attacker.id()
    environmentNames = []
    for cp in attacker.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in attacker.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.motiveList.setEnvironment(environmentName)
    self.motiveList.load(p.motives()) 
    self.capabilitiesList.setEnvironment(environmentName)
    self.capabilitiesList.load(p.capabilities())
    self.environmentList.Select(0)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.roleList.setEnvironment(environmentName)
    self.roleList.load(p.roles()) 
    self.motiveList.setEnvironment(environmentName)
    self.motiveList.load(p.motives()) 
    self.capabilitiesList.setEnvironment(environmentName)
    self.capabilitiesList.load(p.capabilities())

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,self.roleList.dimensions(),self.motiveList.dimensions(),self.capabilitiesList.capabilities())

    self.roleList.setEnvironment('')
    self.roleList.DeleteAllItems() 
    self.motiveList.setEnvironment('')
    self.motiveList.DeleteAllItems() 
    self.capabilitiesList.setEnvironment('')
    self.capabilitiesList.DeleteAllItems()
    self.theSelectedIdx = -1

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AttackerEnvironmentProperties(environmentName,[],[],[])
    self.environmentList.Select(self.theSelectedIdx)
    self.capabilitiesList.setEnvironment(environmentName)
    inheritedEnv = self.environmentList.inheritedEnvironment()
    if (inheritedEnv != '' and self.theAttackerId != None):
      p = self.dbProxy.inheritedAttackerProperties(self.theAttackerId,inheritedEnv)
      self.theEnvironmentDictionary[environmentName] = p
      self.roleList.setEnvironment(environmentName)
#.........这里部分代码省略.........
开发者ID:RachelLar,项目名称:CAIRIS-web,代码行数:103,代码来源:AttackerEnvironmentPanel.py

示例12: AcceptEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class AcceptEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.ACCEPT_PANELENVIRONMENT_ID)
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.ACCEPT_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    costBox = wx.StaticBox(self,-1,'Cost')
    costBoxSizer = wx.StaticBoxSizer(costBox,wx.HORIZONTAL)
    environmentDimSizer.Add(costBoxSizer,0,wx.EXPAND)
    self.costCombo = wx.ComboBox(self,armid.ACCEPT_COMBOCOST_ID,"",choices=['Low','Medium','High'],style=wx.CB_READONLY)
    costBoxSizer.Add(self.costCombo,0,wx.EXPAND)
   
    rationaleBox = wx.StaticBox(self,-1,'Rationale')
    rationaleBoxSizer = wx.StaticBoxSizer(rationaleBox,wx.HORIZONTAL)
    environmentDimSizer.Add(rationaleBoxSizer,1,wx.EXPAND)
    self.rationaleCtrl = wx.TextCtrl(self,armid.ACCEPT_TEXTRATIONALE_ID,'',style=wx.TE_MULTILINE)
    rationaleBoxSizer.Add(self.rationaleCtrl,1,wx.EXPAND)
    self.costCombo.Disable() 
    self.rationaleCtrl.Disable()
    
    self.SetSizer(mainSizer)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.costCombo.SetStringSelection(p.cost())
    self.rationaleCtrl.SetValue(p.description()) 
    self.environmentList.Select(0)
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    p = self.theEnvironmentDictionary[environmentName]
    self.costCombo.SetStringSelection(p.cost())
    self.rationaleCtrl.SetValue(p.description()) 
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()

  def OnEnvironmentDeselected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AcceptEnvironmentProperties(environmentName,self.costCombo.GetValue(),self.rationaleCtrl.GetValue())
    self.costCombo.SetValue('')
    self.rationaleCtrl.SetValue('') 
    self.theSelectedIdx = -1
    self.costCombo.Disable() 
    self.rationaleCtrl.Disable()

  def OnAddEnvironment(self,evt):
    self.theSelectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
    self.theEnvironmentDictionary[environmentName] = AcceptEnvironmentProperties(environmentName)
    self.costCombo.SetValue('')
    self.rationaleCtrl.SetValue('') 
    self.environmentList.Select(self.theSelectedIdx)
    self.costCombo.Enable() 
    self.rationaleCtrl.Enable()

  def OnDeleteEnvironment(self,evt):
    selectedIdx = evt.GetIndex()
    environmentName = self.environmentList.GetItemText(selectedIdx)
    del self.theEnvironmentDictionary[environmentName]
    self.theSelectedIdx = -1

  def environmentProperties(self):
    if (self.theSelectedIdx != -1):
      environmentName = self.environmentList.GetItemText(self.theSelectedIdx)
      properties = AcceptEnvironmentProperties(environmentName,self.costCombo.GetValue(),self.rationaleCtrl.GetValue())
      self.theEnvironmentDictionary[environmentName] = properties
#.........这里部分代码省略.........
开发者ID:RobinQuetin,项目名称:CAIRIS,代码行数:103,代码来源:AcceptEnvironmentPanel.py

示例13: MitigateEnvironmentPanel

# 需要导入模块: from EnvironmentListCtrl import EnvironmentListCtrl [as 别名]
# 或者: from EnvironmentListCtrl.EnvironmentListCtrl import load [as 别名]
class MitigateEnvironmentPanel(wx.Panel):
  def __init__(self,parent,dp):
    wx.Panel.__init__(self,parent,armid.MITIGATE_PANELENVIRONMENT_ID)
    self.theResponsePanel = parent
    self.dbProxy = dp
    self.theEnvironmentDictionary = {}
    self.theSelectedIdx = -1

    mainSizer = wx.BoxSizer(wx.HORIZONTAL)
    environmentBox = wx.StaticBox(self)
    environmentListSizer = wx.StaticBoxSizer(environmentBox,wx.HORIZONTAL)
    mainSizer.Add(environmentListSizer,0,wx.EXPAND)
    self.environmentList = EnvironmentListCtrl(self,armid.MITIGATE_LISTENVIRONMENTS_ID,self.dbProxy)
    environmentListSizer.Add(self.environmentList,1,wx.EXPAND)
    environmentDimSizer = wx.BoxSizer(wx.VERTICAL)
    mainSizer.Add(environmentDimSizer,1,wx.EXPAND)

    typeBox = wx.StaticBox(self,-1,'Type')
    typeBoxSizer = wx.StaticBoxSizer(typeBox,wx.HORIZONTAL)
    environmentDimSizer.Add(typeBoxSizer,0,wx.EXPAND)
    self.typeCombo = wx.ComboBox(self,armid.MITIGATE_COMBOTYPE_ID,"",choices=['Deter','Prevent','Detect','React'],style=wx.CB_READONLY)
    typeBoxSizer.Add(self.typeCombo,1,wx.EXPAND)
   
    pointBox = wx.StaticBox(self,-1,'Detection Point')
    pointBoxSizer = wx.StaticBoxSizer(pointBox,wx.HORIZONTAL)
    environmentDimSizer.Add(pointBoxSizer,0,wx.EXPAND)
    self.pointCombo = wx.ComboBox(self,armid.MITIGATE_COMBODETECTIONPOINT_ID,"",choices=['Before','At','After'],style=wx.CB_READONLY)
    pointBoxSizer.Add(self.pointCombo,1,wx.EXPAND)


    dmBox = wx.StaticBox(self,-1,)
    dmBoxSizer = wx.StaticBoxSizer(dmBox,wx.HORIZONTAL)
    environmentDimSizer.Add(dmBoxSizer,1,wx.EXPAND)
    self.dmList = DimensionListCtrl(self,armid.MITIGATE_LISTDETMECH_ID,wx.DefaultSize,'Detection Mechanism','detection_mechanism',self.dbProxy,listStyle=wx.LC_REPORT)
    dmBoxSizer.Add(self.dmList,1,wx.EXPAND)

    self.typeCombo.Disable()
    self.pointCombo.Disable() 
    self.dmList.Disable()
    
    self.SetSizer(mainSizer)
    self.typeCombo.Bind(wx.EVT_COMBOBOX,self.onTypeChange)
    self.environmentList.Bind(wx.EVT_LIST_INSERT_ITEM,self.OnAddEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_DELETE_ITEM,self.OnDeleteEnvironment)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)

  def onTypeChange(self,evt):
    self.activateTypeCtrls()
    mitType = self.typeCombo.GetValue()
    riskCombo = self.theResponsePanel.FindWindowById(armid.RESPONSE_COMBORISK_ID)
    riskName = riskCombo.GetValue()
    if (riskName != ''):
      riskNameCtrl = self.theResponsePanel.FindWindowById(armid.RESPONSE_TEXTNAME_ID)
      riskNameLabel = mitType + ' ' + riskName
      riskNameCtrl.SetValue(riskNameLabel)

  def activateTypeCtrls(self):
    mitType = self.typeCombo.GetValue()
    if ((mitType == 'Deter') or (mitType == 'Prevent')):
      self.pointCombo.SetValue('')
      self.pointCombo.Disable() 
      self.dmList.DeleteAllItems()
      self.dmList.Disable()
    elif (mitType == 'Detect'):
      self.pointCombo.Enable() 
      self.dmList.Disable()
    elif (mitType == 'React'):
      self.pointCombo.Disable() 
      self.dmList.Enable()
  
  def loadControls(self,accept):
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_SELECTED)
    self.environmentList.Unbind(wx.EVT_LIST_ITEM_DESELECTED)
    environmentNames = []
    for cp in accept.environmentProperties():
      environmentNames.append(cp.name())
    self.environmentList.load(environmentNames)

    for cp in accept.environmentProperties():
      environmentName = cp.name()
      self.theEnvironmentDictionary[environmentName] = cp
      environmentNames.append(environmentName) 
    environmentName = environmentNames[0]
    p = self.theEnvironmentDictionary[environmentName]
    
    self.typeCombo.SetStringSelection(p.type())
    self.pointCombo.SetStringSelection(p.detectionPoint())
    self.dmList.setEnvironment(environmentName)
    self.dmList.load(p.detectionMechanisms())

    self.environmentList.Select(0)

    self.activateTypeCtrls()
    self.environmentList.Bind(wx.EVT_LIST_ITEM_SELECTED,self.OnEnvironmentSelected)
    self.environmentList.Bind(wx.EVT_LIST_ITEM_DESELECTED,self.OnEnvironmentDeselected)
    self.theSelectedIdx = 0

  def OnEnvironmentSelected(self,evt):
    self.theSelectedIdx = evt.GetIndex()
#.........这里部分代码省略.........
开发者ID:RobinQuetin,项目名称:CAIRIS,代码行数:103,代码来源:MitigateEnvironmentPanel.py


注:本文中的EnvironmentListCtrl.EnvironmentListCtrl.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。