Search in sources :

Example 1 with ColumnStyleEditorDialog

use of org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog 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)

Example 2 with ColumnStyleEditorDialog

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

the class DisplayColumnStyleEditorCommandHandler method doCommand.

@Override
public boolean doCommand(DisplayColumnStyleEditorCommand command) {
    int columnIndexOfClick = command.getNattableLayer().getColumnIndexByPosition(command.columnPosition);
    LabelStack configLabels = new LabelStack();
    this.columnLabelAccumulator.accumulateConfigLabels(configLabels, columnIndexOfClick, 0);
    configLabels.addLabel(getConfigLabel(columnIndexOfClick));
    // Column style
    Style clickedCellStyle = (Style) this.configRegistry.getConfigAttribute(CELL_STYLE, NORMAL, configLabels.getLabels());
    this.dialog = new ColumnStyleEditorDialog(Display.getCurrent().getActiveShell(), clickedCellStyle);
    this.dialog.open();
    if (this.dialog.isCancelPressed()) {
        return true;
    }
    int[] selectedColumns = getSelectedColumnIndeces();
    if (selectedColumns.length > 0) {
        applySelectedStyleToColumns(command, selectedColumns);
        // fire refresh event
        this.selectionLayer.fireLayerEvent(new ColumnVisualUpdateEvent(this.selectionLayer, this.selectionLayer.getSelectedColumnPositions()));
    } else {
        applySelectedStyle();
        // fire refresh event
        this.selectionLayer.fireLayerEvent(new VisualRefreshEvent(this.selectionLayer));
    }
    return true;
}
Also used : LabelStack(org.eclipse.nebula.widgets.nattable.layer.LabelStack) ColumnVisualUpdateEvent(org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent) ColumnStyleEditorDialog(org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog) VisualRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent) Style(org.eclipse.nebula.widgets.nattable.style.Style)

Example 3 with ColumnStyleEditorDialog

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

the class ColumnStyleEditorDialogRunner method main.

public static void main(String[] args) throws Exception {
    Shell shell = new Shell();
    ColumnStyleEditorDialog dialog = new ColumnStyleEditorDialog(shell, new Style());
    dialog.open();
    System.out.println("Style: " + dialog.getNewColumnCellStyle());
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ColumnStyleEditorDialog(org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog) Style(org.eclipse.nebula.widgets.nattable.style.Style)

Example 4 with ColumnStyleEditorDialog

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

the class DisplayColumnStyleEditorCommandHandlerTest method shouldRemoveLabelFromPersistenceIfStyleIsCleared.

@Test
public void shouldRemoveLabelFromPersistenceIfStyleIsCleared() throws Exception {
    this.handlerUnderTest.dialog = new ColumnStyleEditorDialog(new Shell(), null);
    this.handlerUnderTest.applySelectedStyleToColumns(this.commandFixture, new int[] { 0 });
    Style selectedStyle = (Style) this.configRegistryFixture.getConfigAttribute(CELL_STYLE, NORMAL, this.handlerUnderTest.getConfigLabel(0));
    DefaultNatTableStyleConfiguration defaultStyle = new DefaultNatTableStyleConfiguration();
    assertEquals(defaultStyle.bgColor, selectedStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR));
    assertEquals(defaultStyle.fgColor, selectedStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR));
    Properties properties = new Properties();
    this.handlerUnderTest.saveState("prefix", properties);
    assertEquals(0, properties.size());
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ColumnStyleEditorDialog(org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) Style(org.eclipse.nebula.widgets.nattable.style.Style) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

Style (org.eclipse.nebula.widgets.nattable.style.Style)4 ColumnStyleEditorDialog (org.eclipse.nebula.widgets.nattable.style.editor.ColumnStyleEditorDialog)4 Shell (org.eclipse.swt.widgets.Shell)3 Test (org.junit.Test)2 Properties (java.util.Properties)1 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)1 LabelStack (org.eclipse.nebula.widgets.nattable.layer.LabelStack)1 ColumnVisualUpdateEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnVisualUpdateEvent)1 VisualRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.VisualRefreshEvent)1 CellStyleFixture (org.eclipse.nebula.widgets.nattable.test.fixture.CellStyleFixture)1