Search in sources :

Example 21 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack)

Example 22 with LabelStack

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);
    }
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnGroup(org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel.ColumnGroup)

Example 23 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Rectangle(org.eclipse.swt.graphics.Rectangle) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 24 with 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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) IDisplayConverter(org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)

Example 25 with LabelStack

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;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack)

Aggregations

LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)80 Test (org.junit.Test)30 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)14 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)13 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)11 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)10 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)10 HashMap (java.util.HashMap)9 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)9 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)9 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 Composite (org.eclipse.swt.widgets.Composite)9 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)8 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)8 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)8 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)8 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)8