use of de.jaret.util.ui.table.model.IRow in project translationstudio8 by heartsome.
the class JaretTable method handleEditorSingleClick.
/**
* Handle a single mouseclick by passing it to the cell editor if present.
*
* @param x x coordinate of the click
* @param y y coordinate of the click
* @return true if the editor handled the click
*/
private boolean handleEditorSingleClick(int x, int y) {
IRow row = rowForY(y);
IColumn col = colForX(x);
if (col != null && row != null) {
ICellEditor editor = getCellEditor(row, col);
if (editor != null) {
Rectangle area = getCellBounds(row, col);
return editor.handleClick(this, row, col, area, x, y);
}
}
return false;
}
use of de.jaret.util.ui.table.model.IRow in project translationstudio8 by heartsome.
the class JaretTable method mouseMoved.
/**
* Handle mouse move. This is mostly: modifying the appearance of the cursor.
*
* @param x x coordinate of pointer
* @param y y coordinate of pointer
* @param stateMask keyStatemask
*/
private void mouseMoved(int x, int y, int stateMask) {
Display display = Display.getCurrent();
Shell activeShell = display != null ? display.getActiveShell() : null;
// check for location over drag marker
if (_dragMarkerRect != null && _dragMarkerRect.contains(x, y)) {
if (activeShell != null) {
// MAYBE other cursor for differentiation?
activeShell.setCursor(display.getSystemCursor(SWT.CURSOR_SIZEALL));
}
return;
}
// check for location over lower border of row
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)))) {
if (activeShell != null) {
activeShell.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENS));
}
return;
} else {
IColumn col = colByRightBorder(x);
if (col != null && _columnResizeAllowed && _tvs.columnResizingAllowed(col) && (!_resizeRestriction || _headerRect == null || _headerRect.contains(x, y))) {
if (activeShell != null) {
activeShell.setCursor(display.getSystemCursor(SWT.CURSOR_SIZEW));
}
return;
}
}
// check header drag symboling
if (_headerRect != null && _headerResizeAllowed && Math.abs(_headerRect.y + _headerRect.height - y) <= SELDELTA) {
if (activeShell != null) {
activeShell.setCursor(display.getSystemCursor(SWT.CURSOR_SIZENS));
}
return;
}
if (Display.getCurrent().getActiveShell() != null) {
Display.getCurrent().getActiveShell().setCursor(Display.getCurrent().getSystemCursor(SWT.CURSOR_ARROW));
}
}
use of de.jaret.util.ui.table.model.IRow in project translationstudio8 by heartsome.
the class JaretTable method handleSelection.
/**
* Handle selection operations.
*
* @param x x
* @param y y
* @param stateMask key state mask
* @param dragging true when dragging
*/
private void handleSelection(int x, int y, int stateMask, boolean dragging) {
// a mouse select always ends a shift-arrow select
_lastKeySelect = null;
_firstKeySelect = null;
_firstKeyColSelectIdx = -1;
_lastKeyColSelectIdx = -1;
_firstKeyRowSelectIdx = -1;
_lastKeyRowSelectIdx = -1;
IRow row = rowForY(y);
int rowIdx = row != null ? _rows.indexOf(row) : -1;
IColumn col = colForX(x);
int colIdx = getColumnIdx(col);
// check fill dragging
if (dragging && _isFillDrag) {
if (_selectionModel.isCellSelectionAllowed() && _tableRect.contains(x, y)) {
if (col != null && row != null) {
if (_firstCellSelectX == -1) {
_firstCellSelectX = colIdx;
_firstCellSelectY = rowIdx;
}
if (Math.abs(_firstCellSelectX - colIdx) > Math.abs(_firstCellSelectY - rowIdx)) {
rowIdx = _firstCellSelectY;
row = rowForIdx(rowIdx);
_horizontalFillDrag = false;
} else {
colIdx = _firstCellSelectX;
col = colForIdx(colIdx);
_horizontalFillDrag = true;
}
ensureSelectionContainsRegion(_firstFillDragSelect, colIdx, rowIdx, _lastCellSelectX, _lastCellSelectY);
// ensureSelectionContainsRegion(_firstCellSelectX, _firstCellSelectY, colIdx, rowIdx,
// _lastCellSelectX, _lastCellSelectY);
_lastCellSelectX = colIdx;
_lastCellSelectY = rowIdx;
// a newly selected cell will always be the focussed cell (causes scrolling this cell to be
// completely visible)
setFocus(row, col);
}
}
return;
}
// check row selection
if (row != null && _selectionModel.isFullRowSelectionAllowed() && (isRowSelection(x, y) || _selectionModel.isOnlyRowSelectionAllowed() || _firstRowSelectIdx != -1)) {
if (_firstRowSelectIdx == -1) {
_firstRowSelectIdx = rowIdx;
}
if ((stateMask & SWT.CONTROL) != 0) {
if (!_selectionModel.getSelection().getSelectedRows().contains(row)) {
_selectionModel.addSelectedRow(row);
} else {
_selectionModel.remSelectedRow(row);
}
_lastSelectType = SelectType.ROW;
} else if (dragging) {
ensureSelectionContainsRowRegion(_firstRowSelectIdx, rowIdx, _lastRowSelectIdx);
_lastRowSelectIdx = rowIdx;
_lastSelectType = SelectType.ROW;
} else {
_selectionModel.clearSelection();
_selectionModel.addSelectedRow(row);
_lastSelectType = SelectType.ROW;
}
_lastRowSelectIdx = rowIdx;
return;
}
// check column selection
if (_selectionModel.isFullColumnSelectionAllowed() && (isColumnSelection(x, y) || _firstColSelectIdx != -1)) {
if (_firstColSelectIdx == -1) {
_firstColSelectIdx = colIdx;
}
if ((stateMask & SWT.CONTROL) != 0) {
if (!_selectionModel.getSelection().getSelectedColumns().contains(col)) {
_selectionModel.addSelectedColumn(col);
} else {
_selectionModel.remSelectedColumn(col);
}
_lastSelectType = SelectType.COLUMN;
} else if (dragging) {
ensureSelectionContainsColRegion(_firstColSelectIdx, colIdx, _lastColSelectIdx);
_lastColSelectIdx = colIdx;
_lastSelectType = SelectType.COLUMN;
} else {
_selectionModel.clearSelection();
_selectionModel.addSelectedColumn(col);
_lastSelectType = SelectType.COLUMN;
}
_lastColSelectIdx = colIdx;
return;
}
// check cell selection
if (_selectionModel.isCellSelectionAllowed() && _tableRect.contains(x, y)) {
if (col != null && row != null) {
IJaretTableCell cell = new JaretTableCellImpl(row, col);
if (_firstCellSelectX == -1) {
_firstCellSelectX = colIdx;
_firstCellSelectY = rowIdx;
}
if ((stateMask & SWT.CONTROL) != 0) {
if (!_selectionModel.getSelection().getSelectedCells().contains(cell)) {
_selectionModel.addSelectedCell(cell);
} else {
_selectionModel.remSelectedCell(cell);
}
_lastSelectType = SelectType.CELL;
} else if (dragging) {
ensureSelectionContainsRegion(_firstCellSelectX, _firstCellSelectY, colIdx, rowIdx, _lastCellSelectX, _lastCellSelectY);
_lastCellSelectX = colIdx;
_lastCellSelectY = rowIdx;
_lastSelectType = SelectType.CELL;
} else {
_selectionModel.clearSelection();
_selectionModel.addSelectedCell(cell);
_lastSelectType = SelectType.CELL;
}
// a newly selected cell will always be the focussed cell (causes scrolling this cell to be completely
// visible)
setFocus(row, col);
}
}
}
use of de.jaret.util.ui.table.model.IRow in project translationstudio8 by heartsome.
the class JaretTable method getAbsBeginYForRowIdx.
/**
* Return the absolute y coordinate for the given row (given by index).
*
* @param rowidx index of the row
* @return absolute y coordinate (of all rows) for the row
*/
private int getAbsBeginYForRowIdx(int rowidx) {
int y = 0;
for (int idx = 0; idx < rowidx; idx++) {
IRow row = _rows.get(idx);
int rowHeight = _tvs.getRowHeight(row);
y += rowHeight;
}
return y;
}
use of de.jaret.util.ui.table.model.IRow 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;
}
Aggregations