

def setFeatureContainer(self, c):
    self._grid.removeAllComponents()
    features = c.getItemIds()
    rootSet = CssLayout()
    rootTitle = None
    highlightRow = CssLayout()
    highlightRow.setStyleName('highlight-row')
    sampleCount = 0
    for f in features:
        if isinstance(f, FeatureSet):
            if c.isRoot(f):
                if (rootTitle is not None):
                    rootTitle.setValue(((('<em>' + str(sampleCount)) + ' samples</em>') + rootTitle.getValue()))
                    sampleCount = 0
                desc = f.getDescription()
                try:
                    idx = desc.index('.')
                except ValueError:
                    idx = (- 1)
                rootTitle = Label((((('<h2>' + f.getName()) + '</h2><span>') + desc[:(idx + 1)]) + '</span>'), Label.CONTENT_XHTML)
                rootTitle.setSizeUndefined()
                if (f.getRelatedFeatures() is not None):
                    rootTitle.setValue(((('<em>' + len(f.getRelatedFeatures())) + ' samples</em>') + rootTitle.getValue()))
                rootSet = CssLayout()
                rootSet.setStyleName('root')
                rootTitle.setStyleName('root-section')
                self._grid.addComponent(rootTitle)
                self._grid.addComponent(rootSet)
        else:
            sampleCount += 1
            resId = ('75-' + f.getIconName())
            res = self._app.getSampleIcon(resId)
            if (rootSet.getParent() is None):
                if (rootTitle is None):
                    parent = self._app._allFeatures.getParent(f)
                    rootTitle = Label((('<h2>' + parent.getName()) + '</h2>'), Label.CONTENT_XHTML)
                    rootTitle.setStyleName('root-section highlights-title')
                    rootTitle.setSizeUndefined()
                    self._grid.addComponent(rootTitle)
                    if (parent.getDescription() is not None):
                        desc = Label(parent.getDescription(), Label.CONTENT_XHTML)
                        desc.setStyleName('highlights-description')
                        desc.setSizeUndefined()
                        self._grid.addComponent(desc)
                if ((sampleCount % 2) == 1):
                    highlightRow = CssLayout()
                    highlightRow.setStyleName('highlight-row')
                    self._grid.addComponent(highlightRow)
                l = CssLayout()
                l.setStyleName('highlight')
                er = ExternalResource(('#' + f.getFragmentName()))
                sample = ActiveLink(f.getName(), er)
                sample.setIcon(res)
                l.addComponent(sample)
                if ((f.getDescription() is not None) and (f.getDescription() != '')):
                    d = f.getDescription()
                    desc = Label(d[:(d.index('.') + 1)], Label.CONTENT_XHTML)
                    desc.setSizeUndefined()
                    l.addComponent(desc)
                highlightRow.addComponent(l)
            else:
                sample = ActiveLink(f.getName(), ExternalResource(('#' + f.getFragmentName())))
                sample.setStyleName(BaseTheme.BUTTON_LINK)
                sample.addStyleName('screenshot')
                if ((f.getDescription() is not None) and (f.getDescription() != '')):
                    desc = f.getDescription()
                    try:
                        idx = desc.index('.')
                    except ValueError:
                        idx = (- 1)
                    sample.setDescription(desc[:(idx + 1)])
                sample.setIcon(res)
                rootSet.addComponent(sample)
    if (rootTitle is not None):
        rootTitle.setValue(((('<em>' + str(sampleCount)) + ' samples</em>') + rootTitle.getValue()))

dataset/ETHPy150Open rwl/muntjac/muntjac/demo/sampler/SamplerApplication.py FeatureGrid.setFeatureContainer/original