/*******************************************************************************
- * Copyright (c) 2009 Ericsson
+ * Copyright (c) 2009, 2010 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: Alvaro Sanchez-Leon - Initial implementation
+ * Contributors:
+ * Alvaro Sanchez-Leon - Initial implementation
+ * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
+ * Bernd Hufmann - Bug fixes
*******************************************************************************/
package org.eclipse.linuxtools.lttng.ui.views.controlflow;
-import java.util.Arrays;
import java.util.Vector;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
-import org.eclipse.linuxtools.lttng.state.StateDataRequest;
-import org.eclipse.linuxtools.lttng.state.StateManager;
-import org.eclipse.linuxtools.lttng.state.evProcessor.EventProcessorProxy;
-import org.eclipse.linuxtools.lttng.state.experiment.StateExperimentManager;
-import org.eclipse.linuxtools.lttng.state.experiment.StateManagerFactory;
+import org.eclipse.linuxtools.lttng.core.control.LttngCoreProviderFactory;
+import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.core.request.ILttngSyntEventRequest;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.ITransEventProcessor;
import org.eclipse.linuxtools.lttng.ui.TraceDebug;
+import org.eclipse.linuxtools.lttng.ui.model.trange.ItemContainer;
import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
-import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeViewerProvider;
import org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView;
import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater;
-import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowTRangeUpdateFactory;
+import org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor.FlowEventToHandlerFactory;
import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.signal.TmfRangeSynchSignal;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
+import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowTimeRangeViewerProvider;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Menu;
/**
* <b><u>ControlFlowView</u></b>
- * <p>
- * TODO: Implement me. Please.
*/
/**
* @author alvaro
ITmfTimeSelectionListener, ITmfTimeScaleSelectionListener,
ITmfTimeFilterSelectionListener {
- public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.controlflow";
+ public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.controlflow"; //$NON-NLS-1$
// ========================================================================
// Table data
// ========================================================================
- private final String PROCESS_COLUMN = "Process";
- private final String BRAND_COLUMN = "Brand";
- private final String PID_COLUMN = "PID";
- private final String TGID_COLUMN = "TGID";
- private final String PPID_COLUMN = "PPID";
- private final String CPU_COLUMN = "CPU";
- private final String BIRTH_SEC_COLUMN = "Birth sec";
- private final String BIRTH_NSEC_COLUMN = "Birth nsec";
- private final String TRACE = "TRACE";
+
+ private final String PROCESS_COLUMN = Messages.getString("ControlFlowView.processColumn"); //$NON-NLS-1$
+ private final String BRAND_COLUMN = Messages.getString("ControlFlowView.brandColumn"); //$NON-NLS-1$
+ private final String PID_COLUMN = Messages.getString("ControlFlowView.pidColumn"); //$NON-NLS-1$
+ private final String TGID_COLUMN = Messages.getString("ControlFlowView.tgidColumn"); //$NON-NLS-1$
+ private final String PPID_COLUMN = Messages.getString("ControlFlowView.ppidColumn"); //$NON-NLS-1$
+ private final String CPU_COLUMN = Messages.getString("ControlFlowView.cpuColumn"); //$NON-NLS-1$
+ private final String BIRTH_SEC_COLUMN = Messages.getString("ControlFlowView.birthSecColumn"); //$NON-NLS-1$
+ private final String BIRTH_NSEC_COLUMN = Messages.getString("ControlFlowView.birthNSecColumn"); //$NON-NLS-1$
+ private final String TRACE = Messages.getString("ControlFlowView.TraceNameColumn"); //$NON-NLS-1$
private final String[] columnNames = new String[] { PROCESS_COLUMN, /* */
BRAND_COLUMN,/* */
private Action filterTraces;
private Action zoomIn;
private Action zoomOut;
- private boolean synch = true; // replaced a previous action
+ private Action zoomFilter;
- private ITimeAnalysisViewer tsfviewer;
private ViewProcessFilter tableFilter = null;
private ScrolledComposite scrollFrame = null;
- private Composite wrapper = null;
- private Composite top;
+
+ private TmfTimeRange initTimeRange = TmfTimeRange.Null;
// private static SimpleDateFormat stimeformat = new SimpleDateFormat(
// "yy/MM/dd HH:mm:ss");
cviewer = v;
}
+ @Override
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
this.elements = (ITmfTimeAnalysisEntry[]) newInput;
if (elements != null) {
- TraceDebug
- .debug("Total number of processes provided to Control Flow view: "
- + elements.length);
+ TraceDebug.debug("Total number of processes provided to Control Flow view: " + elements.length); //$NON-NLS-1$
} else {
- TraceDebug.debug("New input = null");
+ TraceDebug.debug("New input = null"); //$NON-NLS-1$
}
}
+ @Override
public void dispose() {
}
cviewer.replace(elements[index], index);
}
- // @Override
+ @Override
public Object[] getElements(Object inputElement) {
- // TODO Auto-generated method stub
return elements;
}
}
- class ViewLabelProvider extends LabelProvider implements
- ITableLabelProvider {
+ class ViewLabelProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
public String getColumnText(Object obj, int index) {
String strRes = ""; //$NON-NLS-1$
LttngTimestamp time;
return strRes;
}
+ @Override
public Image getColumnImage(Object obj, int index) {
return getImage(obj);
}
return false;
}
} else {
- TraceDebug.debug("Unexpected type of filter element received: "
+ TraceDebug.debug("Unexpected type of filter element received: " //$NON-NLS-1$
+ element.toString());
}
// Compare element versus a list of filtered out
* This is a callback that will allow us to create the viewer and initialize
* it.
*/
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.tmf.ui.views.TmfView#createPartControl(org.eclipse
+ * .swt.widgets.Composite)
+ */
@Override
public void createPartControl(Composite parent) {
- top = new Composite(parent, SWT.BORDER);
- top.setLayout(new FillLayout());
-
- scrollFrame = new ScrolledComposite(top, SWT.V_SCROLL | SWT.H_SCROLL);
- scrollFrame.setBounds(top.getClientArea());
-
- wrapper = new Composite(scrollFrame, SWT.NONE);
- scrollFrame.setEnabled(true);
- scrollFrame.setRedraw(true);
+ scrollFrame = new ScrolledComposite(parent, SWT.V_SCROLL);
+
scrollFrame.setExpandVertical(true);
scrollFrame.setExpandHorizontal(true);
- scrollFrame.setContent(wrapper);
scrollFrame.setAlwaysShowScrollBars(true);
- wrapper.setLayout(new FillLayout());
-
- SashForm sash = new SashForm(wrapper, SWT.NONE);
- final Composite tableComposite = new Composite(sash, SWT.NO_SCROLL);
- FillLayout layout = new FillLayout();
- tableComposite.setLayout(layout);
- tableViewer = new TableViewer(tableComposite, SWT.FULL_SELECTION
- | SWT.H_SCROLL);
+
+ SashForm sash = new SashForm(scrollFrame, SWT.NONE);
+ scrollFrame.setContent(sash);
+
+ tableViewer = new TableViewer(sash, SWT.FULL_SELECTION | SWT.H_SCROLL);
tableViewer.setContentProvider(new ViewContentProvider(tableViewer));
tableViewer.setLabelProvider(new ViewLabelProvider());
Table table = tableViewer.getTable();
- tableViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection sel = event.getSelection();
- if (!sel.isEmpty()) {
- Object firstSel = null;
- if (sel instanceof IStructuredSelection) {
- firstSel = ((IStructuredSelection) sel)
- .getFirstElement();
-
- // Make sure the selection is visible
- updateScrollOrigin();
-
- if (firstSel instanceof ITmfTimeAnalysisEntry) {
- ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel;
- tsfviewer.setSelectedTrace(trace);
- }
- }
+ tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection sel = event.getSelection();
+ if (!sel.isEmpty()) {
+ Object firstSel = null;
+ if (sel instanceof IStructuredSelection) {
+ firstSel = ((IStructuredSelection) sel).getFirstElement();
+
+ // Make sure the selection is visible
+ updateScrollOrigin();
+
+ if (firstSel instanceof ITmfTimeAnalysisEntry) {
+ ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) firstSel;
+ tsfviewer.setSelectedTrace(trace);
}
}
+ }
+ }
- /**
- * Make sure the selected item is visible
- */
- private void updateScrollOrigin() {
- Table table = tableViewer.getTable();
- if (table != null && table.getItemCount() > 0) {
- TableItem item = table.getSelection()[0];
- if (item == null) {
- // no selected reference to go up or down
- return;
- }
+ /**
+ * Make sure the selected item is visible
+ */
+ private void updateScrollOrigin() {
+ Table table = tableViewer.getTable();
+ if (table != null && table.getItemCount() > 0) {
+ TableItem item = table.getSelection()[0];
+ if (item == null) {
+ // no selected reference to go up or down
+ return;
+ }
- Rectangle itemRect = item.getBounds();
- int step = itemRect.height;
+ Rectangle itemRect = item.getBounds();
+ int step = itemRect.height;
- // calculate height of horizontal bar
- int hscrolly = 0;
- ScrollBar hbar = scrollFrame.getHorizontalBar();
- if (hbar != null) {
- hscrolly = hbar.getSize().y;
- }
+ // calculate height of horizontal bar
+ int hscrolly = 0;
+ ScrollBar hbar = scrollFrame.getHorizontalBar();
+ if (hbar != null) {
+ hscrolly = hbar.getSize().y;
+ }
- int visibleHeight = scrollFrame.getSize().y
- - hscrolly;
+ int visibleHeight = scrollFrame.getSize().y - hscrolly;
- // the current scrollbar offset to adjust i.e. start
- // of
- // the visible window
- Point origin = scrollFrame.getOrigin();
- // end of visible window
- int endy = origin.y + visibleHeight;
+ // the current scrollbar offset to adjust i.e. start
+ // of
+ // the visible window
+ Point origin = scrollFrame.getOrigin();
+ // end of visible window
+ int endy = origin.y + visibleHeight;
- int itemStartPos = itemRect.y
- + table.getHeaderHeight()
- + table.getBorderWidth()
- + table.getParent().getBorderWidth();
+ int itemStartPos = itemRect.y + table.getHeaderHeight() + table.getBorderWidth()
+ + table.getParent().getBorderWidth();
- // Item End Position
- int itemEndPos = itemStartPos + step;
+ // Item End Position
+ int itemEndPos = itemStartPos + step;
- // check if need to go up
- if (origin.y >= step && itemStartPos < origin.y) {
- // one step up
- scrollFrame
- .setOrigin(origin.x, origin.y - step);
+ // check if need to go up
+ if (origin.y >= step && itemStartPos < origin.y) {
+ // one step up
+ scrollFrame.setOrigin(origin.x, origin.y - step);
- }
+ }
// check if it needs to go down
- if (itemEndPos > endy) {
- // one step down
- scrollFrame
- .setOrigin(origin.x, origin.y + step);
+ if (itemEndPos > endy) {
+ // one step down
+ scrollFrame.setOrigin(origin.x, origin.y + step);
}
- }
- }
- });
-
+ }
+ }
+ });
+
// Listen to page up /down and Home / Enc keys
tableViewer.getTable().addKeyListener(new KeyListener() {
+ @Override
public void keyPressed(KeyEvent e) {
Table table = tableViewer.getTable();
Point origin = scrollFrame.getOrigin();
}
}
+ @Override
public void keyReleased(KeyEvent e) {
// Nothing to do
int borderWidth = table.getBorderWidth();
- int itemHeight = table.getItemHeight();
+ int itemHeight = table.getItemHeight() + getTableItemHeightAdjustement();
int headerHeight = table.getHeaderHeight();
table.getVerticalBar().setVisible(false);
- tsfviewer = TmfViewerFactory.createViewer(sash,
- new TimeRangeViewerProvider());
-
- tsfviewer.addWidgetSelectionListner(this);
- tsfviewer.addWidgetTimeScaleSelectionListner(this);
+ tsfviewer = TmfViewerFactory.createViewer(sash, new FlowTimeRangeViewerProvider(getParamsUpdater()));
// Traces shall not be grouped to allow synchronisation
tsfviewer.groupTraces(false);
hookDoubleClickAction();
contributeToActionBars();
- scrollFrame.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- tsfviewer.resizeControls();
- updateScrolls(scrollFrame, wrapper);
- }
- });
-
- tableComposite.addControlListener(new ControlListener() {
- public void controlResized(ControlEvent e) {
- scrollFrame.getParent().update();
- }
-
- public void controlMoved(ControlEvent e) {
-
- }
- });
-
- // Register the updater in charge to refresh elements as we update the
- // time ranges
- // FlowParamsUpdater listener = FlowModelFactory.getParamsUpdater();
- // tsfviewer.addWidgetTimeScaleSelectionListner(listener);
-
- // Register this view to receive updates when the model is updated with
- // fresh info
- // ModelListenFactory.getRegister().addFlowModelUpdatesListener(this);
-
- // Register the event processor factory in charge of event handling
- EventProcessorProxy.getInstance().addEventProcessorFactory(
- FlowTRangeUpdateFactory.getInstance());
+ // scrollFrame.addControlListener(new ControlAdapter() {
+ //
+ // @Override
+ // public void controlResized(ControlEvent e) {
+ // tsfviewer.resizeControls();
+ // updateScrolls(scrollFrame);
+ // }
+ // });
// set the initial view parameter values
// Experiment start and end time
// as well as time space width in pixels, used by the time analysis
// widget
- ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater();
- StateExperimentManager experimentManger = StateManagerFactory
- .getExperimentManager();
// Read relevant values
int timeSpaceWidth = tsfviewer.getTimeSpace();
- TmfTimeRange timeRange = experimentManger.getExperimentTimeRange();
- if (timeRange != null) {
- long time0 = timeRange.getStartTime().getValue();
- long time1 = timeRange.getEndTime().getValue();
- paramUpdater.update(time0, time1, timeSpaceWidth);
+ if (timeSpaceWidth < 0) {
+ timeSpaceWidth = -timeSpaceWidth;
}
- experimentManger.readExperiment("flowView", this);
+ TmfExperiment<?> experiment = TmfExperiment.getCurrentExperiment();
+ if (experiment != null) {
+ TmfTimeRange experimentTRange = experiment.getTimeRange();
+
+ if (experimentTRange != TmfTimeRange.Null) {
+ // send request and received the adjusted time used
+ TmfTimeRange adjustedTimeRange = initialExperimentDataRequest(this,
+ experimentTRange);
+
+ // initialize widget time boundaries and filtering parameters
+ ModelUpdateInit(experimentTRange, adjustedTimeRange, this);
+ }
+ } else {
+ TraceDebug.debug("No selected experiment information available"); //$NON-NLS-1$
+ }
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
+ @Override
public void menuAboutToShow(IMenuManager manager) {
ControlFlowView.this.fillContextMenu(manager);
}
private void fillLocalPullDown(IMenuManager manager) {
manager.add(new Separator());
- // manager.add(showLegend);
+ manager.add(showLegend);
manager.add(new Separator());
manager.add(resetScale);
manager.add(nextEvent);
// manager.add(filterTraces);
manager.add(zoomIn);
manager.add(zoomOut);
+ manager.add(zoomFilter);
manager.add(new Separator());
}
private void fillContextMenu(IMenuManager manager) {
- // manager.add(showLegend);
+ manager.add(showLegend);
manager.add(new Separator());
manager.add(resetScale);
manager.add(nextEvent);
manager.add(prevEvent);
manager.add(nextTrace);
manager.add(prevTrace);
- // manager.add(showLegend);
+ manager.add(showLegend);
// manager.add(filterTraces);
manager.add(zoomIn);
manager.add(zoomOut);
+ manager.add(zoomFilter);
manager.add(new Separator());
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
private void fillLocalToolBar(IToolBarManager manager) {
- // manager.add(showLegend);
+ manager.add(showLegend);
manager.add(new Separator());
manager.add(resetScale);
manager.add(nextEvent);
// manager.add(filterTraces);
manager.add(zoomIn);
manager.add(zoomOut);
+ manager.add(zoomFilter);
manager.add(new Separator());
}
private void makeActions() {
- // action4
+ // resetScale
resetScale = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.Reset.ToolTip")); //$NON-NLS-1$
resetScale.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/home_nav.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/home_nav.gif")); //$NON-NLS-1$
- // action5
+ // nextEvent
nextEvent = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.NextEvent.Tooltip")); //$NON-NLS-1$
nextEvent.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/next_event.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/next_event.gif")); //$NON-NLS-1$
- // action6
+ // prevEvent
prevEvent = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.PrevEvent.Tooltip")); //$NON-NLS-1$
prevEvent.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/prev_event.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/prev_event.gif")); //$NON-NLS-1$
- // action7
+ // nextTrace
nextTrace = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.NextProcess.ToolTip")); //$NON-NLS-1$
nextTrace.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/next_item.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/next_item.gif")); //$NON-NLS-1$
- // action8
+ // prevTrace
prevTrace = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.PreviousProcess.Tooltip")); //$NON-NLS-1$
prevTrace.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/prev_item.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/prev_item.gif")); //$NON-NLS-1$
- // action9
+ // showLegend
showLegend = new Action() {
@Override
public void run() {
showLegend.setToolTipText(Messages
.getString("ControlFlowView.Action.Legend.ToolTip")); //$NON-NLS-1$
- // action10
+ // filterTraces
filterTraces = new Action() {
@Override
public void run() {
.getString("ControlFlowView.Action.Filter.ToolTip")); //$NON-NLS-1$
filterTraces.setImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(Messages
- .getString("ControlFlowView.tmf.UI"),
- "icons/filter_items.gif"));
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
- // action10
+ // zoomIn
zoomIn = new Action() {
@Override
public void run() {
zoomIn.setToolTipText(Messages
.getString("ControlFlowView.Action.ZoomIn.Tooltip")); //$NON-NLS-1$
zoomIn.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
- Messages.getString("ControlFlowView.tmf.UI"),
- "icons/zoomin_nav.gif"));
+ Messages.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/zoomin_nav.gif")); //$NON-NLS-1$
- // action10
+ // zoomOut
zoomOut = new Action() {
@Override
public void run() {
zoomOut.setToolTipText(Messages
.getString("ControlFlowView.Action.ZoomOut.tooltip")); //$NON-NLS-1$
zoomOut.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
- Messages.getString("ControlFlowView.tmf.UI"),
- "icons/zoomout_nav.gif"));
+ Messages.getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/zoomout_nav.gif")); //$NON-NLS-1$
+
+ // zoomFilter
+ zoomFilter = new Action() {
+ @Override
+ public void run() {
+ // Nothing to do, however the selection status is needed by the
+ // application
+ }
+ };
+ zoomFilter.setText(Messages
+ .getString("ControlFlowView.Action.ZoomFilter")); //$NON-NLS-1$
+ zoomFilter.setToolTipText(Messages
+ .getString("ControlFlowView.Action.ZoomFilter.tooltip")); //$NON-NLS-1$
+ zoomFilter.setImageDescriptor(AbstractUIPlugin
+ .imageDescriptorFromPlugin(Messages
+ .getString("ControlFlowView.tmf.UI"), //$NON-NLS-1$
+ "icons/elcl16/filter_items.gif")); //$NON-NLS-1$
+ zoomFilter.setChecked(false);
- // action11
// PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_SYNCED);
doubleClickAction = new Action() {
private void hookDoubleClickAction() {
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
+ @Override
public void doubleClick(DoubleClickEvent event) {
doubleClickAction.run();
}
tableViewer.getControl().setFocus();
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
+ * tsfTmProcessSelEvent
+ * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent
+ * )
+ */
+ @Override
public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) {
- Object source = event.getSource();
- if (source == null) {
- return;
- }
+ // common implementation
+ super.tsfTmProcessSelEvent(event);
// Reselect the table viewer to widget selection
ISelection sel = tsfviewer.getSelectionTrace();
if (sel != null && !sel.isEmpty()) {
tableViewer.setSelection(sel);
}
-
- ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater();
- Long savedSelTime = paramUpdater.getSelectedTime();
-
- long selTimens = event.getSelectedTime();
-
- // make sure the new selected time is different than saved before
- // executing update
- if (savedSelTime == null || savedSelTime != selTimens) {
- // Notify listener views.
- synchTimeNotification(selTimens, source);
-
- // Update the parameter updater to save the selected time
- paramUpdater.setSelectedTime(selTimens);
-
- if (TraceDebug.isDEBUG()) {
- // Object selection = event.getSelection();
- TraceDebug.debug("Selected Time in control Flow View: "
- + new LttngTimestamp(selTimens));
- }
- }
- }
-
- public synchronized void tsfTmProcessTimeScaleEvent(
- TmfTimeScaleSelectionEvent event) {
- // source needed to keep track of source values
- Object source = event.getSource();
-
- if (source != null) {
- // Update the parameter updater before carrying out a read request
- ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater();
- boolean newParams = paramUpdater.processTimeScaleEvent(event);
-
- if (newParams) {
- // Read the updated time window
- TmfTimeRange trange = paramUpdater.getTrange();
- if (trange != null) {
-
- // Notify listener views. views to perform data requests
- // upon the notification below
- synchTimeRangeNotification(trange, paramUpdater
- .getSelectedTime(), source);
- }
- }
- }
}
- /**
- * Obtains the remainder fraction on unit Seconds of the entered value in
- * nanoseconds. e.g. input: 1241207054171080214 ns The number of seconds can
- * be obtain by removing the last 9 digits: 1241207054 the fractional
- * portion of seconds, expressed in ns is: 171080214
+ /*
+ * (non-Javadoc)
*
- * @param v
- * @return
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.
+ * ITmfTimeScaleSelectionListener
+ * #tsfTmProcessTimeScaleEvent(org.eclipse.linuxtools
+ * .tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent)
*/
- public String formatNs(long v) {
- StringBuffer str = new StringBuffer();
- boolean neg = v < 0;
- if (neg) {
- v = -v;
- str.append('-');
- }
-
- String strVal = String.valueOf(v);
- if (v < 1000000000) {
- return strVal;
- }
-
- // Extract the last nine digits (e.g. fraction of a S expressed in ns
- return strVal.substring(strVal.length() - 9);
+ @Override
+ public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) {
+ super.tsfTmProcessTimeScaleEvent(event);
}
private void applyTableLayout(Table table) {
table.setLinesVisible(true);
}
- /**
- * @param items
- * @param startTime
- * @param endTime
- * @param updateTimeBounds - Update needed e.g. a new Experiment or trace selected
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#displayModel
+ * (org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.
+ * ITmfTimeAnalysisEntry[], long, long, boolean, long, long,
+ * java.lang.Object)
*/
- public void flowModelUpdates(final ITmfTimeAnalysisEntry[] items,
- final long startTime, final long endTime,
- final boolean updateTimeBounds) {
- final Table table = tableViewer.getTable();
- Display display = table.getDisplay();
-
- // Perform the updates on the UI thread)
- display.asyncExec(new Runnable() {
- public void run() {
-
- tableViewer.setInput(items); // This shall be the minimal
- // initial
- tableFilter = new ViewProcessFilter(tableViewer);
- tableViewer.setFilters(new ViewerFilter[] { tableFilter });
-
- resizeTableColumns(table);
- table.update();
- tableViewer.refresh();
+ @Override
+ public void displayModel(final ITmfTimeAnalysisEntry[] items,
+ final long startBoundTime, final long endBoundTime,
+ final boolean updateTimeBounds, final long startVisibleWindow,
+ final long endVisibleWindow, final Object source) {
+
+ if(tableViewer != null) {
+ final Table table = tableViewer.getTable();
+
+ // Ignore update if widget is disposed
+ if (table.isDisposed()) return;
+
+ Display display = table.getDisplay();
- tsfviewer.display(items, startTime, endTime, updateTimeBounds);
- tsfviewer.resizeControls();
+ // Perform the updates on the UI thread)
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (!table.isDisposed()) {
+ tableViewer.setInput(items); // This shall be the minimal
+ // initial
+ tableFilter = new ViewProcessFilter(tableViewer);
+ tableViewer.setFilters(new ViewerFilter[] { tableFilter });
+
+ resizeTableColumns(table);
+ table.update();
+ tableViewer.refresh();
+
+ tsfviewer.display(items, startBoundTime, endBoundTime,
+ updateTimeBounds);
+
+ // validate visible boundaries
+ if (startVisibleWindow > -1 && endVisibleWindow > -1) {
+ tsfviewer.setSelectVisTimeWindow(startVisibleWindow,
+ endVisibleWindow, source);
+ }
- // Adjust the size of the vertical scroll bar to fit the
- // contents
- if (scrollFrame != null && wrapper != null) {
- updateScrolls(scrollFrame, wrapper);
- // scrollFrame.update();
+ tsfviewer.resizeControls();
+
+ // Adjust asynchronously the size of the vertical scroll bar to fit the
+ // contents
+ tableViewer.getTable().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if ((scrollFrame != null) && (!scrollFrame.isDisposed())) {
+ updateScrolls(scrollFrame);
+ }
+ }
+ });
+ }
}
- }
- });
+ });
+ }
}
@Override
public void dispose() {
// dispose parent resources
super.dispose();
- // Remove the event processor factory
- EventProcessorProxy.getInstance().removeEventProcessorFactory(
- FlowTRangeUpdateFactory.getInstance());
- // Remove listener to model updates
- // ModelListenFactory.getRegister().removeFlowModelUpdatesListener(this);
tsfviewer.removeFilterSelectionListner(this);
tsfviewer.removeWidgetSelectionListner(this);
tsfviewer.removeWidgetTimeScaleSelectionListner(this);
*/
private synchronized void resizeTableColumns(Table table) {
if (table != null) {
- Composite parent = table.getParent();
- int tableWidthSum = parent.getBorderWidth();
-
TableColumn[] columns = table.getColumns();
for (TableColumn column : columns) {
column.pack();
- tableWidthSum += column.getWidth();
}
}
}
- // @Override
+ @Override
public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event) {
if (tableFilter != null) {
Vector<ITmfTimeAnalysisEntry> filteredout = event.getFilteredOut();
* @param scrollFrame
* @param wrapper
*/
- private void updateScrolls(final ScrolledComposite scrollFrame,
- final Composite wrapper) {
-
- Point ptSize = wrapper.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- wrapper.setSize(ptSize);
- scrollFrame.setMinSize(ptSize);
-
- // calculate the increment area considering the table header height and
- // borders
- Rectangle area = top.getBounds();
- int marginsHeight = tableViewer.getTable().getHeaderHeight();
- marginsHeight -= top.getBorderWidth() + wrapper.getBorderWidth();
- area.height -= marginsHeight;
-
- // set page vertical increment area
- ScrollBar verBar = scrollFrame.getVerticalBar();
- ScrollBar horBar = scrollFrame.getHorizontalBar();
- if (verBar != null) {
- verBar.setPageIncrement(area.height);
- }
- if (horBar != null) {
- horBar.setPageIncrement(area.width);
- }
-
+ private void updateScrolls(final ScrolledComposite scrollFrame) {
+ scrollFrame.setMinSize(tableViewer.getTable().computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
/**
- * Trigger time synchronisation to other views this method shall be called
- * when a check has been performed to note that an actual change of time has
- * been performed vs a pure re-selection of the same time
+ * Registers as listener of time selection from other views
*
- * @param time
- * @param source
+ * @param signal
*/
- private void synchTimeNotification(long time, Object source) {
- // if synchronisation selected
- if (synch) {
- // Notify other views
- TmfSignalManager.dispatchSignal(new TmfTimeSynchSignal(source,
- new LttngTimestamp(time)));
- }
+ @Override
+ @TmfSignalHandler
+ public void synchToTime(TmfTimeSynchSignal signal) {
+ super.synchToTime(signal);
}
/**
- * Trigger time range synchronisation to other views this method shall be
- * called when a check has been performed to note that an actual change of
- * time range has been performed vs a pure re-selection of the same.
+ * Annotation Registers as listener of time range selection from other views
+ * The implementation handles the entry of the signal.
*
- * @param trange
- * @param source
+ * @param signal
*/
- private void synchTimeRangeNotification(TmfTimeRange trange,
- Long selectedTime, Object source) {
- // if synchronisation selected
- if (synch) {
- // Notify other views
- TmfSignalManager.dispatchSignal(new TmfRangeSynchSignal(source,
- trange, new LttngTimestamp(selectedTime)));
+ @TmfSignalHandler
+ public void synchToTimeRange(TmfRangeSynchSignal signal) {
+ if (zoomFilter != null) {
+ synchToTimeRange(signal, zoomFilter.isChecked());
}
}
- /**
- * Registers as listener of time selection from other views
+ @Override
+ public void modelIncomplete(ILttngSyntEventRequest request) {
+ // Nothing to do
+ // The data will be refreshed on the next request
+ }
+
+ /*
+ * (non-Javadoc)
*
+ * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
+ * getEventProcessor()
+ */
+ @Override
+ public ITransEventProcessor getEventProcessor() {
+ return FlowEventToHandlerFactory.getInstance();
+ }
+
+ /**
* @param signal
*/
@TmfSignalHandler
- public void synchToTime(TmfTimeSynchSignal signal) {
- if (synch) {
- Object source = signal.getSource();
- if (signal != null && source != null && source != this) {
- // Internal value is expected in nano seconds.
- long selectedTime = signal.getCurrentTime().getValue();
- if (tsfviewer != null) {
- tsfviewer.setSelectedTime(selectedTime, true, source);
- }
+ public void experimentSelected(
+ TmfExperimentSelectedSignal<? extends TmfEvent> signal) {
+ if (signal != null) {
+ TmfTimeRange experimentTRange = signal.getExperiment()
+ .getTimeRange();
+
+ initTimeRange = TmfTimeRange.Null;
+ if (experimentTRange != TmfTimeRange.Null) {
+ // prepare time intervals in widget
+ ModelUpdateInit(experimentTRange, experimentTRange, signal
+ .getSource());
+
+ // request initial data
+ initialExperimentDataRequest(signal
+ .getSource(), experimentTRange);
}
}
}
- /**
- * Annotation Registers as listener of time range selection from other views
- * The implementation handles the entry of the signal.
- *
- * @param signal
- */
@TmfSignalHandler
- public void synchToTimeRange(TmfRangeSynchSignal signal) {
- if (synch) {
- Object source = signal.getSource();
- if (signal != null && source != null && source != this) {
- // Internal value is expected in nano seconds.
- TmfTimeRange trange = signal.getCurrentRange();
- if (tsfviewer != null) {
- tsfviewer
- .setSelectVisTimeWindow(trange.getStartTime()
- .getValue(),
- trange.getEndTime().getValue(), source);
+ public void experimentRangeUpdated(TmfExperimentRangeUpdatedSignal signal) {
+ if (initTimeRange == TmfTimeRange.Null && signal.getExperiment().equals(TmfExperiment.getCurrentExperiment())) {
+ TmfTimeRange experimentTRange = signal.getRange();
- // Request the data to populate the new selected time window
- dataRequest(trange);
- }
+ if (experimentTRange != TmfTimeRange.Null) {
+ // prepare time intervals in widget
+ ModelUpdateInit(experimentTRange, experimentTRange, signal.getSource());
+
+ // request initial data
+ initialExperimentDataRequest(signal.getSource(), experimentTRange);
}
}
}
+
+ /**
+ * @param source
+ * @param experimentTRange
+ * @return Adjusted time window used for the request (smaller window to
+ * initialize view)
+ */
+ private TmfTimeRange initialExperimentDataRequest(Object source,
+ TmfTimeRange experimentTRange) {
+ // Adjust the initial time window to a shorter interval to allow
+ // user to select the interesting area based on the perspective
+ TmfTimeRange initTimeWindow = getInitTRange(experimentTRange);
+
+ eventRequest(initTimeWindow, experimentTRange, true, ExecutionType.FOREGROUND);
+ if (TraceDebug.isDEBUG()) {
+ TraceDebug.debug("Initialization request time range is: " //$NON-NLS-1$
+ + initTimeWindow.getStartTime().toString() + "-" //$NON-NLS-1$
+ + initTimeWindow.getEndTime().toString());
+ }
+
+ initTimeRange = initTimeWindow;
+ return initTimeWindow;
+ }
+
/*
- * (non-Javadoc)
+ * SWT doesn't seem to report correctly the table item height, at least in
+ * the case of KDE.
*
- * @see
- * org.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#waitCursor
- * (boolean)
+ * This method provides an adjustment term according to the desktop session.
+ *
+ * @return Height adjustment
*/
- @Override
- protected synchronized void waitCursor(final boolean waitInd) {
- if (tsfviewer != null) {
- Display display = tsfviewer.getControl().getDisplay();
-
- // Perform the updates on the UI thread
- display.asyncExec(new Runnable() {
- public void run() {
- tsfviewer.waitCursor(waitInd);
- }
- });
+ private int getTableItemHeightAdjustement() {
+ int ajustement = 0;
+ String desktopSession = System.getenv("DESKTOP_SESSION"); //$NON-NLS-1$
+
+ if (desktopSession != null) {
+ if (desktopSession.equals("kde")) { //$NON-NLS-1$
+ ajustement = 2;
+ }
}
+
+ return ajustement;
}
/*
* (non-Javadoc)
*
- * @seeorg.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
- * ModelUpdatePrep(java.lang.String, boolean)
+ * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
+ * getParamsUpdater()
*/
@Override
- public void ModelUpdatePrep(String traceId, boolean clearAllData,
- TmfTimeRange trange) {
- if (clearAllData) {
- FlowModelFactory.getProcContainer().clearProcesses();
- // Obtain the current process array
- TimeRangeEventProcess[] processArr = FlowModelFactory
- .getProcContainer().readProcesses();
-
-
- // initialise to an empty model
- flowModelUpdates(processArr, -1, -1, false);
- } else {
- FlowModelFactory.getProcContainer().clearChildren(traceId);
- }
-
- ParamsUpdater updater = FlowModelFactory.getParamsUpdater();
- // Start over
- updater.setEventsDiscarded(0);
-
- // Update new visible time range if available
- if (trange != null) {
- updater.update(trange.getStartTime().getValue(), trange
- .getEndTime().getValue());
- }
+ protected ParamsUpdater getParamsUpdater() {
+ return FlowModelFactory.getParamsUpdater();
}
/*
* (non-Javadoc)
*
- * @seeorg.eclipse.linuxtools.lttng.ui.views.common.LttngTimeUpdateView#
- * ModelUpdateComplete(org.eclipse.linuxtools.lttng.state.StateDataRequest)
+ * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#
+ * getItemContainer()
*/
@Override
- public void ModelUpdateComplete(StateDataRequest request) {
- long experimentStartTime = -1;
- long experimentEndTime = -1;
- StateManager smanager = request.getStateManager();
- TmfTimeRange experimentTimeRange = smanager.getExperimentTimeWindow();
- if (experimentTimeRange != null) {
- experimentStartTime = experimentTimeRange.getStartTime().getValue();
- experimentEndTime = experimentTimeRange.getEndTime().getValue();
- }
- // Obtain the current process array
- TimeRangeEventProcess[] processArr = FlowModelFactory
- .getProcContainer().readProcesses();
- // Sort the array by pid
- Arrays.sort(processArr);
-
- // Update the view part
- flowModelUpdates(processArr, experimentStartTime, experimentEndTime,
- request.isclearDataInd());
-
- // get back to user selected time if still within range
- ParamsUpdater paramUpdater = FlowModelFactory.getParamsUpdater();
- final Long selTime = paramUpdater.getSelectedTime();
- if (selTime != null) {
- Display display = tsfviewer.getControl().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- tsfviewer.setSelectedTime(selTime, false, this);
- }
- });
- }
-
- if (TraceDebug.isDEBUG()) {
- int eventCount = 0;
- Long count = smanager.getEventCount();
- for ( int pos = 0; pos<processArr.length; pos++ ) {
- eventCount += processArr[pos].getTraceEvents().size();
- }
+ protected ItemContainer<?> getItemContainer() {
+ return FlowModelFactory.getProcContainer();
+ }
- int discarded = FlowModelFactory.getParamsUpdater()
- .getEventsDiscarded();
- int discardedOutofOrder = FlowModelFactory.getParamsUpdater()
- .getEventsDiscardedWrongOrder();
- TmfTimeRange range = request.getRange();
- StringBuilder sb = new StringBuilder(
- "Events handled: "
- + count
- + " Events loaded in Control Flow view: "
- + eventCount
- + " Number of events discarded: "
- + discarded
- + "\n\tNumber of events discarded with start time earlier than next good time: "
- + discardedOutofOrder);
-
- sb.append("\n\t\tRequested Time Range: " + range.getStartTime()
- + "-" + range.getEndTime());
- sb.append("\n\t\tExperiment Time Range: " + experimentStartTime
- + "-" + experimentEndTime);
- TraceDebug.debug(sb.toString());
- }
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.lttng.ui.views.common.AbsTimeUpdateView#getProviderId()
+ */
+ @Override
+ protected int getProviderId() {
+ return LttngCoreProviderFactory.CONTROL_FLOW_LTTNG_SYTH_EVENT_PROVIDER;
}
}
\ No newline at end of file