def Do(self, item):
     if not item.CanDelete() or not item.AskDelete():
         return
     self.data = item.GetFullXml()
     self.treePosition = eg.TreePosition(item)
     eg.actionThread.Func(item.Delete)()
     self.document.AppendUndoHandler(self)
示例#2
0
 def Do(self, item, parent, pos):
     oldParent = item.parent
     self.oldPos = item.parent.childs.index(item)
     eg.actionThread.Func(item.MoveItemTo)(parent, pos)
     self.oldParentPath = oldParent.GetPath()
     self.newPositionData = eg.TreePosition(item)
     item.Select()
     self.document.AppendUndoHandler(self)
示例#3
0
    def Do(self, node):
        self.treePosition = eg.TreePosition(node)

        def ProcessInActionThread():
            state = not node.isEnabled
            node.SetEnable(state)
            return state

        self.state = eg.actionThread.Func(ProcessInActionThread)()
        self.document.AppendUndoHandler(self)
示例#4
0
 def PasteXml(self, selection, clipboardData):
     xmlTree = ElementTree.fromstring(clipboardData.encode("utf-8"))
     for childXmlNode in xmlTree:
         childCls = self.document.XMLTag2ClassDict[childXmlNode.tag.lower()]
         before = None
         insertionHint = selection.DropTest(childCls)
         if insertionHint & HINT_MOVE_INSIDE:
             # item will move inside
             for i in xrange(len(selection.childs) - 1, -1, -1):
                 next = selection.childs[i]
                 insertionHint = next.DropTest(childCls)
                 if insertionHint & HINT_MOVE_AFTER:
                     break
                 before = next
         elif insertionHint & HINT_MOVE_BEFORE:
             # item will move before selection
             before = selection
             parent = selection.parent
             pos = parent.GetChildIndex(selection)
             for i in xrange(pos - 1, -1, -1):
                 next = parent.childs[i]
                 insertionHint = next.DropTest(childCls)
                 if insertionHint != HINT_MOVE_BEFORE:
                     break
                 before = next
             selection = selection.parent
         elif insertionHint == HINT_MOVE_AFTER:
             # item will move after selection
             parent = selection.parent
             pos = parent.GetChildIndex(selection)
             for i in xrange(pos + 1, len(parent.childs)):
                 next = parent.childs[i]
                 insertionHint = next.DropTest(childCls)
                 if insertionHint != HINT_MOVE_AFTER:
                     before = next
                     break
             selection = selection.parent
         else:
             eg.PrintError("Unexpected item in paste.")
             return
         if before is None:
             pos = -1
         else:
             pos = before.parent.childs.index(before)
             if pos + 1 == len(before.parent.childs):
                 pos = -1
         newNode = childCls(selection, childXmlNode)
         newNode.guid = eg.GUID.NewId(newNode)
         newNode.RestoreState()
         selection.AddChild(newNode, pos)
         self.items.append(eg.TreePosition(newNode))
     if len(self.items):
         newNode.Select()
         self.document.TreeLink.StopLoad()
         return True
示例#5
0
 def Undo(self):
     parent1, pos1 = self.newPositionData.GetParentAndPosition()
     item = parent1.childs[pos1]
     parent = item.root
     for parentPos in self.oldParentPath:
         parent = parent.childs[parentPos]
     oldParent = item.parent
     oldPos = self.oldPos
     self.oldPos = item.parent.childs.index(item)
     if parent1 == parent:
         if pos1 < oldPos:
             oldPos += 1
     item.MoveItemTo(parent, oldPos)
     self.oldParentPath = oldParent.GetPath()
     self.newPositionData = eg.TreePosition(item)
     item.Select()
示例#6
0
    def Do(self, item, isFirstConfigure=False):
        if item.openConfigDialog:
            item.openConfigDialog.Raise()
            return False
        item.isFirstConfigure = isFirstConfigure
        ActionThreadFunc = eg.actionThread.Func
        self.oldArgumentString = ActionThreadFunc(item.GetArgumentString)()
        #oldArgs = newArgs = ActionThreadFunc(item.GetArguments)()
        newArgs = ActionThreadFunc(item.GetArguments)(
        )  # bugfix: http://www.eventghost.net/forum/viewtopic.php?f=4&t=3676
        oldArgs = DeepCopy(newArgs)  # bugfix
        revertOnCancel = False
        dialog = eg.ConfigDialog.Create(item, *oldArgs)

        for event, newArgs in dialog:
            if event == wx.ID_OK:
                break
            elif event == wx.ID_APPLY:
                revertOnCancel = True
                ActionThreadFunc(item.SetArguments)(newArgs)
                item.Refresh()
            elif event == eg.ID_TEST:
                revertOnCancel = True
                eg.actionThread.Call(DoExecute, item, newArgs)
        else:
            if revertOnCancel:
                ActionThreadFunc(item.SetArguments)(oldArgs)
                item.Refresh()
            return False
        ActionThreadFunc(item.SetArguments)(newArgs)
        newArgumentString = ActionThreadFunc(item.GetArgumentString)()

        if self.oldArgumentString != newArgumentString:
            if not isFirstConfigure:
                self.treePosition = eg.TreePosition(item)
                item.document.AppendUndoHandler(self)
            item.Refresh()
        return True
示例#7
0
 def ProcessInActionThread():
     self.data = selection.GetFullXml()
     self.treePosition = eg.TreePosition(selection)
     data = selection.GetXmlString()
     selection.Delete()
     return data
示例#8
0
 def StoreItem(self, item):
     self.treePosition = eg.TreePosition(item)
     item.document.AppendUndoHandler(self)
示例#9
0
 def Do(self, item, newName):
     self.newName = newName
     self.oldName = item.name
     self.treePosition = eg.TreePosition(item)
     eg.actionThread.Func(item.RenameTo)(newName)
     self.document.AppendUndoHandler(self)