Show arrows to follow CPU execution in Control Flow view.
Implement a Hide Arrows toggle action to the time graph control.
Change-Id: Ic6e5020f8a7895e482bda9e45c8333dde79e7022
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/15147
Tested-by: Hudson CI
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.linuxtools.internal.lttng2.kernel.core.Attributes;
+import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Activator;
import org.eclipse.linuxtools.internal.lttng2.kernel.ui.Messages;
import org.eclipse.linuxtools.lttng2.kernel.core.trace.LttngKernelTrace;
import org.eclipse.linuxtools.tmf.core.exceptions.AttributeNotFoundException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
import org.eclipse.linuxtools.tmf.core.statevalue.ITmfStateValue;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
import org.eclipse.linuxtools.tmf.ui.views.timegraph.AbstractTimeGraphView;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ILinkEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeLinkEvent;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
setEntryComparator(new ControlFlowEntryComparator());
}
+ @Override
+ protected void fillLocalToolBar(IToolBarManager manager) {
+ IDialogSettings settings = Activator.getDefault().getDialogSettings();
+ IDialogSettings section = settings.getSection(getClass().getName());
+ if (section == null) {
+ section = settings.addNewSection(getClass().getName());
+ }
+ manager.add(getTimeGraphCombo().getTimeGraphViewer().getHideArrowsAction(section));
+ super.fillLocalToolBar(manager);
+ }
+
@Override
protected String getNextText() {
return Messages.ControlFlowView_nextProcessActionNameText;
}
}
}
+
+ @Override
+ protected List<ILinkEvent> getLinkList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
+ List<ILinkEvent> list = new ArrayList<ILinkEvent>();
+ ITmfTrace[] traces = TmfTraceManager.getTraceSet(getTrace());
+ List<TimeGraphEntry> entryList = getEntryListMap().get(getTrace());
+ if (traces == null || entryList == null) {
+ return list;
+ }
+ for (ITmfTrace trace : traces) {
+ if (trace instanceof LttngKernelTrace) {
+ ITmfStateSystem ssq = trace.getStateSystems().get(LttngKernelTrace.STATE_ID);
+ try {
+ long start = Math.max(startTime, ssq.getStartTime());
+ long end = Math.min(endTime, ssq.getCurrentEndTime());
+ if (end < start) {
+ continue;
+ }
+ List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
+ for (int currentThreadQuark : currentThreadQuarks) {
+ List<ITmfStateInterval> currentThreadIntervals = ssq.queryHistoryRange(currentThreadQuark, start, end, resolution, monitor);
+ int prevThread = 0;
+ long prevEnd = 0;
+ for (ITmfStateInterval currentThreadInterval : currentThreadIntervals) {
+ if (monitor.isCanceled()) {
+ return null;
+ }
+ long time = currentThreadInterval.getStartTime();
+ int thread = currentThreadInterval.getStateValue().unboxInt();
+ if (thread > 0 && prevThread > 0 && thread != prevThread && time == prevEnd) {
+ ITimeGraphEntry prevEntry = findEntry(entryList, trace, prevThread);
+ ITimeGraphEntry nextEntry = findEntry(entryList, trace, thread);
+ list.add(new TimeLinkEvent(prevEntry, nextEntry, time, 0, 0));
+ }
+ prevThread = thread;
+ prevEnd = currentThreadInterval.getEndTime() + 1;
+ }
+ }
+ } catch (TimeRangeException e) {
+ e.printStackTrace();
+ } catch (AttributeNotFoundException e) {
+ e.printStackTrace();
+ } catch (StateValueTypeException e) {
+ e.printStackTrace();
+ } catch (StateSystemDisposedException e) {
+ /* Ignored */
+ }
+ }
+ }
+ return list;
+ }
+
+ private ControlFlowEntry findEntry(List<TimeGraphEntry> entryList, ITmfTrace trace, int threadId) {
+ for (TimeGraphEntry entry : entryList) {
+ if (entry instanceof ControlFlowEntry) {
+ ControlFlowEntry controlFlowEntry = (ControlFlowEntry) entry;
+ if (controlFlowEntry.getThreadId() == threadId && controlFlowEntry.getTrace() == trace) {
+ return controlFlowEntry;
+ } else if (entry.hasChildren()) {
+ controlFlowEntry = findEntry(entry.getChildren(), trace, threadId);
+ if (controlFlowEntry != null) {
+ return controlFlowEntry;
+ }
+ }
+ }
+ }
+ return null;
+ }
}
*
* Contributors:
* Bernd Hufmann - initial API and implementation
+ * Patrick Tasse - added icons
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.ui;
public static final String IMG_UI_NEXT_ITEM = IMG_UI_NEXT_PAGE;
public static final String IMG_UI_PREV_ITEM = IMG_UI_PREV_PAGE;
public static final String IMG_UI_PIN_VIEW = ICONS_PATH + "elcl16/pin_view.gif";
+ public static final String IMG_UI_HIDE_ARROWS = ICONS_PATH + "elcl16/hide_arrows.gif";
/* eview16 */
public static final String IMG_UI_SEQ_DIAGRAM_OBJ = ICONS_PATH + "eview16/sequencediagram_view.gif";
public static String TmfTimeGraphViewer_ZoomInActionToolTipText;
public static String TmfTimeGraphViewer_ZoomOutActionNameText;
public static String TmfTimeGraphViewer_ZoomOutActionToolTipText;
+ public static String TmfTimeGraphViewer_HideArrowsActionNameText;
+ public static String TmfTimeGraphViewer_HideArrowsActionToolTipText;
public static String ColorsView_AddActionToolTipText;
public static String ColorsView_BackgroundButtonText;
TmfTimeGraphViewer_ZoomInActionToolTipText=Zoom In
TmfTimeGraphViewer_ZoomOutActionNameText=Zoom Out
TmfTimeGraphViewer_ZoomOutActionToolTipText=Zoom Out
+TmfTimeGraphViewer_HideArrowsActionNameText=Hide Arrows
+TmfTimeGraphViewer_HideArrowsActionToolTipText=Hide Arrows
# org.eclipse.linuxtools.tmf.ui.views.colors
ColorsView_AddActionToolTipText=Insert new color setting
}
for (TimeGraphEntry entry : fZoomEntryList) {
if (fMonitor.isCanceled()) {
- break;
+ return;
}
zoom(entry, fMonitor);
}
/* Refresh the arrows when zooming */
List<ILinkEvent> events = getLinkList(fZoomStartTime, fZoomEndTime, fResolution, fMonitor);
- fTimeGraphCombo.setLinks(events);
- redraw();
+ if (events != null) {
+ fTimeGraphCombo.setLinks(events);
+ redraw();
+ }
}
private void zoom(TimeGraphEntry entry, IProgressMonitor monitor) {
fillLocalToolBar(bars.getToolBarManager());
}
- private void fillLocalToolBar(IToolBarManager manager) {
+ /**
+ * Add actions to local tool bar manager
+ *
+ * @param manager the tool bar manager
+ */
+ protected void fillLocalToolBar(IToolBarManager manager) {
if (fFilterColumns.length > 0) {
manager.add(fTimeGraphCombo.getShowFilterAction());
}
import java.util.List;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
private static final int MAX_NAME_WIDTH = 1000;
private static final int DEFAULT_HEIGHT = 22;
private static final long RECENTERING_MARGIN_FACTOR = 50;
+ private static final String HIDE_ARROWS_KEY = "hide.arrows"; //$NON-NLS-1$
private long fMinTimeInterval;
private ITimeGraphEntry fSelectedEntry;
private List<ITimeGraphTimeListener> fTimeListeners = new ArrayList<ITimeGraphTimeListener>();
private List<ITimeGraphRangeListener> fRangeListeners = new ArrayList<ITimeGraphRangeListener>();
- // Time format, using Epoch reference, Relative time format(default) or Number
+ // Time format, using Epoch reference, Relative time format(default) or
+ // Number
private TimeFormat fTimeFormat = TimeFormat.RELATIVE;
private int fBorderWidth = 0;
private int fTimeScaleHeight = DEFAULT_HEIGHT;
private Action fPreviousItemAction;
private Action fZoomInAction;
private Action fZoomOutAction;
+ private Action fHideArrowsAction;
/**
* Standard constructor
/**
* Sets the timegraph provider used by this timegraph viewer.
*
- * @param timeGraphProvider the timegraph provider
+ * @param timeGraphProvider
+ * the timegraph provider
*/
public void setTimeGraphProvider(ITimeGraphPresentationProvider timeGraphProvider) {
fTimeGraphProvider = timeGraphProvider;
}
/**
- * Sets or clears the input for this time graph viewer.
- * The input array should only contain top-level elements.
+ * Sets or clears the input for this time graph viewer. The input array
+ * should only contain top-level elements.
*
- * @param input The input of this time graph viewer, or <code>null</code> if none
+ * @param input
+ * The input of this time graph viewer, or <code>null</code> if
+ * none
*/
public void setInput(ITimeGraphEntry[] input) {
ITimeGraphEntry[] realInput = input;
}
/**
- * @param tf the {@link TimeFormat} used to display timestamps
+ * @param tf
+ * the {@link TimeFormat} used to display timestamps
* @since 2.0
*/
public void setTimeFormat(TimeFormat tf) {
public void setBorderWidth(int borderWidth) {
if (borderWidth > -1) {
this.fBorderWidth = borderWidth;
- GridLayout gl = (GridLayout)fDataViewer.getLayout();
+ GridLayout gl = (GridLayout) fDataViewer.getLayout();
gl.marginHeight = borderWidth;
}
}
/**
* Set the width for the name column
*
- * @param width The width
+ * @param width
+ * The width
*/
public void setNameWidthPref(int width) {
fNameWidthPref = width;
/**
* Return the x coordinate corresponding to a time
*
- * @param time the time
+ * @param time
+ * the time
* @return the x coordinate corresponding to the time
*
* @since 2.0
/**
* Return the time corresponding to an x coordinate
*
- * @param x the x coordinate
+ * @param x
+ * the x coordinate
* @return the time corresponding to the x coordinate
*
* @since 2.0
return fZoomOutAction;
}
+ /**
+ * Get the hide arrows action
+ *
+ * @param dialogSettings
+ * The dialog settings section where the state should be stored,
+ * or null
+ *
+ * @return The Action object
+ *
+ * @since 2.1
+ */
+ public Action getHideArrowsAction(final IDialogSettings dialogSettings) {
+ if (fHideArrowsAction == null) {
+ fHideArrowsAction = new Action(Messages.TmfTimeGraphViewer_HideArrowsActionNameText, IAction.AS_CHECK_BOX) {
+ @Override
+ public void run() {
+ boolean hideArrows = fHideArrowsAction.isChecked();
+ fTimeGraphCtrl.hideArrows(hideArrows);
+ refresh();
+ if (dialogSettings != null) {
+ dialogSettings.put(HIDE_ARROWS_KEY, hideArrows);
+ }
+ }
+ };
+ fHideArrowsAction.setToolTipText(Messages.TmfTimeGraphViewer_HideArrowsActionToolTipText);
+ fHideArrowsAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_HIDE_ARROWS));
+ if (dialogSettings != null) {
+ boolean hideArrows = dialogSettings.getBoolean(HIDE_ARROWS_KEY);
+ fTimeGraphCtrl.hideArrows(hideArrows);
+ fHideArrowsAction.setChecked(hideArrows);
+ }
+ }
+ return fHideArrowsAction;
+ }
private void adjustVerticalScrollBar() {
int topIndex = fTimeGraphCtrl.getTopIndex();
}
/**
- * @param listener a {@link MenuDetectListener}
+ * @param listener
+ * a {@link MenuDetectListener}
* @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
* @since 1.2
*/
}
/**
- * @param listener a {@link MenuDetectListener}
+ * @param listener
+ * a {@link MenuDetectListener}
* @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeGraphEntryMenuListener(org.eclipse.swt.events.MenuDetectListener)
* @since 1.2
*/
}
/**
- * @param listener a {@link MenuDetectListener}
+ * @param listener
+ * a {@link MenuDetectListener}
* @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#addTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
* @since 1.2
*/
}
/**
- * @param listener a {@link MenuDetectListener}
+ * @param listener
+ * a {@link MenuDetectListener}
* @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeGraphControl#removeTimeEventMenuListener(org.eclipse.swt.events.MenuDetectListener)
* @since 1.2
*/
}
/**
- * @param filter The filter object to be attached to the view
+ * @param filter
+ * The filter object to be attached to the view
* @since 2.0
*/
public void addFilter(ViewerFilter filter) {
}
/**
- * @param filter The filter object to be attached to the view
+ * @param filter
+ * The filter object to be attached to the view
* @since 2.0
*/
public void removeFilter(ViewerFilter filter) {
private final Cursor fZoomCursor = Display.getDefault().getSystemCursor(SWT.CURSOR_SIZEWE);
private final List<ViewerFilter> fFilters = new ArrayList<ViewerFilter>();
private MenuDetectEvent fPendingMenuDetectEvent = null;
+ private boolean fHideArrows = false;
private int fBorderWidth = 0;
private int fHeaderHeight = 0;
fTimeProvider.setStartFinishTimeNotify(time0, time1);
}
+ /**
+ * Hide arrows
+ *
+ * @param hideArrows true to hide arrows
+ *
+ * @since 2.1
+ */
+ public void hideArrows(boolean hideArrows) {
+ fHideArrows = hideArrows;
+ }
+
/**
* Return the currently selected trace
*
*/
public void drawLinks(Rectangle bounds, ITimeDataProvider timeProvider,
List<ILinkEvent> links, int nameSpace, GC gc) {
+ if (fHideArrows) {
+ return;
+ }
for (ILinkEvent event : links) {
drawLink(event, bounds, timeProvider, nameSpace, gc);
}