Search in sources :

Example 51 with LabelStack

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

Example 52 with LabelStack

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);
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) CellLabelMouseEventMatcher(org.eclipse.nebula.widgets.nattable.ui.matcher.CellLabelMouseEventMatcher) Test(org.junit.Test)

Example 53 with LabelStack

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));
}
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 54 with LabelStack

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)));
}
Also used : RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ViewportSelectRowCommand(org.eclipse.nebula.widgets.nattable.viewport.command.ViewportSelectRowCommand) Test(org.junit.Test)

Example 55 with LabelStack

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;
}
Also used : StringTokenizer(java.util.StringTokenizer) 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