Exemple #1
0
    def __init__(self, **kwargs):
        self.attached = False
        self.parent = None
        self.layoutData = None
        self.contextMenu = None

        UIObject.__init__(self, **kwargs)
    def __init__(self, **kwargs):
        self.attached = False
        self.parent = None
        self.layoutData = None
        self.contextMenu = None

        UIObject.__init__(self, **kwargs)
    def __init__(self, text, asHTML, subMenu=None, **kwargs):
        cmd = None
        if subMenu is None:
            if hasattr(asHTML, "execute"):  # text, cmd
                cmd = asHTML
                asHTML = False
            elif hasattr(asHTML, "onShow"):  # text, subMenu
                subMenu = asHTML
                asHTML = False
            # else: text, asHTML
        elif hasattr(subMenu, "execute"):  # text, asHTML, cmd
            cmd = subMenu
            subMenu = None
        # else: text, asHTML, subMenu

        self.command = None
        self.parentMenu = None
        self.subMenu = None

        if kwargs.has_key('Element'):
            element = kwargs.pop('Element')
        else:
            element = DOM.createTD()
        self.setElement(element)

        kwargs['SelectionStyle'] = False
        if asHTML:
            kwargs['HTML'] = text
        else:
            kwargs['Text'] = text

        if cmd:
            kwargs['Command'] = cmd
        if subMenu:
            kwargs['SubMenu'] = subMenu

        if not kwargs.has_key('StyleName'):
            kwargs['StyleName'] = "gwt-MenuItem"

        UIObject.__init__(self, **kwargs)
        self.sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT)
Exemple #4
0
    def __init__(self, text, asHTML, subMenu=None, **kwargs):
        cmd = None
        if subMenu is None:
            if hasattr(asHTML, "execute"): # text, cmd
                cmd = asHTML
                asHTML = False
            elif hasattr(asHTML, "onShow"): # text, subMenu
                subMenu = asHTML
                asHTML = False
            # else: text, asHTML
        elif hasattr(subMenu, "execute"): # text, asHTML, cmd
            cmd = subMenu
            subMenu = None
        # else: text, asHTML, subMenu

        self.command = None
        self.parentMenu = None
        self.subMenu = None

        if kwargs.has_key('Element'):
            element = kwargs.pop('Element')
        else:
            element = DOM.createTD()
        self.setElement(element)

        kwargs['SelectionStyle'] = False
        if asHTML:
            kwargs['HTML'] = text
        else:
            kwargs['Text'] = text

        if cmd:
            kwargs['Command'] = cmd
        if subMenu:
            kwargs['SubMenu'] = subMenu

        if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-MenuItem"

        UIObject.__init__(self, **kwargs)
        self.sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT)
    def __init__(self, html=None, **ka):
        self.children = []
        self.attached = False
        self.contentPanel = None
        self.itemTable = None
        self.contentElem = None
        self.imgElem = None
        self.childSpanElem = None
        self.open = False
        self.parent = None
        self.selected = False
        self.tree = None
        self.userObject = None

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)

        self.itemTable = DOM.createTable()
        self.contentElem = DOM.createSpan()
        self.childSpanElem = DOM.createSpan()
        self.imgElem = DOM.createImg()

        tbody = DOM.createTBody()
        tr = DOM.createTR()
        tdImg = DOM.createTD()
        tdContent = DOM.createTD()
        DOM.appendChild(self.itemTable, tbody)
        DOM.appendChild(tbody, tr)
        DOM.appendChild(tr, tdImg)
        DOM.appendChild(tr, tdContent)
        DOM.setStyleAttribute(tdImg, "verticalAlign", "middle")
        DOM.setStyleAttribute(tdContent, "verticalAlign", "middle")
        DOM.setStyleAttribute(self.getElement(), "cursor", "pointer")

        DOM.appendChild(self.getElement(), self.itemTable)
        DOM.appendChild(self.getElement(), self.childSpanElem)
        DOM.appendChild(tdImg, self.imgElem)
        DOM.appendChild(tdContent, self.contentElem)

        # XXX - can't set pos relative on a div node,
        # or white_space on an HTML Table..
        try:
            DOM.setAttribute(self.getElement(), "position", "relative")
        except:
            pass
        DOM.setStyleAttribute(self.contentElem, "display", "inline")
        DOM.setStyleAttribute(self.getElement(), "whiteSpace", "nowrap")
        try:
            DOM.setAttribute(self.itemTable, "whiteSpace", "nowrap")
        except:
            pass
        DOM.setStyleAttribute(self.childSpanElem, "whiteSpace", "nowrap")
        self.setStyleName(self.contentElem, "gwt-TreeItem", True)

        #if not ka.has_key('StyleName'): ka['StyleName']="gwt-TreeItem"

        if html is not None:
            try:
                # messy. pyjd can do unicode, pyjs can't
                if isinstance(html, unicode):
                    ka['HTML'] = html
                elif isinstance(html, basestring):
                    ka['HTML'] = html
                else:
                    ka['Widget'] = html
            except:
                if isinstance(html, basestring):
                    ka['HTML'] = html
                else:
                    ka['Widget'] = html

        UIObject.__init__(self, **ka)
Exemple #6
0
    def __init__(self, html=None, **ka):
        self.children = []
        self.attached = False
        self.contentPanel = None
        self.itemTable = None
        self.contentElem = None
        self.imgElem = None
        self.childSpanElem = None
        self.open = False
        self.parent = None
        self.selected = False
        self.tree = None
        self.userObject = None

        element = ka.pop('Element', None) or DOM.createDiv()
        self.setElement(element)

        self.itemTable = DOM.createTable()
        self.contentElem = DOM.createSpan()
        self.childSpanElem = DOM.createSpan()
        self.imgElem = self.createImage()

        tbody = DOM.createTBody()
        tr = DOM.createTR()
        tdImg = DOM.createTD()
        tdContent = DOM.createTD()
        DOM.appendChild(self.itemTable, tbody)
        DOM.appendChild(tbody, tr)
        DOM.appendChild(tr, tdImg)
        DOM.appendChild(tr, tdContent)
        DOM.setStyleAttribute(tdImg, "verticalAlign", "middle")
        DOM.setStyleAttribute(tdContent, "verticalAlign", "middle")
        DOM.setStyleAttribute(self.getElement(), "cursor", "pointer")

        DOM.appendChild(self.getElement(), self.itemTable)
        DOM.appendChild(self.getElement(), self.childSpanElem)
        DOM.appendChild(tdImg, self.imgElem)
        DOM.appendChild(tdContent, self.contentElem)

        self.setStyleName(tdImg, "gwt-TreeItemTdImg", True)
        self.setStyleName(tdContent, "gwt-TreeItemTdContent", True)

        # XXX - can't set pos relative on a div node,
        # or white_space on an HTML Table..
        try:
            DOM.setAttribute(self.getElement(), "position", "relative")
        except:
            pass
        DOM.setStyleAttribute(self.contentElem, "display", "inline")
        DOM.setStyleAttribute(self.getElement(), "whiteSpace", "nowrap")
        try:
            DOM.setAttribute(self.itemTable, "whiteSpace", "nowrap")
        except:
            pass
        DOM.setStyleAttribute(self.childSpanElem, "whiteSpace", "nowrap")
        self.setStyleName(self.contentElem, "gwt-TreeItem", True)

        #if not ka.has_key('StyleName'): ka['StyleName']="gwt-TreeItem"

        if html is not None:
            try:
                # messy. pyjd can do unicode, pyjs can't
                if isinstance(html, unicode):
                    ka['HTML'] = html
                elif isinstance(html, basestring):
                    ka['HTML'] = html
                else:
                    ka['Widget'] = html
            except:
                if isinstance(html, basestring):
                    ka['HTML'] = html
                else:
                    ka['Widget'] = html

        UIObject.__init__(self, **ka)