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

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

Introduction

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

Prototype

public static void setRole(Element elem, String roleName) 

Source Link

Document

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

Usage

From source file:cc.alcina.framework.gwt.client.widget.CustomisableTabPanel.java

License:Apache License

/**
 * Creates an empty tab panel./*from   www  .  j  ava 2  s  . co m*/
 */
public CustomisableTabPanel() {
    panel = new FlowPanel();
    panel.add(tabBar);
    panel.add(deck);
    // panel.setCellHeight(deck, "100%");
    // tabBar.setWidth("100%");
    tabBar.addBeforeSelectionHandler(this);
    tabBar.addSelectionHandler(this);
    initWidget(panel);
    setStyleName("gwt-TabPanel");
    deck.setStyleName("gwt-TabPanelBottom");
    // Add a11y role "tabpanel"
    Accessibility.setRole(deck.getElement(), Accessibility.ROLE_TABPANEL);
}

From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java

License:Apache License

/**
 * Creates an empty tab bar.//from  w ww  .j  av a  2 s . c  o m
 */
public FlowTabBar() {
    initWidget(panel2);
    sinkEvents(Event.ONCLICK);
    setStyleName("gwt-TabBar");
    // Add a11y role "tablist"
    Accessibility.setRole(panel2.getElement(), Accessibility.ROLE_TABLIST);
    // panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
    HTML first = new HTML(" ", true), rest = new HTML(" ", true);
    first.setStyleName("gwt-TabBarFirst");
    rest.setStyleName("gwt-TabBarRest");
    first.setHeight("100%");
    rest.setHeight("100%");
    first.setVisible(false);
    rest.setVisible(false);
    panel2.add(first);
    panel2.add(rest);
    first.setHeight("100%");
    // panel.setCellHeight(first, "100%");
    // panel.setCellWidth(rest, "100%");
}

From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java

License:Apache License

/**
 * Inserts a new tab at the specified index.
 * //  w  ww.ja v  a 2  s .  c o  m
 * @param widget
 *            widget to be used in the new tab.
 * @param beforeIndex
 *            the index before which this tab will be inserted.
 */
protected void insertTabWidget(Widget widget, int beforeIndex) {
    checkInsertBeforeTabIndex(beforeIndex);
    ClickDelegatePanel delWidget = new ClickDelegatePanel(widget);
    delWidget.addClickHandler(this);
    delWidget.addKeyDownHandler(this);
    delWidget.setStyleName(STYLENAME_DEFAULT);
    // Add a11y role "tab"
    SimplePanel focusablePanel = delWidget.getFocusablePanel();
    Accessibility.setRole(focusablePanel.getElement(), Accessibility.ROLE_TAB);
    if (beforeIndex == tabs.size()) {
        panel2.add(delWidget);
    } else {
        panel2.insert(delWidget, panel2.getWidgetIndex(tabs.get(beforeIndex)));
    }
    tabs.add(delWidget);
    setStyleName(DOM.getParent(delWidget.getElement()), STYLENAME_DEFAULT + "-wrapper", true);
}

From source file:com.choicetrax.client.display.panels.decorators.BoxTabPanel.java

License:Apache License

/**
 * Creates an empty tab panel.//w w  w.  ja  v  a  2s .c  o m
 */
public BoxTabPanel() {
    boxPanel = new BoxDecoratorPanel(deck);

    VerticalPanel panel = new VerticalPanel();
    panel.add(tabBar);
    panel.add(boxPanel);

    panel.setCellHeight(boxPanel, "100%");
    tabBar.setWidth("100%");

    tabBar.addTabListener(this);
    initWidget(panel);
    setStyleName("gwt-TabPanel");
    deck.setStyleName("gwt-TabPanelBottom");
    // Add a11y role "tabpanel"
    Accessibility.setRole(boxPanel.getElement(), Accessibility.ROLE_TABPANEL);
}

From source file:com.extjs.gxt.ui.client.GXT.java

License:sencha.com license

/**
 * True to enable ARIA functionality. Enabling ARIA will also cause the focus
 * manager to enabled.//from www  .j  a va 2 s . co  m
 * 
 * @param enable true to enable
 */
public static void setAriaEnabled(boolean enable) {
    ariaEnabled = enable;
    Accessibility.setRole(XDOM.getBody(), enable ? "application" : "");
    setFocusManagerEnabled(enable);
}

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

License:sencha.com license

/**
 * Sets the button's icon style. The style name should match a CSS style that
 * specifies a background image using the following format:
 * //from w w  w .  j  a  va 2 s .  c o  m
 * <pre>
 * 
 * &lt;code&gt; .my-icon { background: url(images/icons/my-icon.png) no-repeat
 * center left !important; } &lt;/code&gt;
 * 
 * </pre>
 * 
 * @param icon the icon
 */
public void setIcon(AbstractImagePrototype icon) {
    if (rendered) {
        El oldIcon = buttonEl.selectNode("." + baseStyle + "-image");
        if (oldIcon != null) {
            oldIcon.remove();
            el().removeStyleName(baseStyle + "-text-icon", baseStyle + "-icon", baseStyle + "-noicon");
        }
        el().addStyleName((icon != null
                ? (!Util.isEmptyString(html) ? " " + baseStyle + "-text-icon" : " " + baseStyle + "-icon")
                : " " + baseStyle + "-noicon"));
        Element e = null;

        if (icon != null) {
            e = (Element) icon.createElement().cast();

            Accessibility.setRole(e, "presentation");
            fly(e).addStyleName(baseStyle + "-image");

            buttonEl.insertFirst(e);
            El.fly(e).makePositionable(true);

        }
        autoWidth();
        alignIcon(e);
    }
    this.icon = icon;
}

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  . java 2 s . co 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.IconButton.java

License:sencha.com license

protected void onRender(Element target, int index) {
    setElement(DOM.createDiv(), target, index);
    addStyleName("x-icon-btn");
    addStyleName("x-nodrag");
    addStyleName(style);//from w w w  .  ja v  a  2  s . c om
    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);
    }
}

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

License:sencha.com license

protected void setAriaRole(String roleName) {
    Accessibility.setRole(getElement(), roleName);
}

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;/*from  w  ww  . j a v  a2s .  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);
    }
}