com.google.gwt.dom.client.OptGroupElement Java Examples
The following examples show how to use
com.google.gwt.dom.client.OptGroupElement.
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: GroupedListBox.java From swcv with MIT License | 5 votes |
protected boolean isMatchingGroup(Node child, String group) { if (isGroup(child)) { OptGroupElement optgroup = optgroup(child); return group.equals(optgroup.getLabel()); } else { return false; } }
Example #2
Source File: GroupedListBox.java From swcv with MIT License | 5 votes |
protected OptGroupElement findOptGroupElement(String name) { if (name == null) return null; NodeList<Element> optgroups = getElement().getElementsByTagName("OPTGROUP"); for (int i = 0; i < optgroups.getLength(); i++) { Element optgroup = optgroups.getItem(i); if (isMatchingGroup(optgroup, name)) { return OptGroupElement.as(optgroup); } } return null; }
Example #3
Source File: GroupedListBox.java From swcv with MIT License | 4 votes |
private OptGroupElement optgroup(Node node) { if (node == null) return null; return OptGroupElement.as(Element.as(node)); }
Example #4
Source File: GroupedListBox.java From swcv with MIT License | 4 votes |
@Override public void insertItem(String item, String value, int index) { // find the delimiter if there is one int pipe = (item != null) ? item.indexOf('|') : -1; while (pipe != -1 && pipe + 1 != item.length() && item.charAt(pipe + 1) == '|') { pipe = item.indexOf('|', pipe + 2); } // extract the group if we found a delimiter String group = null; if (pipe != -1) { group = item.substring(0, pipe).trim(); item = item.substring(pipe + 1).trim(); // make sure we convert || -> | in the group name group = group.replace("||", "|"); } Element parent = getSelectElement(); Node before = null; if (group != null) { OptGroupElement optgroup = findOptGroupElement(group); if (optgroup != null) { // add it to this optgroup parent = optgroup; // adjust the index to inside the group int adjusted = getIndexInGroup(group, index); // we had a real index (wasn't negative which means // add to the end), but it was too low for this group. // put it at the beginning of the group. if (adjusted < 0 && index >= 0) { adjusted = 0; } // check the range and if it's out of range, we'll // just add it to the end // of the group (before == null) if (0 <= adjusted && adjusted < optgroup.getChildCount()) { before = optgroup.getChild(adjusted); } } else { // add a new group and add the item to it optgroup = Document.get().createOptGroupElement(); optgroup.setLabel(group); parent.appendChild(optgroup); parent = optgroup; before = null; } } else { // make sure we're not past the initial "group" of // ungrouped options int max = getIndexOfFirstGroup(); if (index < 0 || index > max) { before = (max < parent.getChildCount()) ? parent.getChild(max) : null; } else if (0 <= index && index < parent.getChildCount()) { before = parent.getChild(index); } } OptionElement option = createOption(item, value); parent.insertBefore(option, before); }
Example #5
Source File: OptGroup.java From gwt-material with Apache License 2.0 | 2 votes |
/** * Option label for use in hierarchical menus. * * @see <a * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION">W3C * HTML Specification</a> */ public String getLabel() { return OptGroupElement.as(this.getElement()).getLabel(); }
Example #6
Source File: OptGroup.java From gwt-material with Apache License 2.0 | 2 votes |
/** * The control is unavailable in this context. * * @see <a * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C * HTML Specification</a> */ public boolean isDisabled() { return OptGroupElement.as(this.getElement()).isDisabled(); }
Example #7
Source File: OptGroup.java From gwt-material with Apache License 2.0 | 2 votes |
/** * The control is unavailable in this context. * * @see <a * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-disabled">W3C * HTML Specification</a> */ public void setDisabled(boolean disabled) { OptGroupElement.as(this.getElement()).setDisabled(disabled); }
Example #8
Source File: OptGroup.java From gwt-material with Apache License 2.0 | 2 votes |
/** * Option label for use in hierarchical menus. * * @see <a * href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-label-OPTION">W3C * HTML Specification</a> */ public void setLabel(String label) { OptGroupElement.as(this.getElement()).setLabel(label); }