use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.
the class WHeadingRenderer_Test method testRenderedWithMargins.
@Test
public void testRenderedWithMargins() throws IOException, SAXException, XpathException {
WHeading heading = new WHeading(WHeading.TITLE, "test");
assertXpathNotExists("//ui:heading/ui:margin", heading);
Margin margin = new Margin(0);
heading.setMargin(margin);
assertXpathNotExists("//ui:heading/ui:margin", heading);
margin = new Margin(Size.SMALL);
heading.setMargin(margin);
assertSchemaMatch(heading);
assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@all", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@north", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@east", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@south", heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@west", heading);
margin = new Margin(Size.SMALL, Size.MEDIUM, Size.LARGE, Size.XL);
heading.setMargin(margin);
assertSchemaMatch(heading);
assertXpathEvaluatesTo("", "//ui:heading/ui:margin/@all", heading);
assertXpathEvaluatesTo("sm", "//ui:heading/ui:margin/@north", heading);
assertXpathEvaluatesTo("med", "//ui:heading/ui:margin/@east", heading);
assertXpathEvaluatesTo("lg", "//ui:heading/ui:margin/@south", heading);
assertXpathEvaluatesTo("xl", "//ui:heading/ui:margin/@west", heading);
}
use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.
the class WHeadingRenderer_Test method testRendererCorrectlyConfigured.
@Test
public void testRendererCorrectlyConfigured() {
WHeading component = new WHeading(WHeading.TITLE, "");
Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(component) instanceof WHeadingRenderer);
}
use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.
the class WHeadingRenderer_Test method testPaintWithDecoratedLabel.
@Test
public void testPaintWithDecoratedLabel() throws IOException, SAXException, XpathException {
final String text1 = "WHeading_Test.testPaintWithDecoratedLabel.text1";
final String text2 = "WHeading_Test.testPaintWithDecoratedLabel.text2";
WHeading heading = new WHeading(WHeading.TITLE, new WDecoratedLabel(new WText(text1)));
assertSchemaMatch(heading);
assertXpathEvaluatesTo(text1, "//ui:heading[@level=1]/ui:decoratedlabel/ui:labelbody/text()", heading);
// Test WHeading's WText implementation
heading.setText(text2);
assertXpathEvaluatesTo(text2 + text1, "//ui:heading[@level=1]/ui:decoratedlabel/ui:labelbody/text()", heading);
}
use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.
the class AccordionExample method constructExample.
/**
* Helper to do the work of the constructor since we do not really want to call over-rideable methods in a
* constructor.
*/
private void constructExample() {
add(new WHeading(HeadingLevel.H3, "ACCORDION tabs"));
WTabSet tabset1c = new SampleWTabset(TabSetType.ACCORDION);
add(tabset1c);
/* Content height */
add(new WHeading(HeadingLevel.H2, "Examples showing content height property."));
add(new WHeading(HeadingLevel.H3, "Tall content."));
WTabSet htabset1c = new SampleWTabset(TabSetType.ACCORDION);
htabset1c.setContentHeight(TALL_CONTENT);
add(htabset1c);
add(new WHeading(HeadingLevel.H3, "Short content."));
WTabSet htabset1g = new SampleWTabset(TabSetType.ACCORDION);
htabset1g.setContentHeight(SHORT_CONTENT);
add(htabset1g);
add(new WHeading(HeadingLevel.H2, "Examples showing accordion's single property."));
WTabSet singleOpenAccordionabset = new SampleWTabset(WTabSet.TYPE_ACCORDION);
singleOpenAccordionabset.setSingle(true);
add(singleOpenAccordionabset);
add(new WHeading(HeadingLevel.H2, "Using WSubordinateControl"));
WTabSet targetTabset = new SampleWTabset(TabSetType.ACCORDION);
add(targetTabset);
WFieldLayout layout = new WFieldLayout(WFieldLayout.LAYOUT_STACKED);
add(layout);
final WCheckBox disabledControllerCb = new WCheckBox();
final WCheckBox hiddenControllerCb = new WCheckBox();
layout.addField("disable tabset", disabledControllerCb);
layout.addField("hide tabset", hiddenControllerCb);
// Build & add the subordinate
SubordinateBuilder builder = new SubordinateBuilder();
builder.condition().equals(hiddenControllerCb, String.valueOf(true));
builder.whenTrue().hide(targetTabset);
builder.whenFalse().show(targetTabset);
add(builder.build());
builder = new SubordinateBuilder();
builder.condition().equals(disabledControllerCb, String.valueOf(true));
builder.whenTrue().disable(targetTabset);
builder.whenFalse().enable(targetTabset);
add(builder.build());
}
use of com.github.bordertech.wcomponents.WHeading in project wcomponents by BorderTech.
the class WButtonExample method addImageExamples.
/**
* An example to cover the gamut of image buttons both with and without visible text and with both renderAsLink and
* render as button.
*/
private void addImageExamples() {
// Button rendered with an image only
add(new WHeading(HeadingLevel.H2, "Image buttons"));
add(new ExplanatoryText("This example shows how to use an image inside a WButton."));
add(new WHeading(HeadingLevel.H3, "Just an image"));
add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton. " + "The button must still have text content to adequately explain the button's purpose."));
add(new WHeading(HeadingLevel.H4, "Image in a button"));
add(makeImageButton("Save", false));
add(new WHeading(HeadingLevel.H4, "Image button without button style"));
add(new ExplanatoryText("This example shows how to use an image as the only content of a WButton when styled to be without its button appearance. " + "If you are creating a button containing only an image you should be careful as it may not be obvious to the application user that the 'image' is actually a 'button'." + "The button must still have text content to adequately explain the button's purpose."));
add(makeImageButton("Save", true));
add(new ExplanatoryText("Button using a WImage description as the text equivalent."));
WButton button = new WButton();
WImage buttonImage = new WImage("/image/tick.png", "Mark as OK");
button.setImage(buttonImage.getImage());
add(button);
add(new WHeading(HeadingLevel.H3, "Image and text"));
add(new ExplanatoryText("This example shows how to use an image and text as the content of a button."));
add(new WHeading(HeadingLevel.H4, "Rendered as a button"));
WPanel buttonLayoutPanel = new WPanel(WPanel.Type.BOX);
buttonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BOTTOM));
add(buttonLayoutPanel);
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the North", ImagePosition.NORTH));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the East", ImagePosition.EAST));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the South", ImagePosition.SOUTH));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the West", ImagePosition.WEST));
add(new WHeading(HeadingLevel.H4, "Rendered as a link"));
add(new ExplanatoryText("This example shows how to use an image and text as the content of a button without the button styling."));
buttonLayoutPanel = new WPanel(WPanel.Type.BOX);
buttonLayoutPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 6, 0, FlowLayout.ContentAlignment.BOTTOM));
add(buttonLayoutPanel);
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the North", ImagePosition.NORTH, true));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the East", ImagePosition.EAST, true));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the South", ImagePosition.SOUTH, true));
buttonLayoutPanel.add(makeImageButtonWithPosition("Image on the West", ImagePosition.WEST, true));
add(new WHeading(HeadingLevel.H4, "Using theme icons"));
add(new ExplanatoryText("These examples show ways to add an icon to a button using 'HtmlClassUtil'."));
// \u200b is a zero-width space.
WButton iconButton = new WButton("\u200b");
iconButton.setToolTip("Edit");
iconButton.setHtmlClass(HtmlClassProperties.ICON_EDIT);
add(iconButton);
iconButton = new WButton("Save");
iconButton.setHtmlClass(HtmlClassProperties.ICON_SAVE_BEFORE);
add(iconButton);
iconButton = new WButton("Search");
iconButton.setHtmlClass(HtmlClassProperties.ICON_SEARCH_AFTER);
add(iconButton);
add(new ExplanatoryText("These examples show ways to add a Font-Awesome icon to a button using 'setHtmlClass'."));
// \u200b is a zero-width space.
iconButton = new WButton("\u200b");
iconButton.setToolTip("Open Menu");
iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-bars"));
add(iconButton);
iconButton = new WButton("With text content");
iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-hand-o-left", HtmlIconUtil.IconPosition.BEFORE));
add(iconButton);
iconButton = new WButton("Right icon with text content");
iconButton.setHtmlClass(HtmlIconUtil.getIconClasses("fa-hand-o-right", HtmlIconUtil.IconPosition.AFTER));
add(iconButton);
}
Aggregations