Use the parent LAMI tab page instance as the key for internal signaling.
The signal key is designed to restrict the signal to interested objects.
It was based on the hash of the immutable fResultTable field. Since for multiple
view of the same report the fResultTable is the same object, signals were
processed by objects that were not concerned. Using the result table
instance/hash as a key is not sufficient.
Bug: 495322
Change-Id: Ifba2056b10cd254d1a8c6c030c4b7263463ac834
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@efficios.com>
Reviewed-on: https://git.eclipse.org/r/86103
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
/**
public class LamiSelectionUpdateSignal extends TmfSignal {
private final Set<Integer> fEntryIndexes;
- /*
- * TODO: replace this with an object to equals. A signalHash can only
- * guaranty that objects are different, not that they are the same. Using
- * this is looking for trouble.
+
+ /**
+ * Use the {@link LamiReportViewTabPage LamiReportViewTabPage} object as the
+ * unique key for LAMI internal signaling. The {@link LamiReportViewTabPage}
+ * object is also the synchronization point for LAMI internal signaling.
*/
- private final int fSignalHash;
+ private final LamiReportViewTabPage fSignalKey;
/**
* Constructor for a new signal.
* The object sending this signal
* @param entryIndexList
* The list of selected indices
- * @param signalHash
- * The hash for exclusivity signaling
+ * @param signalKey
+ * The {@link LamiReportViewTabPage LamiReportViewTabPage} acting
+ * as a key for the signal.
*/
- public LamiSelectionUpdateSignal(Object source, Set<Integer> entryIndexList, int signalHash) {
+ public LamiSelectionUpdateSignal(Object source, Set<Integer> entryIndexList, LamiReportViewTabPage signalKey) {
super(source);
fEntryIndexes = new HashSet<>(entryIndexList);
- fSignalHash = signalHash;
+ fSignalKey = signalKey;
}
/**
- * Getter for the exclusivity hash
+ * Getter for the exclusivity key
*
* @return
- * The exclusivity hash
+ * The exclusivity key
*/
- public int getSignalHash() {
- return fSignalHash;
+ public LamiReportViewTabPage getSignalKey() {
+ return fSignalKey;
}
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel;
-import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
/**
* Common interface for all Lami viewers.
*
* @param parent
* The parent composite
- * @param resultTable
- * The result table to display
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @return The new viewer
*/
- static ILamiViewer createLamiTable(Composite parent, LamiResultTable resultTable) {
+ static ILamiViewer createLamiTable(Composite parent, LamiReportViewTabPage page) {
TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.VIRTUAL);
- return new LamiTableViewer(tableViewer, resultTable);
+ return new LamiTableViewer(tableViewer, page);
}
/**
*
* @param parent
* The parent composite
- * @param resultTable
- * The result table to use as a data source
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @param chartModel
* The information about the chart to display
* @return The new viewer
*/
- static ILamiViewer createLamiChart(Composite parent, LamiResultTable resultTable, LamiChartModel chartModel) {
+ static ILamiViewer createLamiChart(Composite parent, LamiReportViewTabPage page, LamiChartModel chartModel) {
switch (chartModel.getChartType()) {
case BAR_CHART:
- return new LamiBarChartViewer(parent, resultTable, chartModel);
+ return new LamiBarChartViewer(parent, page, chartModel);
case XY_SCATTER:
- return new LamiScatterViewer(parent, resultTable, chartModel);
+ return new LamiScatterViewer(parent, page, chartModel);
case PIE_CHART:
default:
throw new UnsupportedOperationException("Unsupported chart type: " + chartModel.toString()); //$NON-NLS-1$
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel.ChartType;
-import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.signals.LamiSelectionUpdateSignal;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.swtchart.IAxis;
import org.swtchart.IAxisTick;
*
* @param parent
* The parent composite to draw in.
- * @param resultTable
- * The result table containing the data from which to build the
- * chart
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @param chartModel
* The information about the chart to build
*/
- public LamiBarChartViewer(Composite parent, LamiResultTable resultTable, LamiChartModel chartModel) {
- super(parent, resultTable, chartModel);
+ public LamiBarChartViewer(Composite parent, LamiReportViewTabPage page, LamiChartModel chartModel) {
+ super(parent, page, chartModel);
List<LamiTableEntryAspect> xAxisAspects = getXAxisAspects();
List<LamiTableEntryAspect> yAxisAspects = getYAxisAspects();
setSelection(selections);
/* Signal all Lami viewers & views of the selection */
LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(this,
- selections, getResultTable().hashCode());
+ selections, getPage());
TmfSignalManager.dispatchSignal(signal);
redraw();
}
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel.ChartType;
-import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.format.LamiLabelFormat;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.format.LamiTimeStampFormat;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.signals.LamiSelectionUpdateSignal;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.swtchart.IAxisTick;
import org.swtchart.ILineSeries;
*
* @param parent
* parent
- * @param resultTable
- * Result table populating this chart
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @param graphModel
* Model of this chart
*/
- public LamiScatterViewer(Composite parent, LamiResultTable resultTable, LamiChartModel graphModel) {
- super(parent, resultTable, graphModel);
+ public LamiScatterViewer(Composite parent, LamiReportViewTabPage page, LamiChartModel graphModel) {
+ super(parent, page, graphModel);
if (getChartModel().getChartType() != ChartType.XY_SCATTER) {
throw new IllegalStateException("Chart type not a Scatter Chart " + getChartModel().getChartType().toString()); //$NON-NLS-1$
}
setSelection(selections);
/* Signal all Lami viewers & views of the selection */
LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(this,
- selections, checkNotNull(getResultTable().hashCode()));
+ selections, getPage());
TmfSignalManager.dispatchSignal(signal);
refresh();
}
package org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.viewers;
-
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
import java.util.HashSet;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect;
-import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.signals.LamiSelectionUpdateSignal;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportView;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer;
// Attributes
// ------------------------------------------------------------------------
- private final LamiResultTable fResultTable;
+ private final LamiReportViewTabPage fPage;
private Set<Integer> fSelections;
// ------------------------------------------------------------------------
Set<Integer> selectionIndexes = new HashSet<>();
for (Object selectedEntry : selections.toArray() ) {
- selectionIndexes.add(fResultTable.getEntries().indexOf(selectedEntry));
+ selectionIndexes.add(fPage.getResultTable().getEntries().indexOf(selectedEntry));
}
fSelections = selectionIndexes;
/* Signal all Lami viewers & views of the selection */
- LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(LamiTableViewer.this, selectionIndexes, checkNotNull(fResultTable).hashCode());
+ LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(LamiTableViewer.this, selectionIndexes, fPage);
TmfSignalManager.dispatchSignal(signal);
}
}
*
* @param tableViewer
* Table viewer of the view
- * @param resultTable
- * Data table populating this viewer
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
*/
- public LamiTableViewer(TableViewer tableViewer, LamiResultTable resultTable) {
+ public LamiTableViewer(TableViewer tableViewer, LamiReportViewTabPage page) {
super(tableViewer);
/*
* The table viewer should always be the first element in the control.
*/
tableViewer.getTable().moveAbove(null);
- fResultTable = resultTable;
+ fPage = page;
fSelections = new HashSet<>();
/* Default sort order of the content provider is by its first column */
// ------------------------------------------------------------------------
private void createColumns() {
- final List<LamiTableEntryAspect> aspects = fResultTable.getTableClass().getAspects();
+ final List<LamiTableEntryAspect> aspects = fPage.getResultTable().getTableClass().getAspects();
Display.getDefault().asyncExec(new Runnable() {
@Override
tableViewer.setSelection(StructuredSelection.EMPTY);
/* Fill the table data */
- tableViewer.setInput(fResultTable.getEntries());
+ tableViewer.setInput(fPage.getResultTable().getEntries());
LamiTableContentProvider latencyContentProvider = (LamiTableContentProvider) getTableViewer().getContentProvider();
tableViewer.setItemCount(latencyContentProvider.getNbEntries());
/* Set the column's alignment and pack them */
TableColumn[] cols = tableViewer.getTable().getColumns();
for (int i = 0; i < cols.length; i++) {
- LamiTableEntryAspect colAspect = fResultTable.getTableClass().getAspects().get(i);
+ LamiTableEntryAspect colAspect = fPage.getResultTable().getTableClass().getAspects().get(i);
int alignment = (colAspect.isContinuous() ? SWT.RIGHT : SWT.LEFT);
cols[i].setAlignment(alignment);
* we have no guarantee of time of execution of the fill data.
*/
if (!fSelections.isEmpty()) {
- int[] selectionsIndexes = fSelections.stream().map(index -> fResultTable.getEntries().get(index)).mapToInt(entry -> ((LamiTableContentProvider) getTableViewer().getContentProvider()).getIndexOf(entry)).toArray();
+ int[] selectionsIndexes = fSelections.stream()
+ .map(index -> fPage.getResultTable().getEntries().get(index))
+ .mapToInt(entry -> ((LamiTableContentProvider) getTableViewer().getContentProvider()).getIndexOf(entry))
+ .toArray();
+
Display.getDefault().asyncExec(() -> {
getTableViewer().getTable().setSelection(selectionsIndexes);
getTableViewer().getTable().redraw();
@TmfSignalHandler
public void updateSelection(LamiSelectionUpdateSignal signal) {
- if (fResultTable.hashCode() != signal.getSignalHash() || equals(signal.getSource())) {
+ if (fPage != signal.getSignalKey() || equals(signal.getSource())) {
/* The signal is not for us */
return;
}
Set<Integer> selections = signal.getEntryIndex();
int[] selectionsIndexes = selections.stream()
- .map(index -> fResultTable.getEntries().get(index))
+ .map(index -> fPage.getResultTable().getEntries().get(index))
.mapToInt(entry -> latencyContentProvider.getIndexOf(entry))
.toArray();
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.format.LamiDecimalUnitFormat;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.format.LamiTimeStampFormat;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.signals.LamiSelectionUpdateSignal;
+import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
import org.eclipse.tracecompass.tmf.ui.viewers.TmfViewer;
import org.eclipse.ui.ISharedImages;
refreshDisplayLabels();
};
- private final LamiResultTable fResultTable;
private final LamiChartModel fChartModel;
+ private final LamiReportViewTabPage fPage;
private final Chart fChart;
*
* @param parent
* The parent composite to draw in.
- * @param resultTable
- * The result table containing the data from which to build the
- * chart
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @param chartModel
* The information about the chart to build
*/
- public LamiXYChartViewer(Composite parent, LamiResultTable resultTable, LamiChartModel chartModel) {
+ public LamiXYChartViewer(Composite parent, LamiReportViewTabPage page, LamiChartModel chartModel) {
super(parent);
fParent = parent;
- fResultTable = resultTable;
+ fPage = page;
fChartModel = chartModel;
fSelection = new HashSet<>();
fChart.addListener(SWT.Resize, fResizeListener);
/* Set Chart title */
- fChartTitle = fResultTable.getTableClass().getTableTitle();
+ fChartTitle = fPage.getResultTable().getTableClass().getTableTitle();
/* Set X axis title */
if (fChartModel.getXSeriesColumns().size() == 1) {
* @return The chart result table.
*/
protected LamiResultTable getResultTable() {
- return fResultTable;
+ return fPage.getResultTable();
+ }
+
+ /**
+ * Get the chart {@code LamiReportViewTabPage} parent.
+ *
+ * @return The {@code LamiReportViewTabPage} parent.
+ */
+ protected LamiReportViewTabPage getPage() {
+ return fPage;
}
/**
*/
@TmfSignalHandler
public void updateSelection(LamiSelectionUpdateSignal signal) {
- if (getResultTable().hashCode() != signal.getSignalHash() || equals(signal.getSource())) {
+ if (getPage() != signal.getSignalKey() || equals(signal.getSource())) {
/* The signal is not for us */
return;
}
fControl = parent;
/* Prepare the table viewer, which is always present */
- LamiViewerControl tableViewerControl = new LamiViewerControl(fControl, fResultTable);
+ LamiViewerControl tableViewerControl = new LamiViewerControl(fControl, this);
fTableViewerControl = tableViewerControl;
/* Automatically open the table viewer initially */
tableViewerControl.getToggleAction().run();
/* Simulate a new external signal to the default viewer */
- LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(LamiReportViewTabPage.this, fSelectionIndexes, checkNotNull(fResultTable).hashCode());
+ LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(LamiReportViewTabPage.this, fSelectionIndexes, this);
TmfSignalManager.dispatchSignal(signal);
fControl.addDisposeListener(e -> {
isXLogScale,
isYLogScale);
- LamiViewerControl viewerControl = new LamiViewerControl(fControl, fResultTable, model);
+ LamiViewerControl viewerControl = new LamiViewerControl(fControl, this, model);
fCustomGraphViewerControls.add(viewerControl);
viewerControl.getToggleAction().run();
/* Signal the current selection to the newly created graph */
LamiSelectionUpdateSignal signal = new LamiSelectionUpdateSignal(LamiReportViewTabPage.this,
- fSelectionIndexes, checkNotNull(fResultTable).hashCode());
+ fSelectionIndexes, this);
TmfSignalManager.dispatchSignal(signal);
}
LamiResultTable table = fResultTable;
Object source = signal.getSource();
- if (table.hashCode() != signal.getSignalHash() ||
- source == this ||
- /*
- * Don't forward signals from other tab pages, especially those
- * from other views.
- */
+ /*
+ * Don't forward signals from other tab pages, especially those
+ * from other views/tab page.
+ */
+ if (this != signal.getSignalKey() ||
+ this == source ||
source instanceof LamiReportViewTabPage) {
/* The signal is not for us */
return;
Set<Integer> selections = getIndexOfEntriesIntersectingTimerange(table, range);
/* Update all LamiViewer */
- LamiSelectionUpdateSignal signal1 = new LamiSelectionUpdateSignal(LamiReportViewTabPage.this, selections, table.hashCode());
+ LamiSelectionUpdateSignal signal1 = new LamiSelectionUpdateSignal(LamiReportViewTabPage.this, selections, this);
TmfSignalManager.dispatchSignal(signal1);
}
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.internal.analysis.lami.ui.Activator;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel;
-import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable;
import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.viewers.ILamiViewer;
/**
*
* @param parent
* The parent composite
- * @param table
- * The results table populating the table viewer
+ * @param page
+ * The {@link LamiReportViewTabPage} page parent
*/
- public LamiViewerControl(Composite parent, LamiResultTable table) {
+ public LamiViewerControl(Composite parent, LamiReportViewTabPage page) {
fToggleAction = new Action() {
@Override
public void run() {
ILamiViewer viewer = fViewer;
if (viewer == null) {
- fViewer = ILamiViewer.createLamiTable(parent, table);
+ fViewer = ILamiViewer.createLamiTable(parent, page);
} else {
viewer.dispose();
fViewer = null;
*
* @param parent
* The parent composite
- * @param table
- * The table containing the source data
+ * @param page
+ * The {@link LamiReportViewTabPage} parent page
* @param graphModel
* The graph model
*/
- public LamiViewerControl(Composite parent, LamiResultTable table, LamiChartModel graphModel) {
+ public LamiViewerControl(Composite parent, LamiReportViewTabPage page, LamiChartModel graphModel) {
fToggleAction = new Action() {
@Override
public void run() {
ILamiViewer viewer = fViewer;
if (viewer == null) {
- fViewer = ILamiViewer.createLamiChart(parent, table, graphModel);
+ fViewer = ILamiViewer.createLamiChart(parent, page, graphModel);
} else {
viewer.dispose();
fViewer = null;