editors/ResourceEditor.py
changeset 1911 c1298e7ffe3a
parent 1611 5e64d552b25a
child 1657 3a98027ff372
equal deleted inserted replaced
1910:a375e31bf312 1911:c1298e7ffe3a
     1 #!/usr/bin/env python
     1 #!/usr/bin/env python
     2 # -*- coding: utf-8 -*-
     2 # -*- coding: utf-8 -*-
     3 
     3 
     4 #This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor
     4 # This file is part of Beremiz, a Integrated Development Environment for
     5 #based on the plcopen standard.
     5 # programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
     6 #
     6 #
     7 #Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
     7 # Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
     8 #
     8 #
     9 #See COPYING file for copyrights details.
     9 # See COPYING file for copyrights details.
    10 #
    10 #
    11 #This library is free software; you can redistribute it and/or
    11 # This program is free software; you can redistribute it and/or
    12 #modify it under the terms of the GNU General Public
    12 # modify it under the terms of the GNU General Public License
    13 #License as published by the Free Software Foundation; either
    13 # as published by the Free Software Foundation; either version 2
    14 #version 2.1 of the License, or (at your option) any later version.
    14 # of the License, or (at your option) any later version.
    15 #
    15 #
    16 #This library is distributed in the hope that it will be useful,
    16 # This program is distributed in the hope that it will be useful,
    17 #but WITHOUT ANY WARRANTY; without even the implied warranty of
    17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    18 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    19 #General Public License for more details.
    19 # GNU General Public License for more details.
    20 #
    20 #
    21 #You should have received a copy of the GNU General Public
    21 # You should have received a copy of the GNU General Public License
    22 #License along with this library; if not, write to the Free Software
    22 # along with this program; if not, write to the Free Software
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    24 
    24 
    25 import wx
    25 import wx
    26 import wx.lib.buttons
    26 import wx.lib.buttons
    27 import wx.grid
    27 import wx.grid
    28 
    28 
   432         self.TasksGrid.RefreshButtons()
   432         self.TasksGrid.RefreshButtons()
   433         self.InstancesGrid.RefreshButtons()
   433         self.InstancesGrid.RefreshButtons()
   434 
   434 
   435     def OnTasksGridCellChange(self, event):
   435     def OnTasksGridCellChange(self, event):
   436         row, col = event.GetRow(), event.GetCol()
   436         row, col = event.GetRow(), event.GetCol()
   437         if self.TasksTable.GetColLabelValue(col) == "Name":
   437         if self.TasksTable.GetColLabelValue(col, False) == "Name":
   438             tasklist = [name for name in self.TaskList.split(",") if name != ""]
   438             tasklist = [name for name in self.TaskList.split(",") if name != ""]
   439             for i in xrange(self.TasksTable.GetNumberRows()):
   439             for i in xrange(self.TasksTable.GetNumberRows()):
   440                 task = self.TasksTable.GetValueByName(i, "Name")
   440                 task = self.TasksTable.GetValueByName(i, "Name")
   441                 if task in tasklist:
   441                 if task in tasklist:
   442                     tasklist.remove(task)
   442                     tasklist.remove(task)
   443             if len(tasklist) > 0:
   443             if len(tasklist) > 0:
   444                 old_name = tasklist[0]
   444                 old_name = tasklist[0].upper()
   445                 new_name = self.TasksTable.GetValue(row, col)
   445                 new_name = self.TasksTable.GetValue(row, col)
   446                 for i in xrange(self.InstancesTable.GetNumberRows()):
   446                 for i in xrange(self.InstancesTable.GetNumberRows()):
   447                     if self.InstancesTable.GetValueByName(i, "Task") == old_name:
   447                     name = self.InstancesTable.GetValueByName(i, "Task").upper()
       
   448                     if old_name == name:
   448                         self.InstancesTable.SetValueByName(i, "Task", new_name)
   449                         self.InstancesTable.SetValueByName(i, "Task", new_name)
   449         self.RefreshModel()
   450         self.RefreshModel()
   450         colname = self.TasksTable.GetColLabelValue(col, False)
   451         colname = self.TasksTable.GetColLabelValue(col, False)
   451         if colname in ["Triggering", "Name", "Single", "Interval"]:
   452         if colname in ["Triggering", "Name", "Single", "Interval"]:
   452             wx.CallAfter(self.RefreshView, False)
   453             wx.CallAfter(self.RefreshView, False)