def getInvalidSizedChildren(self, vertical):
        components = None

        from muntjac.ui.panel import Panel  # FIXME: circular import
        from muntjac.terminal.gwt.server.component_size_validator import \
            ComponentSizeValidator  # FIXME: circular import

        if isinstance(self, Panel):
            p = self
            content = p.getContent()
            if vertical:
                valid = ComponentSizeValidator.checkHeights(content)
            else:
                valid = ComponentSizeValidator.checkWidths(content)
            if not valid:
                components = set()
                components.add(content)
        else:
            for component in self.getComponentIterator():
                if vertical:
                    valid = ComponentSizeValidator.checkHeights(component)
                else:
                    valid = ComponentSizeValidator.checkWidths(component)
                if not valid:
                    if components is None:
                        components = set()
                    components.add(component)

        return components
    def getInvalidSizedChildren(self, vertical):
        components = None

        from muntjac.ui.panel import Panel  # FIXME: circular import
        from muntjac.terminal.gwt.server.component_size_validator import \
            ComponentSizeValidator  # FIXME: circular import

        if isinstance(self, Panel):
            p = self
            content = p.getContent()
            if vertical:
                valid = ComponentSizeValidator.checkHeights(content)
            else:
                valid = ComponentSizeValidator.checkWidths(content)
            if not valid:
                components = set()
                components.add(content)
        else:
            for component in self.getComponentIterator():
                if vertical:
                    valid = ComponentSizeValidator.checkHeights(component)
                else:
                    valid = ComponentSizeValidator.checkWidths(component)
                if not valid:
                    if components is None:
                        components = set()
                    components.add(component)

        return components
    def setHeight(self, height, unit=None):
        if unit is not None:
            from muntjac.terminal.gwt.server.component_size_validator import \
                ComponentSizeValidator  # FIXME: circular import

            # child tree repaints may be needed, due to our fall back support
            # for invalid relative sizes
            dirtyChildren = None
            childrenMayBecomeUndefined = False
            if (self.getHeight() == self.SIZE_UNDEFINED
                    and height != self.SIZE_UNDEFINED):
                # children currently in invalid state may need repaint
                dirtyChildren = self.getInvalidSizedChildren(True)

            elif ((height == self.SIZE_UNDEFINED
                    and self.getHeight() != self.SIZE_UNDEFINED)
                  or (unit == self.UNITS_PERCENTAGE
                    and self.getHeightUnits() != self.UNITS_PERCENTAGE
                    and not ComponentSizeValidator.parentCanDefineHeight(self))):

                # relative height children may get to invalid state if height
                # becomes invalid. Height may also become invalid if units
                # become percentage due to the fallback support.
                childrenMayBecomeUndefined = True
                dirtyChildren = self.getInvalidSizedChildren(True)

            super(AbstractComponentContainer, self).setHeight(height, unit)

            self.repaintChangedChildTrees(dirtyChildren,
                    childrenMayBecomeUndefined, True)
        else:
            super(AbstractComponentContainer, self).setHeight(height)
    def setHeight(self, height, unit=None):
        if unit is not None:
            from muntjac.terminal.gwt.server.component_size_validator import \
                ComponentSizeValidator  # FIXME: circular import

            # child tree repaints may be needed, due to our fall back support
            # for invalid relative sizes
            dirtyChildren = None
            childrenMayBecomeUndefined = False
            if (self.getHeight() == self.SIZE_UNDEFINED
                    and height != self.SIZE_UNDEFINED):
                # children currently in invalid state may need repaint
                dirtyChildren = self.getInvalidSizedChildren(True)

            elif (
                (height == self.SIZE_UNDEFINED
                 and self.getHeight() != self.SIZE_UNDEFINED) or
                (unit == self.UNITS_PERCENTAGE
                 and self.getHeightUnits() != self.UNITS_PERCENTAGE
                 and not ComponentSizeValidator.parentCanDefineHeight(self))):

                # relative height children may get to invalid state if height
                # becomes invalid. Height may also become invalid if units
                # become percentage due to the fallback support.
                childrenMayBecomeUndefined = True
                dirtyChildren = self.getInvalidSizedChildren(True)

            super(AbstractComponentContainer, self).setHeight(height, unit)

            self.repaintChangedChildTrees(dirtyChildren,
                                          childrenMayBecomeUndefined, True)
        else:
            super(AbstractComponentContainer, self).setHeight(height)
Пример #5
0
    def paint(self, target):
        # Paints the component into a UIDL stream.
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0
                    and (self.getHeightUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0
                    and (self.getWidthUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                            list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False
Пример #6
0
    def paint(self, target):
        """Paints the Paintable into a UIDL stream. This method creates the
        UIDL sequence describing it and outputs it to the given UIDL stream.

        It is called when the contents of the component should be painted in
        response to the component first being shown or having been altered so
        that its visual representation is changed.

        B{Do not override this to paint your component.} Override
        L{paintContent} instead.

        @param target:
                  the target UIDL stream where the component should paint
                  itself to.
        @raise PaintException:
                  if the paint operation failed.
        """
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0 and
                    (self.getHeightUnits() != self.UNITS_PERCENTAGE
                     or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0 and
                    (self.getWidthUnits() != self.UNITS_PERCENTAGE
                     or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                                        list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False
Пример #7
0
    def paint(self, target):
        """Paints the Paintable into a UIDL stream. This method creates the
        UIDL sequence describing it and outputs it to the given UIDL stream.

        It is called when the contents of the component should be painted in
        response to the component first being shown or having been altered so
        that its visual representation is changed.

        B{Do not override this to paint your component.} Override
        L{paintContent} instead.

        @param target:
                  the target UIDL stream where the component should paint
                  itself to.
        @raise PaintException:
                  if the paint operation failed.
        """
        tag = target.getTag(self)
        if ((not target.startTag(self, tag))
                or self._repaintRequestListenersNotified):

            # Paint the contents of the component

            # Only paint content of visible components.
            if self.isVisible():
                from muntjac.terminal.gwt.server.component_size_validator \
                    import ComponentSizeValidator  # FIXME: circular import

                if (self.getHeight() >= 0
                    and (self.getHeightUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineHeight(self))):

                    target.addAttribute('height', '' + self.getCSSHeight())

                if (self.getWidth() >= 0
                    and (self.getWidthUnits() != self.UNITS_PERCENTAGE
                    or ComponentSizeValidator.parentCanDefineWidth(self))):

                    target.addAttribute('width', '' + self.getCSSWidth())

                if self._styles is not None and len(self._styles) > 0:
                    target.addAttribute('style', self.getStyle())

                if self.isReadOnly():
                    target.addAttribute('readonly', True)

                if self.isImmediate():
                    target.addAttribute('immediate', True)

                if not self.isEnabled():
                    target.addAttribute('disabled', True)

                if self.getCaption() is not None:
                    target.addAttribute('caption', self.getCaption())

                if self.getIcon() is not None:
                    target.addAttribute('icon', self.getIcon())

                if (self.getDescription() is not None
                        and len(self.getDescription()) > 0):
                    target.addAttribute('description', self.getDescription())

                if self._eventIdentifiers is not None:
                    target.addAttribute('eventListeners',
                            list(self._eventIdentifiers))

                self.paintContent(target)

                error = self.getErrorMessage()
                if error is not None:
                    error.paint(target)
            else:
                target.addAttribute('invisible', True)
        else:
            # Contents have not changed, only cached presentation can be used
            target.addAttribute('cached', True)
        target.endTag(tag)

        self._repaintRequestListenersNotified = False