Search in sources :

Example 1 with WProgressBar

use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.

the class WProgressBarRenderer_Test method testDoPaint.

@Test
public void testDoPaint() throws IOException, SAXException, XpathException {
    BeanProvider provider = new BeanProvider() {

        @Override
        public Object getBean(final BeanProviderBound beanProviderBound) {
            return 13;
        }
    };
    WProgressBar progressBar = new WProgressBar(WProgressBar.ProgressBarType.NORMAL, WProgressBar.UnitType.FRACTION);
    progressBar.setBeanProvider(provider);
    progressBar.setMax(33);
    assertXpathExists("//html:progress[@max='33']", progressBar);
    progressBar = new WProgressBar(WProgressBar.ProgressBarType.SMALL, WProgressBar.UnitType.PERCENTAGE);
    progressBar.setBeanProvider(provider);
    progressBar.setMax(33);
    assertXpathExists("//html:progress[@max='33' and contains(@class, 'wc-progressbar-type-small')]", progressBar);
}
Also used : BeanProvider(com.github.bordertech.wcomponents.BeanProvider) WProgressBar(com.github.bordertech.wcomponents.WProgressBar) BeanProviderBound(com.github.bordertech.wcomponents.BeanProviderBound) Test(org.junit.Test)

Example 2 with WProgressBar

use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.

the class WSkipLinksExample method buildPanel.

/**
 * Creates a panel for the example.
 *
 * @param title the panel title.
 * @return a panel for use in the example.
 */
private WPanel buildPanel(final String title) {
    WPanel panel = new WPanel(WPanel.Type.CHROME);
    panel.setTitleText(title);
    WProgressBar progress = new WProgressBar(18);
    progress.setValue(15);
    panel.add(progress);
    panel.add(new WHorizontalRule());
    WTextField input = new WTextField();
    WLabel label = new WLabel("Text input", input);
    panel.add(label);
    panel.add(input);
    return panel;
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) WPanel(com.github.bordertech.wcomponents.WPanel) WTextField(com.github.bordertech.wcomponents.WTextField) WHorizontalRule(com.github.bordertech.wcomponents.WHorizontalRule) WLabel(com.github.bordertech.wcomponents.WLabel)

Example 3 with WProgressBar

use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.

the class WProgressBarRenderer method doRender.

/**
 * Paints the given WProgressBar.
 *
 * @param component the WProgressBar to paint.
 * @param renderContext the RenderContext to paint to.
 */
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
    WProgressBar progressBar = (WProgressBar) component;
    XmlStringBuilder xml = renderContext.getWriter();
    xml.appendTagOpen("html:progress");
    xml.appendAttribute("id", component.getId());
    xml.appendAttribute("class", getHtmlClass(progressBar));
    xml.appendOptionalAttribute("hidden", progressBar.isHidden(), "hidden");
    xml.appendOptionalAttribute("title", progressBar.getToolTip());
    xml.appendOptionalAttribute("aria-label", progressBar.getAccessibleText());
    xml.appendAttribute("value", progressBar.getValue());
    xml.appendOptionalAttribute("max", progressBar.getMax() > 0, progressBar.getMax());
    xml.appendClose();
    xml.appendEndTag("html:progress");
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) XmlStringBuilder(com.github.bordertech.wcomponents.XmlStringBuilder)

Example 4 with WProgressBar

use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.

the class WProgressBarRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WProgressBar progressBar = new WProgressBar();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(progressBar) instanceof WProgressBarRenderer);
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) Test(org.junit.Test)

Example 5 with WProgressBar

use of com.github.bordertech.wcomponents.WProgressBar in project wcomponents by BorderTech.

the class WProgressBarRenderer_Test method testXssEscaping.

@Test
public void testXssEscaping() throws IOException, SAXException, XpathException {
    WProgressBar progressBar = new WProgressBar(WProgressBar.ProgressBarType.NORMAL, 100);
    assertSafeContent(progressBar);
    progressBar.setToolTip(getMaliciousAttribute("html:progress"));
    assertSafeContent(progressBar);
    progressBar.setAccessibleText(getMaliciousAttribute("html:progress"));
    assertSafeContent(progressBar);
}
Also used : WProgressBar(com.github.bordertech.wcomponents.WProgressBar) Test(org.junit.Test)

Aggregations

WProgressBar (com.github.bordertech.wcomponents.WProgressBar)5 Test (org.junit.Test)3 BeanProvider (com.github.bordertech.wcomponents.BeanProvider)1 BeanProviderBound (com.github.bordertech.wcomponents.BeanProviderBound)1 WHorizontalRule (com.github.bordertech.wcomponents.WHorizontalRule)1 WLabel (com.github.bordertech.wcomponents.WLabel)1 WPanel (com.github.bordertech.wcomponents.WPanel)1 WTextField (com.github.bordertech.wcomponents.WTextField)1 XmlStringBuilder (com.github.bordertech.wcomponents.XmlStringBuilder)1