PLCOpenEditor.py
changeset 427 22d16c457d87
parent 423 53aa0c334f2f
child 428 3b19c34bac04
equal deleted inserted replaced
426:afe2488a4635 427:22d16c457d87
  1587                 elif itemtype == ITEM_POU:
  1587                 elif itemtype == ITEM_POU:
  1588                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug) if name != old_name]:
  1588                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug) if name != old_name]:
  1589                         message = _("\"%s\" pou already exists!")%new_name
  1589                         message = _("\"%s\" pou already exists!")%new_name
  1590                         abort = True
  1590                         abort = True
  1591                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1591                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1592                         messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1592                         messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1593                         if messageDialog.ShowModal() == wx.ID_NO:
  1593                         if messageDialog.ShowModal() == wx.ID_NO:
  1594                             abort = True
  1594                             abort = True
  1595                         messageDialog.Destroy()
  1595                         messageDialog.Destroy()
  1596                     if not abort:
  1596                     if not abort:
  1597                         self.Controler.ChangePouName(old_name, new_name)
  1597                         self.Controler.ChangePouName(old_name, new_name)
  1600                         self.RefreshLibraryTree()
  1600                         self.RefreshLibraryTree()
  1601                         self.RefreshPageTitles()
  1601                         self.RefreshPageTitles()
  1602                 elif itemtype == ITEM_TRANSITION:
  1602                 elif itemtype == ITEM_TRANSITION:
  1603                     pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
  1603                     pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
  1604                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1604                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1605                         message = _("A pou with \"%s\" as name exists!")%new_name
  1605                         message = _("A POU named \"%s\" already exists!")%new_name
  1606                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
  1606                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
  1607                         message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
  1607                         message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
  1608                     else:
  1608                     else:
  1609                         self.Controler.ChangePouTransitionName(pou_name, old_name, new_name)
  1609                         self.Controler.ChangePouTransitionName(pou_name, old_name, new_name)
  1610                         self.RefreshEditorNames(self.Controler.ComputePouTransitionName(pou_name, old_name), 
  1610                         self.RefreshEditorNames(self.Controler.ComputePouTransitionName(pou_name, old_name), 
  1611                                                 self.Controler.ComputePouTransitionName(pou_name, new_name))
  1611                                                 self.Controler.ComputePouTransitionName(pou_name, new_name))
  1612                         self.RefreshPageTitles()
  1612                         self.RefreshPageTitles()
  1613                 elif itemtype == ITEM_ACTION:
  1613                 elif itemtype == ITEM_ACTION:
  1614                     pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
  1614                     pou_name = GetParentName(self.TypesTree, item, ITEM_POU)
  1615                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1615                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1616                         message = _("A pou with \"%s\" as name exists!")%new_name
  1616                         message = _("A POU named \"%s\" already exists!")%new_name
  1617                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
  1617                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(pou_name, self.Debug) if name != old_name]:
  1618                         message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
  1618                         message = _("A variable with \"%s\" as name already exists in this pou!")%new_name
  1619                     else:
  1619                     else:
  1620                         self.Controler.ChangePouActionName(pou_name, old_name, new_name)
  1620                         self.Controler.ChangePouActionName(pou_name, old_name, new_name)
  1621                         self.RefreshEditorNames(self.Controler.ComputePouActionName(pou_name, old_name), 
  1621                         self.RefreshEditorNames(self.Controler.ComputePouActionName(pou_name, old_name), 
  1624                 elif itemtype == ITEM_CONFIGURATION:
  1624                 elif itemtype == ITEM_CONFIGURATION:
  1625                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug) if name != old_name]:
  1625                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug) if name != old_name]:
  1626                         message = _("\"%s\" config already exists!")%new_name
  1626                         message = _("\"%s\" config already exists!")%new_name
  1627                         abort = True
  1627                         abort = True
  1628                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1628                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1629                         messageDialog = wx.MessageDialog(self, _("A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1629                         messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1630                         if messageDialog.ShowModal() == wx.ID_NO:
  1630                         if messageDialog.ShowModal() == wx.ID_NO:
  1631                             abort = True
  1631                             abort = True
  1632                         messageDialog.Destroy()
  1632                         messageDialog.Destroy()
  1633                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1633                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1634                         messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1634                         messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1635                         if messageDialog.ShowModal() == wx.ID_NO:
  1635                         if messageDialog.ShowModal() == wx.ID_NO:
  1636                             abort = True
  1636                             abort = True
  1637                         messageDialog.Destroy()
  1637                         messageDialog.Destroy()
  1638                     if not abort:
  1638                     if not abort:
  1639                         self.Controler.ChangeConfigurationName(old_name, new_name)
  1639                         self.Controler.ChangeConfigurationName(old_name, new_name)
  1644                     config_name = GetParentName(self.TypesTree, item, ITEM_CONFIGURATION)
  1644                     config_name = GetParentName(self.TypesTree, item, ITEM_CONFIGURATION)
  1645                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug)]:
  1645                     if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames(self.Debug)]:
  1646                         message = _("\"%s\" config already exists!")%new_name
  1646                         message = _("\"%s\" config already exists!")%new_name
  1647                         abort = True
  1647                         abort = True
  1648                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1648                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames(self.Debug)]:
  1649                         messageDialog = wx.MessageDialog(self, _("A pou is defined with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1649                         messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1650                         if messageDialog.ShowModal() == wx.ID_NO:
  1650                         if messageDialog.ShowModal() == wx.ID_NO:
  1651                             abort = True
  1651                             abort = True
  1652                         messageDialog.Destroy()
  1652                         messageDialog.Destroy()
  1653                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1653                     elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariables(debug = self.Debug)]:
  1654                         messageDialog = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1654                         messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%new_name, _("Error"), wx.YES_NO|wx.ICON_QUESTION)
  1655                         if messageDialog.ShowModal() == wx.ID_NO:
  1655                         if messageDialog.ShowModal() == wx.ID_NO:
  1656                             abort = True
  1656                             abort = True
  1657                         messageDialog.Destroy()
  1657                         messageDialog.Destroy()
  1658                     if not abort:
  1658                     if not abort:
  1659                         self.Controler.ChangeConfigurationResourceName(config_name, old_name, new_name)
  1659                         self.Controler.ChangeConfigurationResourceName(config_name, old_name, new_name)
  3306         elif pou_name.upper() in self.PouNames:
  3306         elif pou_name.upper() in self.PouNames:
  3307             message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%pou_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3307             message = wx.MessageDialog(self, _("\"%s\" pou already exists!")%pou_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3308             message.ShowModal()
  3308             message.ShowModal()
  3309             message.Destroy()
  3309             message.Destroy()
  3310         elif pou_name.upper() in self.PouElementNames:
  3310         elif pou_name.upper() in self.PouElementNames:
  3311             message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%pou_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3311             message = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%pou_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3312             result = message.ShowModal()
  3312             result = message.ShowModal()
  3313             message.Destroy()
  3313             message.Destroy()
  3314             if result == wx.ID_YES:
  3314             if result == wx.ID_YES:
  3315                 self.EndModal(wx.ID_OK)
  3315                 self.EndModal(wx.ID_OK)
  3316         else:
  3316         else:
  3465         elif transition_name.upper() in IEC_KEYWORDS:
  3465         elif transition_name.upper() in IEC_KEYWORDS:
  3466             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3466             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3467             message.ShowModal()
  3467             message.ShowModal()
  3468             message.Destroy()
  3468             message.Destroy()
  3469         elif transition_name.upper() in self.PouNames:
  3469         elif transition_name.upper() in self.PouNames:
  3470             message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3470             message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3471             message.ShowModal()
  3471             message.ShowModal()
  3472             message.Destroy()
  3472             message.Destroy()
  3473         elif transition_name.upper() in self.PouElementNames:
  3473         elif transition_name.upper() in self.PouElementNames:
  3474             message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3474             message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%transition_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3475             message.ShowModal()
  3475             message.ShowModal()
  3609         elif action_name.upper() in IEC_KEYWORDS:
  3609         elif action_name.upper() in IEC_KEYWORDS:
  3610             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3610             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3611             message.ShowModal()
  3611             message.ShowModal()
  3612             message.Destroy()
  3612             message.Destroy()
  3613         elif action_name.upper() in self.PouNames:
  3613         elif action_name.upper() in self.PouNames:
  3614             message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3614             message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3615             message.ShowModal()
  3615             message.ShowModal()
  3616             message.Destroy()
  3616             message.Destroy()
  3617         elif action_name.upper() in self.PouElementNames:
  3617         elif action_name.upper() in self.PouElementNames:
  3618             message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3618             message = wx.MessageDialog(self, _("\"%s\" element for this pou already exists!")%action_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3619             message.ShowModal()
  3619             message.ShowModal()
  3680         elif config_name.upper() in IEC_KEYWORDS:
  3680         elif config_name.upper() in IEC_KEYWORDS:
  3681             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3681             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3682             message.ShowModal()
  3682             message.ShowModal()
  3683             message.Destroy()
  3683             message.Destroy()
  3684         elif config_name.upper() in self.PouNames:
  3684         elif config_name.upper() in self.PouNames:
  3685             message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3685             message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%config_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3686             message.ShowModal()
  3686             message.ShowModal()
  3687             message.Destroy()
  3687             message.Destroy()
  3688         elif config_name.upper() in self.PouElementNames:
  3688         elif config_name.upper() in self.PouElementNames:
  3689             message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%config_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3689             message = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%config_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3690             result = message.ShowModal()
  3690             result = message.ShowModal()
  3691             message.Destroy()
  3691             message.Destroy()
  3692             if result == wx.ID_YES:
  3692             if result == wx.ID_YES:
  3693                 self.EndModal(wx.ID_OK)
  3693                 self.EndModal(wx.ID_OK)
  3694         else:
  3694         else:
  3743         elif resource_name.upper() in IEC_KEYWORDS:
  3743         elif resource_name.upper() in IEC_KEYWORDS:
  3744             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3744             message = wx.MessageDialog(self, _("\"%s\" is a keyword. It can't be used!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3745             message.ShowModal()
  3745             message.ShowModal()
  3746             message.Destroy()
  3746             message.Destroy()
  3747         elif resource_name.upper() in self.PouNames:
  3747         elif resource_name.upper() in self.PouNames:
  3748             message = wx.MessageDialog(self, _("A pou with \"%s\" as name exists!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3748             message = wx.MessageDialog(self, _("A POU named \"%s\" already exists!")%resource_name, _("Error"), wx.OK|wx.ICON_ERROR)
  3749             message.ShowModal()
  3749             message.ShowModal()
  3750             message.Destroy()
  3750             message.Destroy()
  3751         elif resource_name.upper() in self.PouElementNames:
  3751         elif resource_name.upper() in self.PouElementNames:
  3752             message = wx.MessageDialog(self, _("A pou has an element with \"%s\" as name. It can generate a conflict. Do you wish to continue?")%resource_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3752             message = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?")%resource_name, _("Warning"), wx.YES_NO|wx.ICON_EXCLAMATION)
  3753             result = message.ShowModal()
  3753             result = message.ShowModal()
  3754             message.Destroy()
  3754             message.Destroy()
  3755             if result == wx.ID_YES:
  3755             if result == wx.ID_YES:
  3756                 self.EndModal(wx.ID_OK)
  3756                 self.EndModal(wx.ID_OK)
  3757         else:
  3757         else:
  4281     if cap:
  4281     if cap:
  4282         cap.ReleaseMouse()
  4282         cap.ReleaseMouse()
  4283 
  4283 
  4284     dlg = wx.SingleChoiceDialog(None, 
  4284     dlg = wx.SingleChoiceDialog(None, 
  4285         _("""
  4285         _("""
  4286 An error happens.
  4286 An error has occurred.
  4287 
  4287 
  4288 Click on OK for saving an error report.
  4288 Click OK to save an error report.
  4289 
  4289 
  4290 Please contact LOLITech at:
  4290 Please contact LOLITech at:
  4291 +33 (0)3 29 57 60 42
  4291 +33 (0)3 29 57 60 42
  4292 bugs_PLCOpenEditor@lolitech.fr
  4292 bugs_PLCOpenEditor@lolitech.fr
  4293 
  4293