use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class ColumnOverrideLabelAccumulatorTest method testRegisterOverridesCollectionOnTop.
@Test
public void testRegisterOverridesCollectionOnTop() {
this.labelAccumulator.registerColumnOverridesOnTop(0, TEST_LABEL1);
List<String> labels = new ArrayList<String>();
labels.add(TEST_LABEL2);
labels.add(TEST_LABEL3);
this.labelAccumulator.registerColumnOverridesOnTop(0, labels);
LabelStack configLabels = new LabelStack();
this.labelAccumulator.accumulateConfigLabels(configLabels, 0, 0);
Assert.assertEquals(3, configLabels.getLabels().size());
Assert.assertEquals(TEST_LABEL2, configLabels.getLabels().get(0));
Assert.assertEquals(TEST_LABEL3, configLabels.getLabels().get(1));
Assert.assertEquals(TEST_LABEL1, configLabels.getLabels().get(2));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class CellLabelMouseEventMatcherTest method shouldTakeTheButtomIntoAccountWhileMatching.
@Test
public void shouldTakeTheButtomIntoAccountWhileMatching() throws Exception {
CellLabelMouseEventMatcher matcher = new CellLabelMouseEventMatcher(GridRegion.BODY, MouseEventMatcher.RIGHT_BUTTON, TEST_LABEL);
boolean match = matcher.matches(this.natTableFixture, new MouseEvent(SWTUtils.getLeftClickEvent(100, 100, 0, this.natTableFixture)), new LabelStack(GridRegion.BODY));
Assert.assertFalse(match);
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack 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));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class RowHeaderSelectionTest method shouldReturnFullySelectedStyle.
@Test
public void shouldReturnFullySelectedStyle() {
// Select full column
this.gridLayer.doCommand(new ViewportSelectRowCommand(this.gridLayer, 1, false, false));
RowHeaderLayer rowHeaderLayer = (RowHeaderLayer) this.gridLayer.getChildLayerByLayoutCoordinate(0, 1);
// Since I selected using grid coordinates, the column position should
// be 1 rather than 2
int rowPosition = this.gridLayer.localToUnderlyingRowPosition(1);
final LabelStack labelStack = rowHeaderLayer.getConfigLabelsByPosition(rowPosition, 0);
Assert.assertTrue(labelStack.hasLabel(SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE));
rowPosition = this.gridLayer.localToUnderlyingRowPosition(4);
Assert.assertFalse("Should not have returned fully selected style.", SelectionStyleLabels.ROW_FULLY_SELECTED_STYLE.equals(rowHeaderLayer.getConfigLabelsByPosition(0, rowPosition)));
}
use of org.eclipse.nebula.widgets.nattable.layer.LabelStack in project nebula.widgets.nattable by eclipse.
the class TestLayer method getConfigLabelsByPosition.
@Override
public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition) {
LabelStack labelStack = new LabelStack();
String configLabelsString = this.configLabels[columnPosition][rowPosition];
if (configLabelsString != null) {
StringTokenizer configLabelTokenizer = new StringTokenizer(configLabelsString, ",");
while (configLabelTokenizer.hasMoreTokens()) {
labelStack.addLabel(configLabelTokenizer.nextToken());
}
}
return labelStack;
}
Aggregations