Search in sources :

Example 1 with StyleProxy

use of org.eclipse.nebula.widgets.nattable.style.StyleProxy in project nebula.widgets.nattable by eclipse.

the class CellStyleProxyTest method proxyShouldRetreiveConfigAttributeUsingTheDisplayModeOrdering.

@Test
public void proxyShouldRetreiveConfigAttributeUsingTheDisplayModeOrdering() throws Exception {
    ConfigRegistry configRegistry = new ConfigRegistry();
    Style testCellStyle1 = new Style();
    testCellStyle1.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.RIGHT);
    Style testCellStyle2 = new Style();
    testCellStyle2.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.CENTER);
    testCellStyle2.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, VerticalAlignmentEnum.MIDDLE);
    // NORMAL mode has an horizontal align attribute registered
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, testCellStyle1, DisplayMode.NORMAL, TEST_CONFIG_LABEL1);
    // SELECT mode has a 'default' horizontal align attribute registered
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, testCellStyle2, DisplayMode.SELECT);
    // The 'default' from SELECT gets picked up
    StyleProxy cellStyleProxy = new CellStyleProxy(configRegistry, DisplayMode.SELECT, Arrays.asList(TEST_CONFIG_LABEL1));
    HorizontalAlignmentEnum alignmentFromProxy = cellStyleProxy.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
    Assert.assertEquals(HorizontalAlignmentEnum.CENTER, alignmentFromProxy);
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) HorizontalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum) Style(org.eclipse.nebula.widgets.nattable.style.Style) StyleProxy(org.eclipse.nebula.widgets.nattable.style.StyleProxy) CellStyleProxy(org.eclipse.nebula.widgets.nattable.style.CellStyleProxy) CellStyleProxy(org.eclipse.nebula.widgets.nattable.style.CellStyleProxy) Test(org.junit.Test)

Aggregations

ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1 CellStyleProxy (org.eclipse.nebula.widgets.nattable.style.CellStyleProxy)1 HorizontalAlignmentEnum (org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1 StyleProxy (org.eclipse.nebula.widgets.nattable.style.StyleProxy)1 Test (org.junit.Test)1