diff options
| author | Dirk Fauth | 2023-01-09 09:53:40 +0000 |
|---|---|---|
| committer | Dirk Fauth | 2023-01-09 09:53:40 +0000 |
| commit | 5f483a5408a00f74f8409687cd52bf4b82f914dc (patch) | |
| tree | 41e78c2144b35d01d7526940f1dbc520be823615 | |
| parent | ca3b345bb62c68ac60dced75378f6411013d4ad5 (diff) | |
| download | org.eclipse.nebula.widgets.nattable-5f483a5408a00f74f8409687cd52bf4b82f914dc.tar.gz org.eclipse.nebula.widgets.nattable-5f483a5408a00f74f8409687cd52bf4b82f914dc.tar.xz org.eclipse.nebula.widgets.nattable-5f483a5408a00f74f8409687cd52bf4b82f914dc.zip | |
Bug 581303 - [FilterRowTextCellEditor] - rendering glitch in scrolled
state
Signed-off-by: Dirk Fauth <dirk.fauth@googlemail.com>
Change-Id: I8854dc29a9586544ad3afc2de409036aec1855af
| -rw-r--r-- | org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowTextCellEditor.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowTextCellEditor.java b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowTextCellEditor.java index 55ae8bd0..0cdf85a5 100644 --- a/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowTextCellEditor.java +++ b/org.eclipse.nebula.widgets.nattable.core/src/org/eclipse/nebula/widgets/nattable/filterrow/FilterRowTextCellEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2014, 2020 Dirk Fauth and others. + * Copyright (c) 2014, 2023 Dirk Fauth and others. * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 @@ -18,9 +18,13 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor; +import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum; import org.eclipse.swt.events.KeyAdapter; import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Text; @@ -49,7 +53,43 @@ public class FilterRowTextCellEditor extends TextCellEditor { } }); - text.addDisposeListener(e -> service.shutdownNow()); + PaintListener paintListener = new PaintListener() { + + @Override + public void paintControl(PaintEvent e) { + if (getEditorControl() != null && !getEditorControl().isDisposed()) { + + // we need to retrieve the cell again to get the updated + // cell bounds in case the scrollbar becomes invisible + // because of filtering + ILayerCell cell = FilterRowTextCellEditor.this.layerCell.getLayer().getCellByPosition( + FilterRowTextCellEditor.this.layerCell.getColumnPosition(), + FilterRowTextCellEditor.this.layerCell.getRowPosition()); + + Rectangle cellBounds = cell.getBounds(); + Rectangle editorBounds = cell.getLayer().getLayerPainter().adjustCellBounds( + cell.getColumnPosition(), + cell.getRowPosition(), + new Rectangle(cellBounds.x, cellBounds.y, cellBounds.width, cellBounds.height)); + + editorBounds = calculateControlBounds(editorBounds); + + if (editorBounds.x == 0) { + editorBounds.x += 1; + editorBounds.width -= 1; + } + + getEditorControl().setBounds(editorBounds); + } + + } + }; + parent.addPaintListener(paintListener); + + text.addDisposeListener(e -> { + service.shutdownNow(); + parent.removePaintListener(paintListener); + }); return text; } |
