Search in sources :

Example 1 with ScrollEvent

use of com.google.gwt.event.dom.client.ScrollEvent in project rstudio by rstudio.

the class EnvironmentObjects method setDeferredObjectDisplay.

private void setDeferredObjectDisplay() {
    if (deferredObjectDisplayType_ == null) {
        return;
    }
    final int type = deferredObjectDisplayType_;
    // if we already have an active display of this type, do nothing
    if (type == objectDisplayType_ && objectDisplay_ != null) {
        return;
    }
    // clean up previous object display, if we had one
    if (objectDisplay_ != null) {
        objectDataProvider_.removeDataDisplay(objectDisplay_);
        splitPanel.remove(objectDisplay_);
    }
    try {
        // create the new object display and wire it to the data source
        if (type == OBJECT_LIST_VIEW) {
            objectDisplay_ = new EnvironmentObjectList(this, observer_, environmentName_);
            objectSort_.setSortType(RObjectEntrySort.SORT_AUTO);
        } else if (type == OBJECT_GRID_VIEW) {
            objectDisplay_ = new EnvironmentObjectGrid(this, observer_, environmentName_);
            objectSort_.setSortType(RObjectEntrySort.SORT_COLUMN);
        }
    } catch (Throwable e) {
        if (SuperDevMode.isActive()) {
            if (gridRenderRetryCount_ >= 5) {
                Debug.log("WARNING: Failed to render environment pane data grid");
            }
            gridRenderRetryCount_++;
            Debug.log("WARNING: Retrying environment data grid render (" + gridRenderRetryCount_ + ")");
            Timer t = new Timer() {

                @Override
                public void run() {
                    setObjectDisplay(type);
                }
            };
            t.schedule(5);
        }
        return;
    }
    objectDisplayType_ = type;
    Collections.sort(objectDataProvider_.getList(), objectSort_);
    updateCategoryLeaders(false);
    objectDataProvider_.addDataDisplay(objectDisplay_);
    objectDisplay_.getScrollPanel().addScrollHandler(new ScrollHandler() {

        @Override
        public void onScroll(ScrollEvent event) {
            if (useStatePersistence()) {
                deferredScrollPosition_ = getScrollPosition();
                observer_.setPersistedScrollPosition(deferredScrollPosition_);
            }
        }
    });
    objectDisplay_.setEmptyTableWidget(buildEmptyGridMessage());
    objectDisplay_.addStyleName(style.objectGrid());
    objectDisplay_.addStyleName(style.environmentPanel());
    splitPanel.add(objectDisplay_);
    deferredObjectDisplayType_ = null;
}
Also used : ScrollHandler(com.google.gwt.event.dom.client.ScrollHandler) Timer(com.google.gwt.user.client.Timer) ScrollEvent(com.google.gwt.event.dom.client.ScrollEvent)

Example 2 with ScrollEvent

use of com.google.gwt.event.dom.client.ScrollEvent in project drools-wb by kiegroup.

the class GuidedDecisionTableModellerViewImplTest method testRadarIsUpdatedAfterScrolling.

@Test
public void testRadarIsUpdatedAfterScrolling() throws Exception {
    final ArgumentCaptor<ScrollHandler> scrollHandler = ArgumentCaptor.forClass(ScrollHandler.class);
    final ScrollEvent scrollEvent = mock(ScrollEvent.class);
    final AbsolutePanel mainPanel = mock(AbsolutePanel.class);
    final Transform transform = mock(Transform.class);
    final Viewport viewport = mock(Viewport.class);
    final Mediators mediators = mock(Mediators.class);
    final Element element = mock(Element.class);
    doReturn(transform).when(transform).scale(anyDouble());
    doReturn(presenter).when(view).getPresenter();
    doReturn(transform).when(view).newTransform();
    doReturn(mediators).when(viewport).getMediators();
    doReturn(element).when(mockGridPanel).getElement();
    doReturn(mainPanel).when(mockGridPanel).getScrollPanel();
    doReturn(viewport).when(mockGridPanel).getViewport();
    view.setupGridPanel();
    verify(mainPanel).addDomHandler(scrollHandler.capture(), eq(ScrollEvent.getType()));
    scrollHandler.getValue().onScroll(scrollEvent);
    verify(presenter).updateRadar();
}
Also used : ScrollHandler(com.google.gwt.event.dom.client.ScrollHandler) ScrollEvent(com.google.gwt.event.dom.client.ScrollEvent) Mediators(com.ait.lienzo.client.core.mediator.Mediators) Element(com.google.gwt.user.client.Element) Viewport(com.ait.lienzo.client.core.shape.Viewport) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) Transform(com.ait.lienzo.client.core.types.Transform) Test(org.junit.Test)

Aggregations

ScrollEvent (com.google.gwt.event.dom.client.ScrollEvent)2 ScrollHandler (com.google.gwt.event.dom.client.ScrollHandler)2 Mediators (com.ait.lienzo.client.core.mediator.Mediators)1 Viewport (com.ait.lienzo.client.core.shape.Viewport)1 Transform (com.ait.lienzo.client.core.types.Transform)1 Element (com.google.gwt.user.client.Element)1 Timer (com.google.gwt.user.client.Timer)1 AbsolutePanel (com.google.gwt.user.client.ui.AbsolutePanel)1 Test (org.junit.Test)1