use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class InlineCellEditEventHandler method handleLayerEvent.
@Override
public void handleLayerEvent(InlineCellEditEvent event) {
if (event.convertToLocal(this.layer)) {
ILayerCell cell = this.layer.getCellByPosition(event.getColumnPosition(), event.getRowPosition());
EditController.editCell(cell, event.getParent(), event.getInitialValue(), event.getConfigRegistry());
}
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class ComboBoxFilterRowConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, this.cellEditor, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.TEXT_MATCHING_MODE, TextMatchingMode.REGULAR_EXPRESSION);
ICellPainter cellPainter = new CellPainterDecorator(new TextPainter() {
{
this.paintFg = false;
}
// override the preferred width and height to be 0, as otherwise
// the String that is generated in the background for multiple
// selection will be taken into account for auto resizing
@Override
public int getPreferredWidth(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
return 0;
}
@Override
public int getPreferredHeight(ILayerCell cell, GC gc, IConfigRegistry configRegistry) {
return 0;
}
}, CellEdgeEnum.RIGHT, this.filterIconPainter);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class ColumnGroupGroupHeaderLayer method getCellByPosition.
// Cell features
/**
* If a cell belongs to a column group: column position - set to the start
* position of the group span - set to the width/size of the column group
*
* NOTE: gc.setClip() is used in the CompositeLayerPainter to ensure that
* partially visible Column group header cells are rendered properly.
*/
@Override
public ILayerCell getCellByPosition(int columnPosition, int rowPosition) {
int bodyColumnIndex = getColumnIndexByPosition(columnPosition);
if (rowPosition == 0) {
if (this.model.isPartOfAGroup(bodyColumnIndex)) {
return new LayerCell(this, getStartPositionOfGroup(columnPosition), rowPosition, columnPosition, rowPosition, getColumnSpan(columnPosition), 1);
} else {
ILayerCell underlyingCell = this.columnGroupHeaderLayer.getCellByPosition(columnPosition, rowPosition);
return new LayerCell(this, underlyingCell.getOriginColumnPosition(), underlyingCell.getOriginRowPosition(), columnPosition, rowPosition, underlyingCell.getColumnSpan(), underlyingCell.getRowSpan() + 1);
}
} else if (rowPosition == 1) {
ILayerCell underlyingCell = this.columnGroupHeaderLayer.getCellByPosition(columnPosition, rowPosition - 1);
boolean partOfAGroup = this.model.isPartOfAGroup(bodyColumnIndex);
return new LayerCell(this, underlyingCell.getOriginColumnPosition(), underlyingCell.getOriginRowPosition() + (partOfAGroup ? 1 : 0), columnPosition, rowPosition, underlyingCell.getColumnSpan(), underlyingCell.getRowSpan() + (partOfAGroup ? 0 : 1));
} else if (rowPosition == 2) {
ILayerCell underlyingCell = this.columnGroupHeaderLayer.getCellByPosition(columnPosition, rowPosition - 1);
boolean partOfAGroup = this.model.isPartOfAGroup(bodyColumnIndex) || this.columnGroupHeaderLayer.isColumnInGroup(bodyColumnIndex);
return new LayerCell(this, underlyingCell.getOriginColumnPosition(), underlyingCell.getOriginRowPosition() + (partOfAGroup ? 1 : 0), columnPosition, rowPosition, underlyingCell.getColumnSpan(), underlyingCell.getRowSpan() + (partOfAGroup ? 0 : 1));
}
return null;
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class FreezeSelectionStrategy method getTopLeftPosition.
@Override
public PositionCoordinate getTopLeftPosition() {
PositionCoordinate lastSelectedCellPosition = this.selectionLayer.getLastSelectedCellPosition();
if (lastSelectedCellPosition == null) {
return null;
}
ILayerCell lastSelectedCell = this.selectionLayer.getCellByPosition(lastSelectedCellPosition.columnPosition, lastSelectedCellPosition.rowPosition);
int columnPosition = this.viewportLayer.getScrollableLayer().getColumnPositionByX(this.viewportLayer.getOrigin().getX());
if (columnPosition > 0 && columnPosition >= lastSelectedCellPosition.columnPosition) {
if (!this.include) {
columnPosition = lastSelectedCellPosition.columnPosition - 1;
} else {
columnPosition = lastSelectedCellPosition.columnPosition + lastSelectedCell.getColumnSpan() - 1;
}
}
int rowPosition = this.viewportLayer.getScrollableLayer().getRowPositionByY(this.viewportLayer.getOrigin().getY());
if (rowPosition > 0 && rowPosition >= lastSelectedCellPosition.rowPosition) {
if (!this.include) {
rowPosition = lastSelectedCellPosition.rowPosition - 1;
} else {
rowPosition = lastSelectedCellPosition.rowPosition - lastSelectedCell.getRowSpan() - 1;
}
}
return new PositionCoordinate(this.freezeLayer, columnPosition, rowPosition);
}
use of org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell in project nebula.widgets.nattable by eclipse.
the class HierarchicalTreeAlternatingRowConfigLabelAccumulator method calculateLabel.
/**
* Calculate the even/odd label based on the above row label, taking the
* spanning into account.
*
* @param rowPosition
* The row position for which the label should be determined.
* @return The even/odd row label to be applied for the given row.
*/
protected String calculateLabel(int rowPosition) {
// get cell in first column to determine the origin row position of the
// spanned cell
ILayerCell firstColumn = this.layer.getCellByPosition(0, rowPosition);
// check if there is a label for the origin row already
String label = this.rowLabelCache.get(firstColumn.getOriginRowPosition());
if (label == null) {
if (firstColumn.getOriginRowPosition() == 0) {
label = EVEN_ROW_CONFIG_TYPE;
} else {
// check for the label one row above
// remember: spanned cells are rendered at the end
String labelAbove = this.rowLabelCache.get(firstColumn.getOriginRowPosition() - 1);
if (labelAbove == null) {
labelAbove = calculateLabel(firstColumn.getOriginRowPosition() - 1);
}
label = (labelAbove == EVEN_ROW_CONFIG_TYPE) ? ODD_ROW_CONFIG_TYPE : EVEN_ROW_CONFIG_TYPE;
}
}
return label;
}
Aggregations