/** * Creates a WCollapsible with the given content and heading. * * @param content the content to display inside the collapsible. * @param heading the collapsible's heading. */ public WCollapsible(final WComponent content, final String heading) { this(content, new WDecoratedLabel(heading), CollapsibleMode.CLIENT, null); }
/** * Creates a WSection with the given content and heading. * * @param content the content for the section * @param heading the section's heading. */ public WSection(final WPanel content, final String heading) { this(content, new WDecoratedLabel(heading)); }
/** * Creates a WFigure with the given content and heading. * * @param content the content for the figure * @param heading the figure's heading. */ public WFigure(final WComponent content, final String heading) { this(content, new WDecoratedLabel(heading)); }
/** * Creates a WCollapsible with the given content and heading. * * @param content the content to display inside the collapsible. * @param heading the collapsible's heading. * @param mode the mode of the collapsible */ public WCollapsible(final WComponent content, final String heading, final CollapsibleMode mode) { this(content, new WDecoratedLabel(heading), mode, null); }
/** * Creates a WSubMenu with the given text. * * @param text the sub menu text. */ public WSubMenu(final String text) { this(new WDecoratedLabel(text)); }
/** * Creates a WTableColumn. * * @param heading the column heading text. * @param rendererClass the renderer class for rendering row data. */ public WTableColumn(final String heading, final Class<? extends WComponent> rendererClass) { this(new WDecoratedLabel(heading), rendererClass); }
/** * Creates a WTableColumn. * * @param heading the column heading text. * @param renderer the component for rendering row data. */ public WTableColumn(final String heading, final WComponent renderer) { this(new WDecoratedLabel(heading), renderer); }
/** * Creates a WFieldSet. * * @param title the fieldset title. */ public WFieldSet(final String title) { this.title = title == null ? new WDecoratedLabel() : new WDecoratedLabel(title); add(this.title); }
/** * * @return a decorated label containing an undescribed image. */ private WDecoratedLabel makeAntiPatternLabel() { return new WDecoratedLabel(new WImage("/image/information.png", "")); }
/** * Helper to create the table column heading's WDecoratedLabel. * * @param text The readable text content of the column header * @param menu The WMenu we want in this column header. * @return WDecoratedLabel used to create a column heading. */ private WDecoratedLabel buildColumnHeader(final String text, final WMenu menu) { WDecoratedLabel label = new WDecoratedLabel(null, new WText(text), menu); return label; }
@Test public void testConstructor2() { WHeading heading = new WHeading(WHeading.MAJOR, new WDecoratedLabel("test")); Assert.assertEquals("Constructor - Incorrect type", WHeading.MAJOR, heading.getType()); }
@Test public void testConstructor1() { // Constructor 1 WDecoratedLabel label = new WDecoratedLabel(); Assert.assertNull("Constructor 1 - Label head should be null.", label.getHead()); Assert.assertTrue("Constructor 1 - Label body should be by default a WText.", label.getBody() instanceof WText); Assert.assertNull("Constructor 1 - Label tail should be null.", label.getTail()); }
@Test public void testConstructor2() { WDecoratedLabel label = new WDecoratedLabel(); WSubMenu subMenu = new WSubMenu(label); Assert.assertEquals("Incorrect label set by constructor", label, subMenu.getDecoratedLabel()); }
@Test public void testConstructor1() { WDecoratedLabel lbl = new WDecoratedLabel("test"); WMenuItem item = new WMenuItem(lbl); Assert.assertEquals("Incorrect label set by constructor", lbl, item.getDecoratedLabel()); }
@Test public void testConstructor2() { WDecoratedLabel lbl = new WDecoratedLabel("test"); String url = "A"; WMenuItem item = new WMenuItem(lbl, url); Assert.assertEquals("Incorrect label set by constructor", lbl, item.getDecoratedLabel()); Assert.assertEquals("Incorrect url set by constructor", url, item.getUrl()); }
/** * Create the main content and card manager for the example. */ public ContentSection() { super(new WPanel(), new WDecoratedLabel()); loginForm = new LoginFormCard(); newUserForm = new NewUserCard(); loggedIn = new LoggedInUserCard(); added = new AddedUserCard(); initCard(); }
/** * @param text the label text * @param statusText the status text * @return the decorated label */ private WDecoratedLabel makeHeadingLabel(final String text, final String statusText) { return new WDecoratedLabel(new WImage("/image/information.png", "Informative heading"), new WText(text), new WStyledText(statusText, WStyledText.Type.EMPHASISED)); }
@Test public void testConstructor3() { WComponent body1 = new DefaultWComponent(); // Constructor 3 WDecoratedLabel label = new WDecoratedLabel(body1); Assert.assertNull("Constructor 3 - Label head should be null.", label.getHead()); Assert.assertEquals("Constructor 3 - Incorrect label body.", body1, label.getBody()); Assert.assertNull("Constructor 3 - Label tail should be null.", label.getTail()); }
@Test public void testConstructor5() { WComponent head1 = new DefaultWComponent(); WComponent body1 = new DefaultWComponent(); WComponent tail1 = new DefaultWComponent(); // Constructor 5 WDecoratedLabel label = new WDecoratedLabel(head1, body1, tail1); Assert.assertEquals("Constructor 5 - Incorrect label head.", head1, label.getHead()); Assert.assertEquals("Constructor 5 - Incorrect label body.", body1, label.getBody()); Assert.assertEquals("Constructor 5 - Incorrect label tail.", tail1, label.getTail()); }
@Test public void testXssEscaping() throws IOException, SAXException, XpathException { WHeading heading = new WHeading(WHeading.TITLE, new WDecoratedLabel(new WText("dummy"))); assertSafeContent(heading); heading.setAccessibleText(getMaliciousAttribute("ui:heading")); assertSafeContent(heading); } }