1 package net.mograsim.plugin.tables.mi;
3 import java.util.Optional;
4 import java.util.concurrent.atomic.AtomicBoolean;
6 import org.eclipse.swt.widgets.Display;
7 import org.eclipse.swt.widgets.Table;
9 import net.mograsim.plugin.tables.LazyTableViewer;
11 public class RowHighlighter
13 private int highlighted = -1, toHighlight;
14 private LazyTableViewer viewer;
15 private AtomicBoolean waiting = new AtomicBoolean();
16 private ColorProvider cProv;
18 public RowHighlighter(LazyTableViewer viewer, ColorProvider cProv)
24 public void highlight(int row)
26 synchronized (waiting)
32 Display.getDefault().asyncExec(() ->
34 synchronized (waiting)
37 if (!viewer.getTable().isDisposed())
38 innerHighlight(toHighlight);
45 private void innerHighlight(int row)
47 Table table = viewer.getTable();
51 table.showItem(table.getItem(Math.min(table.getItemCount(), row + 2)));
52 table.showItem(table.getItem(row));
53 Optional.of(table.getItem(row).getData()).ifPresent(d -> viewer.update(d, null));
55 if (highlighted != -1)
56 Optional.of(table.getItem(highlighted).getData()).ifPresent(d -> viewer.update(d, null));