--- a/controls/VariablePanel.py Fri Dec 09 10:22:26 2011 +0100
+++ b/controls/VariablePanel.py Fri Dec 09 11:26:10 2011 +0100
@@ -207,52 +207,55 @@
editor = None
renderer = None
colname = self.GetColLabelValue(col, False)
- if colname == "Option":
- options = GetOptions(constant = var_class in ["Local", "External", "Global"],
- retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"],
- non_retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"])
- if len(options) > 1:
- editor = wx.grid.GridCellChoiceEditor()
- editor.SetParameters(",".join(map(_, options)))
- else:
- grid.SetReadOnly(row, col, True)
- elif col != 0 and self.GetValueByName(row, "Edit"):
- grid.SetReadOnly(row, col, False)
- if colname == "Name":
- if self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
+ if self.Parent.Debug:
+ grid.SetReadOnly(row, col, True)
+ else:
+ if colname == "Option":
+ options = GetOptions(constant = var_class in ["Local", "External", "Global"],
+ retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output", "Global"],
+ non_retain = self.Parent.ElementType != "function" and var_class in ["Local", "Input", "Output"])
+ if len(options) > 1:
+ editor = wx.grid.GridCellChoiceEditor()
+ editor.SetParameters(",".join(map(_, options)))
+ else:
grid.SetReadOnly(row, col, True)
- else:
- editor = wx.grid.GridCellTextEditor()
- renderer = wx.grid.GridCellStringRenderer()
- elif colname == "Initial Value":
- if var_class != "External":
- if self.Parent.Controler.IsEnumeratedType(var_type):
- editor = wx.grid.GridCellChoiceEditor()
- editor.SetParameters(",".join(self.Parent.Controler.GetEnumeratedDataValues(var_type)))
+ elif col != 0 and self.GetValueByName(row, "Edit"):
+ grid.SetReadOnly(row, col, False)
+ if colname == "Name":
+ if self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
+ grid.SetReadOnly(row, col, True)
else:
editor = wx.grid.GridCellTextEditor()
- renderer = wx.grid.GridCellStringRenderer()
- else:
- grid.SetReadOnly(row, col, True)
- elif colname == "Location":
- if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type):
- editor = LocationCellEditor(self, self.Parent.Controler)
- renderer = wx.grid.GridCellStringRenderer()
- else:
- grid.SetReadOnly(row, col, True)
- elif colname == "Class":
- if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
- grid.SetReadOnly(row, col, True)
- else:
- editor = wx.grid.GridCellChoiceEditor()
- excluded = []
- if self.Parent.PouIsUsed:
- excluded.extend(["Input","Output","InOut"])
- if self.Parent.IsFunctionBlockType(var_type):
- excluded.extend(["Local","Temp"])
- editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
- elif colname != "Documentation":
- grid.SetReadOnly(row, col, True)
+ renderer = wx.grid.GridCellStringRenderer()
+ elif colname == "Initial Value":
+ if var_class != "External":
+ if self.Parent.Controler.IsEnumeratedType(var_type):
+ editor = wx.grid.GridCellChoiceEditor()
+ editor.SetParameters(",".join(self.Parent.Controler.GetEnumeratedDataValues(var_type)))
+ else:
+ editor = wx.grid.GridCellTextEditor()
+ renderer = wx.grid.GridCellStringRenderer()
+ else:
+ grid.SetReadOnly(row, col, True)
+ elif colname == "Location":
+ if var_class in ["Local", "Global"] and self.Parent.Controler.IsLocatableType(var_type):
+ editor = LocationCellEditor(self, self.Parent.Controler)
+ renderer = wx.grid.GridCellStringRenderer()
+ else:
+ grid.SetReadOnly(row, col, True)
+ elif colname == "Class":
+ if len(self.Parent.ClassList) == 1 or self.Parent.PouIsUsed and var_class in ["Input", "Output", "InOut"]:
+ grid.SetReadOnly(row, col, True)
+ else:
+ editor = wx.grid.GridCellChoiceEditor()
+ excluded = []
+ if self.Parent.PouIsUsed:
+ excluded.extend(["Input","Output","InOut"])
+ if self.Parent.IsFunctionBlockType(var_type):
+ excluded.extend(["Local","Temp"])
+ editor.SetParameters(",".join([_(choice) for choice in self.Parent.ClassList if choice not in excluded]))
+ elif colname != "Documentation":
+ grid.SetReadOnly(row, col, True)
grid.SetCellEditor(row, col, editor)
grid.SetCellRenderer(row, col, renderer)
@@ -502,11 +505,12 @@
self._init_sizers()
- def __init__(self, parent, window, controler, element_type):
+ def __init__(self, parent, window, controler, element_type, debug=False):
self._init_ctrls(parent)
self.ParentWindow = window
self.Controler = controler
self.ElementType = element_type
+ self.Debug = debug
self.RefreshHighlightsTimer = wx.Timer(self, -1)
self.Bind(wx.EVT_TIMER, self.OnRefreshHighlightsTimer, self.RefreshHighlightsTimer)
@@ -580,6 +584,7 @@
"Delete": self.DeleteButton,
"Up": self.UpButton,
"Down": self.DownButton})
+ self.VariablesGrid.SetEditable(not self.Debug)
def _AddVariable(new_row):
if not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]:
@@ -629,10 +634,10 @@
row_edit = self.Table.GetValueByName(row, "Edit")
if self.PouIsUsed:
row_class = self.Table.GetValueByName(row, "Class")
- self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])
- self.DeleteButton.Enable(table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])
- self.UpButton.Enable(table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
- self.DownButton.Enable(table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
+ self.AddButton.Enable(not self.Debug and (not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"]))
+ self.DeleteButton.Enable(not self.Debug and (table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"]))
+ self.UpButton.Enable(not self.Debug and (table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]))
+ self.DownButton.Enable(not self.Debug and (table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"]))
setattr(self.VariablesGrid, "RefreshButtons", _RefreshButtons)
self.VariablesGrid.SetRowLabelSize(0)
@@ -658,31 +663,31 @@
return name in self.Controler.GetFunctionBlockTypes(self.TagName)
def RefreshView(self):
- self.PouNames = self.Controler.GetProjectPouNames()
+ self.PouNames = self.Controler.GetProjectPouNames(self.Debug)
words = self.TagName.split("::")
if self.ElementType == "config":
self.PouIsUsed = False
returnType = None
- self.Values = self.Controler.GetConfigurationGlobalVars(words[1])
+ self.Values = self.Controler.GetConfigurationGlobalVars(words[1], self.Debug)
elif self.ElementType == "resource":
self.PouIsUsed = False
returnType = None
- self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2])
+ self.Values = self.Controler.GetConfigurationResourceGlobalVars(words[1], words[2], self.Debug)
else:
if self.ElementType == "function":
self.ReturnType.Clear()
- for base_type in self.Controler.GetDataTypes(self.TagName, True):
+ for base_type in self.Controler.GetDataTypes(self.TagName, True, debug=self.Debug):
self.ReturnType.Append(base_type)
returnType = self.Controler.GetEditedElementInterfaceReturnType(self.TagName)
else:
returnType = None
self.PouIsUsed = self.Controler.PouIsUsed(words[1])
- self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName)
+ self.Values = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)
if returnType is not None:
self.ReturnType.SetStringSelection(returnType)
- self.ReturnType.Enable(True)
+ self.ReturnType.Enable(self.Debug)
self.staticText1.Show()
self.ReturnType.Show()
else:
@@ -844,7 +849,7 @@
def OnVariablesGridCellLeftClick(self, event):
row = event.GetRow()
- if event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit"):
+ if not self.Debug and (event.GetCol() == 0 and self.Table.GetValueByName(row, "Edit")):
row = event.GetRow()
var_name = self.Table.GetValueByName(row, "Name")
var_class = self.Table.GetValueByName(row, "Class")