# Path: tree.py
# class DragTreeCtrl(TreeCtrl):
#   def __init__(self, parentWin, name, size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT):
#     TreeCtrl.__init__(self, parentWin, name, size, style)
#     self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag)
#     self.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag)
# 
# 
#   def OnBeginDrag(self, evt):
#     self.currentItem = evt.GetItem()
#     evt.Allow()
#   
#   def OnEndDrag(self, evt):
#     targetItem=evt.GetItem()
#     self.ExecuteDrag(targetItem)
# 
# class TreeItemData(wx.TreeItemData):
#   def __init__(self, node):
#     wx.TreeItemData.__init__(self)
#     self.SetData(node)
# 
# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# class Menu(wx.Menu):
#   def __init__(self, menuOwner=None):
#     wx.Menu.__init__(self)
#     self.menuOwner=menuOwner
#   
#   def Popup(self, evt):
#     evt.EventObject.PopupMenu(self, evt.GetPosition())
#        
#   def getId(self, something):
#     if isinstance(something, wx.MenuItem):
#       return something.GetId()
#     elif isinstance(something, int):
#       return something
#     return self.menuOwner.GetMenuId(something)
# 
#   def Enable(self, something, how):
#     wx.Menu.Enable(self, self.getId(something), how)
#     
#   def IsEnabled(self, something):
#     return wx.Menu.IsEnabled(self, self.getId(something))
#     
#   def Check(self, something, how):
#     wx.Menu.Check(self, self.getId(something), how)
#     
#   def IsChecked(self, something):
#     return wx.Menu.IsChecked(self, self.getId(something))
#     
#   def Add(self, onproc, name, desc=None, id=-1, macproc=None):
#     if desc == None: desc=name
#     if id==-1:
#       id=self.menuOwner.BindMenuId(onproc)
#       item=self.Append(id, name, desc)
#     else:
#       item=self.Append(id, name, desc)
#       self.menuOwner.Bind(wx.EVT_MENU, onproc, id=id)
#       
#     if macproc and wx.Platform == "__WXMAC__":
#       macproc(id)
#     return item
# 
#   def AddCheck(self, onproc, name, desc, how=True):
#     if desc == None: desc=name
#     id=self.menuOwner.BindMenuId(onproc)
#     item=self.AppendCheckItem(id, name, desc)
#     self.Check(id, how)
#     return item
#   
#   def AppendOneMenu(self, menu, txt, help=None):
#     if not help:
#       help=""
#     ic = menu.GetMenuItemCount()
#     if ic > 1:
#       return self.AppendSubMenu(menu, txt, help)
#     if ic == 1:
#       i=menu.GetMenuItems()[0]
#       item=self.Append(i.GetId(), i.GetItemLabel(), i.GetHelp())
#       return item
#     return None
# 
# 
#   def Dup(self):
#     menu=Menu(self.menuOwner)
#     for i in self.GetMenuItems():
#       item=menu.Append(i.GetId(), i.GetItemLabel(), i.GetHelp())
#       item.SetBitmap(i.GetBitmap())
#     return menu
# 
#   def getRepr(self, m, indentstr):
#     strings=[]
#     for i in m.GetMenuItems():
#       if i.IsSeparator():
#         strings.append("%s---" % indentstr)
#       else:
#         strings.append("%s%d: %s" % (indentstr, i.GetId(), i.GetItemLabel()))
#         if i.IsSubMenu():
#           strings.extend(self.getRepr(i.GetSubMenu(), "%s  " & indentstr))
#     return strings
# 
#   def __str__(self):
#     return "\n".join(self.getRepr(self, ""))
# 
# Path: adm.py
# def getModule(instance):
# def IsPackaged():
# def GetProxies():
# def TextExtent(text):
#   def __init__(self, w, h):
#   def GetModuleId(self, inst, name):
#   def GetJoinedId(self, ids):
#   def GetId(self, name):
#   def __getitem__(self, name):
#   def __init__(self, node, txt, error=None):
#   def __init__(self, node, error=None):
#   def __init__(self, node, error):
#   def __init__(self, node, spot, error):
# def RegisterServer(settings):
# def DisplayDialog(cls, parentWin, *params):
# def DisplayNewDialog(cls, parentWin, *params):
# def SetClipboard(data):
# def GetCurrentFrame(wnd=None):
# def SetStatus(text=None):
# def GetCurrentTree(wnd=None):
# def AskPassword(parentWin, msg, caption, withRememberCheck=False):
# def ConfirmDelete(msg, hdr, force=False):
# def ShowHint(parentWin, hint, module=None, title=None, args=None):
# def StartWaiting(txt=None, mayAbort=False):
# def StopWaiting(frame=None, txt=None):
# class ImageList(wx.ImageList):
# class admException(Exception):
# class NoConnectionException(admException):
# class ServerException(admException):
# class ConnectionException(admException):


import wx
from tree import DragTreeCtrl, TreeItemData
from wh import xlt, Menu
from adm import images
from _pgsql import pgQuery
# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage


 
class Snippet:
  def __init__(self, id, parent, name, text, sort):
    self.id=id
    self.sort=sort
    self.name=name
    self.parent=parent
    self.text=text
    self.treeitem=None
    self.prevText=None
    
  def IsGroup(self):
    return not self.text
    

class SnippetTree(DragTreeCtrl):
  def __init__(self, parentWin, server, editor):

# Path: tree.py
# class DragTreeCtrl(TreeCtrl):
#   def __init__(self, parentWin, name, size=wx.DefaultSize, style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT):
#     TreeCtrl.__init__(self, parentWin, name, size, style)
#     self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnBeginDrag)
#     self.Bind(wx.EVT_TREE_END_DRAG, self.OnEndDrag)
# 
# 
#   def OnBeginDrag(self, evt):
#     self.currentItem = evt.GetItem()
#     evt.Allow()
#   
#   def OnEndDrag(self, evt):
#     targetItem=evt.GetItem()
#     self.ExecuteDrag(targetItem)
# 
# class TreeItemData(wx.TreeItemData):
#   def __init__(self, node):
#     wx.TreeItemData.__init__(self)
#     self.SetData(node)
# 
# Path: wh.py
# def xlt(s): # translate
#   return s
#   t=wx.GetTranslation(s)
#   # if dict set and t == s: log untranslated
#   return t
# 
# class Menu(wx.Menu):
#   def __init__(self, menuOwner=None):
#     wx.Menu.__init__(self)
#     self.menuOwner=menuOwner
#   
#   def Popup(self, evt):
#     evt.EventObject.PopupMenu(self, evt.GetPosition())
#        
#   def getId(self, something):
#     if isinstance(something, wx.MenuItem):
#       return something.GetId()
#     elif isinstance(something, int):
#       return something
#     return self.menuOwner.GetMenuId(something)
# 
#   def Enable(self, something, how):
#     wx.Menu.Enable(self, self.getId(something), how)
#     
#   def IsEnabled(self, something):
#     return wx.Menu.IsEnabled(self, self.getId(something))
#     
#   def Check(self, something, how):
#     wx.Menu.Check(self, self.getId(something), how)
#     
#   def IsChecked(self, something):
#     return wx.Menu.IsChecked(self, self.getId(something))
#     
#   def Add(self, onproc, name, desc=None, id=-1, macproc=None):
#     if desc == None: desc=name
#     if id==-1:
#       id=self.menuOwner.BindMenuId(onproc)
#       item=self.Append(id, name, desc)
#     else:
#       item=self.Append(id, name, desc)
#       self.menuOwner.Bind(wx.EVT_MENU, onproc, id=id)
#       
#     if macproc and wx.Platform == "__WXMAC__":
#       macproc(id)
#     return item
# 
#   def AddCheck(self, onproc, name, desc, how=True):
#     if desc == None: desc=name
#     id=self.menuOwner.BindMenuId(onproc)
#     item=self.AppendCheckItem(id, name, desc)
#     self.Check(id, how)
#     return item
#   
#   def AppendOneMenu(self, menu, txt, help=None):
#     if not help:
#       help=""
#     ic = menu.GetMenuItemCount()
#     if ic > 1:
#       return self.AppendSubMenu(menu, txt, help)
#     if ic == 1:
#       i=menu.GetMenuItems()[0]
#       item=self.Append(i.GetId(), i.GetItemLabel(), i.GetHelp())
#       return item
#     return None
# 
# 
#   def Dup(self):
#     menu=Menu(self.menuOwner)
#     for i in self.GetMenuItems():
#       item=menu.Append(i.GetId(), i.GetItemLabel(), i.GetHelp())
#       item.SetBitmap(i.GetBitmap())
#     return menu
# 
#   def getRepr(self, m, indentstr):
#     strings=[]
#     for i in m.GetMenuItems():
#       if i.IsSeparator():
#         strings.append("%s---" % indentstr)
#       else:
#         strings.append("%s%d: %s" % (indentstr, i.GetId(), i.GetItemLabel()))
#         if i.IsSubMenu():
#           strings.extend(self.getRepr(i.GetSubMenu(), "%s  " & indentstr))
#     return strings
# 
#   def __str__(self):
#     return "\n".join(self.getRepr(self, ""))
# 
# Path: adm.py
# def getModule(instance):
# def IsPackaged():
# def GetProxies():
# def TextExtent(text):
#   def __init__(self, w, h):
#   def GetModuleId(self, inst, name):
#   def GetJoinedId(self, ids):
#   def GetId(self, name):
#   def __getitem__(self, name):
#   def __init__(self, node, txt, error=None):
#   def __init__(self, node, error=None):
#   def __init__(self, node, error):
#   def __init__(self, node, spot, error):
# def RegisterServer(settings):
# def DisplayDialog(cls, parentWin, *params):
# def DisplayNewDialog(cls, parentWin, *params):
# def SetClipboard(data):
# def GetCurrentFrame(wnd=None):
# def SetStatus(text=None):
# def GetCurrentTree(wnd=None):
# def AskPassword(parentWin, msg, caption, withRememberCheck=False):
# def ConfirmDelete(msg, hdr, force=False):
# def ShowHint(parentWin, hint, module=None, title=None, args=None):
# def StartWaiting(txt=None, mayAbort=False):
# def StopWaiting(frame=None, txt=None):
# class ImageList(wx.ImageList):
# class admException(Exception):
# class NoConnectionException(admException):
# class ServerException(admException):
# class ConnectionException(admException):


# Path: modPg/_snippet.py
import wx
from tree import DragTreeCtrl, TreeItemData
from wh import xlt, Menu
from adm import images
from _pgsql import pgQuery

# The Admin4 Project
# (c) 2013-2014 Andreas Pflug
#
# Licensed under the Apache License, 
# see LICENSE.TXT for conditions of usage


 
class Snippet:
  def __init__(self, id, parent, name, text, sort):
    self.id=id
    self.sort=sort
    self.name=name
    self.parent=parent
    self.text=text
    self.treeitem=None
    self.prevText=None
    
  def IsGroup(self):
    return not self.text
    

class SnippetTree(DragTreeCtrl):
  def __init__(self, parentWin, server, editor):

    DragTreeCtrl.__init__(self, parentWin, "Snippets", style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_LINES_AT_ROOT)