Пример #1
0
    def SetData(self, container, comp, node):
        self.Freeze()

        oldLabel = self.nb.GetPageText(self.nb.GetSelection())
        self.nb.SetSelection(0)
        map(self.nb.RemovePage, range(self.nb.GetPageCount() - 1, 0, -1))

        self.container = container
        self.comp = comp
        self.node = node  # main node
        self.refNode = node
        panels = []
        # Class and name
        if node.tagName == 'object_ref':
            self.labelRef.Show()
            self.textRef.Show()
            self.textRef.SetValue(node.getAttribute('ref'))
        else:
            self.labelRef.Hide()
            self.textRef.Hide()
        if comp.klass != 'root':
            self.labelClass.Show()
            self.textClass.Show()
            subclass = node.getAttribute('subclass')
            if not subclass:
                self.textClass.SetValue(node.getAttribute('class'))
            else:
                self.textClass.SetValue(subclass +
                                        '(%s)' % node.getAttribute('class'))
        else:  # root node
            self.labelClass.Hide()
            self.textClass.Hide()
            self.labelRef.Hide()
            self.textRef.Hide()
        self.labelName.Show(comp.hasName)
        self.textName.Show(comp.hasName)
        if comp.hasName:
            self.textName.SetValue(node.getAttribute('name'))

        self.Layout()  # update after hiding/showing

        panel = AttributePanel(self.pageA, comp.attributes, comp.params,
                               comp.renameDict)
        panels.append(panel)
        self.pageA.SetPanel(panel)
        self.SetValues(panel, node)

        if comp.windowAttributes:
            panel = AttributePanel(self.pageWA,
                                   comp.windowAttributes,
                                   rename_dict=params.WARenameDict)
            panels.append(panel)
            self.pageWA.SetPanel(panel)
            self.nb.AddPage(self.pageWA, "Look'n'Feel")
            self.SetValues(panel, node)

        if comp.styles or comp.genericStyles:
            # Create style page
            panel = params.StylePanel(self.pageStyle, comp.styles,
                                      comp.genericStyles)
            panels.append(panel)
            self.pageStyle.SetPanel(panel)
            self.nb.AddPage(self.pageStyle, 'Style')
            self.SetStyleValues(panel, comp.getAttribute(node, 'style'))

        if comp.exStyles or comp.genericExStyles:
            # Create extra style page
            panel = params.StylePanel(self.pageExStyle,
                                      comp.exStyles + comp.genericExStyles)
            panels.append(panel)
            self.pageExStyle.SetPanel(panel)
            self.nb.AddPage(self.pageExStyle, 'ExStyle')
            self.SetStyleValues(panel, comp.getAttribute(node, 'exstyle'))

        # Additional panel for hidden node
        if container and container.requireImplicit(
                node) and container.implicitAttributes:
            panel = AttributePanel(self.pageIA, container.implicitAttributes,
                                   container.implicitParams,
                                   container.implicitRenameDict)
            panel.comp = container
            panels.append(panel)
            self.pageIA.SetPanel(panel)
            self.nb.AddPage(self.pageIA, container.implicitPageName)
            self.SetValues(panel, node.parentNode)

        if comp.events:
            # Create code page
            panel = CodePanel(self.pageCode, comp.events)
            panel.node = node
            panels.append(panel)
            self.pageCode.SetPanel(panel)
            self.nb.AddPage(self.pageCode, 'Code')
            self.SetCodeValues(panel, comp.getAttribute(node, 'XRCED'))

        # Select old page if possible and pin is down
        if g.conf.panelPinState:
            for i in range(1, self.nb.GetPageCount()):
                if oldLabel == self.nb.GetPageText(i):
                    self.nb.SetSelection(i)
                    break

        self.Thaw()

        return panels
    def SetData(self, container, comp, node):

        oldLabel = self.nb.GetPageText(self.nb.GetSelection())
        self.nb.SetSelection(0)
        map(self.nb.RemovePage, range(self.nb.GetPageCount() - 1, 0, -1))

        # Don't freeze while removing the pages, but do it
        # after the removes instead.  See
        # https://groups.google.com/d/topic/wxpython-users/I8AJgkUCPj8/discussion
        self.Freeze()

        self.container = container
        self.comp = comp
        self.node = node  # main node
        self.refNode = node
        panels = []
        # Class and name
        if node.nodeType == node.COMMENT_NODE:
            self.labelRef.Hide()
            self.textRef.Hide()
            self.labelClass.Hide()
            self.textClass.Hide()
        elif node.tagName == 'object_ref':
            self.labelRef.Show()
            self.textRef.Show()
            self.textRef.SetValue(node.getAttribute('ref'))
            self.labelClass.Hide()
            self.textClass.Hide()
            # 'class' can be present for ref?
            self.textClass.SetValue(node.getAttribute('class'))
        else:
            self.labelRef.Hide()
            self.textRef.Hide()
            if comp.klass != 'root':
                self.labelClass.Show()
                self.textClass.Show()
                subclass = node.getAttribute('subclass')
                if not subclass:
                    self.textClass.SetValue(node.getAttribute('class'))
                else:
                    self.textClass.SetValue(subclass + '(%s)' %
                                            node.getAttribute('class'))
            else:  # root node
                self.labelClass.Hide()
                self.textClass.Hide()
                self.labelRef.Hide()
                self.textRef.Hide()
        self.labelName.Show(comp.hasName)
        self.textName.Show(comp.hasName)
        if comp.hasName:
            self.textName.SetValue(node.getAttribute('name'))

        self.Layout()  # update after hiding/showing

        panel = AttributePanel(self.pageA, comp.attributes, comp.params,
                               comp.renameDict)
        panels.append(panel)
        self.pageA.SetPanel(panel)
        self.SetValues(panel, node)

        if comp.windowAttributes:
            panel = AttributePanel(self.pageWA,
                                   comp.windowAttributes,
                                   rename_dict=params.WARenameDict)
            panels.append(panel)
            self.pageWA.SetPanel(panel)
            self.nb.AddPage(self.pageWA, "Look'n'Feel")
            self.SetValues(panel, node)

        if comp.styles or comp.genericStyles:
            # Create style page
            panel = params.StylePanel(self.pageStyle,
                                      comp.styles,
                                      comp.genericStyles,
                                      equiv=comp.equivStyles)
            panels.append(panel)
            self.pageStyle.SetPanel(panel)
            self.nb.AddPage(self.pageStyle, 'Style')
            self.SetStyleValues(panel, comp.getAttribute(node, 'style'))

        if comp.exStyles or comp.genericExStyles:
            # Create extra style page
            panel = params.StylePanel(self.pageExStyle,
                                      comp.exStyles + comp.genericExStyles,
                                      tag='exstyle',
                                      equiv=comp.equivStyles)
            panels.append(panel)
            self.pageExStyle.SetPanel(panel)
            self.nb.AddPage(self.pageExStyle, 'ExStyle')
            self.SetStyleValues(panel, comp.getAttribute(node, 'exstyle'))

        # Additional panel for hidden node
        if container and container.requireImplicit(
                node) and container.implicitAttributes:
            panel = AttributePanel(self.pageIA, container.implicitAttributes,
                                   container.implicitParams,
                                   container.implicitRenameDict)
            panel.comp = container
            panels.append(panel)
            self.pageIA.SetPanel(panel)
            self.nb.AddPage(self.pageIA, container.implicitPageName)
            self.SetValues(panel, node.parentNode)

        if comp.hasCode:
            # Create code page
            panel = CodePanel(self.pageCode, comp.events)
            panel.node = node
            panels.append(panel)
            self.pageCode.SetPanel(panel)
            self.nb.AddPage(self.pageCode, 'Code')
            self.SetCodeValues(panel, comp.getAttribute(node, 'XRCED'))

        # Select old page if possible and pin is down
        if g.conf.panelPinState:
            for i in range(1, self.nb.GetPageCount()):
                if oldLabel == self.nb.GetPageText(i):
                    self.nb.SetSelection(i)
                    break

        self.Thaw()

        return panels