Search in sources :

Example 1 with IHierarchyRenderer

use of de.jaret.util.ui.table.renderer.IHierarchyRenderer in project translationstudio8 by heartsome.

the class JaretTable method mousePressed.

/**
     * Handle mouse pressed.
     * 
     * @param x x coordinate
     * @param y y coordinate
     * @param popuptrigger true if the button pressed was the popup trigger
     * @param stateMask statemask from the event
     */
private void mousePressed(int x, int y, boolean popuptrigger, int stateMask) {
    // check for location over drag marker and start fill drag if necessary
    if (_dragMarkerRect != null && _dragMarkerRect.contains(x, y)) {
        _isFillDrag = true;
        _firstFillDragSelect = _selectedIdxRectangle;
        return;
    }
    IRow row = rowByBottomBorder(y);
    if (row != null && _rowResizeAllowed && (_tvs.getRowHeigthMode(row) == RowHeightMode.VARIABLE || _tvs.getRowHeigthMode(row) == RowHeightMode.OPTANDVAR) && (!_resizeRestriction || Math.abs(x - _tableRect.x) <= SELDELTA || (_fixedColRect != null && _fixedColRect.contains(x, y)))) {
        _heightDraggedRowInfo = getRowInfo(row);
        return;
    } else {
        IColumn col = colByRightBorder(x);
        if (col != null && _columnResizeAllowed && _tvs.columnResizingAllowed(col) && (!_resizeRestriction || _headerRect == null || _headerRect.contains(x, y))) {
            _widthDraggedColumn = getColInfo(col);
            return;
        }
    }
    // check header drag
    if (_headerResizeAllowed && Math.abs(_headerRect.y + _headerRect.height - y) <= SELDELTA) {
        _headerDragged = true;
        return;
    }
    // handle mouse press for selection
    boolean doSelect = true;
    // check focus set
    if (_tableRect.contains(x, y) || (_fixedColumns > 0 && _fixedColRect.contains(x, y)) || (_fixedRows > 0 && _fixedRowRect.contains(x, y))) {
        setFocus(x, y);
        doSelect = !handleEditorSingleClick(x, y);
    }
    // check hierarchy
    if (_tableRect.contains(x, y) || (_fixedColumns > 0 && _fixedColRect.contains(x, y)) || (_fixedRows > 0 && _fixedRowRect.contains(x, y))) {
        IRow xrow = rowForY(y);
        IColumn xcol = colForX(x);
        if (xrow != null && xcol != null && isHierarchyColumn(xrow, xcol)) {
            Rectangle rect = getCellBounds(xrow, xcol);
            IHierarchyRenderer hrenderer = (IHierarchyRenderer) getCellRenderer(xrow, xcol);
            if (hrenderer.isInActiveArea(xrow, rect, x, y)) {
                toggleExpanded(xrow);
            }
        }
    }
    // check header sorting clicks
    IColumn xcol = colForX(x);
    if (_allowSorting && _headerRect.contains(x, y) && _headerRenderer.isSortingClick(getHeaderDrawingArea(xcol), xcol, x, y)) {
        _tvs.setSorting(xcol);
    } else if (doSelect) {
        // selection can be intercepted by editor clicks
        handleSelection(x, y, stateMask, false);
    }
}
Also used : IRow(de.jaret.util.ui.table.model.IRow) IColumn(de.jaret.util.ui.table.model.IColumn) Rectangle(org.eclipse.swt.graphics.Rectangle) IHierarchyRenderer(de.jaret.util.ui.table.renderer.IHierarchyRenderer)

Aggregations

IColumn (de.jaret.util.ui.table.model.IColumn)1 IRow (de.jaret.util.ui.table.model.IRow)1 IHierarchyRenderer (de.jaret.util.ui.table.renderer.IHierarchyRenderer)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1