Java Code Examples for com.google.gwt.dom.client.Element#getPropertyBoolean()

The following examples show how to use com.google.gwt.dom.client.Element#getPropertyBoolean() . 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: SelectionUtil.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Takes an html selection and returns it, or null if it's not related to editor content.
 *
 * @param htmlSelection Selection range to filter.
 * @return htmlSelection or null if there's no related content.
 */
public static FocusedPointRange<Node> filterNonContentSelection(
    FocusedPointRange<Node> htmlSelection) {
  if (htmlSelection == null) {
    return null; // quick exit
  }

  // get just the focus point, finding the element it is inside.
  Point<Node> htmlFocus = htmlSelection.getFocus();
  Element el;
  if (htmlFocus.isInTextNode()) {
    el = htmlFocus.getContainer().getParentElement();
  } else {
    el = htmlFocus.getContainer().cast();
  }

  // Assume given range is always in the editor, the htmlHelper should guarantee that.
  while (!NodeManager.hasBackReference(el)) {
    if (NodeManager.getTransparency(el) == Skip.DEEP
        || el.getPropertyBoolean(ContentElement.COMPLEX_IMPLEMENTATION_MARKER)) {

      // Exception: when we explicitly want the selection still to be reported
      if (!NodeManager.mayContainSelectionEvenWhenDeep(el)) {
        htmlSelection = null;
        break;
      }
    }
    el = el.getParentElement();
  }

  return htmlSelection;
}
 
Example 2
Source File: SelectionUtil.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Takes an html selection and returns it, or null if it's not related to editor content.
 *
 * @param htmlSelection Selection range to filter.
 * @return htmlSelection or null if there's no related content.
 */
public static FocusedPointRange<Node> filterNonContentSelection(
    FocusedPointRange<Node> htmlSelection) {
  if (htmlSelection == null) {
    return null; // quick exit
  }

  // get just the focus point, finding the element it is inside.
  Point<Node> htmlFocus = htmlSelection.getFocus();
  Element el;
  if (htmlFocus.isInTextNode()) {
    el = htmlFocus.getContainer().getParentElement();
  } else {
    el = htmlFocus.getContainer().cast();
  }

  // Assume given range is always in the editor, the htmlHelper should guarantee that.
  while (!NodeManager.hasBackReference(el)) {
    if (NodeManager.getTransparency(el) == Skip.DEEP
        || el.getPropertyBoolean(ContentElement.COMPLEX_IMPLEMENTATION_MARKER)) {

      // Exception: when we explicitly want the selection still to be reported
      if (!NodeManager.mayContainSelectionEvenWhenDeep(el)) {
        htmlSelection = null;
        break;
      }
    }
    el = el.getParentElement();
  }

  return htmlSelection;
}
 
Example 3
Source File: DomUtils.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
/**
 * Returns true if the element has the disabled attribute.
 */
public static boolean isEnabled(Element element) {
    return element.getPropertyBoolean("disabled");        
}
 
Example 4
Source File: NodeManager.java    From swellrt with Apache License 2.0 2 votes vote down vote up
/**
 * We usually ignore deep nodes completely when it comes to the selection - if
 * the selection is in a deep node, we usually report there is no selection.
 *
 * If this method returns true, we should make an exception, and report the
 * selection as just outside this node (perhaps recursing as necessary).
 */
public static boolean mayContainSelectionEvenWhenDeep(Element e) {
  return e.getPropertyBoolean(MAY_CONTAIN_SELECTION);
}
 
Example 5
Source File: NodeManager.java    From incubator-retired-wave with Apache License 2.0 2 votes vote down vote up
/**
 * We usually ignore deep nodes completely when it comes to the selection - if
 * the selection is in a deep node, we usually report there is no selection.
 *
 * If this method returns true, we should make an exception, and report the
 * selection as just outside this node (perhaps recursing as necessary).
 */
public static boolean mayContainSelectionEvenWhenDeep(Element e) {
  return e.getPropertyBoolean(MAY_CONTAIN_SELECTION);
}