/** * Assert that the specified widget is null or a child of this widget. * * @param widget the widget to check */ void assertIsChild(Widget widget) { assert (widget == null) || (widget.getParent() == this) : "The specified widget is not a child of this panel"; }
/** * Show the specified widget. If the widget is not a child of this panel, it * is added to the end of the panel. If the specified widget is null, the * currently-visible widget will be hidden. * * @param widget the widget to show, and add if not a child */ @Override public void setWidget(IsWidget widget) { // Hide the currently visible widget. if (widget == null) { showWidget(null); return; } // Add the widget if it is not already a child. if (widget.asWidget().getParent() != this) { add(widget); } // Show the widget. showWidget(widget.asWidget()); }
/** * Assert that the specified widget is null or a child of this widget. * * @param widget the widget to check */ void assertIsChild(Widget widget) { assert (widget == null) || (widget.getParent() == this) : "The specified widget is not a child of this panel"; }
private void assertIsChild(Widget widget) { assert (widget == null) || (widget.getParent() == this) : "The specified widget is not a child of this panel"; }
void assertIsChild(Widget widget) { assert (widget == null) || (widget.getParent() == this) : "The specified widget is not a child of this panel"; }
private void checkWidgetParent(Widget w) { if (w.getParent() != this) { throw new IllegalArgumentException( "Widget must be a child of this panel."); } }
private Layout.Layer getLayer(Widget child) { assert child.getParent() == this : "The requested widget is not a child of this panel"; return (Layout.Layer) child.getLayoutData(); } }
public void remove() { if (lastIndex < 0) { throw new IllegalStateException(); } Widget w = widgetList.get(lastIndex); assert (w.getParent() instanceof HTMLTable); w.removeFromParent(); lastIndex = -1; }
void orphan(Widget widget) { // Validation should already be done. assert (widget.getParent() == this); // Orphan. try { widget.setParent(null); } finally { // Logical detach. childWidgets.remove(widget); } }
/** * Gets the layout direction of the given child widget. * * @param w the widget to be queried * @return the widget's layout direction, or <code>null</code> if it is not * a child of this panel */ public DockLayoutConstant getWidgetDirection(Widget w) { if (w.getParent() != this) { return null; } return ((LayoutData) w.getLayoutData()).direction; }
/** * Finalize the attachment of a Widget to this Panel. This method is the * <b>last</b> step in adding or inserting a Widget into a Panel, and should * be called after physical attachment in the DOM is complete. This Panel * becomes the parent of the child Widget, and the child will now fire its * {@link Widget#onAttach()} event if this Panel is currently attached. * * @param child the widget to be adopted * @see #add(Widget) */ protected final void adopt(Widget child) { assert (child.getParent() == null); child.setParent(this); }
/** * <p> * This method must be called as part of the remove method of any Panel. It * ensures that the Widget's parent is cleared. This method should be called * after verifying that the child Widget is an existing child of the Panel, * but before physically removing the child Widget from the DOM. The child * will now fire its {@link Widget#onDetach()} event if this Panel is * currently attached. * </p> * <p> * Calls to {@link #orphan(Widget)} should be wrapped in a try/finally block * to ensure that the widget is physically detached even if orphan throws an * exception. * </p> * * @param child the widget to be disowned * @see #add(Widget) */ protected final void orphan(Widget child) { assert (child.getParent() == this); child.setParent(null); } }
Element getWidgetTd(Widget w) { if (w.getParent() != this) { return null; } return DOM.getParent(w.getElement()); } }
/** * Gets the layout direction of the given child widget. * * @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; }
/** * Gets the layout size of the given child widget. * * @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; }
/** * Adjusts beforeIndex to account for the possibility that the given widget is * already a child of this panel. * * @param child the widget that might be an existing child * @param beforeIndex the index at which it will be added to this panel * @return the modified index */ protected int adjustIndex(Widget child, int beforeIndex) { checkIndexBoundsForInsertion(beforeIndex); // Check to see if this widget is already a direct child. if (child.getParent() == this) { // If the Widget's previous position was left of the desired new position // shift the desired position left to reflect the removal int idx = getWidgetIndex(child); if (idx < beforeIndex) { beforeIndex--; } } return beforeIndex; }
/** * Show the specified widget. If the widget is not a child of this panel, it * is added to the end of the panel. If the specified widget is null, the * currently-visible widget will be hidden. * * @param w the widget to show, and add if not a child */ @Override public void setWidget(IsWidget w) { // Hide the currently visible widget. if (w == null) { showWidget(null); return; } // Add the widget if it is not already a child. if (w.asWidget().getParent() != this) { add(w); } // Show the widget. showWidget(w.asWidget()); }
/** * Remove the specified widget from the table. * * @param widget widget to remove * @return was the widget removed from the table. */ @Override public boolean remove(Widget widget) { // Validate. if (widget.getParent() != this) { return false; } // Orphan. try { orphan(widget); } finally { // Physical detach. Element elem = widget.getElement(); DOM.getParent(elem).removeChild(elem); // Logical detach. widgetMap.removeByElement(elem); } return true; }
@Override public boolean remove(Widget w) { // Validate. if (w.getParent() != this) { return false; } // Orphan. try { orphan(w); } finally { // Physical detach. Element elem = w.getElement(); DOM.getParent(elem).removeChild(elem); // Logical detach. getChildren().remove(w); } return true; }
@Override public boolean remove(Widget w) { // Validate. if (w.getParent() != this) { return false; } // Orphan. try { orphan(w); } finally { // Physical detach. w.getElement().removeFromParent(); // Logical detach. if (w == content) { content = null; contentContainer.getStyle().setDisplay(Display.NONE); } else if (w == header) { header = null; headerContainer.getStyle().setDisplay(Display.NONE); } else if (w == footer) { footer = null; footerContainer.getStyle().setDisplay(Display.NONE); } } return true; }