package org.eclipse.linuxtools.tmf.ui.views.timegraph;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
+import org.eclipse.linuxtools.tmf.ui.TmfUiRefreshHandler;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphContentProvider;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphRangeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphSelectionListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTimeListener;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphCombo;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEvent;
-import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphSelectionEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphViewer;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ILinkEvent;
* this class typically need to override the getColumnText method if they
* have more than one column to display
*/
- protected static class TreeLabelProvider implements ITableLabelProvider {
+ protected static class TreeLabelProvider implements ITableLabelProvider, ILabelProvider {
@Override
public void addListener(ILabelProviderListener listener) {
return new String();
}
+ /**
+ * @since 3.2
+ */
+ @Override
+ public Image getImage(Object element) {
+ return null;
+ }
+
+ /**
+ * @since 3.2
+ */
+ @Override
+ public String getText(Object element) {
+ TimeGraphEntry entry = (TimeGraphEntry) element;
+ return entry.getName();
+ }
+
}
private class BuildThread extends Thread {
}
}
redraw();
- for (TimeGraphEntry child : entry.getChildren()) {
+ for (ITimeGraphEntry child : entry.getChildren()) {
if (fMonitor.isCanceled()) {
return;
}
- zoom(child, monitor);
+ if (child instanceof TimeGraphEntry) {
+ zoom((TimeGraphEntry) child, monitor);
+ }
}
}
return fTimeGraphWrapper.getTimeGraphViewer();
}
+ /**
+ * Getter for the presentation provider
+ *
+ * @return The time graph presentation provider
+ * @since 3.0
+ */
+ protected ITimeGraphPresentationProvider2 getPresentationProvider() {
+ return fPresentation;
+ }
+
/**
* Sets the tree column labels.
* This should be called from the constructor.
}
});
- fTimeGraphWrapper.addSelectionListener(new ITimeGraphSelectionListener() {
- @Override
- public void selectionChanged(TimeGraphSelectionEvent event) {
- // ITimeGraphEntry selection = event.getSelection();
- }
- });
-
fTimeGraphWrapper.getTimeGraphViewer().setTimeFormat(TimeFormat.CALENDAR);
IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
@TmfSignalHandler
public void traceClosed(final TmfTraceClosedSignal signal) {
synchronized (fBuildThreadMap) {
- for (ITmfTrace trace : TmfTraceManager.getTraceSet(signal.getTrace())) {
+ for (ITmfTrace trace : getTracesToBuild(signal.getTrace())) {
BuildThread buildThread = fBuildThreadMap.remove(trace);
if (buildThread != null) {
buildThread.cancel();
synchronized (fEntryListMap) {
fEntryList = fEntryListMap.get(fTrace);
if (fEntryList == null) {
- setStartTime(Long.MAX_VALUE);
- setEndTime(Long.MIN_VALUE);
- synchronized (fBuildThreadMap) {
- for (ITmfTrace trace : TmfTraceManager.getTraceSet(fTrace)) {
- BuildThread buildThread = new BuildThread(trace, fTrace, getName());
- fBuildThreadMap.put(trace, buildThread);
- buildThread.start();
- }
- }
+ rebuild();
} else {
fStartTime = fTrace.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
fEndTime = fTrace.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
}
}
+ /**
+ * Forces a rebuild of the entries list, even if entries already exist for this trace
+ * @since 3.0
+ */
+ protected void rebuild() {
+ setStartTime(Long.MAX_VALUE);
+ setEndTime(Long.MIN_VALUE);
+ synchronized (fBuildThreadMap) {
+ for (ITmfTrace trace : getTracesToBuild(fTrace)) {
+ BuildThread buildThread = new BuildThread(trace, fTrace, getName());
+ fBuildThreadMap.put(trace, buildThread);
+ buildThread.start();
+ }
+ }
+ }
+
/**
* Method called when synching to a given timestamp. Inheriting classes can
* perform actions here to update the view at the given timestamp.
}
+ /**
+ * Return the list of traces whose data or analysis results will be used to
+ * populate the view. By default, if the trace is an experiment, the traces
+ * under it will be returned, otherwise, the trace itself is returned.
+ *
+ * A build thread will be started for each trace returned by this method,
+ * some of which may receive events in live streaming mode.
+ *
+ * @param trace
+ * The trace associated with this view
+ * @return List of traces with data to display
+ * @since 3.0
+ */
+ protected Iterable<ITmfTrace> getTracesToBuild(ITmfTrace trace) {
+ return Arrays.asList(TmfTraceManager.getTraceSet(trace));
+ }
+
/**
* Build the entries list to show in this time graph
*
* The progress monitor object
* @return The list of events for the entry
*/
- protected abstract List<ITimeEvent> getEventList(TimeGraphEntry entry,
+ protected abstract @Nullable List<ITimeEvent> getEventList(TimeGraphEntry entry,
long startTime, long endTime, long resolution,
IProgressMonitor monitor);
* Refresh the display
*/
protected void refresh() {
- Display.getDefault().asyncExec(new Runnable() {
+ TmfUiRefreshHandler.getInstance().queueUpdate(this, new Runnable() {
@Override
public void run() {
if (fTimeGraphWrapper.isDisposed()) {