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:fr.fg.client.openjwt.ui.JSTab.java

License:Open Source License

@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
    case Event.ONCLICK:
        Widget parent = getParent();
        int index = DOM.getChildIndex(parent.getElement(), getElement());

        while (!(parent instanceof JSTabbedPane))
            parent = parent.getParent();
        JSTabbedPane pane = (JSTabbedPane) parent;
        pane.setSelectedIndex(index);/*  w  w w . j  a v  a2 s .c om*/
        break;
    case Event.ONMOUSEOUT:
        if (event.getToElement() != null && !getElement().isOrHasChild(event.getToElement())) {
            if (updater != null) {
                if (updater.isFinished()) {
                    updater = new ClassNameUpdater(this, "state", 4, 20);
                    TimerManager.register(updater);
                }
                updater.setTargetClass(0, true);
            } else {
                updater = new ClassNameUpdater(this, "state", 4, 20);
                updater.setTargetClass(0, true);
                TimerManager.register(updater);
            }
        }
        break;
    case Event.ONMOUSEOVER:
        if (event.getFromElement() != null && !getElement().isOrHasChild(event.getFromElement())
                && Config.getGraphicsQuality() >= Config.VALUE_QUALITY_AVERAGE) {
            if (updater != null) {
                if (updater.isFinished()) {
                    updater = new ClassNameUpdater(this, "state", 0, 20);
                    TimerManager.register(updater);
                }
                updater.setTargetClass(4, true);
            } else {
                updater = new ClassNameUpdater(this, "state", 0, 20);
                updater.setTargetClass(4, true);
                TimerManager.register(updater);
            }
            updater.setTargetClass(4, true);
        }
        break;
    case Event.ONMOUSEDOWN:
        SoundManager.getInstance().playSound(SOUND_CLICK);
        break;
    }
}

From source file:geogebra.web.gui.app.docklayout.MyDockLayoutPanel.java

License:Apache License

/**
 * Gets the layout direction of the given child widget.
 * //from   w  w  w. j  ava 2s .c o m
 * @param child
 *            the widget to be queried
 * @return the widget's layout direction, or <code>null</code> if it is not
 *         a child of this panel
 * @throws AssertionError
 *             if the widget is not a child and assertions are enabled
 */
public Direction getWidgetDirection(Widget child) {
    assertIsChild(child);
    if (child.getParent() != this) {
        return null;
    }
    return ((LayoutData) child.getLayoutData()).direction;
}

From source file:geogebra.web.gui.app.docklayout.MyDockLayoutPanel.java

License:Apache License

/**
 * Gets the layout size of the given child widget.
 * //from   ww w.  j  ava 2 s. co  m
 * @param child
 *            the widget to be queried
 * @return the widget's layout size, or <code>null</code> if it is not a
 *         child of this panel
 * @throws AssertionError
 *             if the widget is not a child and assertions are enabled
 */
public Double getWidgetSize(Widget child) {
    assertIsChild(child);
    if (child.getParent() != this) {
        return null;
    }
    return ((LayoutData) child.getLayoutData()).size;
}

From source file:geogebra.web.gui.app.docklayout.MyDockLayoutPanel.java

License:Apache License

void assertIsChild(Widget widget) {
    assert (widget == null)
            || (widget.getParent() == this) : "The specified widget is not a child of this panel";
}

From source file:gwt.material.design.addins.client.autocomplete.MaterialAutoComplete.java

License:Apache License

/**
 * Clear the chip items on the autocomplete box
 *//*from w w w  .j av  a2s .  com*/
public void clear() {
    itemBox.setValue("");
    label.removeStyleName(CssName.ACTIVE);

    Collection<Widget> values = suggestionMap.values();
    for (Widget widget : values) {
        Widget parent = widget.getParent();
        if (parent instanceof ListItem) {
            parent.removeFromParent();
        }
    }
    suggestionMap.clear();

    clearStatusText();
}

From source file:gwt.material.design.client.base.error.DefaultErrorHandler.java

License:Apache License

/**
 * Find the sibling {@link MaterialHelpBlock}.
 *
 * @param widget the {@link Widget} to search.
 * @return the found {@link MaterialHelpBlock} of null if not found.
 *///from w  w w.jav a 2  s  . com
protected MaterialHelpBlock findHelpBlock(Widget widget) {
    if (widget != null) {
        if (widget instanceof MaterialHelpBlock) {
            return (MaterialHelpBlock) widget;
        }
        // Try and find the MaterialHelpBlock in the children of the given widget.
        if (widget instanceof HasWidgets) {
            for (Widget w : (HasWidgets) widget) {
                if (w instanceof MaterialHelpBlock) {
                    return (MaterialHelpBlock) w;
                }
            }
        }
        // Try and find the MaterialHelpBlock in the parent of widget.
        return findHelpBlock(widget.getParent());
    }
    return null;
}

From source file:gwt.material.design.client.base.error.DefaultErrorHandler.java

License:Apache License

/**
 * Initialize the instance./* w w  w .j  ava2 s. c o  m*/
 */
public void init() {
    if (initialized) {
        return;
    }
    Widget parent = inputWidget.getParent();
    while (parent != null && !parent.getClass().getName().equals("com.google.gwt.user.client.ui.Widget")) {
        helpBlock = findHelpBlock(inputWidget);
        if (helpBlock != null) {
            break;
        } else {
            parent = parent.getParent();
        }
    }
    initialized = true;
}

From source file:gwt.material.design.client.ui.MaterialCollapsibleBody.java

License:Apache License

private MaterialCollapsibleItem findCollapsibleItemParent(Widget widget) {
    if (widget != null) {
        if (widget instanceof MaterialCollapsibleItem) {
            return (MaterialCollapsibleItem) widget;
        } else {//from  w w w  .  j  a v a  2s .c  o m
            return findCollapsibleItemParent(widget.getParent());
        }
    }
    return null;
}

From source file:gwt.material.design.client.ui.MaterialCollapsibleBody.java

License:Apache License

private ListItem findListItemParent(Widget widget) {
    if (widget != null) {
        if (widget instanceof ListItem) {
            return (ListItem) widget;
        } else {/*from  w  w  w  .  ja v  a2s. co  m*/
            return findListItemParent(widget.getParent());
        }
    }
    return null;
}

From source file:info.magnolia.ui.vaadin.gwt.client.magnoliashell.viewport.connector.ViewportConnector.java

License:Open Source License

@Override
public void onConnectorHierarchyChange(ConnectorHierarchyChangeEvent event) {
    final ViewportWidget viewport = getWidget();
    final List<ComponentConnector> children = getChildComponents();
    final List<ComponentConnector> oldChildren = event.getOldChildren();
    int index = 0;
    for (final ComponentConnector cc : children) {
        final Widget w = cc.getWidget();
        if (w.getParent() != viewport) {
            viewport.insert(w, index);/* ww  w .java2 s. c  o  m*/
            getLayoutManager().addElementResizeListener(w.getElement(), childCenterer);
            w.getElement().getStyle().setOpacity(0d);
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    if (getWidget().getVisibleChild() != cc.getWidget()) {
                        w.getElement().getStyle().setDisplay(Display.NONE);
                    }
                    w.getElement().getStyle().clearOpacity();
                }
            });

        }
        ++index;
    }

    oldChildren.removeAll(children);
    for (final ComponentConnector cc : oldChildren) {
        cc.getLayoutManager().removeElementResizeListener(cc.getWidget().getElement(), childCenterer);
        getWidget().removeChild(cc.getWidget());
    }
}