From 6fe3b6eb2a7df349243d489bb258e22bc4e7b935 Mon Sep 17 00:00:00 2001 From: Matthew Khouzam Date: Fri, 4 Dec 2015 15:32:37 -0500 Subject: [PATCH] analysis: expose GetTableViewer in AbstractSegmentStoreTableView This allows for easier testing. Change-Id: I3ff2e08e2acd4887b25e805e080b74fc7509207a Signed-off-by: Matthew Khouzam Reviewed-on: https://git.eclipse.org/r/62032 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- .../views/latency/SystemCallLatencyView.java | 2 +- .../AbstractSegmentStoreTableView.java | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyView.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyView.java index 3720d196f3..c63b53e9dc 100644 --- a/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyView.java +++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.ui/src/org/eclipse/tracecompass/internal/analysis/os/linux/ui/views/latency/SystemCallLatencyView.java @@ -35,7 +35,7 @@ public class SystemCallLatencyView extends AbstractSegmentStoreTableView { // ------------------------------------------------------------------------ @Override - protected AbstractSegmentStoreTableViewer getSegmentStoreViewer(TableViewer tableViewer) { + protected AbstractSegmentStoreTableViewer createSegmentStoreViewer(TableViewer tableViewer) { return new SystemCallLatencyTableViewer(tableViewer); } } diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableView.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableView.java index 11c9faff4a..356c7b3b67 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableView.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableView.java @@ -32,7 +32,7 @@ public abstract class AbstractSegmentStoreTableView extends TmfView { // Attributes // ------------------------------------------------------------------------ - private @Nullable AbstractSegmentStoreTableViewer fTableViewer; + private @Nullable AbstractSegmentStoreTableViewer fSegmentStoreViewer; // ------------------------------------------------------------------------ // Constructor @@ -53,7 +53,7 @@ public abstract class AbstractSegmentStoreTableView extends TmfView { public void createPartControl(@Nullable Composite parent) { SashForm sf = new SashForm(parent, SWT.NONE); TableViewer tableViewer = new TableViewer(sf, SWT.FULL_SELECTION | SWT.VIRTUAL); - fTableViewer = getSegmentStoreViewer(tableViewer); + fSegmentStoreViewer = createSegmentStoreViewer(tableViewer); setInitialData(); } @@ -63,16 +63,16 @@ public abstract class AbstractSegmentStoreTableView extends TmfView { @Override public void setFocus() { - if (fTableViewer != null) { - fTableViewer.getTableViewer().getControl().setFocus(); + if (fSegmentStoreViewer != null) { + fSegmentStoreViewer.getTableViewer().getControl().setFocus(); } } @Override public void dispose() { super.dispose(); - if (fTableViewer != null) { - fTableViewer.dispose(); + if (fSegmentStoreViewer != null) { + fSegmentStoreViewer.dispose(); } } @@ -83,14 +83,24 @@ public abstract class AbstractSegmentStoreTableView extends TmfView { * the table viewer to use * @return the latency analysis table viewer instance */ - protected abstract AbstractSegmentStoreTableViewer getSegmentStoreViewer(TableViewer tableViewer); + protected abstract AbstractSegmentStoreTableViewer createSegmentStoreViewer(TableViewer tableViewer); + + /** + * Get the table viewer + * + * @return the table viewer, useful for testing + */ + @Nullable + public AbstractSegmentStoreTableViewer getSegmentStoreViewer() { + return fSegmentStoreViewer; + } /** * Set initial data into the viewer */ private void setInitialData() { - if (fTableViewer != null) { - fTableViewer.setData(fTableViewer.getAnalysisModule()); + if (fSegmentStoreViewer != null) { + fSegmentStoreViewer.setData(fSegmentStoreViewer.getAnalysisModule()); } } } -- 2.34.1