Search in sources :

Example 26 with IColumn

use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.

the class JaretTable method getTotalWidth.

/**
     * Retrieve total width of the first n columns.
     * 
     * @param n number of colums to take into account
     * @return sum of the first n column withs
     */
public int getTotalWidth(int n) {
    if (_cols != null) {
        int width = 0;
        for (int i = 0; i < n; i++) {
            IColumn col = _cols.get(i);
            width += _tvs.getColumnWidth(col);
        }
        return width;
    } else {
        return 0;
    }
}
Also used : IColumn(de.jaret.util.ui.table.model.IColumn) Point(org.eclipse.swt.graphics.Point)

Example 27 with IColumn

use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.

the class JaretTable method getCell.

/**
     * Retrieve TableXCell for given pixel coordinates.
     * 
     * @param x pixel coordinate x
     * @param y pixel coordinate y
     * @return table cel if found or <code>null</code> if no cell can be found
     */
public IJaretTableCell getCell(int x, int y) {
    if (_tableRect.contains(x, y)) {
        IRow row = rowForY(y);
        IColumn col = colForX(x);
        if (row == null || col == null) {
            return null;
        }
        return new JaretTableCellImpl(row, col);
    }
    return null;
}
Also used : JaretTableCellImpl(de.jaret.util.ui.table.model.JaretTableCellImpl) IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn)

Example 28 with IColumn

use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.

the class JaretTable method drawHeader.

/**
     * Draw the table header.
     * 
     * @param gc gc
     * @param width width of the table
     * @param height height of the table
     */
private void drawHeader(GC gc, int width, int height) {
    if (_headerRenderer != null && _drawHeader) {
        // draw headers for fixed columns
        for (int cIdx = 0; cIdx < _fixedColumns; cIdx++) {
            int x = getAbsBeginXForColIdx(cIdx);
            IColumn col = _cols.get(cIdx);
            int colwidth = _tvs.getColumnWidth(col);
            // fixed cols may render wherever they want if they disable clipping
            if (!_headerRenderer.disableClipping()) {
                gc.setClipping(x, _headerRect.y, colwidth, _headerRect.height);
            }
            // column may indicate that no header should be painted
            if (col.displayHeader()) {
                drawHeader(gc, x, colwidth, col);
            }
        }
        // draw headers table area
        int x = -_firstColPixelOffset;
        x += _tableRect.x;
        int cIdx = _firstColIdx;
        while (x < getWidth() && cIdx < _cols.size()) {
            IColumn col = _cols.get(cIdx);
            int colwidth = _tvs.getColumnWidth(col);
            int xx = x > _headerRect.x ? x : _headerRect.x;
            int clipWidth = x > _headerRect.x ? colwidth : colwidth - _firstColPixelOffset;
            if (!_headerRenderer.disableClipping()) {
                gc.setClipping(xx, _headerRect.y, clipWidth, _headerRect.height);
            } else if (_fixedColumns > 0) {
                // if fixed columns are present the header renderer of ordinary columns may not interfere with the
                // fixed region
                gc.setClipping(xx, _headerRect.y, _tableRect.width - xx, _headerRect.height);
            }
            // column may indicate that no header should be painted
            if (col.displayHeader()) {
                drawHeader(gc, x, colwidth, col);
            }
            x += colwidth;
            cIdx++;
        }
    }
}
Also used : IColumn(de.jaret.util.ui.table.model.IColumn) Point(org.eclipse.swt.graphics.Point)

Example 29 with IColumn

use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.

the class JaretTable method getColIdxForAbsX.

/**
     * Return the (internal) index of the column corresponding to the given x coordinate value (absolute value taking
     * all visible columns into account).
     * 
     * @param absX absolute x coordinate
     * @return the column index in the internal list of columns (or -1 if none could be determined)
     */
public int getColIdxForAbsX(int absX) {
    int idx = 0;
    int x = 0;
    while (x <= absX && idx < _cols.size()) {
        IColumn col = _cols.get(idx);
        int colWidth = _tvs.getColumnWidth(col);
        x += colWidth;
        idx++;
    }
    return idx < _cols.size() ? idx - 1 : -1;
}
Also used : IColumn(de.jaret.util.ui.table.model.IColumn) Point(org.eclipse.swt.graphics.Point)

Example 30 with IColumn

use of de.jaret.util.ui.table.model.IColumn in project translationstudio8 by heartsome.

the class SimpleJaretTableModel method setValueAt.

/**
     * Set a value.
     * 
     * @param colIdx index of the column (x)
     * @param rowIdx index of the row (y)
     * @param value value
     */
public void setValueAt(int colIdx, int rowIdx, Object value) {
    IColumn col = getColumn(colIdx);
    IRow row = getRow(rowIdx);
    col.setValue(row, value);
}
Also used : IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn)

Aggregations

IColumn (de.jaret.util.ui.table.model.IColumn)33 IRow (de.jaret.util.ui.table.model.IRow)15 Point (org.eclipse.swt.graphics.Point)13 JaretTable (de.jaret.util.ui.table.JaretTable)5 ArrayList (java.util.ArrayList)5 Rectangle (org.eclipse.swt.graphics.Rectangle)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Label (org.eclipse.swt.widgets.Label)4 PropCol (de.jaret.util.ui.table.model.PropCol)3 JaretTableActionFactory (de.jaret.util.ui.table.util.action.JaretTableActionFactory)3 MenuManager (org.eclipse.jface.action.MenuManager)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Button (org.eclipse.swt.widgets.Button)3 Composite (org.eclipse.swt.widgets.Composite)3 IAutoFilter (de.jaret.util.ui.table.filter.IAutoFilter)2 IJaretTableCell (de.jaret.util.ui.table.model.IJaretTableCell)2 ITableNode (de.jaret.util.ui.table.model.ITableNode)2 JaretTableCellImpl (de.jaret.util.ui.table.model.JaretTableCellImpl)2 PropListeningTableModel (de.jaret.util.ui.table.model.PropListeningTableModel)2