List of usage examples for com.google.gwt.user.client.ui ScrollPanel scrollToBottom
public void scrollToBottom()
From source file:org.opencms.ade.galleries.client.ui.CmsResultsTab.java
License:Open Source License
/** * Scrolls to the result which corresponds to a preset value in the editor.<p> *///from www. jav a 2s . co m protected void scrollToPreset() { final ScrollPanel scrollPanel = getList(); if (m_preset != null) { Widget child = scrollPanel.getWidget(); if (child instanceof CmsList<?>) { @SuppressWarnings("unchecked") CmsList<I_CmsListItem> list = (CmsList<I_CmsListItem>) child; if (list.getWidgetCount() > 0) { final Widget first = (Widget) list.getItem(0); Timer timer = new Timer() { @Override public void run() { int firstTop = first.getElement().getAbsoluteTop(); int presetTop = m_preset.getElement().getAbsoluteTop(); final int offset = presetTop - firstTop; if (offset >= 0) { scrollPanel.setVerticalScrollPosition(offset); } else { // something is seriously wrong with the positioning if this case occurs scrollPanel.scrollToBottom(); } } }; timer.schedule(10); } } } }