コード例 #1
0
 private void restoreScrollingPosition() {
   if (scrollingPosition != null) {
     Point size = preview.getSize();
     scroll.setOrigin(
         (int) Math.round(scrollingPosition[0] * size.x),
         (int) Math.round(scrollingPosition[1] * size.y));
   }
 }
コード例 #2
0
  @Test
  public void testRenderOrigin() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    sc.setContent(content);

    sc.setOrigin(1, 2);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    JsonArray expected = JsonArray.readFrom("[ 1, 2 ]");
    assertEquals(expected, message.findSetProperty(sc, "origin"));
  }
コード例 #3
0
 void activeKeyScrolling() {
   if (keyScrollingFilter == null) {
     Composite pageParent = getPageContainer().getParent();
     if (!(pageParent instanceof ScrolledComposite)) {
       return;
     }
     final ScrolledComposite sc = (ScrolledComposite) pageParent;
     keyScrollingFilter =
         event -> {
           if (!keyScrollingEnabled || sc.isDisposed()) {
             return;
           }
           switch (event.keyCode) {
             case SWT.ARROW_DOWN:
               sc.setOrigin(sc.getOrigin().x, sc.getOrigin().y + INCREMENT);
               break;
             case SWT.ARROW_UP:
               sc.setOrigin(sc.getOrigin().x, sc.getOrigin().y - INCREMENT);
               break;
             case SWT.ARROW_LEFT:
               sc.setOrigin(sc.getOrigin().x - INCREMENT, sc.getOrigin().y);
               break;
             case SWT.ARROW_RIGHT:
               sc.setOrigin(sc.getOrigin().x + INCREMENT, sc.getOrigin().y);
               break;
             case SWT.PAGE_DOWN:
               sc.setOrigin(sc.getOrigin().x, sc.getOrigin().y + PAGE_MULTIPLIER * INCREMENT);
               break;
             case SWT.PAGE_UP:
               sc.setOrigin(sc.getOrigin().x, sc.getOrigin().y - PAGE_MULTIPLIER * INCREMENT);
               break;
             case SWT.HOME:
               sc.setOrigin(0, 0);
               break;
             case SWT.END:
               sc.setOrigin(0, sc.getSize().y);
               break;
             default:
               keyScrollingEnabled = false;
           }
           event.type = SWT.None;
           event.doit = false;
         };
     Display display = PlatformUI.getWorkbench().getDisplay();
     display.addFilter(SWT.KeyDown, keyScrollingFilter);
     display.addFilter(SWT.Traverse, keyScrollingFilter);
     sc.addDisposeListener(e -> removeKeyScrolling());
   }
   keyScrollingEnabled = true;
 }
コード例 #4
0
  @Test
  public void testRenderOriginUnchanged() throws IOException {
    Composite content = new Composite(sc, SWT.NONE);
    sc.setContent(content);
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);

    sc.setOrigin(1, 2);
    Fixture.preserveWidgets();
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(hScroll, "selection"));
    assertNull(message.findSetOperation(vScroll, "selection"));
  }
コード例 #5
0
 public void readData(final Widget widget) {
   ScrolledComposite composite = (ScrolledComposite) widget;
   Point origin = composite.getOrigin();
   String value = WidgetLCAUtil.readPropertyValue(widget, PARAM_H_BAR_SELECTION);
   ScrollBar hScroll = composite.getHorizontalBar();
   if (value != null && hScroll != null) {
     origin.x = Integer.parseInt(value);
     processSelection(hScroll);
   }
   value = WidgetLCAUtil.readPropertyValue(widget, PARAM_V_BAR_SELECTION);
   ScrollBar vScroll = composite.getVerticalBar();
   if (value != null && vScroll != null) {
     origin.y = Integer.parseInt(value);
     processSelection(vScroll);
   }
   composite.setOrigin(origin);
   ControlLCAUtil.processMouseEvents(composite);
   ControlLCAUtil.processKeyEvents(composite);
   ControlLCAUtil.processMenuDetect(composite);
   WidgetLCAUtil.processHelp(composite);
 }