コード例 #1
0
ファイル: test_UITemplate.py プロジェクト: pombredanne/thedom
def test_fromFile():
    """
        Ensure UITemplate creates a dictionary structure from an XML File correctly
    """
    assert UITemplate.fromFile(
        "testTemplate.xml",
        formatType=UITemplate.XML) == EXPECTED_STRUCTURE  #xml file
    assert UITemplate.fromFile(
        "testTemplate.shpaml",
        formatType=UITemplate.SHPAML) == EXPECTED_STRUCTURE  #shpaml file
コード例 #2
0
ファイル: Servlet.py プロジェクト: vanroy86/WebBot
    class ContentControl(PageControls.TemplateControl):
        template = UITemplate.fromFile(APP_DIR + "Template.wui")

        def initUI(self, ui, request):
            """
                The initial setup of the interface (such as dynamically adding widgets that are not present in the
                view) should be done here.
            """
            pass

        def setUIData(self, ui, request):
            """
                Any data populating that occurs as a result of the data in the request should be done here.
            """
            pass

        def processPost(self, ui, request):
            """
                Any unique processing that needs to be done on a post should be done here.
                Note: There is corresponding process(Get|Delete|Put) methods.
            """
            pass

        def validPost(self, ui, request):
            """
                Any validation of post data should occur here: with true being returned only if the data
                is valid.
                Note: There is corresponding valid(Get|Delete|Put) methods.
            """
            return True
コード例 #3
0
    class ContentControl(PageControls.TemplateControl):
        template = UITemplate.fromFile("Pages/Documentation/Template.wui")

        def initUI(self, ui, request):
            ui.results.replaceWith(self.results)
            ui.document.replaceWith(self.document)
            ui.search.clientSide.focus()
            ui.search.clientSide.on("keyup", self.results.clientSide.get(timeout=500))

        def setUIData(self, ui, request):
            """
                Any data populating that occurs as a result of the data in the request should be done here.
            """
            pass

        def processPost(self, ui, request):
            """
                Any unique processing that needs to be done on a post should be done here.
                Note: There is corresponding process(Get|Delete|Put) methods.
            """
            pass

        def validPost(self, ui, request):
            """
                Any validation of post data should occur here: with true being returned only if the data
                is valid.
                Note: There is corresponding valid(Get|Delete|Put) methods.
            """
            return True
コード例 #4
0
    class Document(PageControls.TemplateControl):
        template = UITemplate.fromFile("Pages/Documentation/Document.wui")

        def initUI(self, ui, request):
            openDocument = request.fields.get('load')
            if openDocument:
                ui.display.setVisibleElement(ui.openDocument)
                html = ui.openDocument.addChildElement(self.buildElement('straightHTML'))
                htmlDoc = pydoc.HTMLDoc()
                product = GuiBuilderConfig.Factory.build(openDocument.lower(), "", "")
                if product:
                    html.html = htmlDoc.docclass(product.__class__)
                    html.html = html.html.replace('href="', 'href="Documentation?load=').replace(".html", "")
コード例 #5
0
ファイル: BasePage.py プロジェクト: vanroy86/WebBot
    class MainControl(PageControls.TemplateControl):
        """
            Defines how the frame of the page will appear, you can subclass this on a per page basis to change
            the frame.
        """
        template = UITemplate.fromFile("WebBot/Page.wui")

        def initUI(self, ui, request):
            """
                On initializing the main control frame per-request a content control is added which must be
                defined on a per-page basis to define the content of the page.
            """
            ui.pageContents.replaceWith(self.contentControl)
コード例 #6
0
    class MainControl(PageControls.TemplateControl):
        template = UITemplate.fromFile("WebBot/Page.wui")

        def initUI(self, ui, request):
            ui.pageContents.replaceWith(self.contentControl)

            for pageName, page in PAGES:
                newLink = ui.pageLinks.addChildElement(Buttons.Link(href=page))
                button = newLink.addChildElement(Buttons.ToggleButton(page + "Link", text=pageName))
                if page in request.path:
                    button.toggleOn()
                    newLink.setDestination("Home")

        def setUIData(self, ui, request):
            ui.version.setText(WebElements.__version__)
コード例 #7
0
    class ContentControl(PageControls.TemplateControl):
        template = UITemplate.fromFile("Pages/QuickStart/Template.wui")

        def initUI(self, ui, request):
            """
                The initial setup of the interface (such as dynamically adding widgets that are not present in the
                view) should be done here.
            """
            ui.helloWorldPython.code = HELLOWORLD_IN
            ui.helloWorldHTML.code = HELLOWORLD_OUT
            ui.combineExample.code = COMBINE_EXAMPLE
            ui.xmlTemplateExample.code = XML_TEMPLATE_EXAMPLE
            ui.shpamlTemplateExample.code = SHPAML_TEMPLATE_EXAMPLE
            ui.loadTemplateExample.code = LOAD_TEMPLATE_EXAMPLE
            ui.customElementExample.code = CUSTOM_ELEMENT_EXAMPLE
            ui.usingCustomElementsExample.code = USING_CUSTOM_ELEMENT_EXAMPLE
            ui.addingRowsExample.code = ADDING_ROWS_EXAMPLE
            ui.passingDataExample.code = PASSING_DATA_EXAMPLE
            ui.changeOrderExample.code = CHANGE_ORDER_EXAMPLE

            ui.myTable.addRows(EXAMPLE_TABLE_DATA)
            ui.myTable2.addRows(EXAMPLE_TABLE_DATA)

            ui.myTable2.columns = ('Email', 'Phone', 'Name')

        def setUIData(self, ui, request):
            """
                Any data populating that occurs as a result of the data in the request should be done here.
            """
            pass

        def processPost(self, ui, request):
            """
                Any unique processing that needs to be done on a post should be done here.
                Note: There is corresponding process(Get|Delete|Put) methods.
            """
            pass

        def validPost(self, ui, request):
            """
                Any validation of post data should occur here: with true being returned only if the data
                is valid.
                Note: There is corresponding valid(Get|Delete|Put) methods.
            """
            return True
コード例 #8
0
    class Results(PageControls.TemplateControl):
        template = UITemplate.fromFile("Pages/Documentation/Results.wui")
        grabFields = ('search', )

        def setUIData(self, ui, request):
            search = request.fields.get('search', '')
            if not search:
                usedProducts = []
                for data in GuiBuilderConfig.sections:
                    name = data['Name']
                    numberOfElements = len(data['Factory'].products)
                    elements = data['Factory'].products.iteritems()

                    section = ui.sections.addChildElement(self.buildElement("Accordion", name))
                    section.setLabel(name)
                    section.toggle.attributes['tooltip'] = data['Factory'].__doc__
                    section.style['width'] = "100%"
                    elementsContainer = section.addChildElement(self.buildElement("multiSelect"))
                    elementsContainer.style['height'] = "%dpx" % (numberOfElements * 20)
                    elementsContainer.style['width'] = "100%"
                    elementsContainer.addJavascriptEvent('onchange', self.document.clientSide.get(load=
                                            ClientSide.Script("WebElements.selectedOption(this).value")))

                    for elementName, element in elements:
                        if element in usedProducts:
                            continue
                        else:
                            elementsContainer.addOption(elementName)
                ui.sections[0].addClass("First")
                ui.sections[-1].addClass("Last")
                return

            results = ui.sections.addChildElement(self.buildElement("multiSelect"))
            results.addClass("Results")
            results.style['width'] = "100%"
            results.addOptions([productName for productName in ELEMENTS if search.lower() in productName.lower()])
            results.style['height'] = "%dpx" % (len(results.childElements) * 20)
            results.addJavascriptEvent('onchange', self.document.clientSide.get(load=
                                       ClientSide.Script("WebElements.selectedOption(this).value")))
            return results
コード例 #9
0
def test_fromFile():
    """
        Ensure UITemplate creates a dictionary structure from an XML File correctly
    """
    assert UITemplate.fromFile("testTemplate.xml", formatType=UITemplate.XML) == EXPECTED_STRUCTURE #xml file
    assert UITemplate.fromFile("testTemplate.shpaml", formatType=UITemplate.SHPAML) == EXPECTED_STRUCTURE #shpaml file