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

The following examples show how to use com.google.gwt.dom.client.Element#removeFromParent() . 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: ViewClientCriterion.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Styles a multi-row selection with the number of elements.
 *
 * @param drag
 *            the current drag event holding the context.
 */
void setMultiRowDragDecoration(final VDragEvent drag) {
    final Widget widget = drag.getTransferable().getDragSource().getWidget();

    if (widget instanceof VScrollTable) {
        final VScrollTable table = (VScrollTable) widget;
        final int rowCount = table.selectedRowKeys.size();

        Element dragCountElement = Document.get().getElementById(SP_DRAG_COUNT);
        if (rowCount > 1 && table.selectedRowKeys.contains(table.focusedRow.getKey())) {
            if (dragCountElement == null) {
                dragCountElement = Document.get().createStyleElement();
                dragCountElement.setId(SP_DRAG_COUNT);
                final HeadElement head = HeadElement
                        .as(Document.get().getElementsByTagName(HeadElement.TAG).getItem(0));
                head.appendChild(dragCountElement);
            }
            final SafeHtml formattedCssStyle = getDraggableTemplate()
                    .multiSelectionStyle(determineActiveTheme(drag), String.valueOf(rowCount));
            final StyleElement dragCountStyleElement = StyleElement.as(dragCountElement);
            dragCountStyleElement.setInnerSafeHtml(formattedCssStyle);
        } else if (dragCountElement != null) {
            dragCountElement.removeFromParent();
        }
    }
}
 
Example 2
Source File: SelectionImplIE.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Search for node by pasting that element at a textRange and locating that
 * element directly using getElementById. This is a huge shortcut when there
 * are many nodes in parent. However, use with caution as it can fragment text
 * nodes.
 *
 * NOTE(user): The text node fragmentation is a real issue, it causes repairs
 * to happen. The constant splitting and repairing can also have performance
 * issues that needs to be investigated. We should repair the damage here,
 * when its clear how to fix the problem.
 *
 * @param target
 * @param parent
 * @return Point
 */
@SuppressWarnings("unused") // NOTE(user): Use later for nodes with many siblings.
private Point<Node> searchForRangeUsingPaste(JsTextRangeIE target, Element parent) {
  Element elem = null;
  try {
    target.pasteHTML("<b id='__paste_target__'>X</b>");
    elem = Document.get().getElementById("__paste_target__");
    Node nextSibling = elem.getNextSibling();
    if (DomHelper.isTextNode(nextSibling)) {
      return Point.inText(nextSibling, 0);
    } else {
      return Point.inElement(parent, nextSibling);
    }
  } finally {
    if (elem != null) {
      elem.removeFromParent();
    }
  }
}
 
Example 3
Source File: TransparencyUtil.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Helper to remove a list of transparent nodes from the document
 * @param elements
 */
public static void clear(List<Element> elements) {
  for (Element e : elements) {
    if (e.getParentElement() != null) {
      if (NodeManager.getTransparency(e) == Skip.DEEP) {
        e.removeFromParent();
      } else {
        DomHelper.unwrap(e);
      }
    }
    // Break circular references in browsers with poor gc
    NodeManager.setTransparentBackref(e, null);
  }

  elements.clear();
}
 
Example 4
Source File: TransparencyUtil.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Helper to remove a list of transparent nodes from the document
 * @param elements
 */
public static void clear(List<Element> elements) {
  for (Element e : elements) {
    if (e.getParentElement() != null) {
      if (NodeManager.getTransparency(e) == Skip.DEEP) {
        e.removeFromParent();
      } else {
        DomHelper.unwrap(e);
      }
    }
    // Break circular references in browsers with poor gc
    NodeManager.setTransparentBackref(e, null);
  }

  elements.clear();
}
 
Example 5
Source File: SelectionImplIE.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Search for node by pasting that element at a textRange and locating that
 * element directly using getElementById. This is a huge shortcut when there
 * are many nodes in parent. However, use with caution as it can fragment text
 * nodes.
 *
 * NOTE(user): The text node fragmentation is a real issue, it causes repairs
 * to happen. The constant splitting and repairing can also have performance
 * issues that needs to be investigated. We should repair the damage here,
 * when its clear how to fix the problem.
 *
 * @param target
 * @param parent
 * @return Point
 */
@SuppressWarnings("unused") // NOTE(user): Use later for nodes with many siblings.
private Point<Node> searchForRangeUsingPaste(JsTextRangeIE target, Element parent) {
  Element elem = null;
  try {
    target.pasteHTML("<b id='__paste_target__'>X</b>");
    elem = Document.get().getElementById("__paste_target__");
    Node nextSibling = elem.getNextSibling();
    if (DomHelper.isTextNode(nextSibling)) {
      return Point.inText(nextSibling, 0);
    } else {
      return Point.inElement(parent, nextSibling);
    }
  } finally {
    if (elem != null) {
      elem.removeFromParent();
    }
  }
}
 
Example 6
Source File: ParagraphHelperEmptyLineBr.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onChildAdded(Node child, Element paragraph) {
  Element spacer = getSpacer(paragraph);
  if (spacer.hasParentElement()) {
    spacer.removeFromParent();
  }
}
 
Example 7
Source File: HtmlDomRenderer.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/** Turns a UiBuilder rendering into a DOM element. */
private Element parseHtml(UiBuilder ui) {
  if (ui == null) {
    return null;
  }
  SafeHtmlBuilder html = new SafeHtmlBuilder();
  ui.outputHtml(html);
  Element div = com.google.gwt.dom.client.Document.get().createDivElement();
  div.setInnerHTML(html.toSafeHtml().asString());
  Element ret = div.getFirstChildElement();
  // Detach, in order that this element looks free-floating (required by some
  // preconditions).
  ret.removeFromParent();
  return ret;
}
 
Example 8
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Swaps out the old element for the new element.
 * The old element's children are added to the new element
 *
 * @param oldElement
 * @param newElement
 */
public static void replaceElement(Element oldElement, Element newElement) {

  // TODO(danilatos): Profile this to see if it is faster to move the nodes first,
  // and then remove, or the other way round. Profile and optimise some of these
  // other methods too. Take dom mutation event handlers being registered into account.

  if (oldElement.hasParentElement()) {
    oldElement.getParentElement().insertBefore(newElement, oldElement);
    oldElement.removeFromParent();
  }

  DomHelper.moveNodes(newElement, oldElement.getFirstChild(), null, null);
}
 
Example 9
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * @param element The element to unwrap. If not attached, does nothing.
 */
public static void unwrap(Element element) {
  if (element.hasParentElement()) {
    moveNodes(element.getParentElement(),
        element.getFirstChild(), null, element.getNextSibling());
    element.removeFromParent();
  }
}
 
Example 10
Source File: HtmlDomRenderer.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/** Turns a UiBuilder rendering into a DOM element. */
private Element parseHtml(UiBuilder ui) {
  if (ui == null) {
    return null;
  }
  SafeHtmlBuilder html = new SafeHtmlBuilder();
  ui.outputHtml(html);
  Element div = com.google.gwt.dom.client.Document.get().createDivElement();
  div.setInnerHTML(html.toSafeHtml().asString());
  Element ret = div.getFirstChildElement();
  // Detach, in order that this element looks free-floating (required by some
  // preconditions).
  ret.removeFromParent();
  return ret;
}
 
Example 11
Source File: ParagraphHelperEmptyLineBr.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onChildAdded(Node child, Element paragraph) {
  Element spacer = getSpacer(paragraph);
  if (spacer.hasParentElement()) {
    spacer.removeFromParent();
  }
}
 
Example 12
Source File: STextWebRemote.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void deattachFromDOM() {
  Element textElement = interactiveDoc.getDocument().getFullContentView().getDocumentElement()
      .getImplNodelet();

  if (textElement != null) {
    textElement.removeFromParent();
    interactiveDoc.getDocument().setShelved();
  }

}
 
Example 13
Source File: STextWebLocal.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public void deattachFromDOM() {
  Element textElement = doc.getFullContentView().getDocumentElement().getImplNodelet();

  if (textElement != null) {
    textElement.removeFromParent();
    doc.setShelved();
  }
}
 
Example 14
Source File: BasicEntryPoint.java    From shortyz with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onModuleLoad() {
    Element e = DOM.getElementById("loadingIndicator");

    if (e != null) {
        e.removeFromParent();
    }


    Game g = Injector.INSTANCE.game();
    //g.setSmallView(true);
    g.loadList();
    
}
 
Example 15
Source File: ApiRegistry.java    From gwt-material with Apache License 2.0 5 votes vote down vote up
/**
 * Will unregister the provided {@link ApiFeature} in to map of features.
 */
public static void unregister(ApiFeature apiFeature) {
    JavaScriptObject scriptObject = features.get(apiFeature);
    if (scriptObject != null) {
        if (scriptObject.cast() instanceof Element) {
            Element scriptElement = scriptObject.cast();
            scriptElement.removeFromParent();
        }
    }
    features.remove(apiFeature);
}
 
Example 16
Source File: DomViewHelper.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
public static void detach(Element container, Element target) {
  Preconditions.checkArgument(target != null && target.getParentElement().equals(container));
  target.removeFromParent();
}
 
Example 17
Source File: AnchorDomImpl.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
public void removeChild(Element e) {
  Preconditions.checkArgument(e != null && e.getParentElement() == self);
  e.removeFromParent();
}
 
Example 18
Source File: DomViewHelper.java    From swellrt with Apache License 2.0 4 votes vote down vote up
public static void detach(Element container, Element target) {
  Preconditions.checkArgument(target != null && target.getParentElement().equals(container));
  target.removeFromParent();
}
 
Example 19
Source File: AnchorDomImpl.java    From swellrt with Apache License 2.0 4 votes vote down vote up
public void removeChild(Element e) {
  Preconditions.checkArgument(e != null && e.getParentElement() == self);
  e.removeFromParent();
}
 
Example 20
Source File: BasicEntryPoint.java    From shortyz with GNU General Public License v3.0 3 votes vote down vote up
@Override
public void onModuleLoad() {
    Element e = DOM.getElementById("loadingIndicator");

    if (e != null) {
        e.removeFromParent();
    }


    Game g = Injector.INSTANCE.game();
    g.loadList();
    
}