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

The following examples show how to use com.google.gwt.dom.client.Element#equals() . 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: CubaTreeGridWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
public void showEmptyState(boolean show) {
    if (show) {
        if (emptyState == null) {
            emptyState = new CubaGridEmptyState();
        }

        Element wrapper = getEscalator().getTableWrapper();
        Element panelParent = emptyState.getElement().getParentElement();

        if (panelParent == null || !panelParent.equals(wrapper)) {
            wrapper.appendChild(emptyState.getElement());
        }
    } else if (emptyState != null) {
        emptyState.getElement().removeFromParent();
        emptyState = null;
    }
}
 
Example 2
Source File: Lookup.java    From unitime with Apache License 2.0 6 votes vote down vote up
private void scrollToSelectedRow() {
	int row = iTable.getSelectedRow();
	if (row < 0) return;
	
	Element scroll = iScroll.getElement();
	
	Element item = iTable.getRowFormatter().getElement(iTable.getSelectedRow());
	if (item==null) return;
	
	int realOffset = 0;
	while (item !=null && !item.equals(scroll)) {
		realOffset += item.getOffsetTop();
		item = item.getOffsetParent();
	}
	
	scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
}
 
Example 3
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
/** MouseTtouch down event handler. */
protected void handleDownEvent(NativeEvent event) {
    if (isReadOnly()) {
        return;
    }
    if (captureElement != null) {
        stopMoving(event);

        return;
    }

    Element element = event.getEventTarget().cast();
    if (element != null
            && (element.equals(startingPoint) || element
                    .equals(endingPoint))) {
        startMoving(event, element);
    }
}
 
Example 4
Source File: TeachingRequestDetailPage.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected void scrollToRow(Integer row) {
	if (row != null) {
		Element scroll = iScroll.getElement();
		Element item = iForm.getRowFormatter().getElement(row);
		int realOffset = 0;
		while (item !=null && !item.equals(scroll)) {
			realOffset += item.getOffsetTop();
			item = item.getOffsetParent();
		}
		scroll.setScrollTop(realOffset - scroll.getOffsetHeight() / 2);
	}
}
 
Example 5
Source File: SearchPanelWidget.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@UiHandler("self")
void handleClick(ClickEvent e) {
  Element target = e.getNativeEvent().getEventTarget().cast();
  Element top = self.getElement();
  while (!top.equals(target)) {
    if ("digest".equals(target.getAttribute(BuilderHelper.KIND_ATTRIBUTE))) {
      handleClick(byId.get(target.getAttribute(DigestDomImpl.DIGEST_ID_ATTRIBUTE)));
      e.stopPropagation();
      return;
    } else if (showMore.equals(target)) {
      handleShowMoreClicked();
    }
    target = target.getParentElement();
  }
}
 
Example 6
Source File: DomHelper.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the index of an element in its parent's list of child elements.
 * This is not the same as {@link #findChildIndex(Node)}, since it ignores
 * non-element nodes. It is in line with the element-only view of a collection
 * of children exposed by {@link Element#getFirstChildElement()} and
 * {@link Element#getNextSiblingElement()}.
 *
 * @param child  an element
 * @return the index of {@code child}, or -1 if {@code child} is not a child
 *   of its parent.
 * @see #findChildIndex(Node)
 */
public static final int findChildElementIndex(Element child) {
  Element parent = child.getParentElement();
  Element e = parent.getFirstChildElement();
  int i = 0;
  while (e != null) {
    if (e.equals(child)) {
      return i;
    } else {
      e = e.getNextSiblingElement();
      i++;
    }
  }
  return -1;
}
 
Example 7
Source File: EventDispatcherPanel.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatches an event through this handler collection.
 *
 * @param event event to dispatch
 * @param target target element of the event
 * @return true if a handled, false otherwise.
 */
boolean dispatch(E event, Element target) {
  while (target != null) {
    if (target.hasAttribute(KIND_ATTRIBUTE)) {
      W handler = waveHandlers.get(target.getAttribute(KIND_ATTRIBUTE));
      if (handler != null) {
        if (dispatch(event, target, handler)) {
          return true;
        }
      }
    }
    target = !target.equals(top) ? target.getParentElement() : null;
  }
  return dispatchGlobal(event);
}
 
Example 8
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 5 votes vote down vote up
protected void startMoving(NativeEvent event, Element element) {
    if (element.equals(startingPoint)) {
        selectPredecessorMode = true;
        startingPoint.getStyle().setVisibility(Visibility.HIDDEN);
    } else if (element.equals(endingPoint)) {
        selectFollowerMode = true;
        endingPoint.getStyle().setVisibility(Visibility.HIDDEN);
    }
    capturePointScrollTop = getElement().getParentElement()
            .getParentElement().getScrollTop();
    capturePointScrollLeft = getElement().getParentElement()
            .getParentElement().getScrollLeft();
    getParent().getElement().appendChild(movePointElement);
    getElement().getParentElement().addClassName(SELECTION_STYLE_NAME);
    GWT.log("Capturing clicked point.");
    captureElement = getElement();
    Event.setCapture(getElement());
    event.stopPropagation();

    // enable MODE for new predecessor/following step
    // selection.
    addMoveHandler();

    capturePoint = new Point(getTouchOrMouseClientX(event),
            getTouchOrMouseClientY(event));
    originalWidth = width;
    originalHeight = height;
}
 
Example 9
Source File: SearchPanelWidget.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@UiHandler("self")
void handleClick(ClickEvent e) {
  Element target = e.getNativeEvent().getEventTarget().cast();
  Element top = self.getElement();
  while (!top.equals(target)) {
    if ("digest".equals(target.getAttribute(BuilderHelper.KIND_ATTRIBUTE))) {
      handleClick(byId.get(target.getAttribute(DigestDomImpl.DIGEST_ID_ATTRIBUTE)));
      e.stopPropagation();
      return;
    } else if (showMore.equals(target)) {
      handleShowMoreClicked();
    }
    target = target.getParentElement();
  }
}
 
Example 10
Source File: DomHelper.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Finds the index of an element in its parent's list of child elements.
 * This is not the same as {@link #findChildIndex(Node)}, since it ignores
 * non-element nodes. It is in line with the element-only view of a collection
 * of children exposed by {@link Element#getFirstChildElement()} and
 * {@link Element#getNextSiblingElement()}.
 *
 * @param child  an element
 * @return the index of {@code child}, or -1 if {@code child} is not a child
 *   of its parent.
 * @see #findChildIndex(Node)
 */
public static final int findChildElementIndex(Element child) {
  Element parent = child.getParentElement();
  Element e = parent.getFirstChildElement();
  int i = 0;
  while (e != null) {
    if (e.equals(child)) {
      return i;
    } else {
      e = e.getNextSiblingElement();
      i++;
    }
  }
  return -1;
}
 
Example 11
Source File: EventDispatcherPanel.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatches an event through this handler collection.
 *
 * @param event event to dispatch
 * @param target target element of the event
 * @return true if a handled, false otherwise.
 */
boolean dispatch(E event, Element target) {
  while (target != null) {
    if (target.hasAttribute(KIND_ATTRIBUTE)) {
      W handler = waveHandlers.get(target.getAttribute(KIND_ATTRIBUTE));
      if (handler != null) {
        if (dispatch(event, target, handler)) {
          return true;
        }
      }
    }
    target = !target.equals(top) ? target.getParentElement() : null;
  }
  return dispatchGlobal(event);
}
 
Example 12
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();
    }