Example usage for com.google.gwt.user.client.ui Widget getParent

List of usage examples for com.google.gwt.user.client.ui Widget getParent

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getParent.

Prototype

public Widget getParent() 

Source Link

Document

Gets this widget's parent panel.

Usage

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static int getX(Widget w) {
    WebAssert.argTst(w, "w cannot be null");
    int retval;/*from  w w w  .java2s. com*/
    if (w.getParent() != null) {
        retval = w.getAbsoluteLeft() - w.getParent().getAbsoluteLeft();
    } else {
        retval = w.getAbsoluteLeft();
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static int getY(Widget w) {
    WebAssert.argTst(w, "w cannot be null");
    int retval;/*from  ww w .j  a v a 2  s .  c o  m*/
    if (w.getParent() != null) {
        retval = w.getAbsoluteTop() - w.getParent().getAbsoluteTop();
    } else {
        retval = w.getAbsoluteTop();
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static Widget getTopParent(Widget w) {
    Widget retval = w;
    if (w != null) {
        while (retval.getParent() != null) {
            retval = retval.getParent();
        }/*from   w  w  w. j  av a  2s.c  om*/
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.GwtUtil.java

public static boolean isParentOf(Widget w, Widget testParent) {
    boolean retval = false;
    if (w != null && testParent != null) {
        while (w.getParent() != null) {
            if (testParent == w.getParent()) {
                retval = true;/*from   www .  ja va 2  s  .c om*/
                break;
            } else {
                w = w.getParent();
            }

        }
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.imageGrid.BasicImageGrid.java

private static int findIndex(Widget cell) {
    int retval = ((ComplexPanel) cell.getParent()).getWidgetIndex(cell);
    Widget w;/*www.j a  va  2  s . co  m*/
    for (int i = 0; i < ((ComplexPanel) cell.getParent()).getWidgetIndex(cell); i++) {
        w = ((ComplexPanel) cell.getParent()).getWidget(i);
        if (w instanceof HTML)
            retval--;
    }
    return retval;
}

From source file:edu.caltech.ipac.firefly.ui.imageGrid.ImageGridPanel.java

private static int findIndex(Widget cell) {
    return ((ComplexPanel) cell.getParent()).getWidgetIndex(cell);
}

From source file:fi.jasoft.draganddrop.client.configurations.OrderedLayoutDragAndDropConfiguration.java

License:Apache License

protected Slot getSlot(DragAndDropEvent event) {
    Element e = Util.getElementUnderMouse(event.getEvent());

    /*//from   w  w w .  j ava 2  s.c om
     * If we are hitting between slot search around the cursor for the
     * closest slot
     */
    int nextDirection = 0;
    int width = 1;
    int pageX = Util.getTouchOrMouseClientX(event.getEvent());
    int pageY = Util.getTouchOrMouseClientY(event.getEvent());
    while (event.getTargetConnector().getWidget().getElement() == e) {
        if (nextDirection == 0) {
            pageY -= width;
            nextDirection++;
        } else if (nextDirection == 1) {
            pageX += width;
            nextDirection++;
        } else if (nextDirection == 2) {
            pageY += width;
            nextDirection++;
        } else if (nextDirection == 3) {
            pageX -= width;
            width++;
            nextDirection = 0;
        }
        e = Util.getElementFromPoint(pageX, pageY);
    }

    assert e != null : "Event target was null";
    Widget w = Util.findWidget(e, null);
    assert w != null : "Widget was not found";

    if (w != null) {
        while (!(w instanceof Slot) && w != null) {
            w = w.getParent();
        }
    }

    assert w instanceof Slot;
    return (Slot) w;
}

From source file:fi.jasoft.dragdroplayouts.client.ui.tabsheet.VDDTabSheet.java

License:Apache License

public int getTabPosition(Widget tab) {
    if (tab instanceof TabCaption) {
        tab = tab.getParent();
    }//w  ww. j av a 2  s. c  o m
    return tabBar.getWidgetIndex(tab);
}

From source file:fi.jasoft.dragdroplayouts.client.ui.VDDAccordion.java

License:Apache License

/**
 * Creates a drop handler if one does not already exist and updates it from
 * the details received from the server.
 * //from  www  .  j a v a  2  s  .c o m
 * @param childUidl
 *            The UIDL
 */
protected void updateDropHandler(UIDL childUidl) {
    if (dropHandler == null) {
        dropHandler = new VAbstractDropHandler() {

            /*
             * (non-Javadoc)
             * 
             * @see com.vaadin.terminal.gwt.client.ui.dd.VDropHandler#
             * getApplicationConnection()
             */
            public ApplicationConnection getApplicationConnection() {
                return client;
            }

            /*
             * (non-Javadoc)
             * 
             * @see
             * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler
             * #getPaintable()
             */
            @Override
            public Paintable getPaintable() {
                return VDDAccordion.this;
            }

            /*
             * (non-Javadoc)
             * 
             * @see
             * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler
             * #dragAccepted
             * (com.vaadin.terminal.gwt.client.ui.dd.VDragEvent)
             */
            @Override
            protected void dragAccepted(VDragEvent drag) {
                dragOver(drag);
            }

            /*
             * (non-Javadoc)
             * 
             * @see
             * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler
             * #drop(com.vaadin.terminal.gwt.client.ui.dd.VDragEvent)
             */
            @Override
            public boolean drop(VDragEvent drag) {
                deEmphasis();
                Widget w = (Widget) drag.getTransferable().getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);
                if (w instanceof VCaption) {
                    // Convert dragged caption into the real component
                    StackItem item = (StackItem) w.getParent();
                    drag.getTransferable().setData(Constants.TRANSFERABLE_DETAIL_COMPONENT,
                            item.getComponent());
                }

                // Update the details
                updateDropDetails(drag);

                return postDropHook(drag) && super.drop(drag);
            };

            /*
             * (non-Javadoc)
             * 
             * @see
             * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler
             * #dragOver(com.vaadin.terminal.gwt.client.ui.dd.VDragEvent)
             */
            @Override
            public void dragOver(VDragEvent drag) {

                deEmphasis();

                updateDropDetails(drag);

                postOverHook(drag);

                Widget w = (Widget) drag.getTransferable().getData(Constants.TRANSFERABLE_DETAIL_COMPONENT);
                if (VDDAccordion.this.equals(w)) {
                    return;
                }

                // Validate the drop
                validate(new VAcceptCallback() {
                    public void accepted(VDragEvent event) {
                        emphasis(event.getElementOver(), event);
                    }
                }, drag);
            };

            /*
             * (non-Javadoc)
             * 
             * @see
             * com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler
             * #dragLeave(com.vaadin.terminal.gwt.client.ui.dd.VDragEvent)
             */
            @Override
            public void dragLeave(VDragEvent drag) {
                deEmphasis();
                updateDropDetails(drag);
                postLeaveHook(drag);
            };
        };
    }

    // Update the rules
    dropHandler.updateAcceptRules(childUidl);
}

From source file:fi.jasoft.dragdroplayouts.client.ui.VDragDropUtil.java

License:Apache License

private static Widget getTransferableWidget(Widget w) {
    // Ensure w is Paintable
    while (!(w instanceof Paintable) && w.getParent() != null) {
        w = w.getParent();//from  w  w w.  ja va2  s . c  o  m
    }

    // Are we grabbing the caption of a component
    boolean isCaption = w instanceof VCaption;

    if (isCaption) {
        // Dragging caption means dragging component the caption belongs to
        Widget owner = (Widget) ((VCaption) w).getOwner();
        if (owner != null) {
            w = owner;
        }
    } else if (w instanceof VScrollTable.VScrollTableBody.VScrollTableRow) {
        // Table rows are paintable but we do not want to drag them so
        // search for next paintable which should be the table itself
        w = w.getParent();
        while (!(w instanceof Paintable)) {
            w = w.getParent();
        }
    } else if (w.getParent().getParent().getParent() instanceof VTwinColSelect) {
        // TwinColSelect has paintable buttons..
        w = w.getParent().getParent().getParent();
    }

    return w;
}