/** * Returns the type of this input. * @return the type */ @Override public String jsxGet_type() { final String type; if (getHtmlSelect().isMultipleSelectEnabled()) { type = "select-multiple"; } else { type = "select-one"; } return type; }
/** * Returns the type of this input. * @return the type */ @Override public String jsxGet_type() { final String type; if (getHtmlSelect().isMultipleSelectEnabled()) { type = "select-multiple"; } else { type = "select-one"; } return type; }
/** * Returns the type of this input. * @return the type */ @Override public String jsxGet_type() { final String type; if (getHtmlSelect().isMultipleSelectEnabled()) { type = "select-multiple"; } else { type = "select-one"; } return type; }
/** * Returns the type of this input. * @return the type */ @JsxGetter public String getType() { final String type; if (getHtmlSelect().isMultipleSelectEnabled()) { type = "select-multiple"; } else { type = "select-one"; } return type; }
/** * Process {@link HtmlSelect}. * * @param builder the StringBuilder to add to * @param htmlSelect the target to process */ protected void appendSelect(final StringBuilder builder, final HtmlSelect htmlSelect) { final List<HtmlOption> options; if (htmlSelect.isMultipleSelectEnabled()) { options = htmlSelect.getOptions(); } else { options = htmlSelect.getSelectedOptions(); } for (final Iterator<HtmlOption> i = options.iterator(); i.hasNext();) { final HtmlOption currentOption = i.next(); appendNode(builder, currentOption); if (i.hasNext()) { builder.append(AS_TEXT_BLOCK_SEPARATOR); } } }
/** * Returns the type of this input. * @return the type */ @JsxGetter public String getType() { final String type; if (getHtmlSelect().isMultipleSelectEnabled()) { type = "select-multiple"; } else { type = "select-one"; } return type; }
/** * @param htmlSelect */ private void appendHtmlSelect(final HtmlSelect htmlSelect) { final List<HtmlOption> options; if (htmlSelect.isMultipleSelectEnabled()) { options = htmlSelect.getOptions(); } else { options = htmlSelect.getSelectedOptions(); } for (final Iterator<HtmlOption> i = options.iterator(); i.hasNext();) { final HtmlOption currentOption = i.next(); appendNode(currentOption); if (i.hasNext()) { doAppendBlockSeparator(); } } }
/** * @param htmlSelect */ private void appendHtmlSelect(final HtmlSelect htmlSelect) { final List<HtmlOption> options; if (htmlSelect.isMultipleSelectEnabled()) { options = htmlSelect.getOptions(); } else { options = htmlSelect.getSelectedOptions(); } for (final Iterator<HtmlOption> i = options.iterator(); i.hasNext();) { final HtmlOption currentOption = i.next(); appendNode(currentOption); if (i.hasNext()) { doAppendBlockSeparator(); } } }
/** * @param htmlSelect */ private void appendHtmlSelect(final HtmlSelect htmlSelect) { final List<HtmlOption> options; if (htmlSelect.isMultipleSelectEnabled()) { options = htmlSelect.getOptions(); } else { options = htmlSelect.getSelectedOptions(); } for (final Iterator<HtmlOption> i = options.iterator(); i.hasNext();) { final HtmlOption currentOption = i.next(); appendNode(currentOption); if (i.hasNext()) { doAppendBlockSeparator(); } } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); } else { for (final HtmlOption option : getOptions()) { option.setSelectedInternal(option == selectedOption && isSelected); } } }
@Override public void unselectOptions(String selectName, String[] options) { HtmlSelect sel = getForm().getSelectByName(selectName); if (!sel.isMultipleSelectEnabled() && options.length > 1) { throw new RuntimeException("Multiselect not enabled"); } for (String option : options) { boolean found = false; for (HtmlOption opt : sel.getOptions()) { if (opt.asText().equals(option)) { sel.setSelectedAttribute(opt, false); found = true; break; } } if (!found) { throw new RuntimeException("Option " + option + " not found"); } } }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Resets the selectedIndex if needed. */ public void ensureSelectedIndex() { if (getOptionSize() == 0) { setSelectedIndex(-1); } else if (getSelectedIndex() == -1 && !isMultipleSelectEnabled()) { setSelectedIndex(0); } }
private void doSelectOption(final HtmlOption selectedOption, final boolean isSelected, final boolean shiftKey, final boolean ctrlKey, final boolean isClick) { // caution the HtmlOption may have been created from js and therefore the select now need // to "know" that it is selected if (isMultipleSelectEnabled()) { selectedOption.setSelectedInternal(isSelected); if (isClick && !ctrlKey) { if (!shiftKey) { setOnlySelected(selectedOption, isSelected); lastSelectedIndex_ = getOptions().indexOf(selectedOption); } else if (isSelected && lastSelectedIndex_ != -1) { final List<HtmlOption> options = getOptions(); final int newIndex = options.indexOf(selectedOption); for (int i = 0; i < options.size(); i++) { options.get(i).setSelectedInternal(isBetween(i, lastSelectedIndex_, newIndex)); } } } } else { setOnlySelected(selectedOption, isSelected); } }
/** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br> * * Resets the selectedIndex if needed. */ public void ensureSelectedIndex() { if (getOptionSize() == 0) { setSelectedIndex(-1); } else if (getSelectedIndex() == -1 && !isMultipleSelectEnabled()) { setSelectedIndex(0); } }
/** * Sets the value of the {@code selected} property. * @param selected the new selected property */ @JsxSetter public void setSelected(final boolean selected) { final HtmlOption optionNode = (HtmlOption) getDomNodeOrNull(); final HtmlSelect enclosingSelect = optionNode.getEnclosingSelect(); if (!selected && optionNode.isSelected() && enclosingSelect != null && !enclosingSelect.isMultipleSelectEnabled()) { enclosingSelect.getOption(0).setSelectedFromJavaScript(true); } else { optionNode.setSelectedFromJavaScript(selected); } }
/** * Sets the value of the {@code selected} property. * @param selected the new selected property */ @JsxSetter public void setSelected(final boolean selected) { final HtmlOption optionNode = (HtmlOption) getDomNodeOrNull(); final HtmlSelect enclosingSelect = optionNode.getEnclosingSelect(); if (!selected && optionNode.isSelected() && enclosingSelect != null && !enclosingSelect.isMultipleSelectEnabled()) { enclosingSelect.getOption(0).setSelectedFromJavaScript(true); } else { optionNode.setSelectedFromJavaScript(selected); } }
public boolean toggle() { assertElementNotStale(); try { if (element instanceof HtmlCheckBoxInput) { ((HtmlCheckBoxInput) element).click(); return isSelected(); } if (element instanceof HtmlOption) { HtmlOption option = (HtmlOption) element; HtmlSelect select = option.getEnclosingSelect(); if (select.isMultipleSelectEnabled()) { option.setSelected(!option.isSelected()); return isSelected(); } } throw new UnsupportedOperationException("You may only toggle checkboxes or options in a select which allows multiple selections: " + getTagName()); } catch (IOException e) { throw new WebDriverException("Unexpected exception: " + e); } }
/** * Selects the option if it's not already selected. * {@inheritDoc} */ @Override protected boolean doClickStateUpdate(final boolean shiftKey, final boolean ctrlKey) throws IOException { boolean changed = false; if (!isSelected()) { setSelected(true, true, true, shiftKey, ctrlKey); changed = true; } else if (getEnclosingSelect().isMultipleSelectEnabled()) { if (ctrlKey) { setSelected(false, true, true, shiftKey, ctrlKey); changed = true; } else { getEnclosingSelect().setOnlySelected(this, true); } } super.doClickStateUpdate(shiftKey, ctrlKey); return changed; }