set variable documentation when a location is selected from the VariableLocationBrowser
authorb.taylor@willowglen.ca
Wed, 16 Sep 2009 11:51:28 -0600
changeset 425 dbc4a66190a6
parent 424 d19c4a6460ab
child 426 afe2488a4635
set variable documentation when a location is selected from the VariableLocationBrowser
VariablePanel.py
--- a/VariablePanel.py	Tue Sep 15 14:06:59 2009 -0600
+++ b/VariablePanel.py	Wed Sep 16 11:51:28 2009 -0600
@@ -903,17 +903,18 @@
         dia.ShowModal()
 
         if dia.Selection:
-            loc, iec_type = dia.Selection
+            loc, iec_type, doc = dia.Selection
 
             # set the location
             self.SetText(loc)
 
-            # set the variable type
+            # set the variable type and documentation
             # NOTE: this update won't be displayed until editing is complete
             # (when EndEdit is called).
             # we can't call VarPanel.RefreshValues() here because it causes
             # an exception. 
             self.VarPanel.Table.SetValueByName(self.Row, 'Type', iec_type)
+            self.VarPanel.Table.SetValueByName(self.Row, 'Documentation', doc)
 
         self.txt.SetFocus()
 
@@ -1167,5 +1168,14 @@
             dir = self.GetSelectedDirection()
             location = '%' + dir + location
 
-        self.Selection = (location, data.type)
+        # walk up the tree, building documentation for the variable
+        documentation = self.tree.GetItemText(item)
+        parent = self.tree.GetItemParent(item)
+        root = self.tree.GetRootItem()
+        while parent != root:
+            text = self.tree.GetItemText(parent)
+            documentation = text + ":" + documentation
+            parent = self.tree.GetItemParent(parent)
+
+        self.Selection = (location, data.type, documentation)
         self.Destroy()