Exemplo n.º 1
0
  /**
   * Sets the active item. The component must be of type <code>Item</code> to be activated. All
   * other types are ignored.
   *
   * @param c the component to set active
   * @param autoExpand true to auto expand the item
   */
  public void setActiveItem(Component c, boolean autoExpand) {
    if (c == null) {
      deactiveActiveItem();
      return;
    }
    if (c instanceof Item) {
      Item item = (Item) c;
      if (item != activeItem) {
        deactiveActiveItem();

        this.activeItem = item;
        item.activate(autoExpand);
        item.el().scrollIntoView(ul.dom, false);
        focus();

        if (GXT.isFocusManagerEnabled()) {
          FocusFrame.get().frame(item);
          Accessibility.setState(getElement(), "aria-activedescendant", item.getId());
        }

      } else if (autoExpand) {
        item.expandMenu(autoExpand);
      }
    }
  }
Exemplo n.º 2
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);
    }
  }
Exemplo n.º 3
0
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (focusWidget != null) {
       El.fly(focusWidget.getElement()).focus();
     }
   }
 }
Exemplo n.º 4
0
 protected void deactiveActiveItem() {
   if (activeItem != null) {
     activeItem.deactivate();
     activeItem = null;
   }
   if (GXT.isFocusManagerEnabled()) {
     FocusFrame.get().unframe();
     Accessibility.setState(getElement(), "aria-activedescendant", "");
   }
 }
Exemplo n.º 5
0
 @Override
 protected void onFocus(ComponentEvent ce) {
   super.onFocus(ce);
   if (GXT.isFocusManagerEnabled()) {
     if (checkboxToggle && checkbox != null) {
       checkbox.focus();
     } else if (collapseBtn != null) {
       collapseBtn.focus();
     }
   }
 }
Exemplo n.º 6
0
  protected void onKeyPress(WindowEvent we) {
    int keyCode = we.getKeyCode();
    boolean t =
        getElement()
            .isOrHasChild(
                (com.google.gwt.dom.client.Element) we.getEvent().getEventTarget().cast());
    boolean key = GXT.isFocusManagerEnabled() ? we.isShiftKey() : true;
    if (key && closable && onEsc && keyCode == KeyCodes.KEY_ESCAPE && t) {
      hide();
    }

    if (GXT.isAriaEnabled()) {
      if (we.getTarget() == moveBtn.getElement()) {
        Point p = getPosition(true);
        switch (we.getKeyCode()) {
          case KeyCodes.KEY_LEFT:
            setPosition(p.x - ariaMoveResizeDistance, p.y);
            break;
          case KeyCodes.KEY_RIGHT:
            setPosition(p.x + ariaMoveResizeDistance, p.y);
            break;
          case KeyCodes.KEY_DOWN:
            setPosition(p.x, p.y + ariaMoveResizeDistance);
            break;
          case KeyCodes.KEY_UP:
            setPosition(p.x, p.y - ariaMoveResizeDistance);
            break;
        }
      } else if (we.getTarget() == resizeBtn.getElement()) {
        if (!resizable) {
          return;
        }
        Size s = getSize();
        switch (we.getKeyCode()) {
          case KeyCodes.KEY_LEFT:
            setSize(s.width - ariaMoveResizeDistance, s.height);
            break;
          case KeyCodes.KEY_RIGHT:
            setSize(s.width + ariaMoveResizeDistance, s.height);
            break;
          case KeyCodes.KEY_DOWN:
            setSize(s.width, s.height + ariaMoveResizeDistance);
            break;
          case KeyCodes.KEY_UP:
            setSize(s.width, s.height - ariaMoveResizeDistance);
            break;
        }
      }
    }
  }
Exemplo n.º 7
0
  protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    addStyleName("x-icon-btn");
    addStyleName("x-nodrag");
    addStyleName(style);
    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS | Event.ONKEYUP);
    super.onRender(target, index);

    if (GXT.isHighContrastMode) {
      getElement().setInnerHTML("<i>&nbsp;</i>");
    }

    if (GXT.isFocusManagerEnabled()) {
      el().setTabIndex(0);
      Accessibility.setRole(getElement(), Accessibility.ROLE_BUTTON);
    }
  }
Exemplo n.º 8
0
 protected void onFocus(ComponentEvent ce) {
   if (GXT.isFocusManagerEnabled() && !GXT.isIE) {
     FocusFrame.get().frame(this);
   }
 }
Exemplo n.º 9
0
 protected void onBlur(ComponentEvent ce) {
   if (GXT.isFocusManagerEnabled()) {
     FocusFrame.get().unframe();
   }
 }