Search in sources :

Example 6 with RowResizeCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand in project nebula.widgets.nattable by eclipse.

the class VerticalTextPainter method setNewMinLength.

@Override
protected void setNewMinLength(ILayerCell cell, int contentHeight) {
    int cellLength = cell.getBounds().height;
    if (cellLength < contentHeight) {
        ILayer layer = cell.getLayer();
        layer.doCommand(new RowResizeCommand(layer, cell.getRowPosition(), contentHeight, true));
    }
}
Also used : ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)

Example 7 with RowResizeCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand in project nebula.widgets.nattable by eclipse.

the class RichTextCellPainter method paintCell.

@Override
public void paintCell(ILayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
    IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
    setupGCFromConfig(gc, cellStyle);
    String htmlText = CellDisplayConversionUtils.convertDataType(cell, configRegistry);
    Rectangle painterBounds = new Rectangle(bounds.x, bounds.y - this.richTextPainter.getParagraphSpace(), bounds.width, bounds.height);
    this.richTextPainter.paintHTML(htmlText, gc, painterBounds);
    int height = this.richTextPainter.getPreferredSize().y - 2 * this.richTextPainter.getParagraphSpace();
    if (performRowResize(height, painterBounds)) {
        cell.getLayer().doCommand(new RowResizeCommand(cell.getLayer(), cell.getRowPosition(), GUIHelper.convertVerticalDpiToPixel(height) + (cell.getBounds().height - bounds.height)));
    }
    if (performColumnResize(this.richTextPainter.getPreferredSize().x, painterBounds)) {
        cell.getLayer().doCommand(new ColumnResizeCommand(cell.getLayer(), cell.getColumnPosition(), GUIHelper.convertHorizontalDpiToPixel(this.richTextPainter.getPreferredSize().x) + (cell.getBounds().width - bounds.width)));
    }
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) Rectangle(org.eclipse.swt.graphics.Rectangle) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)

Example 8 with RowResizeCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand in project nebula.widgets.nattable by eclipse.

the class SummaryRowIntegrationTest method getRowHeightByPositionForSummaryRow.

@Test
public void getRowHeightByPositionForSummaryRow() throws Exception {
    this.natTable.doCommand(new RowResizeCommand(this.natTable, 4, 100));
    assertEquals(100, this.natTable.getRowHeightByPosition(4));
}
Also used : RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand) Test(org.junit.Test)

Example 9 with RowResizeCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand in project nebula.widgets.nattable by eclipse.

the class TableCellPainter method paintCell.

@Override
public void paintCell(ILayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
    if (this.paintBg) {
        super.paintCell(cell, gc, bounds, configRegistry);
    }
    Object[] cellDataArray = getDataAsArray(cell);
    if (cellDataArray != null) {
        // iterate over all values in the collection and render them
        // separately by creating temporary sub cells
        // and adding grid lines for the sub cells
        int subGridY = bounds.y;
        if (cellDataArray != null) {
            Color originalColor = gc.getForeground();
            for (int i = 0; i < cellDataArray.length; i++) {
                ILayerCell subCell = createSubLayerCell(cell, cellDataArray[i]);
                int subCellHeight = getSubCellHeight(subCell, gc, configRegistry);
                Rectangle subCellBounds = new Rectangle(bounds.x, subGridY, bounds.width, subCellHeight);
                this.getInternalPainter().paintCell(subCell, gc, subCellBounds, configRegistry);
                // render sub grid line
                // update subGridY for calculated height
                subGridY += subCellHeight + 1;
                gc.setForeground(cell.getDisplayMode().equals(DisplayMode.SELECT) ? getSelectedGridColor() : getGridColor());
                gc.drawLine(bounds.x, subGridY, bounds.x + bounds.width, subGridY);
                gc.setForeground(originalColor);
                // increase subGridY by 1 so the next sub cell renders below
                subGridY += 1;
            }
            // perform resize if necessary
            int neededHeight = subGridY - bounds.y;
            if (isCalculateParentCellHeight() && (neededHeight > cell.getBounds().height)) {
                ILayer layer = cell.getLayer();
                layer.doCommand(new RowResizeCommand(layer, cell.getRowPosition(), neededHeight, true));
            }
        }
    } else {
        this.getInternalPainter().paintCell(cell, gc, bounds, configRegistry);
    }
}
Also used : ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)

Example 10 with RowResizeCommand

use of org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand in project nebula.widgets.nattable by eclipse.

the class VerticalTextImagePainter method setNewMinLength.

@Override
protected void setNewMinLength(ILayerCell cell, int contentHeight) {
    int cellLength = cell.getBounds().height;
    if (cellLength < contentHeight) {
        ILayer layer = cell.getLayer();
        layer.doCommand(new RowResizeCommand(layer, cell.getRowPosition(), contentHeight, true));
    }
}
Also used : ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)

Aggregations

RowResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)11 Rectangle (org.eclipse.swt.graphics.Rectangle)6 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)5 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)3 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)3 Test (org.junit.Test)3 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)2 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)2 Shell (org.eclipse.swt.widgets.Shell)2 ColumnHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.ColumnHideCommand)1 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)1 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)1 RowReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.RowReorderCommand)1 Color (org.eclipse.swt.graphics.Color)1 Image (org.eclipse.swt.graphics.Image)1 Point (org.eclipse.swt.graphics.Point)1