1591 message = None |
1591 message = None |
1592 abort = False |
1592 abort = False |
1593 new_name = event.GetLabel() |
1593 new_name = event.GetLabel() |
1594 if new_name != "": |
1594 if new_name != "": |
1595 if not TestIdentifier(new_name): |
1595 if not TestIdentifier(new_name): |
1596 message = _("\"%s\" is not a valid identifier!")%new_name |
1596 message = _("\"%s\" is not a valid identifier!") % new_name |
1597 elif new_name.upper() in IEC_KEYWORDS: |
1597 elif new_name.upper() in IEC_KEYWORDS: |
1598 message = _("\"%s\" is a keyword. It can't be used!")%new_name |
1598 message = _("\"%s\" is a keyword. It can't be used!") % new_name |
1599 else: |
1599 else: |
1600 item = event.GetItem() |
1600 item = event.GetItem() |
1601 old_name = self.ProjectTree.GetItemText(item) |
1601 old_name = self.ProjectTree.GetItemText(item) |
1602 item_infos = self.ProjectTree.GetPyData(item) |
1602 item_infos = self.ProjectTree.GetPyData(item) |
1603 if item_infos["type"] == ITEM_PROJECT: |
1603 if item_infos["type"] == ITEM_PROJECT: |
1604 self.Controler.SetProjectProperties(name = new_name) |
1604 self.Controler.SetProjectProperties(name = new_name) |
1605 elif item_infos["type"] == ITEM_DATATYPE: |
1605 elif item_infos["type"] == ITEM_DATATYPE: |
1606 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]: |
1606 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]: |
1607 message = _("\"%s\" data type already exists!")%new_name |
1607 message = _("\"%s\" data type already exists!") % new_name |
1608 abort = True |
1608 abort = True |
1609 if not abort: |
1609 if not abort: |
1610 self.Controler.ChangeDataTypeName(old_name, new_name) |
1610 self.Controler.ChangeDataTypeName(old_name, new_name) |
1611 self.RefreshEditorNames(self.Controler.ComputeDataTypeName(old_name), |
1611 self.RefreshEditorNames(self.Controler.ComputeDataTypeName(old_name), |
1612 self.Controler.ComputeDataTypeName(new_name)) |
1612 self.Controler.ComputeDataTypeName(new_name)) |
1613 self.RefreshPageTitles() |
1613 self.RefreshPageTitles() |
1614 elif item_infos["type"] == ITEM_POU: |
1614 elif item_infos["type"] == ITEM_POU: |
1615 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
1615 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
1616 message = _("\"%s\" pou already exists!")%new_name |
1616 message = _("\"%s\" pou already exists!") % new_name |
1617 abort = True |
1617 abort = True |
1618 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1618 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1619 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) |
1619 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) |
1620 if messageDialog.ShowModal() == wx.ID_NO: |
1620 if messageDialog.ShowModal() == wx.ID_NO: |
1621 abort = True |
1621 abort = True |
1622 messageDialog.Destroy() |
1622 messageDialog.Destroy() |
1623 if not abort: |
1623 if not abort: |
1624 self.Controler.ChangePouName(old_name, new_name) |
1624 self.Controler.ChangePouName(old_name, new_name) |
1628 self.RefreshPageTitles() |
1628 self.RefreshPageTitles() |
1629 elif item_infos["type"] == ITEM_TRANSITION: |
1629 elif item_infos["type"] == ITEM_TRANSITION: |
1630 pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1630 pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1631 pou_name = self.ProjectTree.GetItemText(pou_item) |
1631 pou_name = self.ProjectTree.GetItemText(pou_item) |
1632 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1632 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1633 message = _("A POU named \"%s\" already exists!")%new_name |
1633 message = _("A POU named \"%s\" already exists!") % new_name |
1634 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1634 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1635 message = _("A variable with \"%s\" as name already exists in this pou!")%new_name |
1635 message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
1636 else: |
1636 else: |
1637 words = item_infos["tagname"].split("::") |
1637 words = item_infos["tagname"].split("::") |
1638 self.Controler.ChangePouTransitionName(words[1], old_name, new_name) |
1638 self.Controler.ChangePouTransitionName(words[1], old_name, new_name) |
1639 self.RefreshEditorNames(self.Controler.ComputePouTransitionName(words[1], old_name), |
1639 self.RefreshEditorNames(self.Controler.ComputePouTransitionName(words[1], old_name), |
1640 self.Controler.ComputePouTransitionName(words[1], new_name)) |
1640 self.Controler.ComputePouTransitionName(words[1], new_name)) |
1641 self.RefreshPageTitles() |
1641 self.RefreshPageTitles() |
1642 elif item_infos["type"] == ITEM_ACTION: |
1642 elif item_infos["type"] == ITEM_ACTION: |
1643 pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1643 pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1644 pou_name = self.ProjectTree.GetItemText(pou_item) |
1644 pou_name = self.ProjectTree.GetItemText(pou_item) |
1645 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1645 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1646 message = _("A POU named \"%s\" already exists!")%new_name |
1646 message = _("A POU named \"%s\" already exists!") % new_name |
1647 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1647 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1648 message = _("A variable with \"%s\" as name already exists in this pou!")%new_name |
1648 message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
1649 else: |
1649 else: |
1650 words = item_infos["tagname"].split("::") |
1650 words = item_infos["tagname"].split("::") |
1651 self.Controler.ChangePouActionName(words[1], old_name, new_name) |
1651 self.Controler.ChangePouActionName(words[1], old_name, new_name) |
1652 self.RefreshEditorNames(self.Controler.ComputePouActionName(words[1], old_name), |
1652 self.RefreshEditorNames(self.Controler.ComputePouActionName(words[1], old_name), |
1653 self.Controler.ComputePouActionName(words[1], new_name)) |
1653 self.Controler.ComputePouActionName(words[1], new_name)) |
1654 self.RefreshPageTitles() |
1654 self.RefreshPageTitles() |
1655 elif item_infos["type"] == ITEM_CONFIGURATION: |
1655 elif item_infos["type"] == ITEM_CONFIGURATION: |
1656 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
1656 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
1657 message = _("\"%s\" config already exists!")%new_name |
1657 message = _("\"%s\" config already exists!") % new_name |
1658 abort = True |
1658 abort = True |
1659 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1659 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1660 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) |
1660 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) |
1661 if messageDialog.ShowModal() == wx.ID_NO: |
1661 if messageDialog.ShowModal() == wx.ID_NO: |
1662 abort = True |
1662 abort = True |
1663 messageDialog.Destroy() |
1663 messageDialog.Destroy() |
1664 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1664 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1665 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) |
1665 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) |
1666 if messageDialog.ShowModal() == wx.ID_NO: |
1666 if messageDialog.ShowModal() == wx.ID_NO: |
1667 abort = True |
1667 abort = True |
1668 messageDialog.Destroy() |
1668 messageDialog.Destroy() |
1669 if not abort: |
1669 if not abort: |
1670 self.Controler.ChangeConfigurationName(old_name, new_name) |
1670 self.Controler.ChangeConfigurationName(old_name, new_name) |
1671 self.RefreshEditorNames(self.Controler.ComputeConfigurationName(old_name), |
1671 self.RefreshEditorNames(self.Controler.ComputeConfigurationName(old_name), |
1672 self.Controler.ComputeConfigurationName(new_name)) |
1672 self.Controler.ComputeConfigurationName(new_name)) |
1673 self.RefreshPageTitles() |
1673 self.RefreshPageTitles() |
1674 elif item_infos["type"] == ITEM_RESOURCE: |
1674 elif item_infos["type"] == ITEM_RESOURCE: |
1675 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
1675 if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
1676 message = _("\"%s\" config already exists!")%new_name |
1676 message = _("\"%s\" config already exists!") % new_name |
1677 abort = True |
1677 abort = True |
1678 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1678 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1679 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) |
1679 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) |
1680 if messageDialog.ShowModal() == wx.ID_NO: |
1680 if messageDialog.ShowModal() == wx.ID_NO: |
1681 abort = True |
1681 abort = True |
1682 messageDialog.Destroy() |
1682 messageDialog.Destroy() |
1683 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1683 elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1684 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) |
1684 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) |
1685 if messageDialog.ShowModal() == wx.ID_NO: |
1685 if messageDialog.ShowModal() == wx.ID_NO: |
1686 abort = True |
1686 abort = True |
1687 messageDialog.Destroy() |
1687 messageDialog.Destroy() |
1688 if not abort: |
1688 if not abort: |
1689 words = item_infos["tagname"].split("::") |
1689 words = item_infos["tagname"].split("::") |