Example #1
0
  protected void createScrollers() {
    if (el().select(".x-menu-scroller").getLength() == 0) {
      Listener<ClickRepeaterEvent> listener =
          new Listener<ClickRepeaterEvent>() {
            public void handleEvent(ClickRepeaterEvent be) {
              onScroll(be);
            }
          };

      El scroller;

      scroller = new El(DOM.createDiv());
      scroller.addStyleName("x-menu-scroller", "x-menu-scroller-top");
      scroller.setInnerHtml("&nbsp;");
      ClickRepeater cr = new ClickRepeater(scroller);
      cr.doAttach();
      cr.addListener(Events.OnClick, listener);
      addAttachable(cr);

      el().insertFirst(scroller.dom);

      scroller = new El(DOM.createDiv());
      scroller.addStyleName("x-menu-scroller", "x-menu-scroller-bottom");
      scroller.setInnerHtml("&nbsp;");
      cr = new ClickRepeater(scroller);
      cr.doAttach();
      cr.addListener(Events.OnClick, listener);
      addAttachable(cr);

      el().appendChild(scroller.dom);
    }
  }
Example #2
0
 private El getGroup(String groupName) {
   El g = el().selectNode("#" + getId() + "-" + groupName);
   if (g == null) {
     g = new El(DOM.createDiv());
     g.makePositionable(true);
     g.dom.setAttribute("role", "group");
     g.addStyleName(HideMode.OFFSETS.value());
     g.addStyleName("x-menu-radio-group");
     g.setId(getId() + "-" + groupName);
     el().appendChild(g.dom);
   }
   return g;
 }
Example #3
0
  @Override
  protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    el().makePositionable(true);
    super.onRender(target, index);

    ul = new El(DOM.createDiv());
    ul.addStyleName(baseStyle + "-list");

    getElement().appendChild(ul.dom);

    // add menu to ignore list
    eventPreview.getIgnoreList().add(getElement());

    el().setTabIndex(0);
    el().setElementAttribute("hideFocus", "true");

    el().addStyleName("x-ignore");
    if (GXT.isAriaEnabled()) {
      Accessibility.setRole(getElement(), "menu");
      Accessibility.setRole(ul.dom, "presentation");
      handleRadioGroups();
    }

    if (plain) {
      addStyleName("x-menu-plain");
    }
    if (!showSeparator) {
      addStyleName("x-menu-nosep");
    }

    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONMOUSEWHEEL);
  }
Example #4
0
 /**
  * Sets the icon style.
  *
  * @param iconStyle the CSS style name
  */
 public void setIconStyle(String iconStyle) {
   if (this.iconStyle != iconStyle) {
     if (rendered) {
       if (this.iconStyle != null) {
         textEl.removeStyleName("x-status-icon");
         textEl.removeStyleName(this.iconStyle);
       }
       if (iconStyle != null) {
         textEl.addStyleName("x-status-icon");
         textEl.addStyleName(iconStyle);
       }
       autoWidth();
     }
     this.iconStyle = iconStyle;
   }
 }
Example #5
0
  @Override
  protected void onRender(Element parent, int pos) {
    setElement(DOM.createFieldSet(), parent, pos);

    legend = new El(DOM.createLegend());
    legend.addStyleName("x-fieldset-header");

    if (checkboxToggle && collapsible) {
      checkbox = DOM.createInputCheck().cast();
      sinkEvents(Event.ONCLICK);
      if (checkboxName != null) {
        checkbox.setAttribute("name", checkboxName);
      }
      legend.appendChild((Element) checkbox.cast());
      checkbox.setDefaultChecked(!collapsed);
      checkbox.setChecked(!collapsed);
      if (GXT.isAriaEnabled()) {
        checkbox.setTitle("Expand " + html);
      }
    } else if (!checkboxToggle && collapsible) {
      collapseBtn = new ToolButton("x-tool-toggle");
      collapseBtn.addListener(
          Events.Select,
          new Listener<ComponentEvent>() {
            public void handleEvent(ComponentEvent be) {
              setExpanded(!isExpanded());
            }
          });
      collapseBtn.render(legend.dom);
      collapseBtn.getAriaSupport().setRole("checkbox");
      if (GXT.isAriaEnabled()) {
        collapseBtn.setTitle("Expand " + html);
      }
      ComponentHelper.setParent(this, collapseBtn);
    }

    heading = DOM.createSpan();
    heading.setClassName("x-fieldset-header-text");
    legend.appendChild(heading);
    getElement().appendChild(legend.dom);

    body = el().appendChild(DOM.createDiv());

    if (html != null) {
      setHeadingHtml(html);
    }

    if (collapsed) {
      onCollapse();
    }

    updateIconTitles();

    if (GXT.isFocusManagerEnabled() && !getFocusSupport().isIgnore()) {
      el().setTabIndex(0);
      el().setElementAttribute("hideFocus", "true");
      sinkEvents(Event.FOCUSEVENTS);
    }
  }
Example #6
0
 protected void onScrollerIn(El t) {
   boolean top = t.is(".x-menu-scroller-top");
   if (top
       ? ul.getScrollTop() > 0
       : ul.getScrollTop() + activeMax < ul.dom.getPropertyInt("scrollHeight")) {
     t.addStyleName("x-menu-item-active", "x-menu-scroller-active");
   }
 }
Example #7
0
 @Override
 protected void onComponentHide(Component component) {
   super.onComponentHide(component);
   El e = findItemElement(component);
   if (e != null) {
     e.addStyleName(component.getHideMode().value());
   }
 }
  /** {@inheritDoc} */
  @Override
  protected void onRender(Element target, int index) {

    final El wrap = new El(DOM.createDiv());
    wrap.addStyleName("x-form-field-wrap");
    wrap.addStyleName("x-form-file-wrap");

    setElement(wrap.dom, target, index);

    createFileInput();

    button = Forms.button(buttonCaption != null ? buttonCaption : "...");
    button.addStyleName("x-form-file-btn");
    button.setIcon(buttonIcon);
    button.render(wrap.dom);

    super.onRender(target, index);
    super.setReadOnly(true);
  }
Example #9
0
  protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    textEl = new El(DOM.createSpan());
    textEl.addStyleName("x-status-text");
    getElement().appendChild(textEl.dom);
    super.onRender(target, index);
    disableTextSelection(true);
    setBox(box);

    String text = this.text;
    String iconStyle = this.iconStyle;
    this.text = null;
    this.iconStyle = null;
    setStatus(text, iconStyle);
  }
Example #10
0
  /** 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());
    }
  }
Example #11
0
 protected void onMouseOver(ComponentEvent ce) {
   El target = ce.getTarget("a", 3);
   if (target != null) {
     target.addStyleName("x-color-palette-hover");
   }
 }