com.google.gwt.aria.client.Roles Java Examples
The following examples show how to use
com.google.gwt.aria.client.Roles.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterBox.java From unitime with Apache License 2.0 | 6 votes |
public ChipPanel(Chip chip, String color) { iChip = chip; setStyleName("chip"); addStyleName(color); iLabel = new Label(chip.getTranslatedValue()); iLabel.setStyleName("text"); add(iLabel); iButton = new HTML("×"); iButton.setStyleName("button"); add(iButton); if (chip.hasToolTip()) setTitle(toString() + "\n" + chip.getToolTip()); else setTitle(toString()); Roles.getDocumentRole().setAriaHiddenState(getElement(), true); }
Example #2
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
public void setTextInputAllowed(boolean textInputAllowed) { debug("VComboBoxMultiselect: setTextInputAllowed()"); // Always update styles as they might have been overwritten if (textInputAllowed) { removeStyleDependentName(STYLE_NO_INPUT); Roles.getTextboxRole() .removeAriaReadonlyProperty(this.tb.getElement()); } else { addStyleDependentName(STYLE_NO_INPUT); Roles.getTextboxRole() .setAriaReadonlyProperty(this.tb.getElement(), true); } if (this.textInputEnabled == textInputAllowed) { return; } this.textInputEnabled = textInputAllowed; updateReadOnly(); }
Example #3
Source File: SimpleForm.java From unitime with Apache License 2.0 | 6 votes |
public int addRow(Widget header, Widget widget, int colSpan) { header.addStyleName("label-cell"); int row = getRowCount(); setWidget(row, 0, header); getCellFormatter().setStyleName(row, 0, "label-td"); if (widget instanceof HasMobileScroll) { ScrollPanel scroll = new ScrollPanel(widget); scroll.addStyleName("table-cell"); setWidget(row, 1, scroll); getCellFormatter().setStyleName(row, 1, "table-td"); } else { widget.addStyleName("widget-cell"); setWidget(row, 1, widget); getCellFormatter().setStyleName(row, 1, "widget-td"); } if (colSpan != 1) getFlexCellFormatter().setColSpan(row, 1, colSpan); if (header.getElement().getId() == null || header.getElement().getId().isEmpty()) header.getElement().setId(DOM.createUniqueId()); if (widget instanceof UniTimeWidget) Roles.getTextboxRole().setAriaLabelledbyProperty(((UniTimeWidget)widget).getWidget().getElement(), Id.of(header.getElement())); else Roles.getTextboxRole().setAriaLabelledbyProperty(widget.getElement(), Id.of(header.getElement())); return row; }
Example #4
Source File: FlowForm.java From unitime with Apache License 2.0 | 6 votes |
public int addRow(Widget header, Widget... widgets) { if (header.getElement().getId() == null || header.getElement().getId().isEmpty()) header.getElement().setId(DOM.createUniqueId()); P head = new P(DOM.createSpan(), "header-cell"); head.add(header); add(head); for (Widget widget: widgets) { P body = new P(DOM.createSpan(), "content-cell"); add(body); if (widget instanceof UniTimeTable) { ScrollPanel scroll = new ScrollPanel(widget); scroll.addStyleName("scroll"); body.add(scroll); } else { body.add(widget); } } if (widgets.length > 0) { if (widgets[0] instanceof UniTimeWidget) Roles.getTextboxRole().setAriaLabelledbyProperty(((UniTimeWidget)widgets[0]).getWidget().getElement(), Id.of(header.getElement())); else Roles.getTextboxRole().setAriaLabelledbyProperty(widgets[0].getElement(), Id.of(header.getElement())); } return getWidgetCount() - widgets.length; }
Example #5
Source File: SuggestionsSelectList.java From hawkbit with Eclipse Public License 1.0 | 6 votes |
/** * Adds suggestions to the suggestion menu bar. * * @param suggestions * the suggestions to be added * @param textFieldWidget * the text field which the suggestion is attached to to bring * back the focus after selection * @param popupPanel * pop-up panel where the menu bar is shown to hide it after * selection * @param suggestionServerRpc * server RPC to ask for new suggestion after a selection */ public void addItems(final List<SuggestTokenDto> suggestions, final VTextField textFieldWidget, final PopupPanel popupPanel, final TextFieldSuggestionBoxServerRpc suggestionServerRpc) { for (int index = 0; index < suggestions.size(); index++) { final SuggestTokenDto suggestToken = suggestions.get(index); final MenuItem mi = new MenuItem(suggestToken.getSuggestion(), true, new ScheduledCommand() { @Override public void execute() { final String tmpSuggestion = suggestToken.getSuggestion(); final TokenStartEnd tokenStartEnd = tokenMap.get(tmpSuggestion); final String text = textFieldWidget.getValue(); final StringBuilder builder = new StringBuilder(text); builder.replace(tokenStartEnd.getStart(), tokenStartEnd.getEnd() + 1, tmpSuggestion); textFieldWidget.setValue(builder.toString(), true); popupPanel.hide(); textFieldWidget.setFocus(true); suggestionServerRpc.suggest(builder.toString(), textFieldWidget.getCursorPos()); } }); tokenMap.put(suggestToken.getSuggestion(), new TokenStartEnd(suggestToken.getStart(), suggestToken.getEnd())); Roles.getListitemRole().set(mi.getElement()); WidgetUtil.sinkOnloadForImages(mi.getElement()); addItem(mi); } }
Example #6
Source File: SuggestionsContainer.java From cuba with Apache License 2.0 | 6 votes |
protected void selectItem(SuggestionItem item) { if (item == selectedItem) { return; } if (selectedItem != null) { selectedItem.updateSelection(false); } if (item != null) { item.updateSelection(true); Roles.getMenubarRole().setAriaActivedescendantProperty(getElement(), Id.of(item.getElement())); } selectedItem = item; updateContainerScroll(item); }
Example #7
Source File: CubaLabelConnector.java From cuba with Apache License 2.0 | 6 votes |
protected void updateContextHelp(CubaLabelWidget widget) { if (isContextHelpIconEnabled(getState())) { widget.contextHelpIcon = DOM.createSpan(); widget.contextHelpIcon.setInnerHTML("?"); widget.contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME); if (hasContextHelpIconListeners(getState())) { widget.contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME); } Roles.getTextboxRole().setAriaHiddenState(widget.contextHelpIcon, true); widget.getElement().appendChild(widget.contextHelpIcon); widget.contextHelpClickHandler = this::contextHelpIconClick; } }
Example #8
Source File: CellTreeNodeView.java From consulo with Apache License 2.0 | 6 votes |
private void updateAriaAttributes(int setSize) { // Early out if this is a root node. if (isRootNode()) { return; } Roles.getTreeitemRole().setAriaSetsizeProperty(getElement(), setSize); int selectionIndex = parentNode.indexOf(this); Roles.getTreeitemRole().setAriaPosinsetProperty(getElement(), selectionIndex + 1); // Set 'aria-expanded' state // don't set aria-expanded on the leaf nodes if (isLeaf()) { Roles.getTreeitemRole().removeAriaExpandedState(getElement()); } else { Roles.getTreeitemRole().setAriaExpandedState(getElement(), ExpandedValue.of(open)); } Roles.getTreeitemRole().setAriaLevelProperty(getElement(), this.depth); }
Example #9
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
public void setTextInputAllowed(boolean textInputAllowed) { debug("VComboBoxMultiselect: setTextInputAllowed()"); // Always update styles as they might have been overwritten if (textInputAllowed) { removeStyleDependentName(STYLE_NO_INPUT); Roles.getTextboxRole() .removeAriaReadonlyProperty(this.tb.getElement()); } else { addStyleDependentName(STYLE_NO_INPUT); Roles.getTextboxRole() .setAriaReadonlyProperty(this.tb.getElement(), true); } if (this.textInputEnabled == textInputAllowed) { return; } this.textInputEnabled = textInputAllowed; updateReadOnly(); }
Example #10
Source File: AriaToggleButton.java From unitime with Apache License 2.0 | 5 votes |
public AriaToggleButton(ImageResource checked, ImageResource unchecked) { iCheckedFace = checked; iUncheckedFace = unchecked; setResource(iUncheckedFace); Roles.getCheckboxRole().set(getElement()); Roles.getCheckboxRole().setAriaCheckedState(getElement(), CheckedValue.FALSE); setTabIndex(0); sinkEvents(Event.ONKEYUP | Event.ONCLICK); }
Example #11
Source File: UniTimeTable.java From unitime with Apache License 2.0 | 5 votes |
public UniTimeTable() { setCellPadding(2); setCellSpacing(0); sinkEvents(Event.ONMOUSEOVER); sinkEvents(Event.ONMOUSEOUT); sinkEvents(Event.ONCLICK); sinkEvents(Event.ONKEYDOWN); sinkEvents(Event.ONDBLCLICK); setStylePrimaryName("unitime-MainTable"); iHintPanel = new PopupPanel(); iHintPanel.setStyleName("unitime-PopupHint"); Roles.getGridRole().set(getElement()); }
Example #12
Source File: AriaTabBar.java From unitime with Apache License 2.0 | 5 votes |
@Override public boolean selectTab(int index, boolean fireEvents) { if (getSelectedTab() >= 0) { Roles.getTabRole().setAriaSelectedState(getTabElement(getSelectedTab()), SelectedValue.FALSE); Roles.getTabRole().setAriaLabelProperty(getTabElement(getSelectedTab()), ARIA.tabNotSelected(1 + getSelectedTab(), getTabCount(), getTabLabel(getSelectedTab()))); } boolean ret = super.selectTab(index, fireEvents); if (getSelectedTab() >= 0) { Roles.getTabRole().setAriaSelectedState(getTabElement(getSelectedTab()), SelectedValue.TRUE); Roles.getTabRole().setAriaLabelProperty(getTabElement(getSelectedTab()), ARIA.tabSelected(1 + getSelectedTab(), getTabCount(), getTabLabel(getSelectedTab()))); if (fireEvents) AriaStatus.getInstance().setHTML(ARIA.onTabSelected(getTabLabel(getSelectedTab()))); } return ret; }
Example #13
Source File: AriaTabBar.java From unitime with Apache License 2.0 | 5 votes |
@Override public void removeTab(int index) { super.removeTab(index); Id ids[] = new Id[getTabCount()]; for (int i = 0; i < getTabCount(); i++) { Roles.getTabRole().setAriaLabelProperty(getTabElement(i), ARIA.tabNotSelected(1 + i, getTabCount(), getTabLabel(i))); ids[i] = Id.of(getTabElement(i)); } Roles.getTablistRole().setAriaOwnsProperty(getElement(), ids); if (getSelectedTab() >= 0) { Roles.getTabRole().setAriaSelectedState(getTabElement(getSelectedTab()), SelectedValue.TRUE); Roles.getTabRole().setAriaLabelProperty(getTabElement(getSelectedTab()), ARIA.tabSelected(1 + getSelectedTab(), getTabCount(), getTabLabel(getSelectedTab()))); } }
Example #14
Source File: AriaTabBar.java From unitime with Apache License 2.0 | 5 votes |
@Override protected void insertTabWidget(Widget widget, int beforeIndex) { super.insertTabWidget(widget, beforeIndex); Roles.getTabRole().setAriaSelectedState(getTabElement(beforeIndex), SelectedValue.FALSE); getTabElement(beforeIndex).setId(DOM.createUniqueId()); Id ids[] = new Id[getTabCount()]; for (int i = 0; i < getTabCount(); i++) { Roles.getTabRole().setAriaLabelProperty(getTabElement(i), ARIA.tabNotSelected(1 + i, getTabCount(), getTabLabel(i))); ids[i] = Id.of(getTabElement(i)); } Roles.getTablistRole().setAriaOwnsProperty(getElement(), ids); }
Example #15
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Default constructor */ SuggestionPopup() { super(true, false); debug("VComboBoxMultiselect.SP: constructor()"); setOwner(VComboBoxMultiselect.this); this.menu = new SuggestionMenu(); setWidget(this.menu); getElement().getStyle() .setZIndex(Z_INDEX); final Element root = getContainerElement(); this.up.setInnerHTML("<span>Prev</span>"); DOM.sinkEvents(this.up, Event.ONCLICK); this.down.setInnerHTML("<span>Next</span>"); DOM.sinkEvents(this.down, Event.ONCLICK); root.insertFirst(this.up); root.appendChild(this.down); root.appendChild(this.status); DOM.sinkEvents(root, Event.ONMOUSEDOWN | Event.ONMOUSEWHEEL); addCloseHandler(this); Roles.getListRole() .set(getElement()); setPreviewingAllNativeEvents(true); }
Example #16
Source File: AriaAnchor.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setAriaLabel(String text) { if (text == null || text.isEmpty()) Roles.getLinkRole().removeAriaLabelledbyProperty(getElement()); else Roles.getLinkRole().setAriaLabelProperty(getElement(), text); }
Example #17
Source File: AddMeetingsDialog.java From unitime with Apache License 2.0 | 5 votes |
public String toAriaLabel(boolean hover, boolean description, boolean selection) { String label = ""; if (hover && iHoverDate != null && iHoverLoc != null) { P p = iPanels.get(iHoverDate + ":" + iHoverLoc.getUniqueId()); if (iSelected.contains(iHoverDate + ":" + iHoverLoc.getUniqueId())) { label = ARIA.selectedSelection(Roles.getTextboxRole().getAriaLabelProperty(p.getElement())); } else { label = Roles.getTextboxRole().getAriaLabelProperty(p.getElement()); } } else if (description) { if (EventCookie.getInstance().areRoomsHorizontal()) label = ARIA.meetingSelectionDescriptionRoomsHorizontal(getDates().size(), 1 + iIndex, Math.min(iIndex + iStep, getRooms().size())); else label = ARIA.meetingSelectionDescriptionDatesHorizontal(getRooms().size(), 1 + iIndex, Math.min(iIndex + iStep, getDates().size())); } if (selection) { if (iSelected.isEmpty()) { label += " " + ARIA.meetingSelectionNothingSelected(); } else { String selected = ""; for (Integer date: getDates()) for (Entity room: getRooms()) { if (iSelected.contains(date + ":" + room.getUniqueId())) { if (!selected.isEmpty()) selected += ", "; selected += ARIA.dateRoomSelection(sAriaDateFormat.format(iDates.getDate(date)), room.getName()); } } label += " " + ARIA.meetingSelectionSelected(selected); } } return label; }
Example #18
Source File: AriaToggleButton.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setValue(Boolean value, boolean fireEvents) { if (value == null) value = false; iValue = value; setResource(iValue ? iCheckedFace : iUncheckedFace); Roles.getCheckboxRole().setAriaCheckedState(getElement(), iValue ? CheckedValue.TRUE : CheckedValue.FALSE); if (fireEvents) ValueChangeEvent.fire(this, getValue()); }
Example #19
Source File: ImageButton.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setEnabled(boolean enabled) { if (iEnabled != enabled) { iEnabled = enabled; setResource(enabled ? iUp : iDisabled != null ? iDisabled : iUp); if (enabled) { removeStyleName("unitime-ImageButton-disabled"); } else { addStyleName("unitime-ImageButton-disabled"); } Roles.getButtonRole().setAriaDisabledState(getElement(), !enabled); } }
Example #20
Source File: ClickableHint.java From unitime with Apache License 2.0 | 5 votes |
public ClickableHint(String text) { super(text); getElement().setTabIndex(0); setStyleName("unitime-Hint"); sinkEvents(Event.KEYEVENTS); Roles.getLinkRole().set(getElement()); }
Example #21
Source File: UniTimeWidget.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setAriaLabel(String text) { if (iWidget instanceof HasAriaLabel) { ((HasAriaLabel)iWidget).setAriaLabel(text); } else { if (iAriaLabel == null) { iAriaLabel = DOM.createLabel(); iAriaLabel.setId(DOM.createUniqueId()); iAriaLabel.setClassName("hidden-label"); DOM.appendChild(getElement(), iAriaLabel); Roles.getCheckboxRole().setAriaLabelledbyProperty(iWidget.getElement(), Id.of(iAriaLabel)); } iAriaLabel.setInnerText(text); } }
Example #22
Source File: ImageLink.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setAriaLabel(String text) { if (text == null || text.isEmpty()) Roles.getLinkRole().removeAriaLabelledbyProperty(iElement); else Roles.getLinkRole().setAriaLabelProperty(iElement, text); }
Example #23
Source File: CourseRequestBox.java From unitime with Apache License 2.0 | 5 votes |
public void addOperation(FilterOperation operation, boolean beforeFinder) { operation.addStyleName("button-image"); if (beforeFinder) iFilter.add(operation); else iFilter.insert(operation, iFilter.getWidgetIndex(iFilter.iFilterFinder)); Roles.getDocumentRole().setAriaHiddenState(operation.getElement(), true); }
Example #24
Source File: WebTable.java From unitime with Apache License 2.0 | 5 votes |
public WebTable() { iTable = new RowSelectingFlexTable(); iTable.setCellPadding(2); iTable.setCellSpacing(0); iTable.setStyleName("unitime-WebTable"); initWidget(iTable); Roles.getGridRole().set(iTable.getElement()); }
Example #25
Source File: WebTable.java From unitime with Apache License 2.0 | 5 votes |
public void setHeader(Row... header) { iHeader = header; for (int i=0; i<header.length; i++) { for (int j=0; j<header[i].getNrCells(); j++) { Cell cell = header[i].getCell(j); if (cell.getWidget() == null) { iTable.setHTML(i, j, (cell.getValue() == null || cell.getValue().isEmpty() ? " " : cell.getValue())); if (cell.getAriaLabel() != null && !cell.getAriaLabel().isEmpty()) Roles.getGridcellRole().setAriaLabelProperty(iTable.getCellFormatter().getElement(i, j), cell.getAriaLabel()); } else iTable.setWidget(i, j, cell.getWidget()); iTable.getFlexCellFormatter().setWordWrap(i, j, cell.getWordWrap()); iTable.getFlexCellFormatter().setStyleName(i, j, (cell.getStyleName() == null ? "unitime-TableHeader" : cell.getStyleName())); if (cell.getWidth() != null) iTable.getFlexCellFormatter().setWidth(i, j, cell.getWidth()); iTable.getFlexCellFormatter().setColSpan(i, j, cell.getColSpan()); iTable.getFlexCellFormatter().setRowSpan(i, j, cell.getRowSpan()); iTable.getFlexCellFormatter().setVerticalAlignment(i, j, cell.getVerticalAlignment()); iTable.getFlexCellFormatter().setHorizontalAlignment(i, j, cell.getHorizontalAlignment()); iTable.getFlexCellFormatter().getElement(i, j).setTitle(cell.getTitle()); Roles.getColumnheaderRole().set(iTable.getCellFormatter().getElement(i, j)); } Roles.getRowRole().set(iTable.getRowFormatter().getElement(i)); if (header[i].getAriaLabel() != null && !header[i].getAriaLabel().isEmpty()) { iTable.setWidget(i, header[i].getNrCells(), new AriaHiddenLabel(header[i].getAriaLabel())); } else { iTable.setHTML(i, header[i].getNrCells(), ""); } Roles.getRowheaderRole().set(iTable.getCellFormatter().getElement(i, header[i].getNrCells())); iTable.getFlexCellFormatter().setStyleName(i, header[i].getNrCells(), "unitime-TableHeader"); iTable.getFlexCellFormatter().addStyleName(i, header[i].getNrCells(), "rowheader"); } }
Example #26
Source File: AriaPasswordTextBox.java From unitime with Apache License 2.0 | 5 votes |
@Override public void setAriaLabel(String text) { if (text == null || text.isEmpty()) Roles.getTextboxRole().removeAriaLabelledbyProperty(getElement()); else Roles.getTextboxRole().setAriaLabelProperty(getElement(), text); }
Example #27
Source File: CellTreeNodeView.java From consulo with Apache License 2.0 | 5 votes |
/** * Update the image based on the current state. * * @param isLoading true if still loading data */ private void updateImage(boolean isLoading) { // Early out if this is a root node. if (isRootNode()) { return; } // Replace the image element with a new one. boolean isTopLevel = parentNode.isRootNode(); SafeHtml html = tree.getClosedImageHtml(isTopLevel); if (open) { html = isLoading ? tree.getLoadingImageHtml() : tree.getOpenImageHtml(isTopLevel); } if (nodeInfoLoaded && nodeInfo == null) { html = LEAF_IMAGE; } Element tmp = Document.get().createDivElement(); tmp.setInnerSafeHtml(html); Element imageElem = tmp.getFirstChildElement(); Element oldImg = getImageElement(); oldImg.getParentElement().replaceChild(imageElem, oldImg); // Set 'aria-expanded' state // don't set aria-expanded on the leaf nodes if (isLeaf()) { Roles.getTreeitemRole().removeAriaExpandedState(getElement()); } else { Roles.getTreeitemRole().setAriaExpandedState(getElement(), ExpandedValue.of(open)); } }
Example #28
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 5 votes |
/** * Default constructor. */ public VComboBoxMultiselect() { this.tb = createTextBox(); this.suggestionPopup = createSuggestionPopup(); this.popupOpener.addMouseDownHandler(VComboBoxMultiselect.this); Roles.getButtonRole() .setAriaHiddenState(this.popupOpener.getElement(), true); Roles.getButtonRole() .set(this.popupOpener.getElement()); this.panel.add(this.tb); this.panel.add(this.popupOpener); initWidget(this.panel); Roles.getComboboxRole() .set(this.panel.getElement()); this.tb.addKeyDownHandler(this); this.tb.addKeyUpHandler(this); this.tb.addFocusHandler(this); this.tb.addBlurHandler(this); this.panel.addDomHandler(this, ClickEvent.getType()); setStyleName(CLASSNAME); sinkEvents(Event.ONPASTE); }
Example #29
Source File: CubaFileUploadProgressWindow.java From cuba with Apache License 2.0 | 5 votes |
public CubaFileUploadProgressWindow() { super(false, true); // no autohide, modal // Different style of shadow for windows Roles.getDialogRole().set(getElement()); Roles.getDialogRole().setAriaRelevantProperty(getElement(), RelevantValue.ADDITIONS); constructDOM(); }
Example #30
Source File: CubaCheckBoxConnector.java From cuba with Apache License 2.0 | 5 votes |
@Override public void onStateChanged(StateChangeEvent stateChangeEvent) { getWidget().captionManagedByLayout = getState().captionManagedByLayout; super.onStateChanged(stateChangeEvent); if (!getWidget().captionManagedByLayout && isContextHelpIconEnabled(getState())) { if (getWidget().contextHelpIcon == null) { getWidget().contextHelpIcon = DOM.createSpan(); getWidget().contextHelpIcon.setInnerHTML("?"); getWidget().contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME); if (hasContextHelpIconListeners(getState())) { getWidget().contextHelpIcon.addClassName(CONTEXT_HELP_CLICKABLE_CLASSNAME); } Roles.getTextboxRole().setAriaHiddenState(getWidget().contextHelpIcon, true); getWidget().getElement().appendChild(getWidget().contextHelpIcon); DOM.sinkEvents(getWidget().contextHelpIcon, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK); } else { getWidget().contextHelpIcon.getStyle().clearDisplay(); } } else if (getWidget().contextHelpIcon != null) { getWidget().contextHelpIcon.getStyle() .setDisplay(Style.Display.NONE); getWidget().setAriaInvalid(false); } if (stateChangeEvent.hasPropertyChanged("readOnly")) { getWidget().setReadOnly(getState().readOnly); } }