Ejemplo n.º 1
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Ejemplo n.º 2
0
  @Test
  public void testRenderShowFocusedControl() throws IOException {
    sc.setShowFocusedControl(true);
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertEquals(JsonValue.TRUE, message.findSetProperty(sc, "showFocusedControl"));
  }
Ejemplo n.º 3
0
  @Test
  public void testRenderShowFocusedControlUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(sc);

    sc.setShowFocusedControl(true);
    Fixture.preserveWidgets();
    lca.renderChanges(sc);

    TestMessage message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(sc, "showFocusedControl"));
  }
Ejemplo n.º 4
0
 @Test
 public void testPreserveValues() {
   RemoteAdapter adapter = WidgetUtil.getAdapter(sc);
   assertEquals(null, adapter.getPreserved(PROP_SHOW_FOCUSED_CONTROL));
   hScroll.setSelection(23);
   vScroll.setSelection(42);
   sc.setShowFocusedControl(true);
   assertEquals(23, hScroll.getSelection());
   assertEquals(42, vScroll.getSelection());
   Rectangle rectangle = new Rectangle(12, 30, 20, 40);
   sc.setBounds(rectangle);
   Fixture.markInitialized(display);
   Fixture.preserveWidgets();
   assertEquals(Boolean.TRUE, adapter.getPreserved(PROP_SHOW_FOCUSED_CONTROL));
 }
  /**
   * Creates the composite holding the details.
   *
   * @param parent the parent
   * @return the right panel/detail composite
   */
  protected ScrolledComposite createRightPanelContent(Composite parent) {
    rightPanel = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    rightPanel.setShowFocusedControl(true);
    rightPanel.setExpandVertical(true);
    rightPanel.setExpandHorizontal(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(rightPanel);
    rightPanel.setLayout(GridLayoutFactory.fillDefaults().create());
    rightPanel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));

    container = new Composite(rightPanel, SWT.FILL);
    container.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(container);
    container.setBackground(rightPanel.getBackground());

    /* The header */
    final Composite header = new Composite(container, SWT.FILL);
    final GridLayout headerLayout = GridLayoutFactory.fillDefaults().create();
    headerLayout.marginWidth = 5;
    header.setLayout(headerLayout);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).applyTo(header);
    header.setBackground(rightPanel.getBackground());

    final Label label = new Label(header, SWT.WRAP);
    label.setText("Details"); // $NON-NLS-1$
    detailsFont = new Font(label.getDisplay(), getDefaultFontName(label), 10, SWT.BOLD);
    label.setFont(detailsFont);
    label.setForeground(getTitleColor(parent));
    label.setBackground(header.getBackground());

    rightPanelContainerComposite = new Composite(container, SWT.FILL);
    rightPanelContainerComposite.setLayout(GridLayoutFactory.fillDefaults().create());
    GridDataFactory.fillDefaults()
        .align(SWT.FILL, SWT.FILL)
        .grab(true, true)
        .applyTo(rightPanelContainerComposite);
    rightPanelContainerComposite.setBackground(rightPanel.getBackground());

    rightPanel.setContent(container);

    rightPanel.layout();
    container.layout();

    final Point point = container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    rightPanel.setMinSize(point);

    return rightPanel;
  }
  /**
   * Creates the inner page container.
   *
   * @param parent
   * @return Composite
   */
  protected Composite createPageContainer(Composite parent) {

    Composite outer = new Composite(parent, SWT.NONE);

    GridData outerData =
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
    outerData.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;

    outer.setLayout(new GridLayout());
    outer.setLayoutData(outerData);

    // Create an outer composite for spacing
    scrolled = new ScrolledComposite(outer, SWT.V_SCROLL | SWT.H_SCROLL);

    // always show the focus control
    scrolled.setShowFocusedControl(true);
    scrolled.setExpandHorizontal(true);
    scrolled.setExpandVertical(true);

    GridData scrolledData =
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);

    scrolled.setLayoutData(scrolledData);

    Composite result = new Composite(scrolled, SWT.NONE);

    GridData resultData =
        new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);

    result.setLayout(getPageLayout());
    result.setLayoutData(resultData);

    scrolled.setContent(result);

    return result;
  }