use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class FilterRowDataLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
// At the data layer level position == index
final LabelStack labels = super.getConfigLabelsByPosition(columnPosition, rowPosition);
// the label needs to be index based as the position changes on
// scrolling
labels.addLabel(FILTER_ROW_COLUMN_LABEL_PREFIX + getColumnIndexByPosition(columnPosition));
labels.addLabel(GridRegion.FILTER_ROW);
return labels;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class ColumnGroupGroupHeaderLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
int columnIndex = getColumnIndexByPosition(columnPosition);
if (rowPosition == 0 && this.model.isPartOfAGroup(columnIndex)) {
LabelStack stack = new LabelStack();
if (getConfigLabelAccumulator() != null) {
getConfigLabelAccumulator().accumulateConfigLabels(stack, columnPosition, rowPosition);
}
stack.addLabel(GridRegion.COLUMN_GROUP_HEADER);
if (this.model.isPartOfACollapseableGroup(columnIndex)) {
ColumnGroup group = this.model.getColumnGroupByIndex(columnIndex);
if (group.isCollapsed()) {
stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_COLLAPSED_CONFIG_TYPE);
} else {
stack.addLabelOnTop(DefaultColumnGroupHeaderLayerConfiguration.GROUP_EXPANDED_CONFIG_TYPE);
}
}
return stack;
} else {
if (rowPosition != 0) {
rowPosition--;
}
return this.columnGroupHeaderLayer.getConfigLabelsByPosition(columnPosition, rowPosition);
}
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class SelectionLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
LabelStack labelStack = super.getConfigLabelsByPosition(columnPosition, rowPosition);
ILayerCell cell = getCellByPosition(columnPosition, rowPosition);
if (cell != null) {
Rectangle cellRectangle = new Rectangle(cell.getOriginColumnPosition(), cell.getOriginRowPosition(), cell.getColumnSpan(), cell.getRowSpan());
if (cellRectangle.contains(getSelectionAnchor().columnPosition, getSelectionAnchor().rowPosition)) {
labelStack.addLabelOnTop(SelectionStyleLabels.SELECTION_ANCHOR_STYLE);
}
if (this.bottomRightInSelection != null && cellRectangle.contains(this.bottomRightInSelection.columnPosition, this.bottomRightInSelection.rowPosition)) {
labelStack.addLabel(SelectionStyleLabels.FILL_HANDLE_CELL);
}
}
if (this.fillHandleRegion != null && this.fillHandleRegion.contains(cell.getColumnIndex(), cell.getRowIndex())) {
labelStack.addLabel(SelectionStyleLabels.FILL_HANDLE_REGION);
}
return labelStack;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class CellDisplayValueSearchUtil method compare.
private static boolean compare(ILayer layer, IConfigRegistry configRegistry, Pattern pattern, String stringValue, Comparator<String> comparator, boolean caseSensitive, boolean wholeWord, boolean regex, int columnPosition, int rowPosition) {
// Convert cell's data
LabelStack labels = layer.getConfigLabelsByPosition(columnPosition, rowPosition);
if (!labels.hasLabel(ISearchStrategy.SKIP_SEARCH_RESULT_LABEL)) {
final IDisplayConverter displayConverter = configRegistry.getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, DisplayMode.NORMAL, labels.getLabels());
Object dataValue = null;
if (displayConverter != null) {
ILayerCell cell = layer.getCellByPosition(columnPosition, rowPosition);
if (cell != null) {
dataValue = displayConverter.canonicalToDisplayValue(cell, configRegistry, cell.getDataValue());
}
}
// Compare with valueToMatch
if (dataValue instanceof Comparable<?>) {
String dataValueString = caseSensitive ? dataValue.toString() : dataValue.toString().toLowerCase();
if (regex) {
if (pattern.matcher(dataValueString).matches()) {
return true;
}
} else if (comparator.compare(stringValue, dataValueString) == 0) {
return true;
} else if (!wholeWord && dataValueString.contains(stringValue)) {
return true;
} else if (wholeWord) {
// we also need to check single words in a multi word value
// $NON-NLS-1$
String[] split = dataValueString.split("\\b");
for (String word : split) {
if (comparator.compare(stringValue, word) == 0) {
return true;
}
}
}
}
}
return false;
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class SortHeaderLayer method getConfigLabelsByPosition.
/**
* @return adds a special configuration label to the stack taking into
* account the following:
* <ol>
* <li>Is the column sorted ?</li>
* <li>What is the sort order of the column</li>
* </ol>
* A special painter is registered against the above labels to
* render the sort arrows
*/
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
LabelStack configLabels = super.getConfigLabelsByPosition(columnPosition, rowPosition);
if (this.sortModel != null) {
int columnIndex = getColumnIndexByPosition(columnPosition);
if (this.sortModel.isColumnIndexSorted(columnIndex)) {
String sortConfig = DefaultSortConfiguration.SORT_SEQ_CONFIG_TYPE + this.sortModel.getSortOrder(columnIndex);
configLabels.addLabelOnTop(sortConfig);
SortDirectionEnum sortDirection = this.sortModel.getSortDirection(columnIndex);
switch(sortDirection) {
case ASC:
configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_UP_CONFIG_TYPE);
break;
case DESC:
configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_DOWN_CONFIG_TYPE);
break;
}
configLabels.addLabelOnTop(DefaultSortConfiguration.SORT_CONFIG_TYPE);
}
}
return configLabels;
}
Aggregations