/** * Hide the widget that just slid out of view. */ private void doAfterLayout() { if (hidingWidget != null) { Layer layer = (Layer) hidingWidget.getLayoutData(); setWidgetVisible(hidingWidget, layer, false); layout.layout(); hidingWidget = null; } }
@Override public boolean remove(Widget widget) { boolean removed = super.remove(widget); if (removed) { Layer layer = (Layer) widget.getLayoutData(); layout.removeChild(layer); widget.setLayoutData(null); if (visibleWidget == widget) { visibleWidget = null; } if (hidingWidget == widget) { hidingWidget = null; } if (lastVisibleWidget == widget) { lastVisibleWidget = null; } } return removed; }
: (Layer) lastVisibleWidget.getLayoutData(); Layer newLayer = (visibleWidget == null) ? null : (Layer) visibleWidget.getLayoutData();
public void setMinSize(int minSize) { this.minSize = minSize; LayoutData layout = (LayoutData) target.getLayoutData(); // Try resetting the associated widget's size, which will enforce the new // minSize value. setAssociatedWidgetSize((int) layout.size); }
private double getMaxSize() { // To avoid seeing stale center size values due to deferred layout // updates, maintain our own copy up to date and resync when the // DockLayoutPanel value changes. double newCenterSize = getCenterSize(); if (syncedCenterSize != newCenterSize) { syncedCenterSize = newCenterSize; centerSize = newCenterSize; } return Math.max(((LayoutData) target.getLayoutData()).size + centerSize, 0); }
/** * 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; }
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(); } }
/** * Gets the container element wrapping the given child widget. * * @param child * @return the widget's container element */ public Element getWidgetContainerElement(Widget child) { assertIsChild(child); return ((LayoutData) child.getLayoutData()).layer.getContainerElement(); }
@Override public void setCellVerticalAlignment(Widget w, VerticalAlignmentConstant align) { LayoutData data = (LayoutData) w.getLayoutData(); data.vAlign = align.getVerticalAlignString(); if (data.td != null) { setCellVerticalAlignment(data.td, align); } }
@Override public void setCellWidth(Widget w, String width) { LayoutData data = (LayoutData) w.getLayoutData(); data.width = width; if (data.td != null) { data.td.getStyle().setProperty("width", data.width); } }
@Override public boolean remove(Widget w) { boolean removed = super.remove(w); if (removed) { layout.removeChild((Layer) w.getLayoutData()); } return removed; }
/** * Hide the widget that just slid out of view. */ private void doAfterLayout() { if (hidingWidget != null) { Layer layer = (Layer) hidingWidget.getLayoutData(); setWidgetVisible(hidingWidget, layer, false); layout.layout(); hidingWidget = null; } }
@Override public void setCellHeight(Widget w, String height) { LayoutData data = (LayoutData) w.getLayoutData(); data.height = height; if (data.td != null) { data.td.getStyle().setProperty("height", data.height); } }
@Override public boolean remove(Widget w) { boolean removed = super.remove(w); if (removed) { // Clear the center widget. if (w == center) { center = null; } LayoutData data = (LayoutData) w.getLayoutData(); layout.removeChild(data.layer); } return removed; }
@Override public void setCellHorizontalAlignment(Widget w, HorizontalAlignmentConstant align) { LayoutData data = (LayoutData) w.getLayoutData(); data.hAlign = align.getTextAlignString(); if (data.td != null) { setCellHorizontalAlignment(data.td, align); } }
/** * 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; }
/** * Updates the size of the widget passed in as long as it is not the center * widget and updates the layout of the dock. * * @param widget the widget that needs to update its size * @param size the size to update the widget to */ public void setWidgetSize(Widget widget, double size) { assertIsChild(widget); LayoutData data = (LayoutData) widget.getLayoutData(); assert data.direction != Direction.CENTER : "The size of the center widget can not be updated."; data.size = size; // Update the layout. animate(0); }
/** * 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; }
/** * Sets whether or not the given widget should be hidden. * * @param widget the widget to hide or display * @param hidden true to hide the widget, false to display it */ public void setWidgetHidden(Widget widget, boolean hidden) { assertIsChild(widget); LayoutData data = (LayoutData) widget.getLayoutData(); if (data.hidden == hidden) { return; } data.hidden = hidden; animate(0); }
@Override public boolean remove(Widget w) { boolean removed = super.remove(w); if (removed) { Layer layer = (Layer) w.getLayoutData(); layout.removeChild(layer); w.setLayoutData(null); if (visibleWidget == w) { visibleWidget = null; } if (hidingWidget == w) { hidingWidget = null; } if (lastVisibleWidget == w) { lastVisibleWidget = null; } } return removed; }