/** * 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); } } }
@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); } }
@Override protected void onFocus(ComponentEvent ce) { super.onFocus(ce); if (GXT.isFocusManagerEnabled()) { if (focusWidget != null) { El.fly(focusWidget.getElement()).focus(); } } }
protected void deactiveActiveItem() { if (activeItem != null) { activeItem.deactivate(); activeItem = null; } if (GXT.isFocusManagerEnabled()) { FocusFrame.get().unframe(); Accessibility.setState(getElement(), "aria-activedescendant", ""); } }
@Override protected void onFocus(ComponentEvent ce) { super.onFocus(ce); if (GXT.isFocusManagerEnabled()) { if (checkboxToggle && checkbox != null) { checkbox.focus(); } else if (collapseBtn != null) { collapseBtn.focus(); } } }
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; } } } }
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> </i>"); } if (GXT.isFocusManagerEnabled()) { el().setTabIndex(0); Accessibility.setRole(getElement(), Accessibility.ROLE_BUTTON); } }
protected void onFocus(ComponentEvent ce) { if (GXT.isFocusManagerEnabled() && !GXT.isIE) { FocusFrame.get().frame(this); } }
protected void onBlur(ComponentEvent ce) { if (GXT.isFocusManagerEnabled()) { FocusFrame.get().unframe(); } }