use of org.uberfire.ext.wires.core.grids.client.widget.context.GridHeaderColumnRenderContext in project kie-wb-common by kiegroup.
the class RendererUtilsTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
text = spy(new Text(""));
headerContext = new GridHeaderColumnRenderContext(0, Collections.singletonList(uiColumn), Collections.singletonList(uiColumn), 0, uiModel, gridRenderer);
bodyContext = new GridBodyCellRenderContext(0, 0, BLOCK_WIDTH, ROW_HEIGHT, 0, 0, 0, 0, false, transform, gridRenderer);
when(cellContext.getRenderer()).thenReturn(gridRenderer);
when(gridRenderer.getTheme()).thenReturn(gridTheme);
when(gridTheme.getBodyText()).thenReturn(text);
when(cellContext.getCellWidth()).thenReturn(WIDTH);
when(cellContext.getCellHeight()).thenReturn(HEIGHT);
when(gridTheme.getHeaderText()).thenReturn(headerText1, headerText2);
when(gridTheme.getPlaceholderText()).thenReturn(placeHolderText);
when(headerText1.asNode()).thenReturn(mock(Node.class));
when(headerText2.asNode()).thenReturn(mock(Node.class));
when(placeHolderText.asNode()).thenReturn(mock(Node.class));
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridHeaderColumnRenderContext in project kie-wb-common by kiegroup.
the class BaseNameAndDataTypeColumnRendererTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.renderer = getColumnRenderer();
this.headerContext = new GridHeaderColumnRenderContext(0, Collections.singletonList(uiColumn), Collections.singletonList(uiColumn), 0, uiModel, gridRenderer);
this.bodyContext = new GridBodyCellRenderContext(0, 0, BLOCK_WIDTH, ROW_HEIGHT, 0, 0, 0, 0, false, transform, gridRenderer);
when(gridRenderer.getTheme()).thenReturn(gridRendererTheme);
when(gridRendererTheme.getHeaderText()).thenReturn(text1, text2);
when(gridRendererTheme.getBodyText()).thenReturn(text1);
when(gridRendererTheme.getPlaceholderText()).thenReturn(text1);
when(text1.asNode()).thenReturn(mock(Node.class));
when(text2.asNode()).thenReturn(mock(Node.class));
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridHeaderColumnRenderContext in project appformer by kiegroup.
the class BaseGridColumnRenderer method renderHeader.
@Override
@SuppressWarnings("unchecked")
public List<GridRenderer.RendererCommand> renderHeader(final List<GridColumn.HeaderMetaData> headerMetaData, final GridHeaderColumnRenderContext context, final BaseGridRendererHelper.RenderingInformation renderingInformation, final BiFunction<Boolean, GridColumn<?>, Boolean> columnRenderingConstraint) {
final GridData model = context.getModel();
final GridRenderer renderer = context.getRenderer();
final GridRendererTheme theme = renderer.getTheme();
final double x = context.getX();
final double headerRowsHeight = renderingInformation.getHeaderRowsHeight();
final double headerRowsYOffset = renderingInformation.getHeaderRowsYOffset();
final double rowHeight = headerRowsHeight / headerMetaData.size();
final List<GridColumn<?>> allBlockColumns = context.getAllColumns();
final List<GridColumn<?>> visibleBlockColumns = context.getBlockColumns();
final int headerStartColumnIndex = allBlockColumns.indexOf(visibleBlockColumns.get(0));
final int headerColumnIndex = allBlockColumns.indexOf(visibleBlockColumns.get(context.getColumnIndex()));
final GridColumn<?> column = visibleBlockColumns.get(context.getColumnIndex());
final List<GridRenderer.RendererCommand> commands = new ArrayList<>();
// Grid lines
commands.add((GridRenderer.RenderHeaderGridLinesCommand) (rc) -> {
if (!rc.isSelectionLayer()) {
final Group g = new Group().setX(x);
final MultiPath headerGrid = theme.getHeaderGridLine().setY(headerRowsYOffset);
for (int headerRowIndex = 0; headerRowIndex < headerMetaData.size(); headerRowIndex++) {
final int blockStartColumnIndex = ColumnIndexUtilities.getHeaderBlockStartColumnIndex(allBlockColumns, headerMetaData.get(headerRowIndex), headerRowIndex, headerColumnIndex);
final int blockEndColumnIndex = ColumnIndexUtilities.getHeaderBlockEndColumnIndex(allBlockColumns, headerMetaData.get(headerRowIndex), headerRowIndex, headerColumnIndex);
if (headerColumnIndex < model.getColumnCount() - 1) {
if (blockEndColumnIndex == headerColumnIndex) {
final double hx = column.getWidth();
headerGrid.M(hx + 0.5, headerRowIndex * rowHeight).L(hx + 0.5, (headerRowIndex + 1) * rowHeight);
}
}
boolean skip;
if (blockStartColumnIndex >= headerStartColumnIndex) {
skip = headerColumnIndex > blockStartColumnIndex;
} else {
skip = headerColumnIndex > headerStartColumnIndex;
}
if (skip) {
continue;
}
final double offsetX = getBlockOffset(allBlockColumns, blockStartColumnIndex, headerColumnIndex);
final double blockWidth = getBlockWidth(allBlockColumns, blockStartColumnIndex, blockEndColumnIndex);
if (headerRowIndex > 0) {
headerGrid.M(offsetX, (headerRowIndex * rowHeight) + 0.5).L(offsetX + blockWidth, (headerRowIndex * rowHeight) + 0.5);
}
}
g.add(headerGrid);
rc.getGroup().add(g);
}
});
// Grid content
commands.add((GridRenderer.RenderHeaderContentCommand) (rc) -> {
if (!rc.isSelectionLayer()) {
final Group g = new Group().setX(x);
for (int headerRowIndex = 0; headerRowIndex < headerMetaData.size(); headerRowIndex++) {
final int blockStartColumnIndex = ColumnIndexUtilities.getHeaderBlockStartColumnIndex(allBlockColumns, headerMetaData.get(headerRowIndex), headerRowIndex, headerColumnIndex);
final int blockEndColumnIndex = ColumnIndexUtilities.getHeaderBlockEndColumnIndex(allBlockColumns, headerMetaData.get(headerRowIndex), headerRowIndex, headerColumnIndex);
boolean skip;
if (blockStartColumnIndex >= headerStartColumnIndex) {
skip = headerColumnIndex > blockStartColumnIndex;
} else {
skip = headerColumnIndex > headerStartColumnIndex;
}
if (skip) {
continue;
}
final double offsetX = getBlockOffset(allBlockColumns, blockStartColumnIndex, headerColumnIndex);
final double blockWidth = getBlockWidth(allBlockColumns, blockStartColumnIndex, blockEndColumnIndex);
final Group headerGroup = renderHeaderContent(headerMetaData, context, headerRowIndex, blockWidth, rowHeight);
final BoundingBox bb = new BoundingBox(0, 0, blockWidth, rowHeight);
final IPathClipper clipper = getBoundingBoxPathClipper(bb);
headerGroup.setX(offsetX);
headerGroup.setY(headerRowsYOffset + headerRowIndex * rowHeight);
headerGroup.setPathClipper(clipper);
clipper.setActive(true);
g.add(headerGroup);
}
rc.getGroup().add(g);
}
});
return commands;
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridHeaderColumnRenderContext in project appformer by kiegroup.
the class BaseGridRenderer method renderHeader.
@Override
public List<RendererCommand> renderHeader(final GridData model, final GridHeaderRenderContext context, final BaseGridRendererHelper rendererHelper, final BaseGridRendererHelper.RenderingInformation renderingInformation) {
final List<RendererCommand> commands = new ArrayList<>();
final int headerRowCount = renderingInformation.getHeaderRowCount();
if (headerRowCount == 0) {
return commands;
}
final List<GridColumn<?>> allBlockColumns = context.getAllColumns();
final List<GridColumn<?>> visibleBlockColumns = context.getBlockColumns();
final double headerRowsHeight = renderingInformation.getHeaderRowsHeight();
final double headerRowsYOffset = renderingInformation.getHeaderRowsYOffset();
// Column backgrounds
double cx = 0;
for (final GridColumn<?> column : visibleBlockColumns) {
if (column.isVisible()) {
final double x = cx;
final double w = column.getWidth();
Rectangle header;
if (column.isLinked()) {
header = theme.getHeaderLinkBackground(column);
} else {
header = theme.getHeaderBackground(column);
}
if (header != null) {
commands.add((RenderHeaderBackgroundCommand) (rc) -> {
if (columnRenderingConstraint.apply(rc.isSelectionLayer(), column)) {
header.setWidth(w).setListening(true).setHeight(headerRowsHeight).setY(headerRowsYOffset).setX(x);
rc.getGroup().add(header);
}
});
}
cx = cx + w;
}
}
// Column title and grid lines
cx = 0;
for (final GridColumn<?> column : visibleBlockColumns) {
if (column.isVisible()) {
final double columnWidth = column.getWidth();
final int columnIndex = visibleBlockColumns.indexOf(column);
final GridHeaderColumnRenderContext headerCellRenderContext = new GridHeaderColumnRenderContext(cx, allBlockColumns, visibleBlockColumns, columnIndex, model, this);
commands.addAll(column.getColumnRenderer().renderHeader(column.getHeaderMetaData(), headerCellRenderContext, renderingInformation, columnRenderingConstraint));
cx = cx + columnWidth;
}
}
// Linked column icons
cx = 0;
for (final GridColumn<?> column : visibleBlockColumns) {
if (column.isVisible()) {
final double x = cx;
final double w = column.getWidth();
if (column.isLinked()) {
commands.add((RenderHeaderContentCommand) (rc) -> {
if (columnRenderingConstraint.apply(rc.isSelectionLayer(), column)) {
final Text t = theme.getBodyText().setFontFamily(LINK_FONT_FAMILY).setFontSize(LINK_FONT_SIZE).setText(LINK_ICON).setY(headerRowsYOffset + LINK_FONT_SIZE).setX(x + w - LINK_FONT_SIZE);
rc.getGroup().add(t);
}
});
}
cx = cx + w;
}
}
// Divider between header and body
commands.add(renderHeaderBodyDivider(rendererHelper.getWidth(visibleBlockColumns)));
return commands;
}
Aggregations