Search in sources :

Example 1 with CellStyleFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture in project nebula.widgets.nattable by eclipse.

the class StylePersistorTest method persistStyleSettingsToProperties.

@Test
public void persistStyleSettingsToProperties() throws Exception {
    Properties properties = new Properties();
    StylePersistor.saveStyle(TEST_PREFIX, properties, new CellStyleFixture());
    String expectedPrefix = TEST_PREFIX + DOT + STYLE_PERSISTENCE_PREFIX + DOT;
    assertEquals("255,255,255", properties.getProperty(expectedPrefix + BG_COLOR_PREFIX + DOT + ColorPersistor.STYLE_PERSISTENCE_PREFIX));
    assertEquals("0,0,0", properties.getProperty(expectedPrefix + FG_COLOR_PREFIX + DOT + ColorPersistor.STYLE_PERSISTENCE_PREFIX));
    assertEquals("LEFT", properties.getProperty(expectedPrefix + H_ALIGNMENT_PREFIX));
    assertEquals("MIDDLE", properties.getProperty(expectedPrefix + V_ALIGNMENT_PREFIX));
    assertEquals(CellStyleFixture.TEST_FONT.getFontData()[0].toString(), properties.getProperty(expectedPrefix + FONT_PREFIX));
    assertEquals(CellStyleFixture.TEST_BORDER_STYLE.toString(), properties.getProperty(expectedPrefix + BORDER_PREFIX));
}
Also used : CellStyleFixture(org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with CellStyleFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture in project nebula.widgets.nattable by eclipse.

the class DisplayColumnStyleEditorCommandHandlerTest method saveStateForMultipleLabels.

@Test
public void saveStateForMultipleLabels() throws Exception {
    CellStyleFixture style1 = new CellStyleFixture(HorizontalAlignmentEnum.LEFT);
    CellStyleFixture style2 = new CellStyleFixture(HorizontalAlignmentEnum.RIGHT);
    this.handlerUnderTest.stylesToPersist.put("label1", style1);
    this.handlerUnderTest.stylesToPersist.put("label2", style2);
    PropertiesFixture propertiesFixture = new PropertiesFixture();
    this.handlerUnderTest.saveState("prefix", propertiesFixture);
    assertEquals(HorizontalAlignmentEnum.LEFT.name(), propertiesFixture.getProperty("prefix.userDefinedColumnStyle.label1.style.horizontalAlignment"));
    assertEquals(HorizontalAlignmentEnum.RIGHT.name(), propertiesFixture.getProperty("prefix.userDefinedColumnStyle.label2.style.horizontalAlignment"));
}
Also used : CellStyleFixture(org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture) PropertiesFixture(org.eclipse.nebula.widgets.nattable.test.fixture.PropertiesFixture) Test(org.junit.Test)

Example 3 with CellStyleFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture in project nebula.widgets.nattable by eclipse.

the class DisplayColumnStyleEditorCommandHandlerTest method doCommand.

@Test
public void doCommand() throws Exception {
    this.handlerUnderTest.dialog = new ColumnStyleEditorDialog(new Shell(), new CellStyleFixture());
    this.handlerUnderTest.applySelectedStyleToColumns(this.commandFixture, new int[] { 0 });
    Style selectedStyle = (Style) this.configRegistryFixture.getConfigAttribute(CELL_STYLE, NORMAL, this.handlerUnderTest.getConfigLabel(0));
    assertEquals(CellStyleFixture.TEST_BG_COLOR, selectedStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    assertEquals(CellStyleFixture.TEST_FG_COLOR, selectedStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    List<String> columnLableOverrides = this.handlerUnderTest.columnLabelAccumulator.getOverrides(Integer.valueOf(0));
    assertEquals(1, columnLableOverrides.size());
    assertEquals(USER_EDITED_COLUMN_STYLE_LABEL_PREFIX + "0", columnLableOverrides.get(0));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ColumnStyleEditorDialog(org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog) CellStyleFixture(org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture) Style(org.eclipse.nebula.widgets.nattable.style.Style) Test(org.junit.Test)

Aggregations

CellStyleFixture (org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture)3 Test (org.junit.Test)3 Properties (java.util.Properties)1 Style (org.eclipse.nebula.widgets.nattable.style.Style)1 ColumnStyleEditorDialog (org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog)1 PropertiesFixture (org.eclipse.nebula.widgets.nattable.test.fixture.PropertiesFixture)1 Shell (org.eclipse.swt.widgets.Shell)1