當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。