/** * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelected(final boolean selected) { setSelected(selected, true, false, false, false); return getPage(); }
/** * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelected(final boolean selected) { setSelected(selected, true, false, false, false); return getPage(); }
/** * {@inheritDoc} */ @Override public boolean handles(final Event event) { if (MouseEvent.TYPE_MOUSE_OVER.equals(event.getType()) && getPage().getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_FOR_DISABLED_OPTION)) { return true; } return super.handles(event); } }
/** * {@inheritDoc} */ @Override public boolean handles(final Event event) { if (MouseEvent.TYPE_MOUSE_OVER.equals(event.getType()) && getPage().getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_FOR_DISABLED_OPTION)) { return true; } return super.handles(event); } }
/** * {@inheritDoc} */ @Override public Page mouseOver(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { final SgmlPage page = getPage(); if (page.getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_NEVER_FOR_SELECT_OPTION)) { return page; } return super.mouseOver(shiftKey, ctrlKey, altKey, button); }
/** * {@inheritDoc} */ @Override public Page mouseOver(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) { final SgmlPage page = getPage(); if (page.getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_NEVER_FOR_SELECT_OPTION)) { return page; } return super.mouseOver(shiftKey, ctrlKey, altKey, button); }
/** * Sets the selected state of this option. This will possibly also change the * selected properties of sibling option elements. * * @param selected true if this option should be selected * @return the page that occupies this window after this change is made (may or * may not be the same as the original page) */ public Page setSelected(boolean selected) { if (selected == isSelected()) { return getPage(); } final HtmlSelect select = getEnclosingSelect(); if (select != null) { if (!select.isMultipleSelectEnabled() && select.getOptionSize() == 1) { selected = true; } return select.setSelectedAttribute(this, selected); } // for instance from JS for an option created by document.createElement('option') // and not yet added to a select setSelectedInternal(selected); return getPage(); }
/** * Sets the text for this HtmlOption. * @param text the text */ public void setText(final String text) { if (getPage().getWebClient().getBrowserVersion().isIE() && (text == null || text.length() == 0)) { removeAllChildren(); } else { final DomNode child = getFirstChild(); if (child == null) { appendChild(new DomText(getPage(), text)); } else { child.setNodeValue(text); } } }
/** * Sets the text for this HtmlOption. * @param text the text */ public void setText(final String text) { if (getPage().getWebClient().getBrowserVersion().isIE() && (text == null || text.length() == 0)) { removeAllChildren(); } else { final DomNode child = getFirstChild(); if (child == null) { appendChild(new DomText(getPage(), text)); } else { child.setNodeValue(text); } } }
/** * Sets the text for this HtmlOption. * @param text the text */ public void setText(final String text) { if (getPage().getWebClient().getBrowserVersion().isIE() && (text == null || text.length() == 0)) { removeAllChildren(); } else { final DomNode child = getFirstChild(); if (child == null) { appendChild(new DomText(getPage(), text)); } else { child.setNodeValue(text); } } }
/** * Returns <tt>true</tt> if the disabled attribute is set for this element. Note that this * method always returns <tt>false</tt> when emulating IE, because IE does not allow individual * options to be disabled. * * @return <tt>true</tt> if the disabled attribute is set for this element (always <tt>false</tt> * when emulating IE) */ public final boolean isDisabled() { if (getPage().getWebClient().getBrowserVersion().hasFeature( BrowserVersionFeatures.HTMLOPTION_PREVENT_DISABLED)) { return false; } return hasAttribute("disabled"); }
/** * Sets the text for this HtmlOption. * @param text the text */ public void setText(final String text) { if (text == null || text.isEmpty()) { removeAllChildren(); } else { final DomNode child = getFirstChild(); if (child == null) { appendChild(new DomText(getPage(), text)); } else { child.setNodeValue(text); } } }
/** * Returns <tt>true</tt> if the disabled attribute is set for this element. Note that this * method always returns <tt>false</tt> when emulating IE, because IE does not allow individual * options to be disabled. * * @return <tt>true</tt> if the disabled attribute is set for this element (always <tt>false</tt> * when emulating IE) */ public final boolean isDisabled() { if (getPage().getWebClient().getBrowserVersion().hasFeature( BrowserVersionFeatures.HTMLOPTION_PREVENT_DISABLED)) { return false; } return hasAttribute("disabled"); }
/** * Returns <tt>true</tt> if the disabled attribute is set for this element. Note that this * method always returns <tt>false</tt> when emulating IE, because IE does not allow individual * options to be disabled. * * @return <tt>true</tt> if the disabled attribute is set for this element (always <tt>false</tt> * when emulating IE) */ public final boolean isDisabled() { if (getPage().getWebClient().getBrowserVersion().hasFeature( BrowserVersionFeatures.HTMLOPTION_PREVENT_DISABLED)) { return false; } return hasAttribute("disabled"); }
/** * Sets the text for this HtmlOption. * @param text the text */ public void setText(final String text) { if (text == null || text.isEmpty()) { removeAllChildren(); } else { final DomNode child = getFirstChild(); if (child == null) { appendChild(new DomText(getPage(), text)); } else { child.setNodeValue(text); } } }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <P extends Page> P click(final Event event, final boolean ignoreVisibility) throws IOException { if (hasFeature(EVENT_ONCLICK_FOR_SELECT_ONLY)) { final SgmlPage page = getPage(); if (isDisabled()) { return (P) page; } if (isStateUpdateFirst()) { doClickStateUpdate(event.isShiftKey(), event.isCtrlKey()); } return getEnclosingSelect().click(event, ignoreVisibility); } return super.click(event, ignoreVisibility); }
/** * {@inheritDoc} */ @Override @SuppressWarnings("unchecked") public <P extends Page> P click(final Event event, final boolean ignoreVisibility) throws IOException { if (hasFeature(EVENT_ONCLICK_FOR_SELECT_ONLY)) { final SgmlPage page = getPage(); if (isDisabled()) { return (P) page; } if (isStateUpdateFirst()) { doClickStateUpdate(event.isShiftKey(), event.isCtrlKey()); } return getEnclosingSelect().click(event, ignoreVisibility); } return super.click(event, ignoreVisibility); }
/** * Changes the number of options: removes options if the new length * is less than the current one else add new empty options to reach the * new length. * @param newLength the new length property value */ public void jsxSet_length(final int newLength) { final int currentLength = htmlSelect_.getOptionSize(); if (currentLength > newLength) { htmlSelect_.setOptionSize(newLength); } else { for (int i = currentLength; i < newLength; i++) { final HtmlOption option = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( htmlSelect_.getPage(), HtmlOption.TAG_NAME, null); htmlSelect_.appendOption(option); if (!getBrowserVersion().isIE()) { option.appendChild(new DomText(option.getPage(), "")); } } } }
/** * Changes the number of options: removes options if the new length * is less than the current one else add new empty options to reach the * new length. * @param newLength the new length property value */ public void jsxSet_length(final int newLength) { final int currentLength = htmlSelect_.getOptionSize(); if (currentLength > newLength) { htmlSelect_.setOptionSize(newLength); } else { for (int i = currentLength; i < newLength; i++) { final HtmlOption option = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( htmlSelect_.getPage(), HtmlOption.TAG_NAME, null); htmlSelect_.appendOption(option); if (!getBrowserVersion().isIE()) { option.appendChild(new DomText(option.getPage(), "")); } } } }
/** * Changes the number of options: removes options if the new length * is less than the current one else add new empty options to reach the * new length. * @param newLength the new length property value */ public void jsxSet_length(final int newLength) { final int currentLength = htmlSelect_.getOptionSize(); if (currentLength > newLength) { htmlSelect_.setOptionSize(newLength); } else { for (int i = currentLength; i < newLength; i++) { final HtmlOption option = (HtmlOption) HTMLParser.getFactory(HtmlOption.TAG_NAME).createElement( htmlSelect_.getPage(), HtmlOption.TAG_NAME, null); htmlSelect_.appendOption(option); if (!getBrowserVersion().isIE()) { option.appendChild(new DomText(option.getPage(), "")); } } } }