Esempio n. 1
0
  /**
   * Replaces the button icon <b>but</b> does not save icon reference into parent {@code icon}
   * attribute.
   *
   * @param icon The button icon to display.
   */
  private void replaceIcon(final AbstractImagePrototype icon) {

    if (rendered) {
      El oldIcon = buttonEl.selectNode("." + baseStyle + "-image");
      if (oldIcon != null) {
        oldIcon.remove();
        el().removeStyleName(baseStyle + "-text-icon", baseStyle + "-icon", baseStyle + "-noicon");
      }
      el().addStyleName(
              (icon != null
                  ? (!Util.isEmptyString(html)
                      ? " " + baseStyle + "-text-icon"
                      : " " + baseStyle + "-icon")
                  : " " + baseStyle + "-noicon"));
      Element e = null;

      if (icon != null) {
        e = (Element) icon.createElement().cast();

        Accessibility.setRole(e, "presentation");
        fly(e).addStyleName(baseStyle + "-image");

        buttonEl.insertFirst(e);
        El.fly(e).makePositionable(true);
      }
      autoWidth();
      alignIcon(e);
    }
  }
Esempio n. 2
0
 /**
  * Sets the item's icon.
  *
  * @param icon the icon
  */
 public void setIcon(AbstractImagePrototype icon) {
   this.icon = icon;
   if (rendered) {
     El node = el().selectNode(".x-tab-image");
     if (node != null) {
       node.remove();
     }
     if (icon != null) {
       Element e = icon.createElement().cast();
       e.setClassName("x-tab-image");
       el().appendChild(e);
     }
     el().setStyleName("x-tab-with-icon", icon != null);
   }
 }