Example usage for org.eclipse.jface.layout AbstractColumnLayout setColumnData

List of usage examples for org.eclipse.jface.layout AbstractColumnLayout setColumnData

Introduction

In this page you can find the example usage for org.eclipse.jface.layout AbstractColumnLayout setColumnData.

Prototype

public void setColumnData(Widget column, ColumnLayoutData data) 

Source Link

Document

Adds a new column of data to this table layout.

Usage

From source file:com.diffplug.common.swt.ColumnFormat.java

License:Apache License

/** 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);
    }/*from  ww  w.  jav a 2 s  .c o  m*/
    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);
}

From source file:com.rcpcompany.uibindings.internal.ViewerBindingImpl.java

License:Open Source License

@Override
public IViewerBinding viewer(ColumnViewer viewer) {
    assertTrue(viewer != null, "viewer must be non-null");
    setViewer(viewer);/*from ww w . jav  a2  s  . c o  m*/

    if (getControl() instanceof Table) {
        /*
         * Add an empty first column to the table to avoid alignment problems
         */
        // TODO: only for Windows?
        final Table table = (Table) getControl();
        final TableColumn column = new TableColumn(table, SWT.NONE, 0);
        setFirstTableColumnOffset(1);
        column.setText("__SPARE__"); //$NON-NLS-1$
        column.setWidth(0);
        column.setMoveable(false);
        column.setResizable(false);

        /*
         * Check whether the table uses any special layout
         */
        Layout l = table.getParent().getLayout();
        if (l instanceof AbstractColumnLayout) {
            final AbstractColumnLayout layout = (AbstractColumnLayout) l;
            layout.setColumnData(column, new ColumnPixelData(0, false, false));
        }
        l = table.getLayout();
        if (l instanceof TableLayout) {
            final TableLayout layout = (TableLayout) l;
            layout.addColumnData(new ColumnPixelData(0, false, false));
        }
    }

    return this;
}

From source file:de.dentrassi.eclipse.rpm.editor.HeaderTable.java

License:Open Source License

private void createColumnCell(final AbstractColumnLayout layout, final String name, final int weight,
        final Consumer<ViewerCell> cellUpdater) {
    final TreeViewerColumn col = new TreeViewerColumn(this.viewer, SWT.NONE);
    col.setLabelProvider(new StyledCellLabelProvider() {

        @Override/*from   www .  ja  v a2  s .c  o  m*/
        public void update(final ViewerCell cell) {
            cellUpdater.accept(cell);
        }
    });
    col.getColumn().setText(name);
    layout.setColumnData(col.getColumn(), new ColumnWeightData(weight));
}

From source file:eu.numberfour.n4js.ui.viewer.TableViewerBuilder.java

License:Open Source License

@Override
protected TableViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout,
        final int style) {
    final TableViewer viewer = new TableViewer(parent, style);
    final Table table = viewer.getTable();
    table.setLinesVisible(linesVisible);
    table.setHeaderVisible(headerVisible);

    int columnIndex = 0;
    for (final String columnLabel : columnLabels) {

        final TableViewerColumn viewerColumn = new TableViewerColumn(viewer, NONE);
        final TableColumn column = viewerColumn.getColumn();
        columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
        column.setText(columnLabel);/*  w w w.  java 2  s .c  o  m*/
        column.setMoveable(moveable);

        columnIndex++;
    }

    return viewer;
}

From source file:eu.numberfour.n4js.ui.viewer.TreeViewerBuilder.java

License:Open Source License

@Override
protected TreeViewer createViewer(final Composite parent, final AbstractColumnLayout columnLayout,
        final int style) {
    final TreeViewer viewer = new TreeViewer(parent, virual ? (style | VIRTUAL) : style);
    final Tree tree = viewer.getTree();
    tree.setLinesVisible(linesVisible);//from ww w .  j a v  a 2s . c  om
    tree.setHeaderVisible(headerVisible);

    int columnIndex = 0;
    for (final String columnLabel : columnLabels) {

        final TreeViewerColumn viewerColumn = new TreeViewerColumn(viewer, NONE);
        final TreeColumn column = viewerColumn.getColumn();
        columnLayout.setColumnData(column, createColumnLayoutData(columnIndex));
        column.setText(columnLabel);
        column.setMoveable(moveable);

        columnIndex++;
    }

    return viewer;
}

From source file:org.eclipse.mylyn.commons.ui.AbstractColumnViewerSupport.java

License:Open Source License

private void setWidth(T column, int width) {
    // if has column data, set that (pixel or weight)
    ColumnLayoutData data = getColumnLayoutData(column);
    AbstractColumnLayout columnLayout = getColumnLayout();
    if (data != null && columnLayout != null) {
        if (width == 0) {
            columnLayout.setColumnData(column, new ColumnPixelData(width, data.resizable));
        } else {//from  w w w . j  a va 2s  .  c  o  m
            columnLayout.setColumnData(column, new ColumnWeightData(width, data.resizable));
        }
        control.getParent().layout();
    } else {
        setColumnWidth(column, width);
    }
    setColumnResizable(column, width > 0);
}