Search in sources :

Example 1 with IConfigLabelProvider

use of org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider in project nebula.widgets.nattable by eclipse.

the class ColumnHeaderLayerSelectionTest method shouldReturnProvidedLabels.

@Test
public void shouldReturnProvidedLabels() {
    ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
    columnHeaderLayer.setConfigLabelAccumulator(new IConfigLabelProvider() {

        @Override
        public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
            if (columnPosition == 2) {
                configLabels.addLabel("test");
            }
        }

        @Override
        public Collection<String> getProvidedLabels() {
            Set<String> result = new HashSet<String>();
            result.add("test");
            return result;
        }
    });
    Collection<String> labels = columnHeaderLayer.getProvidedLabels();
    assertEquals(1, labels.size());
    assertEquals("test", labels.iterator().next());
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Set(java.util.Set) HashSet(java.util.HashSet) IConfigLabelProvider(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) Collection(java.util.Collection) Test(org.junit.Test)

Example 2 with IConfigLabelProvider

use of org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider in project nebula.widgets.nattable by eclipse.

the class CompositeLayer method getProvidedLabels.

@Override
public Collection<String> getProvidedLabels() {
    Collection<String> labels = super.getProvidedLabels();
    for (int layoutX = 0; layoutX < this.layoutXCount; layoutX++) {
        for (int layoutY = 0; layoutY < this.layoutYCount; layoutY++) {
            ILayer childLayer = this.childLayerLayout[layoutX][layoutY];
            String regionName = this.childLayerToRegionNameMap.get(childLayer);
            labels.add(regionName);
            IConfigLabelAccumulator accumulator = this.regionNameToConfigLabelAccumulatorMap.get(regionName);
            if (accumulator != null && accumulator instanceof IConfigLabelProvider) {
                labels.addAll(((IConfigLabelProvider) accumulator).getProvidedLabels());
            }
            if (childLayer instanceof AbstractLayer) {
                labels.addAll(((AbstractLayer) childLayer).getProvidedLabels());
            }
        }
    }
    return labels;
}
Also used : IConfigLabelProvider(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider) IConfigLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator) Point(org.eclipse.swt.graphics.Point)

Example 3 with IConfigLabelProvider

use of org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider in project nebula.widgets.nattable by eclipse.

the class ColumnHeaderLayerSelectionTest method shouldReturnAdditionalLabels.

@Test
public void shouldReturnAdditionalLabels() {
    ColumnHeaderLayer columnHeaderLayer = (ColumnHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(1, 0);
    columnHeaderLayer.setConfigLabelAccumulator(new IConfigLabelProvider() {

        @Override
        public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
            if (columnPosition == 2) {
                configLabels.addLabel("test");
            }
        }

        @Override
        public Collection<String> getProvidedLabels() {
            Set<String> result = new HashSet<String>();
            result.add("test");
            return result;
        }
    });
    LabelStack labelStack = this.gridLayer.getConfigLabelsByPosition(3, 0);
    assertEquals(2, labelStack.getLabels().size());
    assertTrue(labelStack.hasLabel("test"));
    assertTrue(labelStack.hasLabel(GridRegion.COLUMN_HEADER));
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) Set(java.util.Set) HashSet(java.util.HashSet) IConfigLabelProvider(org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) Collection(java.util.Collection) Test(org.junit.Test)

Aggregations

IConfigLabelProvider (org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelProvider)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)2 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)2 Test (org.junit.Test)2 IConfigLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator)1 Point (org.eclipse.swt.graphics.Point)1