org.eclipse.swt.widgets.Table#getColumn ( )源码实例Demo

下面列出了org.eclipse.swt.widgets.Table#getColumn ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tracecompass   文件: TmfEventsTable.java
/**
 * Returns true if the column is expanded to take extra available space.
 * This is the last non-zero-width visible column in the column order on
 * Linux. This column's width should not be persisted.
 *
 * @param column
 *            the column
 * @return true if the column is expanded.
 */
private static boolean isExpanded(TableColumn column) {
    if (IS_LINUX) {
        Table table = column.getParent();
        int[] order = table.getColumnOrder();
        for (int i = order.length - 1; i >= 0; i--) {
            TableColumn col = table.getColumn(order[i]);
            if (col == column) {
                return true;
            }
            if (col.getWidth() > 0) {
                return false;
            }
        }
    }
    return false;
}
 
源代码2 项目: JDeodorant   文件: CloneDiffTooltip.java
protected void packAndFillLastColumn(Table table) {
    int columnsWidth = 0;
    for (int i = 0; i < table.getColumnCount() - 1; i++) {
        columnsWidth += table.getColumn(i).getWidth();
    }
    TableColumn lastColumn = table.getColumn(table.getColumnCount() - 1);
    lastColumn.pack();

    Rectangle area = table.getClientArea();

    Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    int width = area.width - 2*table.getBorderWidth();

    if (preferredSize.y > area.height + table.getHeaderHeight()) {
        // Subtract the scrollbar width from the total column width
        // if a vertical scrollbar will be required
        Point vBarSize = table.getVerticalBar().getSize();
        width -= vBarSize.x;
    }

    // last column is packed, so that is the minimum. If more space is available, add it.
    if(lastColumn.getWidth() < width - columnsWidth) {
        lastColumn.setWidth(width - columnsWidth + 4);
    }
}
 
源代码3 项目: olca-app   文件: CausalFactorTable.java
public void render(Section section, FormToolkit toolkit) {
	Composite composite = UI.sectionClient(section, toolkit, 1);
	String[] columnTitles = getColumnTitles();
	viewer = Tables.createViewer(composite, columnTitles);
	viewer.setLabelProvider(new FactorLabel());
	Action copy = TableClipboard.onCopy(viewer);
	Actions.bind(viewer, copy);
	Tables.bindColumnWidths(viewer, 0.2, 0.1, 0.1, 0.1);
	createModifySupport();
	Table table = viewer.getTable();
	for (int i = 0; i < table.getColumnCount(); i++) {
		if (i < 4)
			continue;
		TableColumn column = table.getColumn(i);
		if (!editor.hasAnyComment("allocationFactors") || i % 2 == 0) {
			column.setWidth(80);
			column.setToolTipText(columnTitles[i]);
		} else {
			column.setWidth(24);
		}
	}
	for (int i = 3; i < table.getColumnCount(); i++) {
		viewer.getTable().getColumns()[i].setAlignment(SWT.RIGHT);
	}
}
 
源代码4 项目: tracecompass   文件: ExportToTsvUtils.java
/**
 * Export content of a table to TSV file
 * @param table
 *              the table to export
 * @param stream
 *              the output stream
 */
public static void exportTableToTsv(Table table, @Nullable OutputStream stream) {
    if (table == null || stream == null) {
        return;
    }
    try (PrintWriter pw = new PrintWriter(stream)) {
        int size = table.getItemCount();
        List<String> columns = new ArrayList<>();
        for (int i = 0; i < table.getColumnCount(); i++) {
            TableColumn column = table.getColumn(i);
            if (column == null) {
                return;
            }
            String columnName = String.valueOf(column.getText());
            if (columnName.isEmpty() && i == table.getColumnCount() - 1) {
                // Linux GTK2 undocumented feature
                break;
            }
            columns.add(columnName);
        }
        pw.println(Joiner.on('\t').join(columns));
        for (int i = 0; i < size; i++) {
            TableItem item = table.getItem(i);
            if (item == null) {
                continue;
            }
            List<String> data = new ArrayList<>();
            for (int col = 0; col < columns.size(); col++) {
                data.add(String.valueOf(item.getText(col)));
            }
            pw.println(Joiner.on('\t').join(data));
        }
    }
}
 
源代码5 项目: olca-app   文件: TableClipboard.java
private static void copyHeaders(Table table, StringBuilder text) {
	int cols = table.getColumnCount();
	for (int col = 0; col < cols; col++) {
		TableColumn column = table.getColumn(col);
		String s = column.getText();
		text.append(s == null ? "" : s);
		if (col != (cols - 1))
			text.append('\t');
	}
	text.append('\n');
}
 
源代码6 项目: nebula   文件: HeaderLayout.java
protected Widget getColumnAt(Composite rowOrHeader, int offset) {
    Table headerTable = getHeader(rowOrHeader).headerTable;
    int[] columnOrder = headerTable.getColumnOrder();
    return headerTable.getColumn(columnOrder[offset]);
}
 
源代码7 项目: xds-ide   文件: UiUtils.java
public static int getColumnTextWidth(Table table, GC gc, int i) {
  TableColumn tableColumn = table.getColumn(i);
  int maxTextExtent = 20 + gc.textExtent(tableColumn.getText()).x;
  return maxTextExtent;
}
 
源代码8 项目: xds-ide   文件: SwtUtils.java
public static int getColumnTextWidth(Table table, GC gc, int i) {
	TableColumn tableColumn = table.getColumn(i);
	int maxTextExtent = 20 + gc.textExtent(tableColumn.getText()).x;
	return maxTextExtent;
}