Java 类com.google.gwt.event.dom.client.ScrollHandler 实例源码

项目:Peergos    文件:ShowMorePagerPanel.java   
/**
 * Construct a new {@link ShowMorePagerPanel}.
 */
public ShowMorePagerPanel() {
  initWidget(scrollable);

  // Do not let the scrollable take tab focus.
  scrollable.getElement().setTabIndex(-1);

  // Handle scroll events.
  scrollable.addScrollHandler(new ScrollHandler() {
    public void onScroll(ScrollEvent event) {
      // If scrolling up, ignore the event.
      int oldScrollPos = lastScrollPos;
      lastScrollPos = scrollable.getVerticalScrollPosition();
      if (oldScrollPos >= lastScrollPos) {
        return;
      }

      HasRows display = getDisplay();
      if (display == null) {
        return;
      }
      int maxScrollTop = scrollable.getWidget().getOffsetHeight()
          - scrollable.getOffsetHeight();
      if (lastScrollPos >= maxScrollTop) {
        // We are near the end, so increase the page size.
        int newPageSize = Math.min(
            display.getVisibleRange().getLength() + incrementSize,
            display.getRowCount());
        display.setVisibleRange(0, newPageSize);
      }
    }
  });
}
项目:vaadin-scrollable-panel    文件:ScrollablePanelWidget.java   
public ScrollablePanelWidget() {
    super();
    setTouchScrollingDisabled(true);

    addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(final ScrollEvent event) {
            ScrollablePanelWidget.this.currentScrollingPos = new ScrollData();

            if (event != null && event.getRelativeElement() != null) {
                final Element e = event.getRelativeElement();

                ScrollablePanelWidget.this.currentScrollingPos.setTop(e.getScrollTop());
                ScrollablePanelWidget.this.currentScrollingPos.setLeft(e.getScrollLeft());
                ScrollablePanelWidget.this.currentScrollingPos.setBottom(e.getScrollHeight() - (e.getScrollTop() + e.getOffsetHeight()));
                ScrollablePanelWidget.this.currentScrollingPos.setRight(e.getScrollWidth() - (e.getScrollLeft() + e.getOffsetWidth()));
                ScrollablePanelWidget.this.currentScrollingPos.setScrollHeight(e.getScrollHeight());
                ScrollablePanelWidget.this.currentScrollingPos.setScrollWidth(e.getScrollWidth());
            }

            startTrigger();
        }
    });

}
项目:firefly    文件:WebPlotView.java   
public void onScroll() {
    int x= getScrollX();
    int y= getScrollY();

    int w= getScrollWidth();
    int h= getScrollHeight();
    if (_lastX!=x || _lastY!=y || _lastW!=w || _lastH!=h) {
        //todo - no lose this optimization - i think it needs to be somewhere else now
        _lastX= x;
        _lastY= y;
        _lastW= w;
        _lastH= h;
    }

    if (_primaryScrollInfo!=null) {
        _primaryScrollInfo._sWidth= w;
        _primaryScrollInfo._sHeight= h;
        _primaryScrollInfo._scrollHPos= x;
        _primaryScrollInfo._scrollVPos= y;
    }
    for(ScrollHandler handler : _scrollHandlerList) {
        handler.onScroll(null);
    }
}
项目:appformer    文件:GridLienzoPanel.java   
private void setupDefaultHandlers() {
    //Prevent DOMElements scrolling into view when they receive the focus
    domElementContainer.addDomHandler(new ScrollHandler() {

                                          @Override
                                          public void onScroll(final ScrollEvent scrollEvent) {
                                              domElementContainer.getElement().setScrollTop(0);
                                              domElementContainer.getElement().setScrollLeft(0);
                                          }
                                      },
                                      ScrollEvent.getType());
    addAttachHandler(new AttachEvent.Handler() {
        @Override
        public void onAttachOrDetach(final AttachEvent event) {
            if (event.isAttached()) {
                onResize();
            }
        }
    });
    addMouseDownHandler((e) -> setFocus(true));
}
项目:appformer    文件:GridLienzoScrollHandlerTest.java   
@Test
public void testSetupScrollBarSynchronization() {

    final AbsolutePanel scrollPanel = mock(AbsolutePanel.class);
    final ScrollHandler scrollHandler = mock(ScrollHandler.class);

    doReturn(scrollHandler).when(gridLienzoScrollHandler).onScroll();
    doReturn(scrollPanel).when(gridLienzoScrollHandler).getScrollPanel();
    doNothing().when(gridLienzoScrollHandler).synchronizeScrollSize();

    gridLienzoScrollHandler.setupScrollBarSynchronization();

    verify(gridLienzoScrollHandler).synchronizeScrollSize();
    verify(scrollPanel).addDomHandler(scrollHandler,
                                      ScrollEvent.getType());
}
项目:gwt-gantt    文件:GanttChartView.java   
public void init() {
        taskScrollPanel.getElement().getStyle().setPosition(Position.ABSOLUTE);
        taskScrollPanel.getElement().getStyle().setOverflow(Overflow.SCROLL);

        //initialize the SVG panel
        initSVG();

        //add scroll handler
        taskScrollPanel.addScrollHandler(new ScrollHandler() {

            @Override
            public void onScroll(ScrollEvent event) {
                int hscroll = taskScrollPanel.getHorizontalScrollPosition() * -1;

                firstHeaderRow.getElement().getStyle().setLeft(hscroll, Unit.PX);
                secondHeaderRow.getElement().getStyle().setLeft(hscroll, Unit.PX);
                taskBackgroundPanel.getElement().getStyle().setLeft(hscroll, Unit.PX);
                display.fireEvent(event);
//                view.onScroll(taskScrollPanel.getHorizontalScrollPosition(),
//                        taskScrollPanel.getScrollPosition());
            }
        });
    }
项目:LazyLayouts    文件:LazyVerticalLayoutConnector.java   
protected void attachScrollingEvents(ComponentConnector connector) {
    Widget widget = connector.getWidget();
    if(widget instanceof LazyScrollNotifier) {
        LazyScrollNotifier not = (LazyScrollNotifier) widget;
        scrollingElement = not.getLazyScrollingElement();
        not.addLazyScrollListener(this);
    } else if (widget instanceof VWindow) {
        final VWindow window = (VWindow)widget;
        scrollingElement = window.contentPanel.getElement();
        handlerRegistration = ((VWindow)widget).contentPanel.addScrollHandler(new ScrollHandler() {
            @Override
            public void onScroll(ScrollEvent event) {
                onLazyScroll(window.contentPanel.getElement());
            }
        });
    } else {
        LOGGER.severe("Failed to connect to scrolling events of " + connector.getClass().getName());
    }
}
项目:EasyML    文件:DiagramController.java   
/**
 * Get the scroll panel in the drawing cavcas.
 * @return
 */
public ScrollPanel getViewAsScrollPanel() {
    scrollPanel.addScrollHandler(new ScrollHandler() {
        @Override
        public void onScroll(ScrollEvent event) {
        }
    });
    return scrollPanel;
}
项目:appformer    文件:GridLienzoScrollHandler.java   
ScrollHandler onScroll() {
    return (ScrollEvent event) -> {
        final Boolean mouseIsNotDragging = !getMousePanMediator().isDragging();

        if (mouseIsNotDragging) {
            updateGridLienzoPosition();
        }
    };
}
项目:appformer    文件:GridLienzoScrollHandlerTest.java   
@Test
public void testOnScrollWhenMouseIsNotDragging() {

    final RestrictedMousePanMediator mediator = mock(RestrictedMousePanMediator.class);
    final ScrollEvent scrollEvent = mock(ScrollEvent.class);

    doReturn(false).when(mediator).isDragging();
    doReturn(mediator).when(gridLienzoScrollHandler).getMousePanMediator();
    doNothing().when(gridLienzoScrollHandler).updateGridLienzoPosition();

    final ScrollHandler scrollHandler = gridLienzoScrollHandler.onScroll();
    scrollHandler.onScroll(scrollEvent);

    verify(gridLienzoScrollHandler).updateGridLienzoPosition();
}
项目:appformer    文件:GridLienzoScrollHandlerTest.java   
@Test
public void testOnScrollWhenMouseIsDragging() {

    final RestrictedMousePanMediator mediator = mock(RestrictedMousePanMediator.class);
    final ScrollEvent scrollEvent = mock(ScrollEvent.class);

    doReturn(true).when(mediator).isDragging();
    doReturn(mediator).when(gridLienzoScrollHandler).getMousePanMediator();

    final ScrollHandler scrollHandler = gridLienzoScrollHandler.onScroll();
    scrollHandler.onScroll(scrollEvent);

    verify(gridLienzoScrollHandler,
           never()).updateGridLienzoPosition();
}
项目:mechaverse    文件:SimulationPresenter.java   
private void addScrollHandler() {
  if (scrollHandler != null) {
    scrollHandler.removeHandler();
  }
  scrollHandler = view.addScrollHandler(new ScrollHandler() {
    @Override
    public void onScroll(ScrollEvent event) {
      updateTimer.cancel();
      updateTimer.schedule(UPDATE_INTERVAL);
    }
  });
}
项目:drools-wb    文件:GuidedDecisionTableModellerViewImplTest.java   
@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();
}
项目:drools-wb    文件:VerticalDecoratedTemplateDataGridWidget.java   
/**
 * Return a ScrollHandler to ensure the Header and Sidebar are repositioned
 * according to the position of the scroll bars surrounding the GridWidget
 */
@Override
protected ScrollHandler getScrollHandler() {
    return new ScrollHandler() {

        public void onScroll( ScrollEvent event ) {
            headerWidget.setScrollPosition( scrollPanel.getHorizontalScrollPosition() );
            sidebarWidget.setScrollPosition( scrollPanel.getVerticalScrollPosition() );
        }

    };
}
项目:swarm    文件:ScrollNavigator.java   
public ScrollNavigator(ViewContext viewContext, Panel scrollContainer, Panel scrollee, Panel mouseLayer)
{
    m_viewContext = viewContext;
    m_scrollContainer = scrollContainer;
    m_scrollContainerInner = scrollee;
    m_mouseLayer = mouseLayer;
    m_scrollBarWidthDiv2 = (int) Math.floor(((double)U_Css.getScrollBarWidth())/2);
    m_cellHudHeight = viewContext.appConfig.cellHudHeight;

    m_scrollContainer.getElement().getStyle().setZIndex(1);

    m_args_SnapToCoord.historyShouldIgnore = true;

    m_scrollContainer.addDomHandler(new ScrollHandler()
    {
        @Override
        public void onScroll(ScrollEvent event)
        {
            State_ViewingCell viewingState =  m_viewContext.stateContext.get(State_ViewingCell.class);
            if( viewingState != null )
            {
                VisualCell cell = (VisualCell)viewingState.getCell().getVisualization();
                setTargetLayout(cell);
                //m_viewContext.cellMngr.updateCellTransforms(0.0);
            }
            else
            {
                //--- DRK > I guess when we leave viewing state and reset scroll left/top to zero,
                //---       that fires a scroll event, so valid case here...ASSERT removed for now.
                //smU_Debug.ASSERT(false, "Expected viewing state to be entered.");
            }

            if( m_scrollListener != null )  m_scrollListener.onScroll();
        }

    }, ScrollEvent.getType());

    this.toggleScrollBars(null, null);
}
项目:swarm    文件:ShowMorePagerPanel.java   
/**
 * Construct a new {@link ShowMorePagerPanel}.
 */
public ShowMorePagerPanel() {
  initWidget(scrollable);

  // Do not let the scrollable take tab focus.
  scrollable.getElement().setTabIndex(-1);

  // Handle scroll events.
  scrollable.addScrollHandler(new ScrollHandler() {
    public void onScroll(ScrollEvent event) {
      // If scrolling up, ignore the event.
      int oldScrollPos = lastScrollPos;
      lastScrollPos = scrollable.getVerticalScrollPosition();
      if (oldScrollPos >= lastScrollPos) {
        return;
      }

      HasRows display = getDisplay();
      if (display == null) {
        return;
      }
      int maxScrollTop = scrollable.getWidget().getOffsetHeight()
          - scrollable.getOffsetHeight();
      if (lastScrollPos >= maxScrollTop) {
        // We are near the end, so increase the page size.
        int newPageSize = Math.min(
            display.getVisibleRange().getLength() + incrementSize,
            display.getRowCount());
        display.setVisibleRange(0, newPageSize);
      }
    }
  });
}
项目:plugin-datasource    文件:ShowMorePagerPanel.java   
/**
 * Construct a new {@link ShowMorePagerPanel}.
 */
public ShowMorePagerPanel() {
    initWidget(scrollable);

    // Do not let the scrollable take tab focus.
    scrollable.getElement().setTabIndex(-1);

    // Handle scroll events.
    scrollable.addScrollHandler(new ScrollHandler() {
        public void onScroll(ScrollEvent event) {
            // If scrolling up, ignore the event.
            int oldScrollPos = lastScrollPos;
            lastScrollPos = scrollable.getVerticalScrollPosition();
            if (oldScrollPos >= lastScrollPos) {
                return;
            }

            HasRows display = getDisplay();
            if (display == null) {
                return;
            }
            int maxScrollTop = scrollable.getWidget().getOffsetHeight()
                               - scrollable.getOffsetHeight();
            if (lastScrollPos >= maxScrollTop) {
                // We are near the end, so increase the page size.
                int newPageSize = Math.min(
                                           display.getVisibleRange().getLength() + incrementSize,
                                           display.getRowCount());
                display.setVisibleRange(0, newPageSize);
            }
        }
    });
}
项目:vaadin-scrollable-panel    文件:ScrollablePanelWidget.java   
@Override
public HandlerRegistration addScrollHandler(final ScrollHandler handler) {
    return super.addScrollHandler(handler);
}
项目:firefly    文件:WebPlotView.java   
public HandlerRegistration addScrollHandler(final ScrollHandler handler) {
    _scrollHandlerList.add(handler);
    return new HandlerRegistration() {
        public void removeHandler() { _scrollHandlerList.remove(handler); }
    };
}
项目:gwt-gantt    文件:GanttChart.java   
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return super.getWidget().addHandler(handler, ScrollEvent.getType());
}
项目:ineform    文件:GreenHorizontalScroll.java   
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return addDomHandler(handler, ScrollEvent.getType());
}
项目:ineform    文件:GreenVerticalScroll.java   
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return addDomHandler(handler, ScrollEvent.getType());
}
项目:ineform    文件:GreenScrollPanel.java   
@Override
public HandlerRegistration addScrollHandler(ScrollHandler handler) {
    return impl.addScrollHandler(handler);
}
项目:touchkit    文件:VNavigationView.java   
public HandlerRegistration addScrollHandler(ScrollHandler scrollHandler) {
    return addHandler(scrollHandler, ScrollEvent.getType());
}
项目:kie-wb-common    文件:AbstractDecoratedGridWidget.java   
/**
 * Return the ScrollPanel in which the DecoratedGridWidget "grid" is nested.
 * This allows ScrollEvents to be hooked up to other defendant controls
 * (e.g. the Header).
 * @return
 */
protected abstract ScrollHandler getScrollHandler();