Java Code Examples for org.eclipse.swt.widgets.TableColumn#getResizable()

The following examples show how to use org.eclipse.swt.widgets.TableColumn#getResizable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void packSingleColumn(int i, final TableColumn column) {
    if (i != MARGIN_COLUMN_INDEX && !column.getResizable()) {
        return;
    }
    int minWidth = column.getWidth();
    fPacking = true;
    column.pack();
    /*
     * Workaround for Linux which doesn't consider the image width of
     * search/filter row in TableColumn.pack() after having executed
     * TableItem.setImage(null) for other rows than search/filter row.
     */
    if (IS_LINUX && (i == MARGIN_COLUMN_INDEX) && fCollapseFilterEnabled) {
        column.setWidth(column.getWidth() + SEARCH_IMAGE.getBounds().width);
    }

    if (column.getWidth() < minWidth) {
        column.setWidth(minWidth);
    }
    fPacking = false;
}
 
Example 2
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void controlResized(ControlEvent e) {
    TableColumn column = (TableColumn) e.widget;
    if (fPacking) {
        /* Don't update column width if resize due to packing */
        return;
    }
    if (column.getResizable() && !isExpanded(column)) {
        int index = (int) column.getData(Key.INDEX);
        fColumnSize[index] = column.getWidth();
        /* Turns off AutoFit */
        column.setData(Key.WIDTH, fColumnSize[index]);
    }
}
 
Example 3
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Get the array of item strings (e.g., what to display in each cell of the
 * table row) corresponding to the columns and trace event passed in
 * parameter. The order of the Strings in the returned array will correspond
 * to the iteration order of 'columns'.
 *
 * <p>
 * To ensure consistent results, make sure only call this within a scope
 * synchronized on 'columns'! If the order of 'columns' changes right after
 * this method is called, the returned value won't be ordered correctly
 * anymore.
 */
private String[] getItemStrings(List<TmfEventTableColumn> columns, ITmfEvent event) {
    if (event == null) {
        return EMPTY_STRING_ARRAY;
    }
    synchronized (columns) {
        String[] itemStrings = new String[columns.size()];
        TableColumn[] tableColumns = fTable.getColumns();
        for (int i = 0; i < columns.size(); i++) {
            TmfEventTableColumn column = columns.get(i);
            ITmfEvent passedEvent = event;
            if (!(column instanceof TmfMarginColumn) && (event instanceof CachedEvent)) {
                /*
                 * Make sure that the event object from the trace is passed to all columns but
                 * the TmfMarginColumn
                 */
                passedEvent = ((CachedEvent) event).event;
            }
            // Check if column is hidden but not a margin column.
            TableColumn tableColumn = tableColumns[fColumns.indexOf(column)];
            if (passedEvent == null || (!tableColumn.getResizable() && tableColumn.getWidth() == 0)) {
                itemStrings[i] = EMPTY_STRING;
            } else {
                String s = column.getItemString(passedEvent);
                s = s.replaceAll("\\n", " "); //$NON-NLS-1$//$NON-NLS-2$
                s = s.replaceAll("\\r", " "); //$NON-NLS-1$//$NON-NLS-2$
                itemStrings[i] = s;
            }
        }
        return itemStrings;
    }
}
 
Example 4
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Sets the column width and resizability
 *
 * @param width
 *            an array of widths
 * @param resizable
 *            an array of bools saying if a column is resizable or not
 * @since 2.1
 */
public void setColumnWidth(int[] width, boolean[] resizable) {
    int length = fTable.getColumns().length;
    if (width == null || resizable == null || resizable.length != length || width.length != length) {
        return;
    }
    if (width.length > 0 && width[0] == 0) {
        /*
         * When width of margin column is 0 instead of SWT.DEFAULT, it is an old
         * setting. Reset all widths to SWT.DEFAULT to initially enable AutoFit.
         */
        Arrays.fill(width, SWT.DEFAULT);
    }
    int i = 0;
    for (TableColumn column : fTable.getColumns()) {
        if (i != MARGIN_COLUMN_INDEX) {
            column.setData(Key.WIDTH, width[i]);
            column.setResizable(resizable[i]);
            if (column.getResizable() && width[i] > 0) {
                column.setWidth(width[i]);
            } else if (width[i] == 0) {
                column.setWidth(0);
            }
        }
        i++;
    }
    fColumnSize = width;
    fColumnResizable = resizable;
}
 
Example 5
Source File: TmfEventsTable.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Returns true if the column is a visible event column.
 *
 * @param column
 *            the column
 * @return false if the column is the margin column or hidden, true
 *         otherwise
 */
private static boolean isVisibleEventColumn(TableColumn column) {
    if (column.getData(Key.ASPECT) == TmfMarginColumn.MARGIN_ASPECT) {
        return false;
    }
    return !(!column.getResizable() && column.getWidth() == 0);
}