/** * Creates a header with the specified appearance. * * @param appearance the appearance of the header */ public Header(HeaderAppearance appearance) { this.appearance = appearance; SafeHtmlBuilder sb = new SafeHtmlBuilder(); this.appearance.render(sb); setElement((Element) XDOM.create(sb.toSafeHtml())); addStyleName("x-small-editor"); widgetPanel = new HorizontalPanel(); widgetPanel.addStyleName("x-panel-toolbar"); XElement barElem = appearance.getBarElem(getElement()); barElem.appendChild(widgetPanel.getElement()); if (tools.size() > 0) { for (int i = 0; i < tools.size(); i++) { widgetPanel.add(tools.get(i)); } } else { widgetPanel.setVisible(false); } ComponentHelper.setParent(this, widgetPanel); appearance.getTextElem(getElement()).setId(getId() + "-label"); setText(text); if (icon != null) { setIcon(icon); } getFocusSupport().setIgnore(true); }
/** * Sets the header's text. * * @param text the new text */ public void setText(String text) { this.text = text; appearance.getTextElem(getElement()).setInnerHTML(text == null ? " " : text); }
@Override public void setHTML(String html) { appearance.getTextElem(getElement()).setInnerHTML(html); }
@Override public void setIcon(ImageResource icon) { this.icon = icon; appearance.setIcon(getElement(), icon); }
@Override public String getHTML() { return appearance.getTextElem(getElement()).getInnerHTML(); }