Ejemplo n.º 1
0
 def __init__(self, **kwargs):
     self.visibleWidget = None
     if kwargs.has_key("Element"):
         element = kwargs.pop("Element")
     else:
         element = DOM.createDiv()
     self.setElement(element)
     ComplexPanel.__init__(self, **kwargs)
Ejemplo n.º 2
0
Archivo: Map.py Proyecto: Afey/pyjs
 def __init__(self, Name, **kwargs):
     kwargs['Name'] = Name
     if kwargs.has_key('Element'):
         element = kwargs.pop('Element')
     else:
         element = DOM.createElement("map")
     self.setElement(element)
     ComplexPanel.__init__(self, **kwargs)
Ejemplo n.º 3
0
 def __init__(self, html, **ka):
     # NOTE! don't set a default style on this panel, because the
     # HTML might expect to have one already.  Explicitly add a StyleName
     # if one is needed.
     #if not ka.has_key('StyleName'): ka['StyleName']="gwt-HTMLPanel"
     if html: ka['HTML'] = html
     element = ka.pop('Element', None) or DOM.createDiv()
     self.setElement(element)
     ComplexPanel.__init__(self, **ka)
Ejemplo n.º 4
0
    def insert(self, widget, beforeIndex=None):
        if (beforeIndex < 0) or (beforeIndex > self.getWidgetCount()):
            # throw new IndexOutOfBoundsException();
            return

        ComplexPanel.insert(self, widget, self.getElement(), beforeIndex)

        child = widget.getElement()
        DOM.setStyleAttribute(child, "width", "100%")
        DOM.setStyleAttribute(child, "height", "100%")
        widget.setVisible(False)
Ejemplo n.º 5
0
 def onEditContentClick(self, sender):
     if self.editor:
         editor = self.editor
         self.editor = None
         ComplexPanel.remove(self, editor)
         self.editButton.setText("edit " + unescape(self.templateName))
     else:
         self.editor = RichTextEditor(self.originalText)
         self.editor.addSaveListener(self)
         ComplexPanel.insert(self, self.editor, self.getElement(),
                             len(self.children))
         self.editButton.setText("close editor")
Ejemplo n.º 6
0
 def onError(self, html, statusCode):
     if statusCode == 404 and self.allowEdit:
         self.editor = None
         self.originalText = ""
         DOM.setInnerHTML(self.getElement(), '')
         self.editButton = Label("create "+unescape(self.templateName))
         self.editButton.addStyleName("link")
         self.editButton.addStyleName("ContentPanelEditLink")
         self.editButton.addClickListener(EventDelegate("onClick", self,
                                          self.onEditContentClick))
         ComplexPanel.insert(self, self.editButton, self.getElement(),
                             len(self.children))
         return
Ejemplo n.º 7
0
    def remove(self, widget):
        if isinstance(widget, int):
            widget = self.getWidget(widget)

        if not ComplexPanel.remove(self, widget):
            return False

        if self.visibleWidget == widget:
            self.visibleWidget = None

        return True
Ejemplo n.º 8
0
    def __init__(self, **kwargs):

        kwargs['Spacing'] = kwargs.get('Spacing', 0)
        kwargs['Padding'] = kwargs.get('Padding', 0)
        kwargs['HorizontalAlignment'] = kwargs.get('HorizontalAlignment',
                            HasHorizontalAlignment.ALIGN_LEFT)
        kwargs['VerticalAlignment'] = kwargs.get('VerticalAlignment',
                            HasVerticalAlignment.ALIGN_TOP)

        element = kwargs.pop('Element', None) or DOM.createTable()
        fc = DOM.getFirstChild(element)
        if fc:
            self.body = fc
        else:
            self.body = DOM.createTBody()
        self.table = element
        self.setElement(self.table)
        DOM.appendChild(self.table, self.body)

        ComplexPanel.__init__(self, **kwargs)
Ejemplo n.º 9
0
 def __init__(self, templateName, allowEdit=False):
     ComplexPanel.__init__(self)
     self.loaded = False # Set after widgets are attached
     self.widgetsAttached = False
     self.id = None
     self.templateName = None
     self.title = None
     self.elementsById = {}
     self.metaTags = {}
     self.body = None
     self.links = []
     self.forms = []
     self.metaTagList = []
     self.loadListeners = []
     self.toAttach = []
     self.toInsert = []
     self.setElement(DOM.createDiv())
     self.editor = None
     self.allowEdit = allowEdit
     if templateName:
         self.loadTemplate(templateName)
Ejemplo n.º 10
0
Archivo: Map.py Proyecto: Afey/pyjs
 def insert(self, widget, beforeIndex):
     widget.removeFromParent()
     ComplexPanel.insert(self, widget, self.getElement(), beforeIndex)
Ejemplo n.º 11
0
    def add(self, widget, left=None, top=None):
        ComplexPanel.add(self, widget, self.getElement())

        if left is not None:
            self.setWidgetPosition(widget, left, top)
Ejemplo n.º 12
0
 def __init__(self, **ka):
     element = ka.pop('Element', None) or DOM.createDiv()
     self.setElement(element)
     DOM.setStyleAttribute(element, "position", "relative")
     DOM.setStyleAttribute(element, "overflow", "hidden")
     ComplexPanel.__init__(self, **ka)
Ejemplo n.º 13
0
 def _getProps(self):
     return ComplexPanel._getProps() + self._props
Ejemplo n.º 14
0
    def setTemplateText(self, text):
        """
        Set the template text; if the template is not HTML, a subclass
        could override this to pre-process the text into HTML before
        passing it to the default implementation.
        """
        if self.allowEdit:
            self.originalText = text
        # If we have children, remove them all first since we are
        # trashing their DOM
        for child in List(self.children):
            self.remove(child)

        DOM.setInnerHTML(self.getElement(), text)
        self.elementsById = {}
        self.links = []
        self.metaTags = {}
        self.forms = []
        self.metaTagList = []

        # Make the ids unique and store a pointer to each named element
        for node in DOM.walkChildren(self.getElement()):
            #console.log("Passing node with name %s", node.nodeName)
            if node.nodeName == "META":
                name = node.getAttribute("name")
                content = node.getAttribute("content")
                console.log("Found meta %o name %s content %s",
                            node, name, content)
                self.metaTags[name] = content
                self.metaTagList.append(node)
            elif node.nodeName == "BODY":
                self.body = node
            elif node.nodeName == "TITLE":
                self.title = DOM.getInnerText(node)
            elif node.nodeName == "FORM":
                self.forms.append(node)

            nodeId = DOM.getAttribute(node, "id")
            if nodeId:
                self.elementsById[nodeId] = node
                DOM.setAttribute(node, "id", self.id + ":" + node.id)
            nodeHref = DOM.getAttribute(node, "href")
            if nodeHref:
                self.links.append(node)

        self.loaded = True
        if self.attached:
            self.attachWidgets()
            self.widgetsAttached = True

        if self.allowEdit:
            self.editor = None
            self.editButton = Label("edit "+unescape(self.templateName))
            self.editButton.addStyleName("link")
            self.editButton.addStyleName("ContentPanelEditLink")
            self.editButton.addClickListener(EventDelegate("onClick", self,
                                             self.onEditContentClick))
            ComplexPanel.insert(self, self.editButton, self.getElement(),
                                len(self.children))

        self.notifyLoadListeners()
Ejemplo n.º 15
0
 def add(self, widget, id):
     element = getElementById(self.getElement(), id)
     if element is None:
         raise Exception("HTMLPanel.add: no element with id '%s'" % str(id))
     ComplexPanel.add(self, widget, element)
Ejemplo n.º 16
0
 def _getElementProps(self):
     return ComplexPanel._getElementProps() + self.elem_props