Example #1
0
 def getThemeBase(cls):
     """Gets the base url used to reference theme resources.
     """
     from muntjac.demo.sampler.SamplerApplication import SamplerApplication
     return SamplerApplication.getThemeBase()
Example #2
0
    def setFeature(self, feature):

        from muntjac.demo.sampler.SamplerApplication import SamplerApplication

        if feature != self._currentFeature:
            self._currentFeature = feature
            self._right.removeAllComponents()
            self._left.removeAllComponents()

            self._left.addComponent(self._controls)
            self._title.setValue('<span>' + feature.getName() + '</span>')
            #            if feature.getSinceVersion().isNew():
            #                self._title.addStyleName('new')
            #            else:
            #                self._title.removeStyleName('new')

            self._left.addComponent(self.getExampleFor(feature))

            self._right.setCaption('Description and Resources')

            # Do not show parent description if it's directly inside the root
            alll = SamplerApplication.getAllFeatures()
            parent = alll.getParent(feature)
            isRoot = alll.getParent(parent) is None
            desc = parent.getDescription()
            hasParentDesc = False

            if parent is not None and not isRoot:
                parentLabel = Label(parent.getDescription())
                if desc is not None and desc != '':
                    parentLabel.setContentMode(Label.CONTENT_XHTML)
                    self._right.addComponent(parentLabel)
                    hasParentDesc = True
            desc = feature.getDescription()
            if desc is not None and desc != '':
                # Sample description uses additional decorations if a parent
                # description is found
                l = Label(
                    ("<div class=\"outer-deco\"><div class=\"deco\">"
                     "<span class=\"deco\"></span>") + desc + "</div></div>",
                    Label.CONTENT_XHTML)
                self._right.addComponent(l)
                if hasParentDesc:
                    l.setStyleName('sample-description')
                else:
                    l.setStyleName('description')

            # open src in new window -link
            self._showSrc.setTargetName(self._currentFeature.getFragmentName())
            er = ExternalResource(self.getApplication().getURL() + 'src/' +
                                  self._currentFeature.getFragmentName())
            self._showSrc.setResource(er)

            resources = feature.getRelatedResources()
            if resources is not None:
                res = VerticalLayout()
                self.caption = Label("<span>Additional Resources</span>",
                                     Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                res.addComponent(self.caption)
                res.setMargin(False, False, True, False)
                for r in resources:
                    l = Link(r.getName(), r)
                    l.setIcon(ThemeResource('../runo/icons/16/note.png'))
                    res.addComponent(l)
                self._right.addComponent(res)

            apis = feature.getRelatedAPI()
            if apis is not None:
                api = VerticalLayout()
                self.caption = Label("<span>API Documentation</span>",
                                     Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                api.addComponent(self.caption)
                api.setMargin(False, False, True, False)
                for r in apis:
                    l = Link(r.getName(), r)
                    ic = ThemeResource('../runo/icons/16/document-txt.png')
                    l.setIcon(ic)
                    api.addComponent(l)
                self._right.addComponent(api)

            features = feature.getRelatedFeatures()
            if features is not None:
                rel = VerticalLayout()
                self.caption = Label("<span>Related Samples</span>",
                                     Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                rel.addComponent(self.caption)
                rel.setMargin(False, False, True, False)
                for c in features:
                    f = SamplerApplication.getFeatureFor(c)
                    if f is not None:
                        er = ExternalResource(self.getApplication().getURL() +
                                              '#' + f.getFragmentName())
                        al = ActiveLink(f.getName(), er)
                        if isinstance(f, FeatureSet):
                            ic = ThemeResource('../sampler/icons/category.gif')
                        else:
                            ic = ThemeResource('../sampler/icons/sample.png')
                        al.setIcon(ic)

                        al.addListener(LinkListener(self, f),
                                       ILinkActivatedListener)
                        rel.addComponent(al)
                self._right.addComponent(rel)
Example #3
0
 def getThemeBase(cls):
     """Gets the base url used to reference theme resources.
     """
     from muntjac.demo.sampler.SamplerApplication import SamplerApplication
     return SamplerApplication.getThemeBase()
Example #4
0
    def setFeature(self, feature):

        from muntjac.demo.sampler.SamplerApplication import SamplerApplication

        if feature != self._currentFeature:
            self._currentFeature = feature
            self._right.removeAllComponents()
            self._left.removeAllComponents()

            self._left.addComponent(self._controls)
            self._title.setValue('<span>' + feature.getName() + '</span>')
            if feature.getSinceVersion().isNew():
                self._title.addStyleName('new')
            else:
                self._title.removeStyleName('new')

            self._left.addComponent(self.getExampleFor(feature))

            self._right.setCaption('Description and Resources')

            # Do not show parent description if it's directly inside the root
            alll = SamplerApplication.getAllFeatures()
            parent = alll.getParent(feature)
            isRoot = alll.getParent(parent) is None
            desc = parent.getDescription()
            hasParentDesc = False

            if parent is not None and not isRoot:
                parentLabel = Label(parent.getDescription())
                if desc is not None and desc != '':
                    parentLabel.setContentMode(Label.CONTENT_XHTML)
                    self._right.addComponent(parentLabel)
                    hasParentDesc = True
            desc = feature.getDescription()
            if desc is not None and desc != '':
                # Sample description uses additional decorations if a parent
                # description is found
                l = Label(("<div class=\"outer-deco\"><div class=\"deco\">"
                        "<span class=\"deco\"></span>")
                        + desc + "</div></div>", Label.CONTENT_XHTML)
                self._right.addComponent(l)
                if hasParentDesc:
                    l.setStyleName('sample-description')
                else:
                    l.setStyleName('description')

            # open src in new window -link
            self._showSrc.setTargetName(self._currentFeature.getFragmentName())
            er = ExternalResource(self.getApplication().getURL()
                    + 'src/' + self._currentFeature.getFragmentName())
            self._showSrc.setResource(er)

            resources = feature.getRelatedResources()
            if resources is not None:
                res = VerticalLayout()
                self.caption = Label("<span>Additional Resources</span>",
                        Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                res.addComponent(self.caption)
                res.setMargin(False, False, True, False)
                for r in resources:
                    l = Link(r.getName(), r)
                    l.setIcon( ThemeResource('../runo/icons/16/note.png') )
                    res.addComponent(l)
                self._right.addComponent(res)

            apis = feature.getRelatedAPI()
            if apis is not None:
                api = VerticalLayout()
                self.caption = Label("<span>API Documentation</span>",
                        Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                api.addComponent(self.caption)
                api.setMargin(False, False, True, False)
                for r in apis:
                    l = Link(r.getName(), r)
                    ic = ThemeResource('../runo/icons/16/document-txt.png')
                    l.setIcon(ic)
                    api.addComponent(l)
                self._right.addComponent(api)

            features = feature.getRelatedFeatures()
            if features is not None:
                rel = VerticalLayout()
                self.caption = Label("<span>Related Samples</span>",
                        Label.CONTENT_XHTML)
                self.caption.setStyleName('section')
                self.caption.setWidth('100%')
                rel.addComponent(self.caption)
                rel.setMargin(False, False, True, False)
                for c in features:
                    f = SamplerApplication.getFeatureFor(c)
                    if f is not None:
                        er = ExternalResource(self.getApplication().getURL()
                                + '#' + f.getFragmentName())
                        al = ActiveLink(f.getName(), er)
                        if isinstance(f, FeatureSet):
                            ic = ThemeResource('../sampler/icons/category.gif')
                        else:
                            ic = ThemeResource('../sampler/icons/sample.png')
                        al.setIcon(ic)

                        al.addListener(LinkListener(self, f),
                                ILinkActivatedListener)
                        rel.addComponent(al)
                self._right.addComponent(rel)