# 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, ""))


import wx
import logger
import adm
import wx.propgrid as wxpg
from wh import xlt, Menu

  def OnAddObjectClass(self, evt=None):
    self.GetServer().AllObjectClasses()

    presentMarker="("
    def addClass(childlist, level, onlyStructural):
      for cls in childlist:
        if onlyStructural and cls.kind != 0:
          continue
        tab="                                                                     "[:level*3]
        if cls.name.lower() in map(lambda x: x.lower(), self.dialog.objectClasses):
          pm=presentMarker
          pme=")"
        else:
          pm=" "
          pme=""
        ocs.append("%s%s%s%s" % (tab, pm, cls.names[0],pme))

        addClass(cls.children, level+1, onlyStructural)


    oldlen=len(self.dialog.objectClasses)

    ocs=[]
    onlyStructural=(oldlen == 0)
    addClass(self.GetServer().GetClassSchema('top').children, 0, onlyStructural)

    if onlyStructural:
      caption= xlt("Available structural objectClasses")
    else:

# 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: modLdap/GenericEntry.py
import wx
import logger
import adm
import wx.propgrid as wxpg
from wh import xlt, Menu


  def OnAddObjectClass(self, evt=None):
    self.GetServer().AllObjectClasses()

    presentMarker="("
    def addClass(childlist, level, onlyStructural):
      for cls in childlist:
        if onlyStructural and cls.kind != 0:
          continue
        tab="                                                                     "[:level*3]
        if cls.name.lower() in map(lambda x: x.lower(), self.dialog.objectClasses):
          pm=presentMarker
          pme=")"
        else:
          pm=" "
          pme=""
        ocs.append("%s%s%s%s" % (tab, pm, cls.names[0],pme))

        addClass(cls.children, level+1, onlyStructural)


    oldlen=len(self.dialog.objectClasses)

    ocs=[]
    onlyStructural=(oldlen == 0)
    addClass(self.GetServer().GetClassSchema('top').children, 0, onlyStructural)

    if onlyStructural:
      caption= xlt("Available structural objectClasses")
    else:

      caption= xlt("Available objectClasses")