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

The following examples show how to use com.google.gwt.dom.client.Element#removeChild() . 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: CubaTooltip.java    From cuba with Apache License 2.0 6 votes vote down vote up
protected void checkRequiredIndicatorVisible() {
    if (requiredIndicatorVisible == null) {
        Element requiredIndicatorFake = DOM.createDiv();
        requiredIndicatorFake.setClassName(REQUIRED_INDICATOR);
        requiredIndicatorFake.getStyle().setPosition(Style.Position.ABSOLUTE);

        String rootPanelId = ac.getConfiguration().getRootPanelId();
        Element rootPanel = Document.get().getElementById(rootPanelId);
        rootPanel.appendChild(requiredIndicatorFake);

        String display = new ComputedStyle(requiredIndicatorFake).getProperty("display");

        requiredIndicatorVisible = !"none".equals(display);

        rootPanel.removeChild(requiredIndicatorFake);
    }
}
 
Example 2
Source File: VDDTabSheet.java    From cuba with Apache License 2.0 6 votes vote down vote up
/**
 * Removes any previous emphasis made by drag&drop
 */
protected void deEmphasis() {
    if (currentlyEmphasised != null
            && tabBar.getElement().isOrHasChild(currentlyEmphasised)) {
        Widget w = Util.findWidget(currentlyEmphasised, null);

        currentlyEmphasised.removeClassName(CLASSNAME_NEW_TAB_LEFT);
        currentlyEmphasised.removeClassName(CLASSNAME_NEW_TAB_RIGHT);
        currentlyEmphasised.removeClassName(CLASSNAME_NEW_TAB_CENTER);

        if (w == tabBar) {
            // Over spacer
            Element spacerContent = spacer.getChild(0).cast();
            spacerContent.removeChild(newTab);
        }

        currentlyEmphasised = null;
    }
}
 
Example 3
Source File: Application.java    From SensorWebClient with GNU General Public License v2.0 6 votes vote down vote up
public static void continueStartup() {

        // init handlers before throwing events
        SosDataManager.getDataManager();
        new SOSController();
        if (ClientUtils.isSesEnabled()) {
            new SesController();
        }
        View.getView();
        Element element = Document.get().getElementById("loadingWrapper");
        while (element.hasChildNodes()) {
            element.removeChild(element.getFirstChild());
        }

        Application.finishStartup();
    }
 
Example 4
Source File: MockForm.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private static int getVerticalScrollbarWidth() {
  // We only calculate the vertical scroll bar width once, then we store it in the static field
  // verticalScrollbarWidth. If the field is non-zero, we don't need to calculate it again.
  if (verticalScrollbarWidth == 0) {
    // The following code will calculate (on the fly) the width of a vertical scroll bar.
    // We'll create two divs, one inside the other and add the outer div to the document body,
    // but off-screen where the user won't see it.
    // We'll measure the width of the inner div twice: (first) when the outer div's vertical
    // scrollbar is hidden and (second) when the outer div's vertical scrollbar is visible.
    // The width of inner div will be smaller when outer div's vertical scrollbar is visible.
    // By subtracting the two measurements, we can calculate the width of the vertical scrollbar.

    // I used code from the following websites as reference material:
    // http://jdsharp.us/jQuery/minute/calculate-scrollbar-width.php
    // http://www.fleegix.org/articles/2006-05-30-getting-the-scrollbar-width-in-pixels

    Document document = Document.get();

    // Create an outer div.
    DivElement outerDiv = document.createDivElement();
    Style outerDivStyle = outerDiv.getStyle();
    // Use absolute positioning and set the top/left so that it is off-screen.
    // We don't want the user to see anything while we do this calculation.
    outerDivStyle.setProperty("position", "absolute");
    outerDivStyle.setProperty("top", "-1000px");
    outerDivStyle.setProperty("left", "-1000px");
    // Set the width and height of the outer div to a fixed size in pixels.
    outerDivStyle.setProperty("width", "100px");
    outerDivStyle.setProperty("height", "50px");
    // Hide the outer div's scrollbar by setting the "overflow" property to "hidden".
    outerDivStyle.setProperty("overflow", "hidden");

    // Create an inner div and put it inside the outer div.
    DivElement innerDiv = document.createDivElement();
    Style innerDivStyle = innerDiv.getStyle();
    // Set the height of the inner div to be 4 times the height of the outer div so that a
    // vertical scrollbar will be necessary (but hidden for now) on the outer div.
    innerDivStyle.setProperty("height", "200px");
    outerDiv.appendChild(innerDiv);

    // Temporarily add the outer div to the document body. It's off-screen so the user won't
    // actually see anything.
    Element bodyElement = document.getElementsByTagName("body").getItem(0);
    bodyElement.appendChild(outerDiv);

    // Get the width of the inner div while the outer div's vertical scrollbar is hidden.
    int widthWithoutScrollbar = innerDiv.getOffsetWidth();
    // Show the outer div's vertical scrollbar by setting the "overflow" property to "auto".
    outerDivStyle.setProperty("overflow", "auto");
    // Now, get the width of the inner div while the vertical scrollbar is visible.
    int widthWithScrollbar = innerDiv.getOffsetWidth();

    // Remove the outer div from the document body.
    bodyElement.removeChild(outerDiv);

    // Calculate the width of the vertical scrollbar by subtracting the two widths.
    verticalScrollbarWidth = widthWithoutScrollbar - widthWithScrollbar;
  }

  return verticalScrollbarWidth;
}
 
Example 5
Source File: UniTimeTable.java    From unitime with Apache License 2.0 5 votes vote down vote up
private void swapRows(int r0, int r1) {
	if (r0 == r1) return;
	if (r0 > r1) {
		swapRows(r1, r0);
	} else { // r0 < r1
		Element body = getBodyElement();
		Element a = DOM.getChild(body, r0);
		Element b = DOM.getChild(body, r1);
		body.removeChild(a);
		body.removeChild(b);
		DOM.insertChild(body, b, r0);
		DOM.insertChild(body, a, r1);
	}
}
 
Example 6
Source File: PasteBufferImplSafariAndNewFirefox.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void maybeStripMarker(Node node, Element parent, boolean leading) {
  if (node == null) {
    logEndNotFound("node is null");
    return;
  }
  if (DomHelper.isTextNode(node)) {
    Text textNode = node.cast();
    String text = textNode.getData();
    if (!text.isEmpty()) {
      if (leading) {
        if (text.charAt(0) == MARKER_CHAR) {
          textNode.setData(text.substring(1));
        }
      } else {
        if (text.charAt(text.length() - 1) == MARKER_CHAR) {
          textNode.setData(text.substring(0, text.length() - 1));
        } else {
          logEndNotFound("last character is not marker");
        }
      }
    } else {
      logEndNotFound("text node is empty");
    }
    if (textNode.getData().isEmpty()) {
      parent.removeChild(textNode);
    }
  } else {
    // In some cases, Safari will put the marker inside of a div, so this
    // traverses down the left or right side of the tree to find it.
    // For example: x<div><span>pasted</span>x</div>
    maybeStripMarker(leading ? node.getFirstChild() : node.getLastChild(), node.<Element> cast(),
        leading);
  }
}
 
Example 7
Source File: GroupedListBox.java    From swcv with MIT License 5 votes vote down vote up
@Override
public void clear()
{
    super.clear();

    // we need special handling to remove any OPTGROUP elements
    Element elm = getElement();
    while (elm.hasChildNodes())
    {
        elm.removeChild(elm.getFirstChild());
    }
}
 
Example 8
Source File: GroupedListBox.java    From gwt-traction with Apache License 2.0 5 votes vote down vote up
@Override
public void remove() {
    Element select = getElement();
    while (count-- > 0) {
        Element option = select.getFirstChildElement();
        if (option != null) {
            select.removeChild(option);
        }
    }
    count = 0;
}
 
Example 9
Source File: PasteBufferImplSafariAndNewFirefox.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void maybeStripMarker(Node node, Element parent, boolean leading) {
  if (node == null) {
    logEndNotFound("node is null");
    return;
  }
  if (DomHelper.isTextNode(node)) {
    Text textNode = node.cast();
    String text = textNode.getData();
    if (!text.isEmpty()) {
      if (leading) {
        if (text.charAt(0) == MARKER_CHAR) {
          textNode.setData(text.substring(1));
        }
      } else {
        if (text.charAt(text.length() - 1) == MARKER_CHAR) {
          textNode.setData(text.substring(0, text.length() - 1));
        } else {
          logEndNotFound("last character is not marker");
        }
      }
    } else {
      logEndNotFound("text node is empty");
    }
    if (textNode.getData().isEmpty()) {
      parent.removeChild(textNode);
    }
  } else {
    // In some cases, Safari will put the marker inside of a div, so this
    // traverses down the left or right side of the tree to find it.
    // For example: x<div><span>pasted</span>x</div>
    maybeStripMarker(leading ? node.getFirstChild() : node.getLastChild(), node.<Element> cast(),
        leading);
  }
}
 
Example 10
Source File: CurriculumProjectionRulesPage.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void moveRow(Element tr, Element before) {
	Element body = DOM.getParent(tr);
	body.removeChild(tr);
	DOM.insertBefore(body, tr, before);
}
 
Example 11
Source File: DomHelper.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * Remove all children from an element
 * @param element
 */
public static void emptyElement(Element element) {
  while (element.getFirstChild() != null) {
    element.removeChild(element.getFirstChild());
  }
}
 
Example 12
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * Remove all children from an element
 * @param element
 */
public static void emptyElement(Element element) {
  while (element.getFirstChild() != null) {
    element.removeChild(element.getFirstChild());
  }
}