Example usage for com.google.gwt.user.client DOM isOrHasChild

List of usage examples for com.google.gwt.user.client DOM isOrHasChild

Introduction

In this page you can find the example usage for com.google.gwt.user.client DOM isOrHasChild.

Prototype

@Deprecated
public static boolean isOrHasChild(Element parent, Element child) 

Source Link

Document

Determine whether one element is equal to, or the child of, another.

Usage

From source file:asquare.gwt.sb.client.fw.HoverControllerBase.java

License:Apache License

@Override
public void onMouseOver(MouseEvent e) {
    Widget source = e.getSourceWidget();
    CellId targetCell = getCellId(source, e.getTarget());

    Element fromElement = e.getFrom();
    CellId fromCell = null;/*  ww  w  .jav  a 2  s .c  o m*/
    if (fromElement != null && DOM.isOrHasChild(source.getElement(), fromElement)) {
        fromCell = getCellId(source, fromElement);
    }

    // Ignore "over" events generated within the same view cell
    if (!GwtUtil.equals(targetCell, fromCell)) {
        onHoverChanged(source, targetCell);
    }
}

From source file:asquare.gwt.sb.client.fw.HoverControllerBase.java

License:Apache License

@Override
public void onMouseOut(MouseEvent e) {
    Widget source = e.getSourceWidget();
    CellId targetCell = getCellId(source, e.getTarget());

    Element toElement = e.getTo();
    CellId toCell = null;/*from ww  w  .ja  v  a  2s  .co m*/
    if (toElement != null && DOM.isOrHasChild(source.getElement(), toElement)) {
        toCell = getCellId(source, toElement);
    }

    // Ignore "out" events generated within the same view cell
    if (!GwtUtil.equals(targetCell, toCell)) {
        /*
         * Performance: ignore "out" events if the cursor is moving to
         * another cell in the same view. (The over event will set
         * the active index anyway, resulting in a 2nd update).
         */
        if (toCell == null) {
            onHoverChanged(source, null);
        }
    }
}

From source file:asquare.gwt.sb.client.fw.ListWidgetBasic.java

License:Apache License

@Override
public Element getCellRootElement(Element eventTarget) {
    for (int i = 0, size = m_elements.size(); i < size; i++) {
        if (DOM.isOrHasChild(m_elements.get(i), eventTarget)) {
            return m_elements.get(i);
        }/*from  w  w w  .  j a v a  2s .c  o m*/
    }
    return null;
}

From source file:asquare.gwt.sb.client.fw.ListWidgetBasic.java

License:Apache License

@Override
public int getIndexOf(Element eventTarget) {
    for (int i = 0, size = m_elements.size(); i < size; i++) {
        if (DOM.isOrHasChild(m_elements.get(i), eventTarget)) {
            return i;
        }//from  w w w .  j av a 2s. c  om
    }
    return -1;
}

From source file:asquare.gwt.sb.client.fw.ListWidgetTable.java

License:Apache License

@Override
public Element getCellRootElement(Element eventTarget) {
    for (int i = 0, size = m_panel.getCellCount(); i < size; i++) {
        Element candidate = m_panel.getCellElement(i);
        if (DOM.isOrHasChild(candidate, eventTarget)) {
            return candidate;
        }//ww  w .java2s.  co  m
    }
    return null;
}

From source file:asquare.gwt.sb.client.fw.ListWidgetTable.java

License:Apache License

@Override
public int getIndexOf(Element eventTarget) {
    for (int i = 0, size = m_panel.getCellCount(); i < size; i++) {
        if (DOM.isOrHasChild(m_panel.getCellElement(i), eventTarget)) {
            return i;
        }/*from   w  w  w  . j  ava2  s  .c  o m*/
    }
    return -1;
}

From source file:asquare.gwt.tk.client.ui.behavior.EventBaseImpl.java

License:Apache License

public boolean didEventOccurIn(Element e) {
    return DOM.isOrHasChild(e, m_target);
}

From source file:bufferings.ktr.wjr.client.ui.widget.WjrTree.java

License:Apache License

private boolean elementClicked(Element hElem) {
    ArrayList<Element> chain = new ArrayList<Element>();
    collectElementChain(chain, getElement(), hElem);

    WjrTreeItem item = findItemByChain(chain, 0, root);
    if (item != null && item != root) {
        if (item.hasChild() && DOM.isOrHasChild(item.toggleIconLabel.getElement(), hElem)) {
            boolean newState = !item.getState();
            item.setState(newState);/*from  w w w. ja va 2  s. c  o  m*/
            maybeUpdateSelection(item, newState);
            return true;
        } else if (DOM.isOrHasChild(item.getElement(), hElem)) {
            setSelectedItem(item, true);
            return true;
        }
    }

    return false;
}

From source file:com.allen_sauer.gwt.dnd.client.DropControllerCollection.java

License:Apache License

/**
 * Cache a list of eligible drop controllers, sorted by relative DOM positions of their respective
 * drop targets. Called at the beginning of each drag operation, or whenever drop target
 * eligibility has changed while dragging.
 * /*  w ww  .j a  v a 2 s. co  m*/
 * @param boundaryPanel boundary area for drop target eligibility considerations
 * @param context the current drag context
 */
void resetCache(Panel boundaryPanel, DragContext context) {
    ArrayList<Candidate> list = new ArrayList<Candidate>();

    if (context.draggable != null) {
        WidgetArea boundaryArea = new WidgetArea(boundaryPanel, null);
        for (DropController dropController : dropControllerList) {
            Candidate candidate = new Candidate(dropController);
            Widget dropTarget = candidate.getDropTarget();
            if (DOM.isOrHasChild(context.draggable.getElement(), dropTarget.getElement())) {
                continue;
            }
            if (candidate.getTargetArea().intersects(boundaryArea)) {
                list.add(candidate);
            }
        }
    }

    sortedCandidates = list.toArray(new Candidate[list.size()]);
    Arrays.sort(sortedCandidates);
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.dayview.DayView.java

License:Open Source License

/**
 * Returns the {@link Appointment} indirectly associated to the passed <code>element</code>. Each Appointment drawn on the CalendarView maps to a Widget and
 * therefore an Element. This method attempts to find an Appointment based on the provided Element. If no match is found a null value is returned.
 * //ww w . ja  v  a2  s  .  c  o  m
 * @param element
 *            Element to look up.
 * @return Appointment matching the element.
 */
private Appointment findAppointmentByElement(Element element) {
    Appointment appointmentAtElement = null;
    for (AppointmentWidget widget : appointmentWidgets) {
        if (DOM.isOrHasChild(widget.getElement(), element)) {
            appointmentAtElement = widget.getAppointment();
            break;
        }
    }
    return appointmentAtElement;
}