Beispiel #1
0
  protected void onRender(Element target, int index) {
    if (template == null) {
      if (buttonTemplate == null) {
        StringBuffer sb = new StringBuffer();
        sb.append(
            "<table cellspacing=\"0\" class=\"x-btn\" role=\"presentation\"><tbody class=\"{2}\" >");
        sb.append(
            "<tr><td class=\"x-btn-tl\"><i>&#160;</i></td><td class=\"x-btn-tc\"></td><td class=\"x-btn-tr\"><i>&#160;</i></td></tr>");
        sb.append(
            "<tr><td class=\"x-btn-ml\"><i>&#160;</i></td><td class=\"x-btn-mc\"><em class=\"{3}\" unselectable=\"on\"><button class=\"x-btn-text\" type=\"{1}\">{0}</button></em></td><td class=\"x-btn-mr\"><i>&#160;</i></td></tr>");
        sb.append(
            "<tr><td class=\"x-btn-bl\"><i>&#160;</i></td><td class=\"x-btn-bc\"></td><td class=\"x-btn-br\"><i>&#160;</i></td></tr>");
        sb.append("</tbody></table>");

        buttonTemplate = new Template(sb.toString());
      }
      template = buttonTemplate;
    }

    setElement(
        template.create(
            (text != null && text.length() > 0) ? text : "&nbsp;",
            getType(),
            "x-btn-"
                + scale.name().toLowerCase()
                + " x-btn-icon-"
                + scale.name().toLowerCase()
                + "-"
                + iconAlign.name().toLowerCase(),
            getMenuClass()),
        target,
        index);

    super.onRender(target, index);

    buttonEl = el().selectNode(buttonSelector);
    buttonEl.makePositionable();

    if (getFocusEl() != null) {
      getFocusEl().addEventsSunk(Event.FOCUSEVENTS);
    }

    preview.getIgnoreList().add(getElement());

    buttonEl.setTabIndex(0);

    if (GXT.isAriaEnabled()) {
      Accessibility.setRole(buttonEl.dom, Accessibility.ROLE_BUTTON);
      if (menu != null) {
        Accessibility.setState(buttonEl.dom, "aria-haspopup", "true");
      }
    }

    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS);
  }
  /** Creates the underlying file input. */
  private void createFileInput() {

    if (file != null) {
      el().removeChild(file.dom);
    }

    final InputElement fileElement = Document.get().createFileInputElement();

    file = new El((Element) fileElement.cast());
    file.addEventsSunk(Event.ONCHANGE | Event.FOCUSEVENTS);
    file.setId(XDOM.getUniqueId());
    file.addStyleName("x-form-file");
    file.setTabIndex(-1);
    getFileInput().setName(name);
    getFileInput().setAccept(accept);
    file.insertInto(getElement(), 1);
    if (file != null) {
      file.setEnabled(isEnabled());
    }
  }