Java 类org.eclipse.swt.widgets.Scrollable 实例源码

项目:durian-swt    文件:ColumnFormat.java   
/** Builds the layout. */
private static void buildLayout(Scrollable control, AbstractColumnLayout layout, List<? extends Widget> columns, List<? extends ColumnBuilder> columnBuilders) {
    // create the layout
    for (int i = 0; i < columns.size(); ++i) {
        layout.setColumnData(columns.get(i), columnBuilders.get(i).dataBuilder.data);
    }
    control.getParent().setLayout(layout);

    // update the layout on every resize
    SwtMisc.asyncLayoutOnResize(control.getParent());
    // sometimes complicated trees can take a long time to get settled, so we'll do some last-ditch checks
    Runnable checkLayout = () -> {
        control.getParent().layout(true, true);
    };
    SwtExec.Guarded guarded = SwtExec.async().guardOn(control);
    guarded.timerExec(500, checkLayout);
    guarded.timerExec(1000, checkLayout);
    guarded.timerExec(2000, checkLayout);
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyOfSchemeAfterFlatScrollbar() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_BACKGROUND, BACK_GROUND, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_BACKGROUND, BACK_GROUND, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_PAGE_INCREMENT, PAGE_INC, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_LENGTH, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_DEMEANOR, FIXED_WIDTH, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( shell.getChildren()[ 0 ].getBackground() ).isEqualTo( expectedColor( BACK_GROUND ) );
  assertThat( getAdapterStyle().getBackgroundColor() ).isEqualTo( expectedColor( BACK_GROUND ) );
  assertThat( getAdapterStyle().getThumbColor() ).isEqualTo( expectedColor( THUMB ) );
  assertThat( getAdapterStyle().getPageIncrementColor() ).isEqualTo( expectedColor( PAGE_INC ) );
  assertThat( getAdapterStyle().getDemeanor() ).isSameAs( Demeanor.FIXED_SCROLL_BAR_BREADTH );
  assertThat( getAdapterStyle().getIncrementButtonLength() ).isEqualTo( expectedInt( INC_LENGTH ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbarAfterScheme() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_BACKGROUND, BACK_GROUND, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_PAGE_INCREMENT, PAGE_INC, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_LENGTH, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_BACKGROUND, BACK_GROUND, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_DEMEANOR, FIXED_WIDTH, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( shell.getChildren()[ 0 ].getBackground() ).isEqualTo( expectedColor( BACK_GROUND ) );
  assertThat( getAdapterStyle().getBackgroundColor() ).isEqualTo( expectedColor( BACK_GROUND ) );
  assertThat( getAdapterStyle().getThumbColor() ).isEqualTo( expectedColor( THUMB ) );
  assertThat( getAdapterStyle().getPageIncrementColor() ).isEqualTo( expectedColor( PAGE_INC ) );
  assertThat( getAdapterStyle().getDemeanor() ).isEqualTo( Demeanor.FIXED_SCROLL_BAR_BREADTH );
  assertThat( getAdapterStyle().getIncrementButtonLength() ).isEqualTo( expectedInt( INC_LENGTH ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyOfThumbWithAlternateTopLevelWindowSelectorOnTopLevelShellAfterFlatScrollbar()
  throws Exception
{
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  CSSPrimitiveValue colorValue = stubCssColorValue( 123, 22, 213 );
  String thumbSelectorForTopLevelWindow = FLAT_SCROLL_BAR_THUMB + TOP_LEVEL_WINDOW_SELECTOR;

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), thumbSelectorForTopLevelWindow, colorValue, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( getAdapterStyle().getThumbColor() ).isEqualTo( expectedColor( colorValue ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbarThumbWithAlternateTopLevelWindowSelectorOnTopLevelShell()
  throws Exception
{
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  CSSPrimitiveValue colorValue = stubCssColorValue( 123, 22, 213 );
  String thumbSelectorForTopLevelWindow = FLAT_SCROLL_BAR_THUMB + TOP_LEVEL_WINDOW_SELECTOR;

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), thumbSelectorForTopLevelWindow, colorValue, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( getAdapterStyle().getThumbColor() ).isEqualTo( expectedColor( colorValue ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyOfThumbWithAlternateTopLevelWindowSelectorOnTopLevelShellAndReverseSettingAfterFlatBar()
  throws Exception
{
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  CSSPrimitiveValue colorValue = stubCssColorValue( 123, 22, 213 );
  String thumbSelectorForTopLevelWindow = FLAT_SCROLL_BAR_THUMB + TOP_LEVEL_WINDOW_SELECTOR;

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), thumbSelectorForTopLevelWindow, colorValue, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( getAdapterStyle().getThumbColor() ).isEqualTo( expectedColor( colorValue ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyOfThumbWithAlternateTopLevelWindowSelectorOnChildShellAfterFlatScrollbar()
  throws Exception
{
  Shell child = new Shell( shell );
  Scrollable scrollable = createScrollable( child, typePair.scrollableType );
  CSSPrimitiveValue colorValue = stubCssColorValue( 123, 22, 213 );
  String thumbSelectorForTopLevelWindow = FLAT_SCROLL_BAR_THUMB + TOP_LEVEL_WINDOW_SELECTOR;

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), thumbSelectorForTopLevelWindow, colorValue, null, null );

  assertThat( child.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( ( ( ScrollbarStyle )child.getChildren()[ 0 ] ).getThumbColor() ).isEqualTo( expectedColor( THUMB ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbarThumbWithAlternateTopLevelWindowSelectorOnChildShellWithReverseSetting()
  throws Exception
{
  Shell child = new Shell( shell );
  Scrollable scrollable = createScrollable( child, typePair.scrollableType );
  CSSPrimitiveValue colorValue = stubCssColorValue( 123, 22, 213 );
  String thumbSelectorForTopLevelWindow = FLAT_SCROLL_BAR_THUMB + TOP_LEVEL_WINDOW_SELECTOR;

  contribution.applyCSSProperty( newElement( scrollable ), thumbSelectorForTopLevelWindow, colorValue, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( child.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
  assertThat( ( ( ScrollbarStyle )child.getChildren()[ 0 ] ).getThumbColor() ).isEqualTo( expectedColor( THUMB ) );
}
项目:xiliary    文件:ScrollableAdapterFactory.java   
private <A extends Scrollable & Adapter<S>, S extends Scrollable> Optional<A> adapt( S scrollable, Class<A> type ) {
  Composite parent = scrollable.getParent();
  int ordinalNumber = captureDrawingOrderOrdinalNumber( scrollable );
  A result = createAdapter( scrollable, type );
  if( platformSupport.isGranted() ) {
    markAdapted( scrollable );
    applyDrawingOrderOrdinalNumber( result, ordinalNumber );
  }
  result.adapt( scrollable, platformSupport );
  if( platformSupport.isGranted() ) {
    parent.layout();
    result.setBackground( scrollable.getBackground() );
    reflectionUtil.setField( scrollable, ControlReflectionUtil.PARENT, parent );
  }
  return Optional.of( result );
}
项目:xiliary    文件:AdaptionContextHelper.java   
static AdaptionContext<Scrollable> stubContext(
  Vertical vBarVisible, Horizontal hBarVisible, Point preferredSize, Rectangle area, Demeanor demeanor )
{
  @SuppressWarnings("unchecked")
  AdaptionContext<Scrollable> result = mock( AdaptionContext.class );
  when( result.isVerticalBarVisible() ).thenReturn( vBarVisible.value );
  when( result.isHorizontalBarVisible() ).thenReturn( hBarVisible.value );
  when( result.getPreferredSize() ).thenReturn( preferredSize );
  when( result.getVerticalBarOffset() ).thenReturn( STUB_VERTICAL_BAR_OFFSET );
  when( result.getOffset() ).thenReturn( OFFSET );
  when( result.getBorderWidth() ).thenReturn( BORDER_WIDTH );
  when( result.getVisibleArea() )
    .thenReturn( new Rectangle( area.x, area.y, area.width + BORDER_ADJUSTMENT, area.height + BORDER_ADJUSTMENT ) );
  when( result.getOriginOfScrollableOrdinates() )
    .thenReturn( new Point( area.x - BORDER_WIDTH, area.y - BORDER_WIDTH ) );
  when( result.get( Demeanor.class ) ).thenReturn( demeanor );
  return result;
}
项目:DarwinSPL    文件:DwprofileSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyexpressionSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyvalidityformulaSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HydatavalueSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HymappingSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HyconstraintsSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:DarwinSPL    文件:HymanifestSyntaxColoringPreferencePage.java   
private void createListViewer(Composite editorComposite) {
    fListViewer = new TreeViewer(editorComposite, SWT.SINGLE | SWT.BORDER);
    fListViewer.setLabelProvider(new ColorListLabelProvider());
    fListViewer.setContentProvider(new ColorListContentProvider());

    GridData gd = new GridData(GridData.FILL, GridData.FILL, true, true);
    gd.heightHint = convertHeightInCharsToPixels(26);
    int maxWidth = 0;
    for (Iterator<List<HighlightingColorListItem>> it = content.values().iterator(); it.hasNext();) {
        for (Iterator<HighlightingColorListItem> j = it.next().iterator(); j.hasNext();) {
            HighlightingColorListItem item = j.next();
            maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length()));
        }
    }
    ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar();
    if (vBar != null) {
        // scrollbars and tree indentation guess
        maxWidth += vBar.getSize().x * 3;
    }
    gd.widthHint = maxWidth;

    fListViewer.getControl().setLayoutData(gd);

    fListViewer.setInput(content);
    fListViewer.setSelection(new StructuredSelection(content.values().iterator().next()));
    fListViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            handleSyntaxColorListSelection();
        }
    });
}
项目:xiliary    文件:StructureScrollableRedrawInsuranceTest.java   
@Test
public void constructionWithNonVirtualAndOwnerDrawnStructuredScrollable() {
  Scrollable scrollable = createTable( shell, 10 );
  scrollable.addListener( SWT.MeasureItem, evt -> {} );

  newRedrawInsurance( scrollable );

  assertThat( scrollable.getVerticalBar().getListeners( SWT.Selection ) ).isEmpty();
}
项目:gef-gwt    文件:TableColumnLayout.java   
/**
 * {@inheritDoc}
 * 
 * @since 3.5
 */
protected void setColumnWidths(Scrollable tableTree, int[] widths) {
    TableColumn[] columns = ((Table) tableTree).getColumns();
    for (int i = 0; i < widths.length; i++) {
        columns[i].setWidth(widths[i]);
    }
}
项目:xiliary    文件:HorizontalSelectionComputerTest.java   
@Test
public void computeWithAdapterReplacementFake() {
  Composite composite = new Composite( scrollable.getParent(), SWT.H_SCROLL | SWT.V_SCROLL );
  AdaptionContext<Scrollable> context = new AdaptionContext<>( composite, new ScrollableControl<>( scrollable ) );

  int actual = computer.compute( context );

  assertThat( actual ).isEqualTo( 0 );
}
项目:xiliary    文件:StructuredScrollableLayouterTest.java   
private AdaptionContext<Scrollable> stubAdaptionContext(
  Vertical verticalBarVisible, Horizontal horizontalBarVisible, Point preferredSize, Rectangle visibleArea )
{
  AdaptionContext<Scrollable> result
    = stubContext( verticalBarVisible, horizontalBarVisible, preferredSize, visibleArea, FIXED_SCROLL_BAR_BREADTH );
  when( result.getScrollable() ).thenReturn( new ScrollableControl<>( scrollable ) );
  when( result.getAdapter() ).thenReturn( adapter );
  return result;
}
项目:xiliary    文件:ColorApplicator.java   
private void doApply(
  Scrollable scrollable, CSSValue value, String attribute, BiConsumer<ScrollbarStyle, Color> colorSetter )
{
  new AttributeApplicationOperation( scrollable, colorKey( attribute ) )
    .onDefault( preserver -> attributeApplicator.apply( scrollable, colorSetter, () -> getColor( value ) ) )
    .onTopLevelWindow( preserver -> preserver.put( colorKey( attribute ), getColor( value ) ) )
    .execute();
}
项目:xiliary    文件:ScrollbarPreferenceApplicator.java   
private static <T> void apply(
  ScrollbarStyle style,
  ScrollbarPreference preference,
  BiConsumer<ScrollbarStyle, ScrollbarPreference> preferenceSetter,
  AttributeKey<?> attributeKey,
  BiConsumer<ScrollbarStyle, T> attributeSetter,
  Consumer<Scrollable> styleApplicator,
  T defaultValue )
{
  preference.apply( style, preferenceSetter );
  if( !preference.isCustomized() ) {
    applyCssStyle( style, attributeKey, attributeSetter, styleApplicator, defaultValue );
  }
  ( ( Composite )style ).layout();
}
项目:gef-gwt    文件:TreeColumnLayout.java   
/**
 * {@inheritDoc}
 * 
 * @since 3.5
 */
protected void setColumnWidths(Scrollable tree, int[] widths) {
    TreeColumn[] columns = ((Tree) tree).getColumns();
    for (int i = 0; i < widths.length; i++) {
        columns[i].setWidth(widths[i]);
    }
}
项目:xiliary    文件:LayoutReconciliationTest.java   
@Test
public void registerSourceViewerRulerLayoutActorIfAdapterHasNoParent() {
  Shell shell = displayHelper.createShell();
  Composite scrollable = new Composite( shell, SWT.NONE );

  Throwable actual = thrownBy( () ->  {
    new LayoutReconciliation( shell, new ScrollableControl<Scrollable>( scrollable ) );
  } );

  assertThat( actual ).isNull();
}
项目:gef-gwt    文件:ViewFormLayout.java   
int computeTrim(Control c) {
    if (c instanceof Scrollable) {
        Rectangle rect = ((Scrollable) c).computeTrim(0, 0, 0, 0);
        return rect.width;
    }
    return c.getBorderWidth() * 2;
}
项目:xiliary    文件:DemeanorApplicator.java   
void apply(
  Scrollable scrollable, CSSValue value, String attribute, BiConsumer<ScrollbarStyle, Demeanor> demeanorSetter )
{
  if( attributeApplicator.canApply( scrollable ) ) {
    doApply( scrollable, value, attribute, demeanorSetter );
  } else {
    preserve( scrollable, value, attribute );
  }
}
项目:xiliary    文件:ControlElementsTest.java   
@Test
public void extractScrollable() {
  Shell expected = displayHelper.createShell();

  ControlElement controlElement = new ControlElement( expected, null );
  Scrollable actual = ControlElements.extractScrollable( controlElement );

  assertThat( actual ).isSameAs( expected );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbar() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.adapterType );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyPreferenceOnFlatScrollbarAdaption() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  scrollbarPreferenceRule.setValue( FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_LENGTH.getCssText() );
  scrollbarPreferenceRule.setValue( ADAPTER_DEMEANOR, DEMEANOR_FIXED_WIDTH );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_ZERO, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_DEMEANOR, EXPAND, null, null );

  assertThat( getAdapterStyle().getIncrementButtonLength() ).isEqualTo( expectedInt( INC_LENGTH ) );
  assertThat( getAdapterStyle().getDemeanor() ).isSameAs( Demeanor.FIXED_SCROLL_BAR_BREADTH );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyPreferenceOnFlatScrollbarAfterScheme() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  scrollbarPreferenceRule.setValue( FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_LENGTH.getCssText() );
  scrollbarPreferenceRule.setValue( ADAPTER_DEMEANOR, DEMEANOR_FIXED_WIDTH );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_INCREMENT_LENGTH, INC_ZERO, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), ADAPTER_DEMEANOR, EXPAND, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( getAdapterStyle().getDemeanor() ).isEqualTo( Demeanor.FIXED_SCROLL_BAR_BREADTH );
  assertThat( getAdapterStyle().getIncrementButtonLength() ).isEqualTo( expectedInt( INC_LENGTH ) );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbarAfterSchemeIfMarkedAdapted() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );
  new ScrollableAdapterFactory().markAdapted( scrollable );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR_THUMB, THUMB, null, null );
  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, TRUE, null, null );

  assertThat( shell.getChildren()[ 0 ] ).isInstanceOf( typePair.scrollableType );
}
项目:xiliary    文件:HorizontalSelectionComputerTest.java   
@Test
public void computeWithSelection() {
  expandTopBranch( scrollable );
  adapter.getHorizontalBar().setSelection( SELECTION );
  AdaptionContext<Scrollable> context = new AdaptionContext<>( adapter, new ScrollableControl<>( scrollable ) );

  int actual = computer.compute( context );

  assertThat( actual ).isEqualTo( 0 );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCSSPropertyFlatScrollbarWithWrongCssValueType() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );

  contribution.applyCSSProperty( newElement( scrollable ), FLAT_SCROLL_BAR, stubCssStringValue( "bad" ), null, null );

  assertThat( shell.getChildren()[ 0 ] ).isSameAs( scrollable );
}
项目:xiliary    文件:HorizontalSelectionComputerTest.java   
@Test
public void compute() {
  AdaptionContext<Scrollable> context = new AdaptionContext<>( adapter, new ScrollableControl<>( scrollable ) );

  int actual = computer.compute( context );

  assertThat( actual ).isEqualTo( 0 );
}
项目:xiliary    文件:ScrollableAdapterContributionPDETest.java   
@Test
@ConditionalIgnore( condition = NonWindowsPlatform.class )
public void applyCssPropertyWithUnsupportedAttribute() throws Exception {
  Scrollable scrollable = createScrollable( shell, typePair.scrollableType );

  Throwable actual
    = thrownBy( () -> contribution.applyCSSProperty( newElement( scrollable ), "unsupported", TRUE, null, null ) );

  assertThat( actual )
    .hasMessageContaining( "unsupported" )
    .isInstanceOf( IllegalArgumentException.class );
}
项目:xiliary    文件:LayoutReconciliationTest.java   
@Test
public void registerSourceViewerRulerLayoutActor() {
  Shell shell = displayHelper.createShell();
  shell.setLayout( new SourceViewer.RulerLayout() );
  Composite adapter = new Composite( shell, SWT.NONE );
  Composite scrollable = new Composite( adapter, SWT.NONE );

  new LayoutReconciliation( adapter, new ScrollableControl<Scrollable>( scrollable ) );

  assertThat( shell.getLayout() ).isInstanceOf( LayoutActor.class );
}
项目:xiliary    文件:TypeToAdapterMappingTest.java   
@Test
@SuppressWarnings("rawtypes")
public void tryFindTypeToAdapterMapping() {
  Shell shell = createShell( displayHelper );
  Control control = new ScrolledComposite( shell, SWT.H_SCROLL | SWT.V_SCROLL );

  Optional<TypeToAdapterMapping<? extends Scrollable, ? extends Adapter>> actual
    = TypeToAdapterMapping.tryFindTypeToAdapterMapping( control );

  assertThat( actual ).isPresent();
}
项目:xiliary    文件:TypeToAdapterMappingTest.java   
@Test
@SuppressWarnings("rawtypes")
public void tryFindTypeToAdapterMappingOfUnsupportedType() {
  Shell shell = createShell( displayHelper );
  Control control = new Label( shell, SWT.NONE );

  Optional<TypeToAdapterMapping<? extends Scrollable, ? extends Adapter>> actual
  = TypeToAdapterMapping.tryFindTypeToAdapterMapping( control );

  assertThat( actual ).isNotPresent();
}
项目:xiliary    文件:ScrollableControlTest.java   
@Test
public void setHorizontalBarVisibleIfHorizontalBarIsNull() {
  Scrollable scrollable = new Tree( displayHelper.createShell(), SWT.NO_SCROLL );

  new ScrollableControl<>( scrollable ).setHorizontalBarVisible( true );
  boolean actual = new ScrollableControl<>( scrollable ).getHorizontalBarVisible();

  assertThat( actual ).isFalse();
}