org.eclipse.tracecompass.tmf.ui,
org.eclipse.tracecompass.tmf.ctf.core,
org.eclipse.tracecompass.segmentstore.core,
- org.eclipse.tracecompass.analysis.timing.core
+ org.eclipse.tracecompass.analysis.timing.core,
+ org.eclipse.tracecompass.analysis.timing.ui
Import-Package: com.google.common.collect,
org.swtchart
Export-Package: org.eclipse.tracecompass.analysis.os.linux.ui.views.controlflow,
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2015 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * France Lapointe Nguyen - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;
-
-import java.util.Arrays;
-import java.util.Comparator;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.tracecompass.segmentstore.core.ISegment;
-import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
-import org.eclipse.tracecompass.tmf.ui.viewers.table.ISortingLazyContentProvider;
-
-import com.google.common.collect.Iterables;
-
-/**
- * Content provider for the latency table viewers.
- *
- * @author France Lapointe Nguyen
- */
-public class LatencyContentProvider implements ISortingLazyContentProvider {
-
- /**
- * Array of all the segments in the segment store of the current trace
- */
- private @Nullable ISegment[] fSegmentArray = null;
-
- /**
- * Table viewer of the latency table viewer
- */
- private @Nullable TableViewer fTableViewer = null;
-
- /**
- * Segment comparator
- */
- private @Nullable Comparator<ISegment> fComparator = null;
-
- @Override
- public void updateElement(int index) {
- final TableViewer tableViewer = fTableViewer;
- final ISegment[] segmentArray = fSegmentArray;
- if (tableViewer != null && segmentArray != null) {
- tableViewer.replace(segmentArray[index], index);
- }
- }
-
- @Override
- public void dispose() {
- fSegmentArray = null;
- fTableViewer = null;
- fComparator = null;
- }
-
- @Override
- public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) {
- fTableViewer = (TableViewer) viewer;
- if (newInput instanceof ISegmentStore<?>) {
- ISegmentStore<?> segmentStore = (ISegmentStore<?>) newInput;
- fSegmentArray = Iterables.toArray(segmentStore, ISegment.class);
- if (fComparator != null) {
- Arrays.sort(fSegmentArray, fComparator);
- }
- } else {
- fSegmentArray = null;
- }
- }
-
- @Override
- public void setSortOrder(@Nullable Comparator<?> comparator) {
- if (comparator == null) {
- return;
- }
- if (fSegmentArray == null) {
- return;
- }
- final TableViewer tableViewer = fTableViewer;
- if (tableViewer == null) {
- return;
- }
- fComparator = (Comparator<ISegment>) comparator;
- Arrays.sort(fSegmentArray, fComparator);
- tableViewer.refresh();
- }
-
- /**
- * Get the segment count
- *
- * @return the segment count
- */
- public int getSegmentCount() {
- ISegment[] segmentArray = fSegmentArray;
- return (segmentArray == null ? 0 : segmentArray.length);
- }
-}
package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;
import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Display;
import org.eclipse.tracecompass.analysis.os.linux.core.latency.LatencyAnalysis;
import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule;
-import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener;
-import org.eclipse.tracecompass.common.core.NonNullUtils;
-import org.eclipse.tracecompass.segmentstore.core.ISegment;
-import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
-import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
-import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AbstractSegmentStoreTableViewer;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
-import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
-import org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer;
/**
* Displays the latency analysis data in a column table
*
* @author France Lapointe Nguyen
*/
-public class LatencyTableViewer extends TmfSimpleTableViewer {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
-
- /**
- * Abstract class for the column label provider for the latency analysis
- * table viewer
- */
- private abstract class LatencyTableColumnLabelProvider extends ColumnLabelProvider {
-
- @Override
- public String getText(@Nullable Object input) {
- if (!(input instanceof ISegment)) {
- /* Doubles as a null check */
- return ""; //$NON-NLS-1$
- }
- return getTextForSegment((ISegment) input);
- }
-
- public abstract String getTextForSegment(ISegment input);
- }
-
- /**
- * Listener to update the model with the latency analysis results once the
- * latency analysis is fully completed
- */
- private final class AnalysisProgressListener implements IAnalysisProgressListener {
- @Override
- public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore<ISegment> data) {
- // Check if the active trace was changed while the analysis was
- // running
- if (activeAnalysis.equals(fAnalysisModule)) {
- updateModel(data);
- }
- }
- }
-
- /**
- * Listener to select a range in other viewers when a cell of the latency
- * table view is selected
- */
- private class LatencyTableSelectionListener extends SelectionAdapter {
- @Override
- public void widgetSelected(@Nullable SelectionEvent e) {
- ISegment selectedSegment = ((ISegment) NonNullUtils.checkNotNull(e).item.getData());
- ITmfTimestamp start = new TmfNanoTimestamp(selectedSegment.getStart());
- ITmfTimestamp end = new TmfNanoTimestamp(selectedSegment.getEnd());
- TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(LatencyTableViewer.this, start, end));
- }
- }
-
- /**
- * Current latency analysis module
- */
- private @Nullable AbstractSegmentStoreAnalysisModule fAnalysisModule = null;
-
- /**
- * Latency analysis completion listener
- */
- private AnalysisProgressListener fListener;
-
- /**
- * Flag to create columns once
- */
- boolean fColumnsCreated = false;
+public class LatencyTableViewer extends AbstractSegmentStoreTableViewer {
// ------------------------------------------------------------------------
// Constructor
* Constructor
*
* @param tableViewer
- * Table viewer of the view
+ * The table viewer
*/
public LatencyTableViewer(TableViewer tableViewer) {
super(tableViewer);
- // Sort order of the content provider is by start time by default
- getTableViewer().setContentProvider(new LatencyContentProvider());
- ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
- if (trace != null) {
- fAnalysisModule = TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID);
- }
- createColumns();
- getTableViewer().getTable().addSelectionListener(new LatencyTableSelectionListener());
- fListener = new AnalysisProgressListener();
}
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
- /**
- * Create default columns for start time, end time and duration
- */
- private void createColumns() {
- createColumn(Messages.LatencyTableViewer_startTime, new LatencyTableColumnLabelProvider() {
- @Override
- public String getTextForSegment(ISegment input) {
- return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getStart()));
- }
- }, SegmentComparators.INTERVAL_START_COMPARATOR);
-
- createColumn(Messages.LatencyTableViewer_endTime, new LatencyTableColumnLabelProvider() {
- @Override
- public String getTextForSegment(ISegment input) {
- return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getEnd()));
- }
- }, SegmentComparators.INTERVAL_END_COMPARATOR);
-
- createColumn(Messages.LatencyTableViewer_duration, new LatencyTableColumnLabelProvider() {
- @Override
- public String getTextForSegment(ISegment input) {
- return NonNullUtils.nullToEmptyString(Long.toString(input.getLength()));
- }
- }, SegmentComparators.INTERVAL_LENGTH_COMPARATOR);
- }
-
- /**
- * Create columns specific to the analysis
- */
- private void createAnalysisColumns() {
- if (!fColumnsCreated) {
- AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule();
- if (analysis != null) {
- for (final ISegmentAspect aspect : analysis.getSegmentAspects()) {
- createColumn(aspect.getName(), new LatencyTableColumnLabelProvider() {
- @Override
- public String getTextForSegment(ISegment input) {
- return NonNullUtils.nullToEmptyString(aspect.resolve(input));
- }
- },
- null);
- }
- }
- fColumnsCreated = true;
- }
- }
-
- /**
- * Update the data in the table viewer
- *
- * @param dataInput
- * New data input
- */
- public void updateModel(final @Nullable ISegmentStore<ISegment> dataInput) {
- final TableViewer tableViewer = getTableViewer();
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!tableViewer.getTable().isDisposed()) {
- // Go to the top of the table
- tableViewer.getTable().setTopIndex(0);
- // Reset selected row
- tableViewer.setSelection(StructuredSelection.EMPTY);
- if (dataInput == null) {
- tableViewer.setInput(null);
- tableViewer.setItemCount(0);
- return;
- }
- tableViewer.setInput(dataInput);
- LatencyContentProvider latencyContentProvider = (LatencyContentProvider) getTableViewer().getContentProvider();
- tableViewer.setItemCount(latencyContentProvider.getSegmentCount());
- }
- }
- });
- }
-
- /**
- * Set the data into the viewer. Will update model is analysis is completed
- * or run analysis if not completed
- *
- * @param analysis
- * Latency analysis module
- */
- public void setData(@Nullable AbstractSegmentStoreAnalysisModule analysis) {
- // Set the current latency analysis module
- fAnalysisModule = analysis;
- if (analysis == null) {
- updateModel(null);
- return;
- }
-
- createAnalysisColumns();
-
- ISegmentStore<ISegment> results = analysis.getResults();
- // If results are not null, then analysis is completed and model can be
- // updated
- if (results != null) {
- updateModel(results);
- return;
- }
- // If results are null, then add completion listener and run analysis
- updateModel(null);
- analysis.addListener(fListener);
- analysis.schedule();
- }
-
@Override
- protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
- final ISegment segment = (ISegment) sel.getFirstElement();
-
- IAction gotoStartTime = new Action(Messages.LatencyView_goToStartEvent) {
- @Override
- public void run() {
- broadcast(new TmfSelectionRangeUpdatedSignal(LatencyTableViewer.this, new TmfNanoTimestamp(segment.getStart())));
- }
- };
-
- IAction gotoEndTime = new Action(Messages.LatencyView_goToEndEvent) {
- @Override
- public void run() {
- broadcast(new TmfSelectionRangeUpdatedSignal(LatencyTableViewer.this, new TmfNanoTimestamp(segment.getEnd())));
- }
- };
-
- manager.add(gotoStartTime);
- manager.add(gotoEndTime);
- }
-
- // ------------------------------------------------------------------------
- // Getters
- // ------------------------------------------------------------------------
-
- /**
- * Get current latency analysis module
- *
- * @return current latency analysis module
- */
- public @Nullable AbstractSegmentStoreAnalysisModule getAnalysisModule() {
- return fAnalysisModule;
- }
-
- // ------------------------------------------------------------------------
- // Signal handlers
- // ------------------------------------------------------------------------
-
- /**
- * Trace selected handler
- *
- * @param signal
- * Different opened trace (on which latency analysis as already
- * been performed) has been selected
- */
- @TmfSignalHandler
- public void traceSelected(TmfTraceSelectedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (trace != null) {
- setData(TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID));
- }
- }
-
- /**
- * Trace opened handler
- *
- * @param signal
- * New trace (on which latency analysis has not been performed)
- * is opened
- */
- @TmfSignalHandler
- public void traceOpened(TmfTraceOpenedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (trace != null) {
- setData(TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID));
- }
- }
-
- /**
- * Trace closed handler
- *
- * @param signal
- * Last opened trace was closed
- */
- @TmfSignalHandler
- public void traceClosed(TmfTraceClosedSignal signal) {
- // Check if there is no more opened trace
- if (TmfTraceManager.getInstance().getActiveTrace() == null) {
- if (!getTableViewer().getTable().isDisposed()) {
- getTableViewer().setInput(null);
- refresh();
- }
- }
+ protected @Nullable AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace) {
+ return TmfTraceUtils.getAnalysisModuleOfClass(trace, LatencyAnalysis.class, LatencyAnalysis.ID);
}
}
package org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency;
-import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tracecompass.tmf.ui.views.TmfView;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AbstractSegmentStoreTableView;
+import org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.AbstractSegmentStoreTableViewer;
/**
* View for the latency analysis
*
* @author France Lapointe Nguyen
*/
-public class LatencyView extends TmfView {
+public class LatencyView extends AbstractSegmentStoreTableView {
// ------------------------------------------------------------------------
// Attributes
/** The view's ID */
public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.views.latency"; //$NON-NLS-1$
- private @Nullable LatencyTableViewer fTableViewer;
-
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
- /**
- * Constructor
- */
- public LatencyView() {
- super(ID);
- }
-
- // ------------------------------------------------------------------------
- // ViewPart
- // ------------------------------------------------------------------------
-
@Override
- public void createPartControl(@Nullable Composite parent) {
- SashForm sf = new SashForm(parent, SWT.NONE);
- TableViewer tableViewer = new TableViewer(sf, SWT.FULL_SELECTION | SWT.VIRTUAL);
- fTableViewer = new LatencyTableViewer(tableViewer);
- setInitialData();
- }
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- @Override
- public void setFocus() {
- if (fTableViewer != null) {
- fTableViewer.getTableViewer().getControl().setFocus();
- }
- }
-
- @Override
- public void dispose() {
- super.dispose();
- if (fTableViewer != null) {
- fTableViewer.dispose();
- }
- }
-
- /**
- * Set initial data into the viewer
- */
- private void setInitialData() {
- if (fTableViewer != null) {
- fTableViewer.setData(fTableViewer.getAnalysisModule());
- }
+ protected AbstractSegmentStoreTableViewer getSegmentStoreViewer(TableViewer tableViewer) {
+ return new LatencyTableViewer(tableViewer);
}
}
org.eclipse.tracecompass.segmentstore.core,
org.eclipse.tracecompass.tmf.core,
org.eclipse.tracecompass.tmf.ui
-Export-Package: org.eclipse.tracecompass.internal.analysis.timing.ui
+Export-Package: org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore,
+ org.eclipse.tracecompass.internal.analysis.timing.ui,
+ org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * France Lapointe Nguyen - Initial API and implementation
+ * Bernd Hufmann - Move abstract class to TMF
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tracecompass.tmf.ui.views.TmfView;
+
+/**
+ * View for displaying a segment store analysis in a table.
+ *
+ * @author France Lapointe Nguyen
+ * @since 2.0
+ */
+public abstract class AbstractSegmentStoreTableView extends TmfView {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ private @Nullable AbstractSegmentStoreTableViewer fTableViewer;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ */
+ public AbstractSegmentStoreTableView() {
+ super(""); //$NON-NLS-1$
+ }
+
+ // ------------------------------------------------------------------------
+ // ViewPart
+ // ------------------------------------------------------------------------
+
+ @Override
+ 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);
+ setInitialData();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ public void setFocus() {
+ if (fTableViewer != null) {
+ fTableViewer.getTableViewer().getControl().setFocus();
+ }
+ }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ if (fTableViewer != null) {
+ fTableViewer.dispose();
+ }
+ }
+
+ /**
+ * Returns the latency analysis table viewer instance
+ *
+ * @param tableViewer
+ * the table viewer to use
+ * @return the latency analysis table viewer instance
+ */
+ protected abstract AbstractSegmentStoreTableViewer getSegmentStoreViewer(TableViewer tableViewer);
+
+ /**
+ * Set initial data into the viewer
+ */
+ private void setInitialData() {
+ if (fTableViewer != null) {
+ fTableViewer.setData(fTableViewer.getAnalysisModule());
+ }
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * France Lapointe Nguyen - Initial API and implementation
+ * Bernd Hufmann - Move abstract class to TMF
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.AbstractSegmentStoreAnalysisModule;
+import org.eclipse.tracecompass.analysis.timing.core.segmentstore.IAnalysisProgressListener;
+import org.eclipse.tracecompass.common.core.NonNullUtils;
+import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.Messages;
+import org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.SegmentStoreContentProvider;
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
+import org.eclipse.tracecompass.segmentstore.core.SegmentComparators;
+import org.eclipse.tracecompass.tmf.core.segment.ISegmentAspect;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer;
+
+/**
+ * Displays the segment store analysis data in a column table
+ *
+ * @author France Lapointe Nguyen
+ * @since 2.0
+ */
+public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableViewer {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /**
+ * Abstract class for the column label provider for the segment store
+ * analysis table viewer
+ */
+ private abstract class SegmentStoreTableColumnLabelProvider extends ColumnLabelProvider {
+
+ @Override
+ public String getText(@Nullable Object input) {
+ if (!(input instanceof ISegment)) {
+ /* Doubles as a null check */
+ return ""; //$NON-NLS-1$
+ }
+ return getTextForSegment((ISegment) input);
+ }
+
+ public abstract String getTextForSegment(ISegment input);
+ }
+
+ /**
+ * Listener to update the model with the segment store analysis results
+ * once the analysis is fully completed
+ */
+ private final class AnalysisProgressListener implements IAnalysisProgressListener {
+ @Override
+ public void onComplete(AbstractSegmentStoreAnalysisModule activeAnalysis, ISegmentStore<ISegment> data) {
+ // Check if the active trace was changed while the analysis was
+ // running
+ if (activeAnalysis.equals(fAnalysisModule)) {
+ updateModel(data);
+ }
+ }
+ }
+
+ /**
+ * Listener to select a range in other viewers when a cell of the segment
+ * store table view is selected
+ */
+ private class TableSelectionListener extends SelectionAdapter {
+ @Override
+ public void widgetSelected(@Nullable SelectionEvent e) {
+ ISegment selectedSegment = ((ISegment) NonNullUtils.checkNotNull(e).item.getData());
+ ITmfTimestamp start = new TmfNanoTimestamp(selectedSegment.getStart());
+ ITmfTimestamp end = new TmfNanoTimestamp(selectedSegment.getEnd());
+ TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, start, end));
+ }
+ }
+
+ /**
+ * Current segment store analysis module
+ */
+ private @Nullable AbstractSegmentStoreAnalysisModule fAnalysisModule = null;
+
+ /**
+ * Analysis progress listener
+ */
+ private AnalysisProgressListener fListener;
+
+ /**
+ * Flag to create columns once
+ */
+ boolean fColumnsCreated = false;
+
+ // ------------------------------------------------------------------------
+ // Constructor
+ // ------------------------------------------------------------------------
+
+ /**
+ * Constructor
+ *
+ * @param tableViewer
+ * Table viewer of the view
+ */
+ public AbstractSegmentStoreTableViewer(TableViewer tableViewer) {
+ super(tableViewer);
+ // Sort order of the content provider is by start time by default
+ getTableViewer().setContentProvider(new SegmentStoreContentProvider());
+ ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
+ if (trace != null) {
+ fAnalysisModule = getSegmentStoreAnalysisModule(trace);
+ }
+ createColumns();
+ getTableViewer().getTable().addSelectionListener(new TableSelectionListener());
+ fListener = new AnalysisProgressListener();
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ /**
+ * Create default columns for start time, end time and duration
+ */
+ private void createColumns() {
+ createColumn(Messages.SegmentStoreTableViewer_startTime, new SegmentStoreTableColumnLabelProvider() {
+ @Override
+ public String getTextForSegment(ISegment input) {
+ return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getStart()));
+ }
+ }, SegmentComparators.INTERVAL_START_COMPARATOR);
+
+ createColumn(Messages.SegmentStoreTableViewer_endTime, new SegmentStoreTableColumnLabelProvider() {
+ @Override
+ public String getTextForSegment(ISegment input) {
+ return NonNullUtils.nullToEmptyString(TmfTimestampFormat.getDefaulTimeFormat().format(input.getEnd()));
+ }
+ }, SegmentComparators.INTERVAL_END_COMPARATOR);
+
+ createColumn(Messages.SegmentStoreTableViewer_duration, new SegmentStoreTableColumnLabelProvider() {
+ @Override
+ public String getTextForSegment(ISegment input) {
+ return NonNullUtils.nullToEmptyString(Long.toString(input.getLength()));
+ }
+ }, SegmentComparators.INTERVAL_LENGTH_COMPARATOR);
+ }
+
+ /**
+ * Create columns specific to the analysis
+ */
+ protected void createAnalysisColumns() {
+ if (!fColumnsCreated) {
+ AbstractSegmentStoreAnalysisModule analysis = getAnalysisModule();
+ if (analysis != null) {
+ for (final ISegmentAspect aspect : analysis.getSegmentAspects()) {
+ createColumn(aspect.getName(), new SegmentStoreTableColumnLabelProvider() {
+ @Override
+ public String getTextForSegment(ISegment input) {
+ return NonNullUtils.nullToEmptyString(aspect.resolve(input));
+ }
+ },
+ null);
+ }
+ }
+ fColumnsCreated = true;
+ }
+ }
+
+ /**
+ * Update the data in the table viewer
+ *
+ * @param dataInput
+ * New data input
+ */
+ public void updateModel(final @Nullable ISegmentStore<ISegment> dataInput) {
+ final TableViewer tableViewer = getTableViewer();
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (!tableViewer.getTable().isDisposed()) {
+ // Go to the top of the table
+ tableViewer.getTable().setTopIndex(0);
+ // Reset selected row
+ tableViewer.setSelection(StructuredSelection.EMPTY);
+ if (dataInput == null) {
+ tableViewer.setInput(null);
+ tableViewer.setItemCount(0);
+ return;
+ }
+ tableViewer.setInput(dataInput);
+ SegmentStoreContentProvider contentProvider = (SegmentStoreContentProvider) getTableViewer().getContentProvider();
+ tableViewer.setItemCount(contentProvider.getSegmentCount());
+ }
+ }
+ });
+ }
+
+ /**
+ * Set the data into the viewer. Will update model is analysis is completed
+ * or run analysis if not completed
+ *
+ * @param analysis
+ * segment store analysis module
+ */
+ public void setData(@Nullable AbstractSegmentStoreAnalysisModule analysis) {
+ // Set the current segment store analysis module
+ fAnalysisModule = analysis;
+ if (analysis == null) {
+ updateModel(null);
+ return;
+ }
+
+ createAnalysisColumns();
+
+ ISegmentStore<ISegment> results = analysis.getResults();
+ // If results are not null, then analysis is completed and model can be
+ // updated
+ if (results != null) {
+ updateModel(results);
+ return;
+ }
+ // If results are null, then add completion listener and run analysis
+ updateModel(null);
+ analysis.addListener(fListener);
+ analysis.schedule();
+ }
+
+ /**
+ * Returns the segment store analysis module
+ * @param trace
+ * The trace to consider
+ * @return the segment store analysis module
+ */
+ protected @Nullable abstract AbstractSegmentStoreAnalysisModule getSegmentStoreAnalysisModule(ITmfTrace trace);
+
+ @Override
+ protected void appendToTablePopupMenu(IMenuManager manager, IStructuredSelection sel) {
+ final ISegment segment = (ISegment) sel.getFirstElement();
+
+ IAction gotoStartTime = new Action(Messages.SegmentStoreTableViewer_goToStartEvent) {
+ @Override
+ public void run() {
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getStart())));
+ }
+ };
+
+ IAction gotoEndTime = new Action(Messages.SegmentStoreTableViewer_goToEndEvent) {
+ @Override
+ public void run() {
+ broadcast(new TmfSelectionRangeUpdatedSignal(AbstractSegmentStoreTableViewer.this, new TmfNanoTimestamp(segment.getEnd())));
+ }
+ };
+
+ manager.add(gotoStartTime);
+ manager.add(gotoEndTime);
+ }
+
+ // ------------------------------------------------------------------------
+ // Getters
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get current segment store analysis module
+ *
+ * @return current segment store analysis module
+ */
+ public @Nullable AbstractSegmentStoreAnalysisModule getAnalysisModule() {
+ return fAnalysisModule;
+ }
+
+ // ------------------------------------------------------------------------
+ // Signal handlers
+ // ------------------------------------------------------------------------
+
+ /**
+ * Trace selected handler
+ *
+ * @param signal
+ * Different opened trace (on which segment store analysis as
+ * already been performed) has been selected
+ */
+ @TmfSignalHandler
+ public void traceSelected(TmfTraceSelectedSignal signal) {
+ ITmfTrace trace = signal.getTrace();
+ if (trace != null) {
+ setData(getSegmentStoreAnalysisModule(trace));
+ }
+ }
+
+ /**
+ * Trace opened handler
+ *
+ * @param signal
+ * New trace (on which segment store analysis has not been
+ * performed) is opened
+ */
+ @TmfSignalHandler
+ public void traceOpened(TmfTraceOpenedSignal signal) {
+ ITmfTrace trace = signal.getTrace();
+ if (trace != null) {
+ setData(getSegmentStoreAnalysisModule(trace));
+ }
+ }
+
+ /**
+ * Trace closed handler
+ *
+ * @param signal
+ * Last opened trace was closed
+ */
+ @TmfSignalHandler
+ public void traceClosed(TmfTraceClosedSignal signal) {
+ // Check if there is no more opened trace
+ if (TmfTraceManager.getInstance().getActiveTrace() == null) {
+ if (!getTableViewer().getTable().isDisposed()) {
+ getTableViewer().setInput(null);
+ refresh();
+ }
+ }
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore;
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * France Lapointe Nguyen - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author France Lapointe Nguyen
+ * @since 2.0
+ */
+@NonNullByDefault(false)
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore.messages"; //$NON-NLS-1$
+
+ /**
+ * Name of the duration column
+ */
+ public static String SegmentStoreTableViewer_duration;
+
+ /**
+ * Name of the end time column
+ */
+ public static String SegmentStoreTableViewer_endTime;
+
+ /**
+ * Name of the start time column
+ */
+ public static String SegmentStoreTableViewer_startTime;
+
+ /**
+ * Title of the scatter graph
+ */
+ public static String LatencyView_title;
+
+ /**
+ * Title of the x axis of the scatter graph
+ */
+ public static String LatencyView_xAxis;
+
+ /**
+ * Title of the y axis of the scatter graph
+ */
+ public static String LatencyView_yAxis;
+
+ /**
+ * Title of action to goto start time time
+ */
+ public static String SegmentStoreTableViewer_goToStartEvent;
+
+ /**
+ * Title of action to goto end event
+ */
+ public static String SegmentStoreTableViewer_goToEndEvent;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * France Lapointe Nguyen - Initial API and implementation
+ * Bernd Hufmann - MOve abstract class to TMF
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tracecompass.segmentstore.core.ISegment;
+import org.eclipse.tracecompass.segmentstore.core.ISegmentStore;
+import org.eclipse.tracecompass.tmf.ui.viewers.table.ISortingLazyContentProvider;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Content provider for the latency table viewers.
+ *
+ * @author France Lapointe Nguyen
+ * @since 2.0
+ */
+public class SegmentStoreContentProvider implements ISortingLazyContentProvider {
+
+ /**
+ * Array of all the segments in the segment store of the current trace
+ */
+ private @Nullable ISegment[] fSegmentArray = null;
+
+ /**
+ * Table viewer of the latency table viewer
+ */
+ private @Nullable TableViewer fTableViewer = null;
+
+ /**
+ * Segment comparator
+ */
+ private @Nullable Comparator<ISegment> fComparator = null;
+
+ @Override
+ public void updateElement(int index) {
+ final TableViewer tableViewer = fTableViewer;
+ final ISegment[] segmentArray = fSegmentArray;
+ if (tableViewer != null && segmentArray != null) {
+ tableViewer.replace(segmentArray[index], index);
+ }
+ }
+
+ @Override
+ public void dispose() {
+ fSegmentArray = null;
+ fTableViewer = null;
+ fComparator = null;
+ }
+
+ @Override
+ public void inputChanged(@Nullable Viewer viewer, @Nullable Object oldInput, @Nullable Object newInput) {
+ fTableViewer = (TableViewer) viewer;
+ if (newInput instanceof ISegmentStore<?>) {
+ ISegmentStore<?> segmentStore = (ISegmentStore<?>) newInput;
+ fSegmentArray = Iterables.toArray(segmentStore, ISegment.class);
+ if (fComparator != null) {
+ Arrays.sort(fSegmentArray, fComparator);
+ }
+ } else {
+ fSegmentArray = null;
+ }
+ }
+
+ @Override
+ public void setSortOrder(@Nullable Comparator<?> comparator) {
+ if (comparator == null) {
+ return;
+ }
+ if (fSegmentArray == null) {
+ return;
+ }
+ final TableViewer tableViewer = fTableViewer;
+ if (tableViewer == null) {
+ return;
+ }
+ fComparator = (Comparator<ISegment>) comparator;
+ Arrays.sort(fSegmentArray, fComparator);
+ tableViewer.refresh();
+ }
+
+ /**
+ * Get the segment count
+ *
+ * @return the segment count
+ */
+ public int getSegmentCount() {
+ ISegment[] segmentArray = fSegmentArray;
+ return (segmentArray == null ? 0 : segmentArray.length);
+ }
+}
--- /dev/null
+SegmentStoreTableViewer_duration=Duration
+SegmentStoreTableViewer_endTime=End Time
+SegmentStoreTableViewer_startTime=Start Time
+LatencyView_title=Latency vs Time
+LatencyView_xAxis=Time
+LatencyView_yAxis=Latency
+SegmentStoreTableViewer_goToStartEvent=Go to start time
+SegmentStoreTableViewer_goToEndEvent=Go to end time
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.analysis.timing.ui.views.segmentstore;
org.eclipse.ui.navigator.resources,
org.swtchart,
com.ibm.icu,
- org.eclipse.linuxtools.dataviewers.piechart
+ org.eclipse.linuxtools.dataviewers.piechart,
+ org.eclipse.tracecompass.segmentstore.core;bundle-version="1.0.0"
Export-Package: org.eclipse.tracecompass.internal.tmf.ui;x-friends:="org.eclipse.tracecompass.tmf.ui.tests,org.eclipse.tracecompass.tmf.ctf.ui.tests",
org.eclipse.tracecompass.internal.tmf.ui.commands;x-internal:=true,
org.eclipse.tracecompass.internal.tmf.ui.dialogs;x-internal:=true,