use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator in project nebula.widgets.nattable by eclipse.
the class DefaultFilterRowConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// Plug in custom painter
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new PaddingDecorator(this.cellPainter, 0, 0, 0, 5), DisplayMode.NORMAL, GridRegion.FILTER_ROW);
configRegistry.registerConfigAttribute(CellConfigAttributes.RENDER_GRID_LINES, Boolean.TRUE, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
// Make cells editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
// Default text matching mode
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.TEXT_MATCHING_MODE, this.textMatchingMode);
// Default display converter. Used to convert the values typed into the
// text boxes into String objects.
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER, new DefaultDisplayConverter());
// Default comparator. Used to compare objects in the column during
// threshold matching.
configRegistry.registerConfigAttribute(FilterRowConfigAttributes.FILTER_COMPARATOR, DefaultComparator.getInstance());
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator in project nebula.widgets.nattable by eclipse.
the class DefaultHierarchicalTreeLayerConfiguration method configureRegistry.
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// configure the tree structure painter
ICellPainter treeImagePainter = new PaddingDecorator(new TreeImagePainter(), 5, 2, 5, 2);
IndentedTreeImagePainter treePainter = new IndentedTreeImagePainter(0, CellEdgeEnum.TOP_LEFT, treeImagePainter);
treePainter.getInternalPainter().setPaintDecorationDependent(false);
ICellPainter treeStructurePainter = new BackgroundPainter(treePainter);
configRegistry.registerConfigAttribute(TreeConfigAttributes.TREE_STRUCTURE_PAINTER, treeStructurePainter, DisplayMode.NORMAL);
// configure the style and the cell painter for the tree/node columns
// necessary because the IndentedTreeImagePainter is inspecting and
// using the underlying painter
ICellPainter basePainter = new PaddingDecorator(new TextPainter(), 2, 2, 2, 15);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, basePainter, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
Style treeStyle = new Style();
treeStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, VerticalAlignmentEnum.TOP);
treeStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, treeStyle, DisplayMode.NORMAL, TreeLayer.TREE_COLUMN_CELL);
// configure styling for tree level header
Style levelHeaderStyle = new Style();
levelHeaderStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.levelHeaderColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, levelHeaderStyle, DisplayMode.NORMAL, HierarchicalTreeLayer.LEVEL_HEADER_CELL);
Style levelHeaderSelectedStyle = new Style();
levelHeaderSelectedStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.levelHeaderSelectedColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, levelHeaderSelectedStyle, DisplayMode.SELECT, HierarchicalTreeLayer.LEVEL_HEADER_CELL);
// register special empty painter to not render content in collapsed
// childs
// this also allows for example some different styling of collapsed
// childs
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new BackgroundPainter(), DisplayMode.NORMAL, HierarchicalTreeLayer.COLLAPSED_CHILD);
// configure alternate row style
Style evenRowCellStyle = new Style();
evenRowCellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.evenRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, evenRowCellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
Style oddRowCellStyle = new Style();
oddRowCellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.oddRowBgColor);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, oddRowCellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.ODD_ROW_CONFIG_TYPE);
configureEditableRules(configRegistry);
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator in project nebula.widgets.nattable by eclipse.
the class _6044_HierarchicalTreeLayerGridExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("manufacturer", "Manufacturer");
propertyToLabelMap.put("model", "Model");
propertyToLabelMap.put("motors.identifier", "Identifier");
propertyToLabelMap.put("motors.capacity", "Capacity");
propertyToLabelMap.put("motors.capacityUnit", "Capacity Unit");
propertyToLabelMap.put("motors.maximumSpeed", "Maximum Speed");
propertyToLabelMap.put("motors.feedbacks.creationTime", "Creation Time");
propertyToLabelMap.put("motors.feedbacks.classification", "Classification");
propertyToLabelMap.put("motors.feedbacks.comment", "Comment");
ConfigRegistry configRegistry = new ConfigRegistry();
BodyLayerStack bodyLayerStack = new BodyLayerStack(CarService.getInput(), CarService.PROPERTY_NAMES);
// create the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// add the SortHeaderLayer to the column header layer stack
final SortHeaderLayer<HierarchicalWrapper> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new HierarchicalWrapperSortModel(bodyLayerStack.getSortedList(), bodyLayerStack.getColumnPropertyAccessor(), bodyLayerStack.getTreeLayer().getLevelIndexMapping(), columnHeaderDataLayer, configRegistry), false);
// create the row header layer stack
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyLayerStack.getBodyDataProvider());
ILayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowHeaderDataProvider, 40, 20), bodyLayerStack, bodyLayerStack.getSelectionLayer());
// create the corner layer stack
ILayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider)), rowHeaderLayer, sortHeaderLayer);
// create the grid layer composed with the prior created layer stacks
GridLayer gridLayer = new GridLayer(bodyLayerStack, sortHeaderLayer, rowHeaderLayer, cornerLayer);
NatTable natTable = new NatTable(parent, gridLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.vAlign = VerticalAlignmentEnum.TOP;
this.hAlign = HorizontalAlignmentEnum.LEFT;
this.cellPainter = new PaddingDecorator(new TextPainter(), 2);
}
});
// adds the key bindings that allows pressing space bar to
// expand/collapse tree nodes
natTable.addConfiguration(new TreeLayerExpandCollapseKeyBindings(bodyLayerStack.getTreeLayer(), bodyLayerStack.getSelectionLayer()));
// add sorting configuration
natTable.addConfiguration(new SingleClickSortConfiguration());
natTable.configure();
return natTable;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator in project nebula.widgets.nattable by eclipse.
the class _6045_HierarchicalTreeLayerExample method createExampleControl.
@Override
public Control createExampleControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new GridLayout());
// mapping from property to label, needed for column header labels
Map<String, String> propertyToLabelMap = new HashMap<>();
propertyToLabelMap.put("manufacturer", "Manufacturer");
propertyToLabelMap.put("model", "Model");
propertyToLabelMap.put("motors.identifier", "Identifier");
propertyToLabelMap.put("motors.capacity", "Capacity");
propertyToLabelMap.put("motors.capacityUnit", "Capacity Unit");
propertyToLabelMap.put("motors.maximumSpeed", "Maximum Speed");
propertyToLabelMap.put("motors.feedbacks.creationTime", "Creation Time");
propertyToLabelMap.put("motors.feedbacks.classification", "Classification");
propertyToLabelMap.put("motors.feedbacks.comment", "Comment");
ConfigRegistry configRegistry = new ConfigRegistry();
BodyLayerStack bodyLayerStack = new BodyLayerStack(CarService.getInput(), CarService.PROPERTY_NAMES);
// create the column header layer stack
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(CarService.PROPERTY_NAMES, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DataLayer(columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, bodyLayerStack, bodyLayerStack.getSelectionLayer());
// add the SortHeaderLayer to the column header layer stack
final SortHeaderLayer<HierarchicalWrapper> sortHeaderLayer = new SortHeaderLayer<>(columnHeaderLayer, new HierarchicalWrapperSortModel(bodyLayerStack.getSortedList(), bodyLayerStack.getColumnPropertyAccessor(), bodyLayerStack.getTreeLayer().getLevelIndexMapping(), columnHeaderDataLayer, configRegistry), false);
// add the filter row functionality
final FilterRowHeaderComposite<HierarchicalWrapper> filterRowHeaderLayer = new FilterRowHeaderComposite<>(new DefaultGlazedListsFilterStrategy<>(bodyLayerStack.getFilterList(), bodyLayerStack.getColumnPropertyAccessor(), configRegistry), sortHeaderLayer, columnHeaderDataLayer.getDataProvider(), configRegistry);
filterRowHeaderLayer.addConfigLabelAccumulatorForRegion(GridRegion.FILTER_ROW, new IConfigLabelAccumulator() {
@Override
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
int columnIndex = filterRowHeaderLayer.getColumnIndexByPosition(columnPosition);
// header column
if (columnIndex < 0) {
configLabels.addLabelOnTop(HierarchicalTreeLayer.LEVEL_HEADER_CELL);
}
}
});
// create the composite layer composed with the prior created layer
// stacks
CompositeLayer compositeLayer = new CompositeLayer(1, 2);
compositeLayer.setChildLayer(GridRegion.COLUMN_HEADER, filterRowHeaderLayer, 0, 0);
compositeLayer.setChildLayer(GridRegion.BODY, bodyLayerStack, 0, 1);
compositeLayer.addConfiguration(new DefaultGridLayerConfiguration(compositeLayer) {
@Override
protected void addAlternateRowColoringConfig(CompositeLayer gridLayer) {
// do nothing to avoid the default grid alternate row coloring
// needed because the alternate row coloring in the hierarchical
// tree
// is based on the spanned cells and not per individual row
// position
}
});
NatTable natTable = new NatTable(container, compositeLayer, false);
natTable.setConfigRegistry(configRegistry);
natTable.addConfiguration(new DefaultNatTableStyleConfiguration() {
{
this.vAlign = VerticalAlignmentEnum.TOP;
this.hAlign = HorizontalAlignmentEnum.LEFT;
this.cellPainter = new PaddingDecorator(new TextPainter(), 2);
}
});
// add editing configuration
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
// make identifier editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 2);
// make capacity unit editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new ComboBoxCellEditor("KW", "PS"), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new PaddingDecorator(new ComboBoxPainter(), 2), DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 4);
// make comment editable
configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, EditableRule.ALWAYS_EDITABLE, DisplayMode.NORMAL, ColumnLabelAccumulator.COLUMN_LABEL_PREFIX + 8);
}
});
// adds the key bindings that allows pressing space bar to
// expand/collapse tree nodes
natTable.addConfiguration(new TreeLayerExpandCollapseKeyBindings(bodyLayerStack.getTreeLayer(), bodyLayerStack.getSelectionLayer()));
// add sorting configuration
natTable.addConfiguration(new SingleClickSortConfiguration());
// add some additional filter configuration
natTable.addConfiguration(new AbstractRegistryConfiguration() {
@Override
public void configureRegistry(IConfigRegistry configRegistry) {
Style style = new Style();
style.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, GUIHelper.getColor(173, 216, 230));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, GridRegion.FILTER_ROW);
}
});
natTable.configure();
GridDataFactory.fillDefaults().grab(true, true).applyTo(natTable);
Composite buttonPanel = new Composite(container, SWT.NONE);
buttonPanel.setLayout(new RowLayout());
GridDataFactory.fillDefaults().grab(true, false).applyTo(buttonPanel);
Button collapseAllButton = new Button(buttonPanel, SWT.PUSH);
collapseAllButton.setText("Collapse All");
collapseAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeCollapseAllCommand());
}
});
Button expandAllButton = new Button(buttonPanel, SWT.PUSH);
expandAllButton.setText("Expand All");
expandAllButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeExpandAllCommand());
}
});
Button expandAllFirstLevelButton = new Button(buttonPanel, SWT.PUSH);
expandAllFirstLevelButton.setText("Expand All First Level");
expandAllFirstLevelButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
natTable.doCommand(new TreeExpandToLevelCommand(0));
}
});
Button toggleExpandButton = new Button(buttonPanel, SWT.PUSH);
toggleExpandButton.setText("Enable Advanced Expand");
toggleExpandButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled = !_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled;
if (_6045_HierarchicalTreeLayerExample.this.advancedExpandEnabled) {
toggleExpandButton.setText("Disable Advanced Expand");
// configure advanced action
natTable.getUiBindingRegistry().registerFirstSingleClickBinding(_6045_HierarchicalTreeLayerExample.this.treeImagePainterMouseEventMatcher, _6045_HierarchicalTreeLayerExample.this.advancedTreeExpandCollapseAction);
} else {
toggleExpandButton.setText("Enable Advanced Expand");
// configure simple action
natTable.getUiBindingRegistry().registerFirstSingleClickBinding(_6045_HierarchicalTreeLayerExample.this.treeImagePainterMouseEventMatcher, _6045_HierarchicalTreeLayerExample.this.simpleTreeExpandCollapseAction);
}
}
});
Button multiReorderButton = new Button(buttonPanel, SWT.PUSH);
multiReorderButton.setText("Reorder Second Level");
multiReorderButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
List<Integer> fromColumnPositions = Arrays.asList(4, 5);
natTable.doCommand(new MultiColumnReorderCommand(natTable, fromColumnPositions, 8));
}
});
Button deleteButton = new Button(buttonPanel, SWT.PUSH);
deleteButton.setText("Delete Row 4");
deleteButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// remove the element
HierarchicalWrapper rowObject = bodyLayerStack.getFilterList().remove(3);
// fire the event to refresh
bodyLayerStack.getBodyDataLayer().fireLayerEvent(new RowDeleteEvent(bodyLayerStack.getBodyDataLayer(), 3));
bodyLayerStack.getTreeLayer().cleanupRetainedCollapsedNodes(rowObject);
}
});
return container;
}
use of org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator in project nebula.widgets.nattable by eclipse.
the class NatTableCSSHandler method retrieveCSSProperty.
@Override
public String retrieveCSSProperty(Object control, String property, String pseudo, CSSEngine engine) throws Exception {
NatTable natTable = null;
String label = null;
String displayMode = NatTableCSSHelper.getDisplayMode(pseudo);
if (control instanceof NatTable) {
natTable = (NatTable) control;
} else if (control instanceof NatTableWrapper) {
natTable = ((NatTableWrapper) control).getNatTable();
label = ((NatTableWrapper) control).getLabel();
}
if (natTable != null) {
// check property
if (NatTableCSSConstants.BACKGROUND_COLOR.equalsIgnoreCase(property)) {
return CSSPropertyBackgroundSWTHandler.INSTANCE.retrieveCSSPropertyBackgroundColor(control, pseudo, engine);
} else if (NatTableCSSConstants.BACKGROUND_IMAGE.equalsIgnoreCase(property)) {
return CSSPropertyBackgroundSWTHandler.INSTANCE.retrieveCSSPropertyBackgroundImage(control, pseudo, engine);
} else if (NatTableCSSConstants.CELL_BACKGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BACKGROUND_COLOR, displayMode, label), engine, null);
} else if (NatTableCSSConstants.CELL_BACKGROUND_IMAGE.equalsIgnoreCase(property)) {
// TODO : manage path of Image.
return "none";
} else if (NatTableCSSConstants.FOREGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FOREGROUND_COLOR, displayMode, label), engine, null);
} else if (NatTableCSSConstants.HORIZONTAL_ALIGNMENT.equalsIgnoreCase(property)) {
HorizontalAlignmentEnum align = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.HORIZONTAL_ALIGNMENT, displayMode, label);
switch(align) {
case CENTER:
return "center";
case LEFT:
return "left";
case RIGHT:
return "right";
}
} else if (NatTableCSSConstants.VERTICAL_ALIGNMENT.equalsIgnoreCase(property)) {
VerticalAlignmentEnum align = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.VERTICAL_ALIGNMENT, displayMode, label);
switch(align) {
case TOP:
return "top";
case MIDDLE:
return "middle";
case BOTTOM:
return "bottom";
}
} else if (NatTableCSSConstants.FONT.equalsIgnoreCase(property)) {
Font font = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FONT, displayMode, label);
return CSSSWTFontHelper.getFontComposite(font);
} else if (NatTableCSSConstants.FONT_FAMILY.equalsIgnoreCase(property)) {
Font font = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FONT, displayMode, label);
return CSSSWTFontHelper.getFontFamily(font);
} else if (NatTableCSSConstants.FONT_SIZE.equalsIgnoreCase(property)) {
Font font = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FONT, displayMode, label);
return CSSSWTFontHelper.getFontSize(font);
} else if (NatTableCSSConstants.FONT_STYLE.equalsIgnoreCase(property)) {
Font font = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FONT, displayMode, label);
return CSSSWTFontHelper.getFontStyle(font);
} else if (NatTableCSSConstants.FONT_WEIGHT.equalsIgnoreCase(property)) {
Font font = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.FONT, displayMode, label);
return CSSSWTFontHelper.getFontWeight(font);
} else if (NatTableCSSConstants.IMAGE.equalsIgnoreCase(property)) {
// TODO : manage path of Image.
return "none";
} else if (NatTableCSSConstants.BORDER.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BORDER_STYLE, displayMode, label);
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return border.getThickness() + " " + border.getLineStyle().toString().toLowerCase() + " " + border.getBorderMode().toString().toLowerCase() + " " + cssValueConverter.convert(border.getColor(), engine, null);
} else if (NatTableCSSConstants.BORDER_COLOR.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BORDER_STYLE, displayMode, label);
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(border.getColor(), engine, null);
} else if (NatTableCSSConstants.BORDER_STYLE.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BORDER_STYLE, displayMode, label);
return border.getLineStyle().toString().toLowerCase();
} else if (NatTableCSSConstants.BORDER_WIDTH.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BORDER_STYLE, displayMode, label);
return "" + border.getThickness();
} else if (NatTableCSSConstants.BORDER_MODE.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.BORDER_STYLE, displayMode, label);
return "" + border.getBorderMode();
} else if (NatTableCSSConstants.PASSWORD_ECHO_CHAR.equalsIgnoreCase(property)) {
return "" + NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.PASSWORD_ECHO_CHAR, displayMode, label);
} else if (NatTableCSSConstants.TEXT_DECORATION.equalsIgnoreCase(property)) {
TextDecorationEnum decoration = NatTableCSSHelper.getNatTableStyle(natTable, CellStyleAttributes.TEXT_DECORATION, displayMode, label);
switch(decoration) {
case NONE:
return "none";
case STRIKETHROUGH:
return "line-through";
case UNDERLINE:
return "underline";
case UNDERLINE_STRIKETHROUGH:
return "underline line-through";
}
} else if (NatTableCSSConstants.FREEZE_SEPARATOR_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(natTable.getConfigRegistry().getConfigAttribute(IFreezeConfigAttributes.SEPARATOR_COLOR, displayMode, label), engine, null);
} else if (NatTableCSSConstants.GRID_LINE_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.GRID_LINE_COLOR, displayMode, label), engine, null);
} else if (NatTableCSSConstants.GRID_LINE_WIDTH.equalsIgnoreCase(property)) {
Integer width = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.GRID_LINE_WIDTH, displayMode, label);
if (width == null) {
return "0";
} else {
return width.toString();
}
} else if (NatTableCSSConstants.RENDER_GRID_LINES.equalsIgnoreCase(property)) {
Boolean render = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.RENDER_GRID_LINES, displayMode, label);
if (render == null) {
return Boolean.TRUE.toString();
} else {
return render.toString();
}
} else if (NatTableCSSConstants.CONVERSION_ERROR_FONT.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontComposite(font);
} else if (NatTableCSSConstants.CONVERSION_ERROR_FONT_FAMILY.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontFamily(font);
} else if (NatTableCSSConstants.CONVERSION_ERROR_FONT_SIZE.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontSize(font);
} else if (NatTableCSSConstants.CONVERSION_ERROR_FONT_STYLE.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontStyle(font);
} else if (NatTableCSSConstants.CONVERSION_ERROR_FONT_WEIGHT.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontWeight(font);
} else if (NatTableCSSConstants.CONVERSION_ERROR_BACKGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
return cssValueConverter.convert(style.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR), engine, null);
} else if (NatTableCSSConstants.CONVERSION_ERROR_FOREGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.CONVERSION_ERROR_STYLE, displayMode, label);
return cssValueConverter.convert(style.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR), engine, null);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FONT.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontComposite(font);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FONT_FAMILY.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontFamily(font);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FONT_SIZE.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontSize(font);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FONT_STYLE.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontStyle(font);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FONT_WEIGHT.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
Font font = style.getAttributeValue(CellStyleAttributes.FONT);
return CSSSWTFontHelper.getFontWeight(font);
} else if (NatTableCSSConstants.VALIDATION_ERROR_BACKGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
return cssValueConverter.convert(style.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR), engine, null);
} else if (NatTableCSSConstants.VALIDATION_ERROR_FOREGROUND_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
IStyle style = natTable.getConfigRegistry().getConfigAttribute(EditConfigAttributes.VALIDATION_ERROR_STYLE, displayMode, label);
return cssValueConverter.convert(style.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR), engine, null);
} else if (NatTableCSSConstants.WORD_WRAP.equalsIgnoreCase(property)) {
Boolean wrap = Boolean.FALSE;
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
}
}
if (painter instanceof AbstractTextPainter) {
wrap = ((AbstractTextPainter) painter).isWordWrapping();
}
return wrap.toString();
} else if (NatTableCSSConstants.TEXT_WRAP.equalsIgnoreCase(property)) {
Boolean wrap = Boolean.FALSE;
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
}
}
if (painter instanceof AbstractTextPainter) {
wrap = ((AbstractTextPainter) painter).isWrapText();
}
return wrap.toString();
} else if (NatTableCSSConstants.TEXT_TRIM.equalsIgnoreCase(property)) {
Boolean trim = Boolean.FALSE;
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
}
}
if (painter instanceof AbstractTextPainter) {
trim = ((AbstractTextPainter) painter).isTrimText();
}
return trim.toString();
} else if (NatTableCSSConstants.LINE_SPACING.equalsIgnoreCase(property)) {
int spacing = 0;
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
}
}
if (painter instanceof AbstractTextPainter) {
spacing = ((AbstractTextPainter) painter).getLineSpacing();
}
return "" + spacing;
} else if (NatTableCSSConstants.TEXT_DIRECTION.equalsIgnoreCase(property)) {
String direction = "horizontal";
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
}
}
if (painter instanceof VerticalTextPainter) {
direction = "vertical";
}
return direction;
} else if (NatTableCSSConstants.COLUMN_WIDTH.equalsIgnoreCase(property)) {
// inherit is not supported here
return "default";
} else if (NatTableCSSConstants.ROW_HEIGHT.equalsIgnoreCase(property)) {
// inherit is not supported here
return "default";
} else if (NatTableCSSConstants.PADDING.equalsIgnoreCase(property)) {
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
if (painter instanceof PaddingDecorator) {
PaddingDecorator decorator = (PaddingDecorator) painter;
return new StringBuilder().append(decorator.getTopPadding()).append(" ").append(decorator.getRightPadding()).append(" ").append(decorator.getBottomPadding()).append(" ").append(decorator.getLeftPadding()).toString();
}
}
}
} else if (NatTableCSSConstants.PADDING_TOP.equalsIgnoreCase(property)) {
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
if (painter instanceof PaddingDecorator) {
return "" + ((PaddingDecorator) painter).getTopPadding();
}
}
}
return "0";
} else if (NatTableCSSConstants.PADDING_RIGHT.equalsIgnoreCase(property)) {
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
if (painter instanceof PaddingDecorator) {
return "" + ((PaddingDecorator) painter).getRightPadding();
}
}
}
return "0";
} else if (NatTableCSSConstants.PADDING_BOTTOM.equalsIgnoreCase(property)) {
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
if (painter instanceof PaddingDecorator) {
return "" + ((PaddingDecorator) painter).getBottomPadding();
}
}
}
return "0";
} else if (NatTableCSSConstants.PADDING_LEFT.equalsIgnoreCase(property)) {
ICellPainter painter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_PAINTER, displayMode, label);
if (painter != null) {
while (painter instanceof CellPainterWrapper) {
painter = ((CellPainterWrapper) painter).getWrappedPainter();
if (painter instanceof PaddingDecorator) {
return "" + ((PaddingDecorator) painter).getLeftPadding();
}
}
}
return "0";
} else if (NatTableCSSConstants.TABLE_BORDER_COLOR.equalsIgnoreCase(property)) {
for (Iterator<IOverlayPainter> it = natTable.getOverlayPainters().iterator(); it.hasNext(); ) {
IOverlayPainter painter = it.next();
if (painter instanceof NatTableBorderOverlayPainter) {
return engine.getCSSValueConverter(String.class).convert(((NatTableBorderOverlayPainter) painter).getBorderColor(), engine, null);
}
}
} else if (NatTableCSSConstants.FILL_HANDLE_BORDER.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, FillHandleConfigAttributes.FILL_HANDLE_BORDER_STYLE, displayMode, label);
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return border.getThickness() + " " + border.getLineStyle().toString().toLowerCase() + " " + border.getBorderMode().toString().toLowerCase() + " " + cssValueConverter.convert(border.getColor(), engine, null);
} else if (NatTableCSSConstants.FILL_HANDLE_COLOR.equalsIgnoreCase(property)) {
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(natTable.getConfigRegistry().getConfigAttribute(FillHandleConfigAttributes.FILL_HANDLE_COLOR, displayMode, label), engine, null);
} else if (NatTableCSSConstants.FILL_REGION_BORDER.equalsIgnoreCase(property)) {
BorderStyle border = NatTableCSSHelper.getNatTableStyle(natTable, FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE, displayMode, label);
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return border.getThickness() + " " + border.getLineStyle().toString().toLowerCase() + " " + border.getBorderMode().toString().toLowerCase() + " " + cssValueConverter.convert(border.getColor(), engine, null);
} else if (NatTableCSSConstants.INVERT_ICONS.equalsIgnoreCase(property)) {
// not able to determine it easily here
return Boolean.FALSE.toString();
} else if (NatTableCSSConstants.DECORATION.equalsIgnoreCase(property)) {
// TODO : manage path of Image.
return "none";
} else if (NatTableCSSConstants.PERCENTAGE_DECORATOR_COLORS.equalsIgnoreCase(property)) {
IStyle style = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.CELL_STYLE, displayMode, label);
Color c1 = style.getAttributeValue(PercentageBarDecorator.PERCENTAGE_BAR_COMPLETE_REGION_START_COLOR);
Color c2 = style.getAttributeValue(PercentageBarDecorator.PERCENTAGE_BAR_COMPLETE_REGION_END_COLOR);
Color c3 = style.getAttributeValue(PercentageBarDecorator.PERCENTAGE_BAR_INCOMPLETE_REGION_COLOR);
ICSSValueConverter cssValueConverter = engine.getCSSValueConverter(String.class);
return cssValueConverter.convert(c1, engine, null) + " " + cssValueConverter.convert(c2, engine, null) + " " + cssValueConverter.convert(c3, engine, null);
} else if (NatTableCSSConstants.CONVERTER.equalsIgnoreCase(property)) {
IDisplayConverter converter = natTable.getConfigRegistry().getConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, displayMode, label);
return NatTableCSSHelper.getDisplayConverterString(converter);
}
}
return null;
}
Aggregations