当前位置: 首页>>代码示例>>Java>>正文


Java TableColumn.setImage方法代码示例

本文整理汇总了Java中org.eclipse.swt.widgets.TableColumn.setImage方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setImage方法的具体用法?Java TableColumn.setImage怎么用?Java TableColumn.setImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.widgets.TableColumn的用法示例。


在下文中一共展示了TableColumn.setImage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStepsTable

import org.eclipse.swt.widgets.TableColumn; //导入方法依赖的package包/类
/**
 * Create the steps table.
 *
 * @param composite
 *        the parent layout composite
 * @param workItem
 *        the test case work item
 *
 * @return the allocated table viewer
 */
private TableViewer createStepsTable(final Composite composite, final WorkItem workItem) {
    final TableViewer viewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
    GridDataBuilder.newInstance().align(SWT.FILL, SWT.FILL).grab(true, true).span(1, 1).minHeight(75).applyTo(
        viewer.getTable());

    final Table table = viewer.getTable();
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    final TableLayout tableLayout = new TableLayout();
    table.setLayout(tableLayout);

    tableLayout.addColumnData(new ColumnPixelData(60, true));
    final TableColumn column1 = new TableColumn(table, SWT.NONE);
    column1.setImage(TestStepUtil.imageHelper.getImage("images/common/attachment.gif")); //$NON-NLS-1$
    column1.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(10, true));
    final TableColumn column2 = new TableColumn(table, SWT.NONE);
    column2.setText(Messages.getString("TestStepsControl.ColumnNameAction")); //$NON-NLS-1$
    column2.setResizable(true);

    tableLayout.addColumnData(new ColumnWeightData(8, true));
    final TableColumn column3 = new TableColumn(table, SWT.NONE);
    column3.setText(Messages.getString("TestStepsControl.ColumnNameExpectedResult")); //$NON-NLS-1$
    column3.setResizable(true);

    viewer.setContentProvider(new TestStepContentProvider());
    viewer.setLabelProvider(new TestStepLabelProvider());
    viewer.setInput(workItem);

    return viewer;
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:43,代码来源:TestStepsControl.java

示例2: setupTable

import org.eclipse.swt.widgets.TableColumn; //导入方法依赖的package包/类
/**
 * Creates {@link TableColumn}s for the specified {@link Table} based on the
 * specified {@link TableColumnData} array.
 *
 * @param table
 *        the {@link Table} to create columns for (must not be
 *        <code>null</code>)
 * @param headerVisible
 *        <code>true</code> if the {@link Table}'s header should be visible
 * @param linesVisible
 *        <code>true</code> if the {@link Table}'s lines should be visible
 * @param persistenceKey
 *        a persistence key used to save and restore column widths, or
 *        <code>null</code> if no column width persistence should be done
 * @param columnData
 *        the {@link TableColumnData} array that controls the number and
 *        kind of columns that are created (must not be <code>null</code>
 *        and must not contain <code>null</code> elements)
 */
public static void setupTable(
    final Table table,
    final boolean headerVisible,
    final boolean linesVisible,
    final String persistenceKey,
    final TableColumnData[] columnData) {
    Check.notNull(table, "table"); //$NON-NLS-1$
    Check.notNull(columnData, "columnData"); //$NON-NLS-1$

    table.setHeaderVisible(headerVisible);
    table.setLinesVisible(linesVisible);

    TableColumnWidthsPersistence persistenceStore = null;

    /* Clear any existing columns */
    final TableColumn[] existingColumns = table.getColumns();

    for (int i = 0; i < existingColumns.length; i++) {
        existingColumns[i].dispose();
    }

    boolean persist = false;
    for (int i = 0; i < columnData.length; i++) {
        if (columnData[i] == null) {
            throw new IllegalArgumentException("columnData[" + i + "] is null"); //$NON-NLS-1$ //$NON-NLS-2$
        }

        final TableColumn column = new TableColumn(table, columnData[i].style);

        if (columnData[i].text != null) {
            column.setText(columnData[i].text);
        }

        if (columnData[i].image != null) {
            column.setImage(columnData[i].image);
        }

        column.setResizable(columnData[i].resizeable);

        if (columnData[i].persistenceKey != null) {
            persist = true;
        }
    }

    if (persist && persistenceKey != null) {
        persistenceStore = new TableColumnWidthsPersistence(table, persistenceKey);

        for (int i = 0; i < columnData.length; i++) {
            if (columnData[i].persistenceKey != null) {
                persistenceStore.addMapping(columnData[i].persistenceKey, i);
            }
        }
    }

    table.setLayout(new PersistentTableLayout(columnData, persistenceStore));
    table.layout(true);
}
 
开发者ID:Microsoft,项目名称:team-explorer-everywhere,代码行数:77,代码来源:TableUtils.java


注:本文中的org.eclipse.swt.widgets.TableColumn.setImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。