X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Ftables%2Fmi%2FRowHighlighter.java;h=03cb37cc4ba7e0762d1d8322f3fdccddabc62277;hb=0eb525202d3c871a2a20f789af1728248f3cff11;hp=17b2cd22dd93a239ebe258587b7d34ba7d5fe6aa;hpb=a4ef021616f9bf3b6a7778c7b5b6a22d5a7d1c20;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/RowHighlighter.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/RowHighlighter.java index 17b2cd22..03cb37cc 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/RowHighlighter.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/RowHighlighter.java @@ -1,19 +1,18 @@ package net.mograsim.plugin.tables.mi; import java.util.Optional; -import java.util.concurrent.atomic.AtomicBoolean; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Table; import net.mograsim.plugin.tables.LazyTableViewer; +import net.mograsim.plugin.util.SingleSWTRequest; public class RowHighlighter { - private int highlighted = -1, toHighlight; + private int highlighted = -1; private LazyTableViewer viewer; - private AtomicBoolean waiting = new AtomicBoolean(); private ColorProvider cProv; + private SingleSWTRequest requester = new SingleSWTRequest(); public RowHighlighter(LazyTableViewer viewer, ColorProvider cProv) { @@ -23,23 +22,11 @@ public class RowHighlighter public void highlight(int row) { - synchronized (waiting) + requester.request(() -> { - toHighlight = row; - if (!waiting.get()) - { - waiting.set(true); - Display.getDefault().asyncExec(() -> - { - synchronized (waiting) - { - waiting.set(false); - if (!viewer.getTable().isDisposed()) - innerHighlight(toHighlight); - } - }); - } - } + if (!viewer.getTable().isDisposed()) + innerHighlight(row); + }); } private void innerHighlight(int row) @@ -50,10 +37,10 @@ public class RowHighlighter { table.showItem(table.getItem(Math.min(table.getItemCount(), row + 2))); table.showItem(table.getItem(row)); - Optional.of(table.getItem(row).getData()).ifPresent(d -> viewer.update(d, null)); + Optional.ofNullable(table.getItem(row).getData()).ifPresent(d -> viewer.update(d, null)); } if (highlighted != -1) - Optional.of(table.getItem(highlighted).getData()).ifPresent(d -> viewer.update(d, null)); + Optional.ofNullable(table.getItem(highlighted).getData()).ifPresent(d -> viewer.update(d, null)); highlighted = row; } }