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:org.vaadin.henrik.drawer.widgetset.client.ui.VDrawer.java

License:Apache License

public boolean hasChildComponent(final Widget component) {
    return component.getParent() == drawer;
}

From source file:org.vaadin.sasha.portallayout.client.dnd.PickupDragController.java

License:Apache License

/**
 * Save the selected widgets' current location in case they much be restored due to a cancelled
 * drop./*from  w w w .jav a  2 s.  c  o m*/
 * 
 * @see #restoreSelectedWidgetsLocation()
 */
protected void saveSelectedWidgetsLocationAndStyle() {
    savedWidgetInfoMap = new HashMap<Widget, SavedWidgetInfo>();
    for (Widget widget : context.selectedWidgets) {
        SavedWidgetInfo info = new SavedWidgetInfo();
        info.initialDraggableParent = widget.getParent();

        if (info.initialDraggableParent instanceof AbsolutePanel) {
            info.initialDraggableParentLocation = new WidgetLocation(widget, info.initialDraggableParent);
        } else if (info.initialDraggableParent instanceof InsertPanel) {
            info.initialDraggableIndex = ((InsertPanel) info.initialDraggableParent).getWidgetIndex(widget);
        } else if (info.initialDraggableParent instanceof SimplePanel) {
            // save nothing
        } else {
            throw new RuntimeException("Unable to handle 'initialDraggableParent instanceof "
                    + info.initialDraggableParent.getClass().getName() + "'; Please create your own "
                    + PickupDragController.class.getName()
                    + " and override saveSelectedWidgetsLocationAndStyle(), restoreSelectedWidgetsLocation() and restoreSelectedWidgetsStyle()");
        }

        widget.getElement().getStyle().setProperty("margin", "0px");
        savedWidgetInfoMap.put(widget, info);
    }
}

From source file:org.vectomatic.svg.edit.client.gxt.form.SVGLengthContainer.java

License:Open Source License

public static boolean containsField(Field<?> f) {
    Widget w = f;
    while ((w = w.getParent()) != null) {
        if (w instanceof SVGLengthContainer) {
            return true;
        }//from w w  w . j a  v a2s . c  om
    }
    return false;
}

From source file:org.viewer.client.MySplitLayoutPanel.java

License:Apache License

/**
 * Sets the minimum allowable size for the given widget.
 *
 * <p>/*from  w ww .  ja v  a 2 s .  co m*/
 * Its associated splitter cannot be dragged to a position that would make it
 * smaller than this size. This method has no effect for the
 * {@link DockLayoutPanel.Direction#CENTER} widget.
 * </p>
 *
 * @param child the child whose minimum size will be set
 * @param minSize the minimum size for this widget
 */
public void setWidgetMinSize(Widget child, int minSize) {
    //assertIsChild(child);
    assert (child == null) || (child.getParent() == this) : "The specified widget is not a child of this panel";
    Splitter splitter = getAssociatedSplitter(child);
    // The splitter is null for the center element.
    if (splitter != null) {
        splitter.setMinSize(minSize);
    }
}

From source file:org.viewer.client.MySplitLayoutPanel.java

License:Apache License

/**
 * Sets a size below which the slider will close completely. This can be used
 * in conjunction with {@link #setWidgetMinSize} to provide a speed-bump
 * effect where the slider will stick to a preferred minimum size before
 * closing completely./* ww  w.j  av a  2 s  . c o  m*/
 *
 * <p>
 * This method has no effect for the {@link DockLayoutPanel.Direction#CENTER}
 * widget.
 * </p>
 *
 * @param child the child whose slider should snap closed
 * @param snapClosedSize the width below which the widget will close or
 *        -1 to disable.
 */
public void setWidgetSnapClosedSize(Widget child, int snapClosedSize) {
    //assertIsChild(child);
    assert (child == null) || (child.getParent() == this) : "The specified widget is not a child of this panel";
    Splitter splitter = getAssociatedSplitter(child);
    // The splitter is null for the center element.
    if (splitter != null) {
        splitter.setSnapClosedSize(snapClosedSize);
    }
}

From source file:org.viewer.client.MySplitLayoutPanel.java

License:Apache License

/**
 * Sets whether or not double-clicking on the splitter should toggle the
 * display of the widget.//  www  .  j av  a  2 s .c  o  m
 *
 * @param child the child whose display toggling will be allowed or not.
 * @param allowed whether or not display toggling is allowed for this widget
 */
public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
    //assertIsChild(child);
    assert (child == null) || (child.getParent() == this) : "The specified widget is not a child of this panel";
    Splitter splitter = getAssociatedSplitter(child);
    // The splitter is null for the center element.
    if (splitter != null) {
        splitter.setToggleDisplayAllowed(allowed);
    }
}

From source file:org.waveprotocol.wave.client.editor.gwt.GwtRenderingMutationHandler.java

License:Apache License

private void maybeLogicalDetach(ContentElement element) {
    Widget w = getGwtWidget(element);
    LogicalPanel p = getLogicalPanel(element);
    if (p != null && w != null && w.getParent() != null) {
        p.doOrphan(w);/*from  www  . j ava  2s  . c  o m*/
    }
}

From source file:org.waveprotocol.wave.client.widget.common.ImplPanel.java

License:Apache License

@Override
public void doAdopt(Widget child) {
    Preconditions.checkArgument(child != null && child.getParent() == null, "Not an orphan");
    getChildren().add(child);//from   w  w w.j  ava  2  s. c  o  m
    adopt(child);
}

From source file:org.waveprotocol.wave.client.widget.common.ImplPanel.java

License:Apache License

@Override
public void doOrphan(Widget child) {
    Preconditions.checkArgument(child != null && child.getParent() == this, "Not a child");
    orphan(child);/*from   ww  w .  jav  a 2 s.co m*/
    getChildren().remove(child);
}

From source file:org.waveprotocol.wave.client.widget.common.ImplPanel.java

License:Apache License

/**
 * Narrows an object to a widget, if it is a child of this panel. Otherwise,
 * throws an exception./* w  w w  .  j  av  a 2  s .c  o  m*/
 *
 * @param o object to narrow
 * @return {@code o} as a widget
 * @throws IllegalArgumentException if {@code o} is not a child of this panel.
 */
public Widget narrowChild(Object o) {
    // Note: it is very important that this method can be implemented WITHOUT
    // casting.  This implementation uses casting as an optimization.  However,
    // a non-casting version is provided in comments. Anyone touching this
    // method must ensure that a non-casting possibility exists.
    //
    // for (Widget child : getChildren()) {
    //   if (child == o) {
    //     return child;
    //   }
    // }
    // return null;
    //
    Widget w = o instanceof Widget ? (Widget) o : null;
    if (w != null && w.getParent() == this) {
        return w;
    } else {
        throw new IllegalArgumentException("Not a child");
    }
}