+class UndoReplace:
+ def __init__(self, item):
+ self.itemIndex = g.tree.ItemFullIndex(item)
+ self.xxx = g.tree.GetPyData(item)
+ def destroy(self):
+ if self.xxx: self.xxx.element.unlink()
+ def undo(self):
+ print 'Sorry, UndoReplace is not yet implemented.'
+ return
+ item = g.tree.ItemAtFullIndex(self.itemIndex)
+ xxx = g.tree.GetPyData(item)
+ # Replace with old element
+ parent = xxx.parent.element
+ if xxx is self.xxx: # sizeritem or notebookpage - replace child
+ parent.replaceChild(self.xxx.child.element, xxx.child.element)
+ else:
+ parent.replaceChild(self.xxx.element, xxx.element)
+ self.xxx.parent = xxx.parent
+ xxx = self.xxx
+ g.tree.SetPyData(item, xxx)
+ g.tree.SetItemText(item, xxx.treeName())
+ g.tree.SetItemImage(item, xxx.treeImage())
+
+ # Update panel
+ g.panel.SetData(xxx)
+ # Update tools
+ g.tools.UpdateUI()
+ g.tree.EnsureVisible(item)
+ g.tree.SelectItem(item)
+ # Delete testWin?
+ if g.testWin:
+ # If deleting top-level item, delete testWin
+ if selected == g.testWin.item:
+ g.testWin.Destroy()
+ g.testWin = None
+ else:
+ # Remove highlight, update testWin
+ if g.testWin.highLight:
+ g.testWin.highLight.Remove()
+ g.tree.needUpdate = True
+ def redo(self):
+ return
+