Class Escalator
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.vaadin.v7.client.widgets.Escalator
-
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.IsWidget,com.google.gwt.user.client.ui.RequiresResize,DeferredWorker,SubPartAware
public class Escalator extends com.google.gwt.user.client.ui.Widget implements com.google.gwt.user.client.ui.RequiresResize, DeferredWorker, SubPartAware
A low-level table-like widget that features a scrolling virtual viewport and lazily generated rows.- Since:
- 7.4
- Author:
- Vaadin Ltd
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classEscalator.AbstractRowContainerstatic classEscalator.SubPartArgumentsUtility class for parsing and storing SubPart request string attributes for Grid and Escalator.
-
Constructor Summary
Constructors Constructor Description Escalator()Creates a new Escalator widget instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistrationaddRowVisibilityChangeHandler(RowVisibilityChangeHandler rowVisibilityChangeHandler)Adds an event handler that gets notified when the range of visible rows changes e.g. because of scrolling, row resizing or spacers appearing/disappearing.com.google.gwt.event.shared.HandlerRegistrationaddScrollHandler(ScrollHandler handler)Adds a scroll handler to this escalator.RowContainerfindRowContainer(com.google.gwt.dom.client.Element element)Returns theRowContainerwhich contains the element.RowContainer.BodyRowContainergetBody()Returns the row container for the body in this Escalator.ColumnConfigurationgetColumnConfiguration()Returns the configuration object for the columns in this Escalator.RowContainergetFooter()Returns the row container for the footer in this Escalator.RowContainergetHeader()Returns the row container for the header in this Escalator.doublegetHeightByRows()Gets the amount of rows in Escalator's body that are shown, whilegetHeightMode()isHeightMode.ROW.HeightModegetHeightMode()Returns the currentHeightModethe Escalator is in.doublegetInnerWidth()Gets the escalator's inner width.intgetMaxVisibleRowCount()Gets the maximum number of body rows that can be visible on the screen at once.doublegetScrollHeight()Returns the scroll height for the escalator.doublegetScrollLeft()Returns the logical horizontal scroll offset.doublegetScrollTop()Returns the vertical scroll offset.doublegetScrollWidth()Returns the scroll width for the escalator.com.google.gwt.user.client.ElementgetSubPartElement(String subPart)StringgetSubPartName(com.google.gwt.user.client.Element subElement)com.vaadin.shared.RangegetVisibleRowRange()Gets the logical index range of currently visible rows.booleanisScrollLocked(ScrollbarBundle.Direction direction)Checks whether or not an direction is locked for scrolling.booleanisWorkPending()protected voidonLoad()voidonResize()protected voidonUnload()voidresetSizesFromDom()Resets all cached pixel sizes and reads new values from the DOM.voidscrollToColumn(int columnIndex, ScrollDestination destination, int padding)Scrolls the body horizontally so that the column at the given index is visible and there is at leastpaddingpixels in the direction of the given scroll destination.voidscrollToRow(int rowIndex, ScrollDestination destination, int padding)Scrolls the body vertically so that the row at the given index is visible and there is at least padding pixels to the given scroll destination.voidscrollToRowAndSpacer(int rowIndex, ScrollDestination destination, int padding)Scrolls vertically to a row and the spacer below it.voidscrollToSpacer(int spacerIndex, ScrollDestination destination, int padding)Scrolls the body vertically so that the spacer at the given row index is visible and there is at least padding pixesl to the given scroll destination.voidsetHeight(String height)voidsetHeightByRows(double rows)Sets the number of rows that should be visible in Escalator's body, whilegetHeightMode()isHeightMode.ROW.voidsetHeightMode(HeightMode heightMode)Defines the mode in which the Escalator widget's height is calculated.voidsetScrollLeft(double scrollLeft)Sets the logical horizontal scroll offset.voidsetScrollLocked(ScrollbarBundle.Direction direction, boolean locked)Sets whether a scroll direction is locked or not.voidsetScrollTop(double scrollTop)Sets the vertical scroll offset.voidsetStylePrimaryName(String style)voidsetWidth(String width)-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, setVisible, sinkBitlessEvent, toString
-
-
-
-
Method Detail
-
onLoad
protected void onLoad()
- Overrides:
onLoadin classcom.google.gwt.user.client.ui.Widget
-
onUnload
protected void onUnload()
- Overrides:
onUnloadin classcom.google.gwt.user.client.ui.Widget
-
getHeader
public RowContainer getHeader()
Returns the row container for the header in this Escalator.- Returns:
- the header. Never
null
-
getBody
public RowContainer.BodyRowContainer getBody()
Returns the row container for the body in this Escalator.- Returns:
- the body. Never
null
-
getFooter
public RowContainer getFooter()
Returns the row container for the footer in this Escalator.- Returns:
- the footer. Never
null
-
getColumnConfiguration
public ColumnConfiguration getColumnConfiguration()
Returns the configuration object for the columns in this Escalator.- Returns:
- the configuration object for the columns in this Escalator. Never
null
-
setWidth
public void setWidth(String width)
- Overrides:
setWidthin classcom.google.gwt.user.client.ui.UIObject
-
setHeight
public void setHeight(String height)
If Escalator is currently not in
HeightMode.CSS, the given value is remembered, and applied once the mode is applied.- Overrides:
setHeightin classcom.google.gwt.user.client.ui.UIObject- See Also:
setHeightMode(HeightMode)
-
getScrollTop
public double getScrollTop()
Returns the vertical scroll offset. Note that this is not necessarily the same as thescrollTopattribute in the DOM.- Returns:
- the logical vertical scroll offset
-
setScrollTop
public void setScrollTop(double scrollTop)
Sets the vertical scroll offset. Note that this will not necessarily become the same as thescrollTopattribute in the DOM.- Parameters:
scrollTop- the number of pixels to scroll vertically
-
getScrollLeft
public double getScrollLeft()
Returns the logical horizontal scroll offset. Note that this is not necessarily the same as thescrollLeftattribute in the DOM.- Returns:
- the logical horizontal scroll offset
-
setScrollLeft
public void setScrollLeft(double scrollLeft)
Sets the logical horizontal scroll offset. Note that will not necessarily become the same as thescrollLeftattribute in the DOM.- Parameters:
scrollLeft- the number of pixels to scroll horizontally
-
getScrollWidth
public double getScrollWidth()
Returns the scroll width for the escalator. Note that this is not necessary the same asElement.scrollWidthin the DOM.- Returns:
- the scroll width in pixels
- Since:
- 7.5.0
-
getScrollHeight
public double getScrollHeight()
Returns the scroll height for the escalator. Note that this is not necessary the same asElement.scrollHeightin the DOM.- Returns:
- the scroll height in pixels
- Since:
- 7.5.0
-
scrollToColumn
public void scrollToColumn(int columnIndex, ScrollDestination destination, int padding) throws IndexOutOfBoundsException, IllegalArgumentExceptionScrolls the body horizontally so that the column at the given index is visible and there is at leastpaddingpixels in the direction of the given scroll destination.- Parameters:
columnIndex- the index of the column to scroll todestination- where the column should be aligned visually after scrollingpadding- the number pixels to place between the scrolled-to column and the viewport edge.- Throws:
IndexOutOfBoundsException- ifcolumnIndexis not a valid index for an existing columnIllegalArgumentException- ifdestinationisScrollDestination.MIDDLEand padding is nonzero; or if the indicated column is frozen; or ifdestination == null
-
scrollToRow
public void scrollToRow(int rowIndex, ScrollDestination destination, int padding) throws IndexOutOfBoundsException, IllegalArgumentExceptionScrolls the body vertically so that the row at the given index is visible and there is at least padding pixels to the given scroll destination.- Parameters:
rowIndex- the index of the logical row to scroll todestination- where the row should be aligned visually after scrollingpadding- the number pixels to place between the scrolled-to row and the viewport edge.- Throws:
IndexOutOfBoundsException- ifrowIndexis not a valid index for an existing rowIllegalArgumentException- ifdestinationisScrollDestination.MIDDLEand padding is nonzero; or ifdestination == null- See Also:
scrollToRowAndSpacer(int, ScrollDestination, int),scrollToSpacer(int, ScrollDestination, int)
-
scrollToSpacer
public void scrollToSpacer(int spacerIndex, ScrollDestination destination, int padding) throws IllegalArgumentExceptionScrolls the body vertically so that the spacer at the given row index is visible and there is at least padding pixesl to the given scroll destination.- Parameters:
spacerIndex- the row index of the spacer to scroll todestination- where the spacer should be aligned visually after scrollingpadding- the number of pixels to place between the scrolled-to spacer and the viewport edge- Throws:
IllegalArgumentException- ifspacerIndexis not an opened spacer; or ifdestinationisScrollDestination.MIDDLEand padding is nonzero; or ifdestination == null- Since:
- 7.5.0
- See Also:
scrollToRow(int, ScrollDestination, int),scrollToRowAndSpacer(int, ScrollDestination, int)
-
scrollToRowAndSpacer
public void scrollToRowAndSpacer(int rowIndex, ScrollDestination destination, int padding) throws IllegalArgumentExceptionScrolls vertically to a row and the spacer below it.If a spacer is not open at that index, this method behaves like
scrollToRow(int, ScrollDestination, int)- Parameters:
rowIndex- the index of the logical row to scroll to. -1 takes the topmost spacer into account as well.destination- where the row should be aligned visually after scrollingpadding- the number pixels to place between the scrolled-to row and the viewport edge.- Throws:
IllegalArgumentException- ifdestinationisScrollDestination.MIDDLEandpaddingis not zero; or ifrowIndexis not a valid row index, or -1; or ifdestination == null; or ifrowIndex == -1and there is no spacer open at that index.- Since:
- 7.5.0
- See Also:
scrollToRow(int, ScrollDestination, int),scrollToSpacer(int, ScrollDestination, int)
-
addRowVisibilityChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addRowVisibilityChangeHandler(RowVisibilityChangeHandler rowVisibilityChangeHandler)
Adds an event handler that gets notified when the range of visible rows changes e.g. because of scrolling, row resizing or spacers appearing/disappearing.- Parameters:
rowVisibilityChangeHandler- the event handler- Returns:
- a handler registration for the added handler
-
getVisibleRowRange
public com.vaadin.shared.Range getVisibleRowRange()
Gets the logical index range of currently visible rows.- Returns:
- logical index range of visible rows
-
setStylePrimaryName
public void setStylePrimaryName(String style)
- Overrides:
setStylePrimaryNamein classcom.google.gwt.user.client.ui.UIObject
-
setHeightByRows
public void setHeightByRows(double rows) throws IllegalArgumentExceptionSets the number of rows that should be visible in Escalator's body, whilegetHeightMode()isHeightMode.ROW.If Escalator is currently not in
HeightMode.ROW, the given value is remembered, and applied once the mode is applied.- Parameters:
rows- the number of rows that should be visible in Escalator's body- Throws:
IllegalArgumentException- ifrowsis ≤ 0,infiniteorNaN.- See Also:
setHeightMode(HeightMode)
-
getHeightByRows
public double getHeightByRows()
Gets the amount of rows in Escalator's body that are shown, whilegetHeightMode()isHeightMode.ROW.By default, it is 10.
- Returns:
- the amount of rows that are being shown in Escalator's body
- See Also:
setHeightByRows(double)
-
setHeightMode
public void setHeightMode(HeightMode heightMode)
Defines the mode in which the Escalator widget's height is calculated.If
HeightMode.CSSis given, Escalator will respect the values given viasetHeight(String), and behave as a traditional Widget.If
HeightMode.ROWis given, Escalator will make sure that thebodywill display as many rows asgetHeightByRows()defines. Note: If headers/footers are inserted or removed, the widget will resize itself to still display the required amount of rows in its body. It also takes the horizontal scrollbar into account.- Parameters:
heightMode- the mode in to which Escalator should be set
-
getHeightMode
public HeightMode getHeightMode()
Returns the currentHeightModethe Escalator is in.Defaults to
HeightMode.CSS.- Returns:
- the current HeightMode
-
findRowContainer
public RowContainer findRowContainer(com.google.gwt.dom.client.Element element)
Returns theRowContainerwhich contains the element.- Parameters:
element- the element to check for- Returns:
- the container the element is in or
nullif element is not present in any container.
-
setScrollLocked
public void setScrollLocked(ScrollbarBundle.Direction direction, boolean locked)
Sets whether a scroll direction is locked or not.If a direction is locked, the escalator will refuse to scroll in that direction.
- Parameters:
direction- the orientation of the scroll to set the lock statuslocked-trueto lock,falseto unlock
-
isScrollLocked
public boolean isScrollLocked(ScrollbarBundle.Direction direction)
Checks whether or not an direction is locked for scrolling.- Parameters:
direction- the direction of the scroll of which to check the lock status- Returns:
trueif the direction is locked
-
addScrollHandler
public com.google.gwt.event.shared.HandlerRegistration addScrollHandler(ScrollHandler handler)
Adds a scroll handler to this escalator.- Parameters:
handler- the scroll handler to add- Returns:
- a handler registration for the registered scroll handler
-
isWorkPending
public boolean isWorkPending()
- Specified by:
isWorkPendingin interfaceDeferredWorker
-
onResize
public void onResize()
- Specified by:
onResizein interfacecom.google.gwt.user.client.ui.RequiresResize
-
getMaxVisibleRowCount
public int getMaxVisibleRowCount()
Gets the maximum number of body rows that can be visible on the screen at once.- Returns:
- the maximum capacity
-
getInnerWidth
public double getInnerWidth()
Gets the escalator's inner width. This is the entire width in pixels, without the vertical scrollbar.- Returns:
- escalator's inner width
-
resetSizesFromDom
public void resetSizesFromDom()
Resets all cached pixel sizes and reads new values from the DOM. This methods should be used e.g. when styles affecting the dimensions of elements in this escalator have been changed.
-
getSubPartElement
public com.google.gwt.user.client.Element getSubPartElement(String subPart)
- Specified by:
getSubPartElementin interfaceSubPartAware
-
getSubPartName
public String getSubPartName(com.google.gwt.user.client.Element subElement)
- Specified by:
getSubPartNamein interfaceSubPartAware
-
-