use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WLinkRenderer method doRender.
/**
* Paints the given {@link WLink}.
*
* @param component the WLink to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WLink link = (WLink) component;
XmlStringBuilder xml = renderContext.getWriter();
String text = link.getText();
String targetWindowName = link.getOpenNewWindow() ? link.getTargetWindowName() : null;
String imageUrl = link.getImageUrl();
xml.appendTagOpen("ui:link");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("disabled", link.isDisabled(), "true");
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
xml.appendOptionalAttribute("toolTip", link.getToolTip());
xml.appendOptionalAttribute("accessibleText", link.getAccessibleText());
xml.appendUrlAttribute("url", link.getUrl());
xml.appendOptionalAttribute("rel", link.getRel());
xml.appendOptionalAttribute("accessKey", Util.upperCase(link.getAccessKeyAsString()));
if (imageUrl != null) {
xml.appendUrlAttribute("imageUrl", imageUrl);
ImagePosition imagePosition = link.getImagePosition();
if (imagePosition != null) {
switch(imagePosition) {
case NORTH:
xml.appendAttribute("imagePosition", "n");
break;
case EAST:
xml.appendAttribute("imagePosition", "e");
break;
case SOUTH:
xml.appendAttribute("imagePosition", "s");
break;
case WEST:
xml.appendAttribute("imagePosition", "w");
break;
default:
throw new SystemException("Unknown image position: " + imagePosition);
}
}
// we have an image. We must have a text equivalent
if (Util.empty(text) && Util.empty(link.getToolTip()) && Util.empty(link.getAccessibleText())) {
// If the link has an umageUrl but no text equivalent get the text equivalent off of the image
WImage linkImage = link.getImageHolder();
if (null != linkImage) {
xml.appendOptionalAttribute("toolTip", linkImage.getAlternativeText());
}
}
}
if (link.isRenderAsButton()) {
xml.appendAttribute("type", "button");
}
xml.appendClose();
if (targetWindowName != null) {
xml.appendTagOpen("ui:windowAttributes");
xml.appendAttribute("name", targetWindowName);
WLink.WindowAttributes attributes = link.getWindowAttrs();
if (attributes != null) {
xml.appendOptionalAttribute("top", attributes.getTop() >= 0, attributes.getTop());
xml.appendOptionalAttribute("left", attributes.getLeft() >= 0, attributes.getLeft());
xml.appendOptionalAttribute("width", attributes.getWidth() > 0, attributes.getWidth());
xml.appendOptionalAttribute("height", attributes.getHeight() > 0, attributes.getHeight());
xml.appendOptionalAttribute("resizable", attributes.isResizable(), "true");
xml.appendOptionalAttribute("showMenubar", attributes.isMenubar(), "true");
xml.appendOptionalAttribute("showToolbar", attributes.isToolbars(), "true");
xml.appendOptionalAttribute("showLocation", attributes.isLocation(), "true");
xml.appendOptionalAttribute("showStatus", attributes.isStatus(), "true");
xml.appendOptionalAttribute("showScrollbars", attributes.isScrollbars(), "true");
xml.appendOptionalAttribute("showDirectories", attributes.isDirectories(), "true");
}
xml.appendEnd();
}
if (text != null) {
xml.appendEscaped(text);
}
xml.appendEndTag("ui:link");
// Paint the AJAX trigger if the link has an action
if (link.getAction() != null) {
paintAjaxTrigger(link, xml);
}
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WDefinitionListRenderer method doRender.
/**
* Paints the given definition list.
*
* @param component the list to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WDefinitionList list = (WDefinitionList) component;
XmlStringBuilder xml = renderContext.getWriter();
xml.appendTagOpen("ui:definitionlist");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
switch(list.getType()) {
case FLAT:
xml.appendAttribute("type", "flat");
break;
case COLUMN:
xml.appendAttribute("type", "column");
break;
case STACKED:
xml.appendAttribute("type", "stacked");
break;
case NORMAL:
break;
default:
throw new SystemException("Unknown layout type: " + list.getType());
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(list, renderContext);
for (Duplet<String, ArrayList<WComponent>> term : list.getTerms()) {
xml.appendTagOpen("ui:term");
xml.appendAttribute("text", I18nUtilities.format(null, term.getFirst()));
xml.appendClose();
for (WComponent data : term.getSecond()) {
xml.appendTag("ui:data");
data.paint(renderContext);
xml.appendEndTag("ui:data");
}
xml.appendEndTag("ui:term");
}
xml.appendEndTag("ui:definitionlist");
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WFigureRenderer method doRender.
/**
* Paints the given WFigure.
*
* @param component the WFigure to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WFigure figure = (WFigure) component;
XmlStringBuilder xml = renderContext.getWriter();
boolean renderChildren = isRenderContent(figure);
xml.appendTagOpen("ui:figure");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
if (FigureMode.LAZY.equals(figure.getMode())) {
xml.appendOptionalAttribute("hidden", !renderChildren, "true");
} else {
xml.appendOptionalAttribute("hidden", component.isHidden(), "true");
}
FigureMode mode = figure.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 figure mode: " + figure.getMode());
}
}
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(figure, renderContext);
if (renderChildren) {
// Label
figure.getDecoratedLabel().paint(renderContext);
// Content
xml.appendTagOpen("ui:content");
xml.appendAttribute("id", component.getId() + "-content");
xml.appendClose();
figure.getContent().paint(renderContext);
xml.appendEndTag("ui:content");
}
xml.appendEndTag("ui:figure");
}
use of com.github.bordertech.wcomponents.util.SystemException in project wcomponents by BorderTech.
the class WListRenderer method doRender.
/**
* Paints the given WList.
*
* @param component the WList to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WList list = (WList) component;
XmlStringBuilder xml = renderContext.getWriter();
WList.Type type = list.getType();
WList.Separator separator = list.getSeparator();
Size gap = list.getSpace();
String gapString = gap == null ? null : gap.toString();
xml.appendTagOpen("ui:panel");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("type", list.isRenderBorder(), "box");
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(list, renderContext);
xml.appendTagOpen("ui:listlayout");
xml.appendOptionalAttribute("gap", gapString);
if (type != null) {
switch(type) {
case FLAT:
xml.appendAttribute("type", "flat");
break;
case STACKED:
xml.appendAttribute("type", "stacked");
break;
case STRIPED:
xml.appendAttribute("type", "striped");
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
if (separator != null) {
switch(separator) {
case BAR:
xml.appendAttribute("separator", "bar");
break;
case DOT:
xml.appendAttribute("separator", "dot");
break;
case NONE:
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
xml.appendClose();
paintRows(list, renderContext);
xml.appendEndTag("ui:listlayout");
xml.appendEndTag("ui:panel");
}
use of com.github.bordertech.wcomponents.util.SystemException 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");
}
Aggregations