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

The following examples show how to use com.google.gwt.dom.client.Element#isOrHasChild() . 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: DemoGwtWebApp.java    From demo-gwt-springboot with Apache License 2.0 5 votes vote down vote up
private void removeLoadingImage() {
	// Remove loadingImage from Host HTML page
       Element body = Document.get().getBody();
       Element loading = Document.get().getElementById(HOST_LOADING_IMAGE);

       if(body.isOrHasChild(loading)){
           loading.removeFromParent();
       }
}
 
Example 2
Source File: AutoHider.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * @param target An element.
 * @return {@code true} if the given element is considered to be inside the
 *         entity.
 */
public boolean doesContain(Element target) {
  for (Element element : insideElements) {
    if (element.isOrHasChild(target)) {
      return true;
    }
  }
  return false;
}
 
Example 3
Source File: CompositeFocusHelper.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isOrHasChildOfContainerOrPartner(Element target) {
	if (this.containerWidget.getElement().isOrHasChild(target)) {
		return true;
	}
	for (Element elem : this.focusPartners) {
		if (elem.isOrHasChild(target)) {
			return true;
		}
	}
	return false;
}
 
Example 4
Source File: AutoHider.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * @param target An element.
 * @return {@code true} if the given element is considered to be inside the
 *         entity.
 */
public boolean doesContain(Element target) {
  for (Element element : insideElements) {
    if (element.isOrHasChild(target)) {
      return true;
    }
  }
  return false;
}
 
Example 5
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Fire an event to the {@link com.google.gwt.cell.client.AbstractCell}.
 *
 * @param event the native event
 */
@SuppressWarnings("unchecked")
protected void fireEventToCell(NativeEvent event) {
  if (parentNodeInfo == null) {
    return;
  }

  Cell<T> parentCell = parentNodeInfo.getCell();
  String eventType = event.getType();
  Element cellParent = getCellParent();
  Object key = getValueKey();
  Context context = new Context(getIndex(), 0, key);
  boolean cellWasEditing = parentCell.isEditing(context, cellParent, value);

  // Update selection.
  boolean isSelectionHandled = parentCell.handlesSelection() || KeyboardSelectionPolicy.BOUND_TO_SELECTION == tree.getKeyboardSelectionPolicy();
  HasData<T> display = (HasData<T>)parentNode.listView;
  CellPreviewEvent<T> previewEvent = CellPreviewEvent.fire(display, event, display, context, value, cellWasEditing, isSelectionHandled);

  // Forward the event to the cell.
  if (previewEvent.isCanceled() || !cellParent.isOrHasChild(Element.as(event.getEventTarget()))) {
    return;
  }
  Set<String> consumedEvents = parentCell.getConsumedEvents();
  if (consumedEvents != null && consumedEvents.contains(eventType)) {
    parentCell.onBrowserEvent(context, cellParent, value, event, parentNodeInfo.getValueUpdater());
    tree.cellIsEditing = parentCell.isEditing(context, cellParent, value);
    if (cellWasEditing && !tree.cellIsEditing) {
      CellBasedWidgetImpl.get().resetFocus(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
          tree.setFocus(true);
        }
      });
    }
  }
}
 
Example 6
Source File: VDDCssLayout.java    From cuba with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the drop details while dragging. This is needed to ensure client
 * side criterias can validate the drop location.
 * 
 * @param event
 *            The drag event
 */
protected void updateDragDetails(VDragEvent event) {

    Element over = event.getElementOver();
    if (placeHolderElement.isOrHasChild(over)) {
        // Dragging over the placeholder
        return;
    }

    Widget widget = (Widget) Util.findWidget(over, null);
    if (widget == null) {
        // Null check
        return;
    }

    int offset = 0;
    int index = -1;
    for (int i = 0; i < getElement().getChildCount(); i++) {
        Element child = getElement().getChild(i).cast();
        if (child.isOrHasChild(placeHolderElement)) {
            offset--;
        } else if (child.isOrHasChild(widget.getElement())) {
            index = i + offset;
            break;
        }
    }
    event.getDropDetails().put(Constants.DROP_DETAIL_TO, index);

    /*
     * The horizontal position within the cell
     */
    event.getDropDetails().put(
            Constants.DROP_DETAIL_HORIZONTAL_DROP_LOCATION,
            getHorizontalDropLocation(widget, event));

    /*
     * The vertical position within the cell
     */
    event.getDropDetails().put(Constants.DROP_DETAIL_VERTICAL_DROP_LOCATION,
            getVerticalDropLocation(widget, event));

    // Add mouse event details
    MouseEventDetails details = MouseEventDetailsBuilder
            .buildMouseEventDetails(event.getCurrentGwtEvent(),
                    getElement());
    event.getDropDetails().put(Constants.DROP_DETAIL_MOUSE_EVENT,
            details.serialize());
}
 
Example 7
Source File: VDDFormLayoutDropHandler.java    From cuba with Apache License 2.0 4 votes vote down vote up
private Widget getTableRowWidgetFromDragEvent(VDragEvent event) {

        /**
         * Find the widget of the row
         */
        Element e = event.getElementOver();

        if (getLayout().table.getRowCount() == 0) {
            /*
             * Empty layout
             */
            return getLayout();
        }

        /**
         * Check if element is inside one of the table widgets
         */
        for (int i = 0; i < getLayout().table.getRowCount(); i++) {
            Element caption = getLayout().table
                    .getWidget(i, getLayout().COLUMN_CAPTION).getElement();
            Element error = getLayout().table
                    .getWidget(i, getLayout().COLUMN_ERRORFLAG).getElement();
            Element widget = getLayout().table
                    .getWidget(i, getLayout().COLUMN_WIDGET).getElement();
            if (caption.isOrHasChild(e) || error.isOrHasChild(e)
                    || widget.isOrHasChild(e)) {
                return getLayout().table.getWidget(i,
                        getLayout().COLUMN_WIDGET);
            }
        }

        /*
         * Is the element a element outside the row structure but inside the
         * layout
         */
        Element rowElement = getLayout().getRowFromChildElement(e,
                getLayout().getElement());
        if (rowElement != null) {
            Element tableElement = rowElement.getParentElement();
            for (int i = 0; i < tableElement.getChildCount(); i++) {
                Element r = tableElement.getChild(i).cast();
                if (r.equals(rowElement)) {
                    return getLayout().table.getWidget(i,
                            getLayout().COLUMN_WIDGET);
                }
            }
        }

        /*
         * Element was not found in rows so defaulting to the form layout
         * instead
         */
        return getLayout();
    }