fix issue that was impossible to remove local instance of functional
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 06 May 2016 10:35:46 +0300
changeset 1510 7272baadd7f6
parent 1509 7aaf850d8d1c
child 1511 91538d0c242c
fix issue that was impossible to remove local instance of functional
block if pou is written in ST or IL
controls/VariablePanel.py
--- a/controls/VariablePanel.py	Thu Apr 28 16:54:01 2016 +0300
+++ b/controls/VariablePanel.py	Fri May 06 10:35:46 2016 +0300
@@ -584,7 +584,7 @@
         setattr(self.VariablesGrid, "_AddRow", _AddVariable)
 
         def _DeleteVariable(row):
-            if self.Table.GetValueByName(row, "Edit"):
+            if _GetRowEdit(row):
                 self.Values.remove(self.Table.GetRow(row))
                 self.SaveValues()
                 if self.ElementType == "resource":
@@ -603,6 +603,14 @@
             return row
         setattr(self.VariablesGrid, "_MoveRow", _MoveVariable)
 
+        def _GetRowEdit(row):
+            row_edit = False
+            if self:
+                row_edit = self.Table.GetValueByName(row, "Edit")
+                bodytype = self.Controler.GetEditedElementBodyType(self.TagName)
+                row_edit = row_edit or (bodytype in ["ST", "IL"])
+            return row_edit
+
         def _RefreshButtons():
             if self:
                 table_length = len(self.Table.data)
@@ -611,7 +619,7 @@
                 row = 0
                 if table_length > 0:
                     row = self.VariablesGrid.GetGridCursorRow()
-                    row_edit = self.Table.GetValueByName(row, "Edit")
+                    row_edit = _GetRowEdit(row)
                 self.AddButton.Enable(not self.Debug)
                 self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit))
                 self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All"))