use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WSectionRenderer method doRender.
/**
* Paints the given WSection.
*
* @param component the WSection to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSection section = (WSection) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(section);
xml.appendTagOpen("ui:section");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (SectionMode.LAZY.equals(section.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
SectionMode mode = section.getMode();
if (mode != null) {
switch(mode) {
case LAZY:
xml.appendAttribute("mode", "lazy");
break;
case EAGER:
xml.appendAttribute("mode", "eager");
break;
default:
throw new SystemException("Unknown section mode: " + section.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(section, renderContext);
if (renderChildren) {
// Label
section.getDecoratedLabel().paint(renderContext);
// Content
section.getContent().paint(renderContext);
}
xml.appendEndTag("ui:section");
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WSeparatorRenderer method doRender.
/**
* Paints the given WSeparator.
*
* @param component the WSeparator to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:separator");
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendEnd();
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WSkipLinksRenderer method doRender.
/**
* Paints the given WSkipLinks.
*
* @param component the WSkipLinks to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:skiplinks");
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendEnd();
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WStyledTextRenderer method doRender.
/**
* Paints the given WStyledText.
*
* @param component the WStyledText to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WStyledText text = (WStyledText) component;
XmlStringBuilder xml = renderContext.getWriter();
String textString = text.getText();
if (textString != null && textString.length() > 0) {
xml.appendTagOpen("ui:text");
xml.appendOptionalAttribute("class", component.getHtmlClass());
switch(text.getType()) {
case EMPHASISED:
xml.appendAttribute("type", "emphasised");
break;
case HIGH_PRIORITY:
xml.appendAttribute("type", "highPriority");
break;
case LOW_PRIORITY:
xml.appendAttribute("type", "lowPriority");
break;
case MEDIUM_PRIORITY:
xml.appendAttribute("type", "mediumPriority");
break;
case ACTIVE_INDICATOR:
xml.appendAttribute("type", "activeIndicator");
break;
case MATCH_INDICATOR:
xml.appendAttribute("type", "matchIndicator");
break;
case INSERT:
xml.appendAttribute("type", "insert");
break;
case DELETE:
xml.appendAttribute("type", "delete");
break;
case MANDATORY_INDICATOR:
xml.appendAttribute("type", "mandatoryIndicator");
break;
case PLAIN:
default:
xml.appendAttribute("type", "plain");
break;
}
switch(text.getWhitespaceMode()) {
case PARAGRAPHS:
xml.appendAttribute("space", "paragraphs");
break;
case PRESERVE:
xml.appendAttribute("space", "preserve");
break;
case DEFAULT:
break;
default:
throw new IllegalArgumentException("Unknown white space mode: " + text.getWhitespaceMode());
}
xml.appendClose();
if (WStyledText.WhitespaceMode.PARAGRAPHS.equals(text.getWhitespaceMode())) {
textString = text.isEncodeText() ? WebUtilities.encode(textString) : HtmlToXMLUtil.unescapeToXML(textString);
writeParagraphs(textString, xml);
} else {
xml.append(textString, text.isEncodeText());
}
xml.appendEndTag("ui:text");
}
}
use of com.github.bordertech.wcomponents.XmlStringBuilder in project wcomponents by BorderTech.
the class WSubordinateControlRenderer method doRender.
/**
* Paints the given SubordinateControl.
*
* @param component the SubordinateControl to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WSubordinateControl subordinate = (WSubordinateControl) component;
XmlStringBuilder xml = renderContext.getWriter();
if (!subordinate.getRules().isEmpty()) {
int seq = 0;
for (Rule rule : subordinate.getRules()) {
xml.appendTagOpen("ui:subordinate");
xml.appendAttribute("id", subordinate.getId() + "-c" + seq++);
xml.appendClose();
paintRule(rule, xml);
xml.appendEndTag("ui:subordinate");
}
}
}
Aggregations