Exemplo n.º 1
0
  /**
   * Sets the button's icon style. The style name should match a CSS style that specifies a
   * background image using the following format:
   *
   * <pre>
   *
   * &lt;code&gt; .my-icon { background: url(images/icons/my-icon.png) no-repeat
   * center left !important; } &lt;/code&gt;
   *
   * </pre>
   *
   * @param icon the icon
   */
  public void setIcon(AbstractImagePrototype icon) {
    if (rendered) {
      if (buttonEl.selectNode("img") != null) {
        buttonEl.selectNode("img").remove();
        el().removeStyleName("x-btn-text-icon", "x-btn-icon", "x-btn-noicon");
      }
      el().addStyleName(
              (icon != null
                  ? ((text != null && text.length() > 0) ? " x-btn-text-icon" : " x-btn-icon")
                  : " x-btn-noicon"));
      if (icon != null) {

        Element e = (Element) icon.createElement().cast();
        buttonEl.insertFirst(e);
        El.fly(e).makePositionable(true);
        String align = "b-b";
        if (iconAlign == IconAlign.BOTTOM) {
          align = "b-b";
        } else if (iconAlign == IconAlign.TOP) {
          align = "t-t";
        } else if (iconAlign == IconAlign.LEFT) {
          align = "tl-tl";
        } else if (iconAlign == IconAlign.RIGHT) {
          align = "tr-tr";
        }
        El.fly(e).alignTo(buttonEl.dom, align, null);
      }
    }
    this.icon = icon;
  }
Exemplo n.º 2
0
 protected void clearGroups() {
   NodeList<Element> groups = el().select(".x-menu-radio-group");
   for (int i = 0; i < groups.getLength(); i++) {
     Element e = groups.getItem(i);
     El.fly(e).removeFromParent();
   }
 }
Exemplo n.º 3
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);
    }
  }
Exemplo n.º 4
0
  protected void updateCellValues(int col, Element cell, HorizontalAlignment align) {
    String salign;
    switch (align) {
      case START:
        {
          if (LocaleInfo.getCurrentLocale().isRTL()) salign = "right";
          else salign = "left";
          break;
        }
      case END:
        {
          if (LocaleInfo.getCurrentLocale().isRTL()) salign = "left";
          else salign = "right";
          break;
        }
      default:
        salign = align.name().toLowerCase();
    }

    String widthClassName = ((TreeTableItem) item).treeTable.getId() + "-col-" + col;

    String className = cell.getClassName();
    className = (className == null) ? widthClassName : className + " " + widthClassName;
    cell.setClassName(className);

    className = DOM.getElementProperty(DOM.getFirstChild(cell), "className");
    className = (className == null) ? widthClassName : className + " " + widthClassName;
    DOM.setElementProperty(DOM.getFirstChild(cell), "className", className);

    El.fly(cell).subChild(2).setStyleAttribute("textAlign", salign);
  }
Exemplo n.º 5
0
 protected Element getTextCellElement(int column) {
   if (column == 0) {
     return textSpanEl;
   } else {
     return El.fly(cells[column]).getSubChild(2);
   }
 }
Exemplo n.º 6
0
 @Override
 public void onSelectedChange(boolean selected) {
   if (item.isRendered()) {
     El.fly(tableItemEl).setStyleName("my-treetbl-item-sel", selected);
     if (!selected) {
       onMouseOut(null);
     }
   }
 }
Exemplo n.º 7
0
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (focusWidget != null) {
       El.fly(focusWidget.getElement()).focus();
     }
   }
 }
Exemplo n.º 8
0
 protected void onGroupSelect(Element group, boolean select) {
   El.fly(group).firstChild().setStyleName("x-grid3-group-selected", select);
   grid.getAriaSupport().setState("aria-activedescendant", group.getFirstChildElement().getId());
 }
Exemplo n.º 9
0
 public void onMouseOver(BaseEvent be) {
   if (!item.isRoot()) {
     El.fly(tableItemEl).addStyleName("my-treetbl-item-over");
   }
 }
Exemplo n.º 10
0
  public void render(Element target, int index) {
    if (item.isRoot() == true) {
      return;
    }

    item.setTreeTableElement(DOM.createDiv());
    item.setStyleName("my-treeitem x-tree-item");
    DOM.insertChild(target, item.getElement(), index);

    TableColumnModel cm = getTreeTableItem().getTreeTable().getColumnModel();

    DOM.setInnerHTML(item.getElement(), Markup.TREETABLE_ITEM);
    tableItemEl = item.el().firstChild().dom;

    rowTableEl = DOM.getFirstChild(tableItemEl);
    rowTrEl = fly(rowTableEl).getSubChild(2);
    updateCellValues(0, DOM.getFirstChild(rowTrEl), cm.getColumn(0).getAlignment());
    itemEl = fly(rowTrEl).getSubChild(4);
    Element td = fly(itemEl).subChild(3).dom;
    indentEl = DOM.getFirstChild(td);
    jointEl = DOM.getNextSibling(td);
    jointDivEl = DOM.getFirstChild(jointEl);
    checkEl = DOM.getNextSibling(DOM.getNextSibling(jointEl));
    checkDivEl = DOM.getFirstChild(checkEl);
    iconEl = DOM.getNextSibling(checkEl);
    iconDivEl = DOM.getFirstChild(iconEl);
    textEl = DOM.getNextSibling(iconEl);
    textSpanEl = DOM.getFirstChild(textEl);
    Element tbl = DOM.getFirstChild(item.getElement());
    containerEl = new El(DOM.getNextSibling(tbl));

    int numColumns = cm.getColumnCount();
    cells = new Element[numColumns];

    for (int i = 1; i < numColumns; i++) {
      cells[i] = DOM.createTD();
      DOM.appendChild(rowTrEl, cells[i]);

      DOM.setElementProperty(cells[i], "className", "my-treetbl-cell");
      DOM.setElementAttribute(cells[i], "index", String.valueOf(i));

      Element overflowDiv = DOM.createDiv();
      DOM.setElementProperty(overflowDiv, "className", "my-treetbl-cell-overflow");
      DOM.appendChild(cells[i], overflowDiv);
      Element textDiv = DOM.createDiv();

      String textStyle = "my-treetbl-cell-text";
      if (((TreeTableItem) item).getCellStyle(i) != null) {
        textStyle += " " + ((TreeTableItem) item).getCellStyle(i);
      }
      DOM.setElementProperty(textDiv, "className", textStyle);
      DOM.appendChild(overflowDiv, textDiv);
      updateCellValues(i, cells[i], cm.getColumn(i).getAlignment());
    }

    boolean checkable = getTreeTableItem().getTreeTable().getCheckable();
    El.fly(checkEl).setVisible(checkable);

    onValuesChanged(getTreeTableItem().getTreeTable(), getTreeTableItem().getRenderedValues());

    item.updateIconStyle();
    item.updateJointStyle();

    if (item.isChecked()) {
      onCheckChange(true);
    }

    El.fly(indentEl).setWidth(item.getIndent());

    item.updateJointStyle();
    item.disableTextSelection(true);
  }