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));
}
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;
}
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());
}
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());
}
Aggregations