Example usage for com.google.gwt.user.client.ui Accessibility setState

List of usage examples for com.google.gwt.user.client.ui Accessibility setState

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Accessibility setState.

Prototype

public static void setState(Element elem, String stateName, String stateValue) 

Source Link

Document

Assigns the specified element the specified state and value for that state.

Usage

From source file:com.extjs.gxt.ui.client.widget.button.Button.java

License:sencha.com license

@Override
protected void onRender(Element target, int index) {
    SafeHtml label = SafeGxt.emptyToNbSpace(html);
    String style = baseStyle + "-" + scale.name().toLowerCase() + " " + baseStyle + "-icon-"
            + scale.name().toLowerCase() + "-" + iconAlign.name().toLowerCase();

    DivElement element = com.google.gwt.dom.client.Document.get().createDivElement();
    element.setInnerSafeHtml(TEMPLATES.button(label, getType(), style, getMenuClass(), baseStyle));

    setElement(element, target, index);//from w  w  w .  j av  a 2  s.  c  o m

    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");
            addStyleName(baseStyle + "-menu");
        }
    }

    sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS | Event.KEYEVENTS);
}

From source file:com.extjs.gxt.ui.client.widget.button.Button.java

License:sencha.com license

@Override
protected void setAriaState(String stateName, String stateValue) {
    Accessibility.setState(buttonEl.dom, stateName, stateValue);
}

From source file:com.extjs.gxt.ui.client.widget.button.ToggleButton.java

License:sencha.com license

/**
 * Sets the current pressed state.//from  ww w . j  a va  2s  . c  o m
 * 
 * @param state true to set pressed state
 * @param silent true to not fire the toggle event
 */
protected void toggle(boolean state, boolean silent) {
    this.pressed = state;
    if (rendered) {
        ButtonEvent be = new ButtonEvent(this);
        if (state) {
            addStyleName(baseStyle + "-pressed");
            removeStyleName(baseStyle + "-over");
            removeStyleName(baseStyle + "-blur");
        } else {
            removeStyleName(baseStyle + "-pressed");
        }
        if (state && toggleGroup != null && toggleGroup.length() > 0) {
            List<Component> list = new ArrayList<Component>(ComponentManager.get().getAll());
            for (Component c : list) {
                if (c instanceof ToggleButton && c != this
                        && toggleGroup.equals(((ToggleButton) c).getToggleGroup())) {
                    ((ToggleButton) c).toggle(false, silent);
                }
            }
        }
        Accessibility.setState(buttonEl.dom, "aria-pressed", "" + state);
        if (!silent) {
            fireEvent(Events.Toggle, be);
        }
    }
}

From source file:com.extjs.gxt.ui.client.widget.Component.java

License:sencha.com license

protected void setAriaState(String stateName, String stateValue) {
    Accessibility.setState(getElement(), stateName, stateValue);
}

From source file:com.extjs.gxt.ui.client.widget.ContentPanel.java

License:sencha.com license

protected void afterCollapse() {
    addStyleName(collapseStyle);/*from  w w w.ja va  2  s. co m*/
    removeStyleName(baseStyle + "-animated");
    collapsed = true;
    animating = false;

    for (Component c : getItems()) {
        if (!c.hidden && c.isRendered()) {
            c.notifyHide();
        }
    }

    if (topComponent != null && topComponent.isRendered()) {
        topComponent.notifyHide();
    }
    if (bottomComponent != null && bottomComponent.isRendered()) {
        bottomComponent.notifyHide();
    }
    if (fbar != null && fbar.isRendered()) {
        fbar.notifyHide();
    }

    sync(true);

    if (GXT.isAriaEnabled()) {
        Accessibility.setState(getElement(), "aria-expanded", "false");
        collapseBtn.setTitle(GXT.MESSAGES.panel_expandPanel());
    }

    ComponentEvent ce = new ComponentEvent(this);
    fireEvent(Events.Collapse, ce);
}

From source file:com.extjs.gxt.ui.client.widget.ContentPanel.java

License:sencha.com license

protected void afterExpand() {
    removeStyleName(collapseStyle);/*from   ww  w.ja  v  a  2s .c  o  m*/
    removeStyleName(baseStyle + "-animated");
    collapsed = false;
    animating = false;

    for (Component c : getItems()) {
        if (!c.hidden && c.isRendered()) {
            c.notifyShow();
        }
    }

    if (topComponent != null && topComponent.isRendered()) {
        topComponent.notifyShow();
    }
    if (bottomComponent != null && bottomComponent.isRendered()) {
        bottomComponent.notifyShow();
    }
    if (fbar != null && fbar.isRendered()) {
        fbar.notifyShow();
    }

    sync(true);

    if (GXT.isAriaEnabled()) {
        Accessibility.setState(getElement(), "aria-expanded", "true");
        collapseBtn.setTitle(GXT.MESSAGES.panel_collapsePanel());
    }

    ComponentEvent ce = new ComponentEvent(this);
    fireEvent(Events.Expand, ce);
}

From source file:com.extjs.gxt.ui.client.widget.ContentPanel.java

License:sencha.com license

@Override
protected void onRender(Element parent, int pos) {
    super.onRender(parent, pos);

    if (fbar.getItemCount() > 0) {
        footer = true;//  w w w .j  ava2 s  . c o m
    }

    if (frame) {
        String s = Format.substitute(Markup.BBOX, baseStyle);
        DomHelper.insertHtml("afterBegin", el().dom, s);

        head.baseStyle = headerStyle;
        head.setTextStyle(headerTextStyle);
        initTools();
        head.render(el().dom);
        el().subChild(3).dom.appendChild(head.getElement());
        bwrap = el().createChild("<div role=presentation class='" + bwrapStyle + "'></div>");

        Element bw = bwrap.dom;
        Element ml = DOM.getChild(el().dom, 1);
        Element bl = DOM.getChild(el().dom, 2);
        DOM.appendChild(bw, ml);
        DOM.appendChild(bw, bl);

        Element mc = fly(bw).getSubChild(3);

        if (topComponent != null) {
            tbar = fly(mc).createChild("<div role=presentation class=" + tbarStyle + "></div>");
        }
        body = fly(mc).createChild("<div role=presentation class=" + bodStyle + "></div>");
        if (bottomComponent != null) {
            bbar = fly(mc).createChild("<div role=presentation class=" + bbarStyle + "></div>");
        }

        El e = fly(bw).lastChild().firstChild().firstChild();
        foot = e.createChild("<div role=presentation class=" + footerStyle + "></div>");

    } else {
        head.baseStyle = headerStyle;
        head.setTextStyle(headerTextStyle);
        initTools();
        head.render(el().dom);
        bwrap = el().createChild("<div role=presentation class=" + bwrapStyle + "></div>");

        Element bw = bwrap.dom;
        if (topComponent != null) {
            tbar = fly(bw).createChild("<div role=presentation class=" + tbarStyle + "></div>");
        }
        body = fly(bw).createChild("<div role=presentation class=" + bodStyle + "></div>");
        if (bottomComponent != null) {
            bbar = fly(bw).createChild("<div role=presentation class=" + bbarStyle + "></div>");
        }
        foot = fly(bw).createChild("<div role=presentation class=" + footerStyle + "></div>");
    }

    if (!headerVisible) {
        head.hide();
        body.addStyleName(bodStyle + "-noheader");
        if (tbar != null) {
            tbar.addStyleName(tbarStyle + "-noheader");
        }
    }

    if (footer && fbar.getItemCount() > 0) {
        Element div = DOM.createDiv();
        fly(div).addStyleName("x-panel-btns");
        foot.appendChild(div);
        fbar.render(div);
        Element clearDiv = DOM.createDiv();
        clearDiv.setClassName("x-clear");
        div.appendChild(clearDiv);
    } else if (!footer) {
        bwrap.lastChild().addStyleName(baseStyle + "-nofooter");
    }

    if (!bodyBorder) {
        el().addStyleName(baseStyle + "-noborder");
        body.addStyleName(bodStyle + "-noborder");
        if (tbar != null) {
            tbar.addStyleName(tbarStyle + "-noborder");
        }
        if (bbar != null) {
            bbar.addStyleName(bbarStyle + "-noborder");
        }
    }

    if (bodyStyle != null) {
        body.applyStyles(bodyStyle);
    }

    if (bodyStyleName != null) {
        body.addStyleName(bodyStyleName);
    }

    if (headerVisible) {
        head.disableTextSelection(true);
    }

    if (topComponent != null) {
        topComponent.render(tbar.dom);
    }

    if (bottomComponent != null) {
        bottomComponent.render(bbar.dom);
    }

    if (titleCollapse) {
        head.setStyleAttribute("cursor", "pointer");
        sinkEvents(Event.ONCLICK);
    }

    if (collapsible && GXT.isAriaEnabled()) {
        Accessibility.setState(getElement(), "aria-expanded", "true");
    }

    if (GXT.isAriaEnabled()) {
        Accessibility.setRole(getElement(), "region");
        if (head != null) {
            getAriaSupport().setLabelledBy(head.getId() + "-label");
        }
    }

    // early render
    layoutBars();

    if (collapsed) {
        boolean anim = animCollapse;
        collapsed = false;
        setAnimCollapse(false);
        collapse();
        setAnimCollapse(anim);
    }
}

From source file:com.extjs.gxt.ui.client.widget.form.CheckBox.java

License:sencha.com license

@Override
protected void setAriaState(String stateName, String stateValue) {
    Accessibility.setState(input.dom, stateName, stateValue);
}

From source file:com.extjs.gxt.ui.client.widget.grid.Grid.java

License:sencha.com license

protected void setAriaState(String stateName, String stateValue) {
    if (isViewReady()) {
        Accessibility.setState(view.focusEl.dom, stateName, stateValue);
    } else {/*from w w  w  .  j  a v a2  s.  co m*/
        states.put(stateName, stateValue);
    }
}

From source file:com.extjs.gxt.ui.client.widget.Header.java

License:sencha.com license

@Override
protected void onRender(Element target, int index) {
    super.onRender(target, index);
    setElement(DOM.createDiv(), target, index);
    getAriaSupport().setPresentation(true);

    addStyleName("x-small-editor");
    widgetPanel = new HorizontalPanel();
    widgetPanel.setParent(this);
    widgetPanel.addStyleName("x-panel-toolbar");
    widgetPanel.setLayoutOnChange(true);
    widgetPanel.setStyleAttribute("float", "right");
    widgetPanel.getAriaSupport().setPresentation(true);

    if (tools.size() > 0) {
        for (int i = 0; i < tools.size(); i++) {
            widgetPanel.add(tools.get(i));
        }// ww w .  j a v a  2  s. com
    } else {
        widgetPanel.setVisible(false);
    }

    widgetPanel.render(getElement());
    widgetPanel.setParent(this);

    contentEl = new El(DOM.createSpan());
    contentEl.setId(getId() + "-label");
    Accessibility.setRole(contentEl.dom, "heading");
    Accessibility.setState(contentEl.dom, "aria-level", "1");
    getElement().appendChild(contentEl.dom);

    if (textStyle != null) {
        setTextStyle(textStyle);
    }

    setHtml(html);

    if (icon != null) {
        setIcon(icon);
    }
}