1 /*******************************************************************************
2 * Copyright (c) 2010, 2011, 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Factored out from events view
12 * Francois Chouinard - Replaced Table by TmfVirtualTable
13 * Patrick Tasse - Filter implementation (inspired by www.eclipse.org/mat)
14 * Ansgar Radermacher - Support navigation to model URIs (Bug 396956)
15 *******************************************************************************/
17 package org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
;
19 import java
.io
.FileNotFoundException
;
20 import java
.util
.ArrayList
;
21 import java
.util
.Arrays
;
22 import java
.util
.HashMap
;
23 import java
.util
.List
;
25 import java
.util
.Map
.Entry
;
26 import java
.util
.regex
.Pattern
;
27 import java
.util
.regex
.PatternSyntaxException
;
29 import org
.eclipse
.core
.resources
.IFile
;
30 import org
.eclipse
.core
.resources
.IMarker
;
31 import org
.eclipse
.core
.resources
.IResource
;
32 import org
.eclipse
.core
.resources
.IResourceVisitor
;
33 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
34 import org
.eclipse
.core
.runtime
.CoreException
;
35 import org
.eclipse
.core
.runtime
.IPath
;
36 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
37 import org
.eclipse
.core
.runtime
.IStatus
;
38 import org
.eclipse
.core
.runtime
.ListenerList
;
39 import org
.eclipse
.core
.runtime
.Path
;
40 import org
.eclipse
.core
.runtime
.Status
;
41 import org
.eclipse
.core
.runtime
.jobs
.Job
;
42 import org
.eclipse
.emf
.common
.util
.URI
;
43 import org
.eclipse
.emf
.ecore
.EValidator
;
44 import org
.eclipse
.jface
.action
.Action
;
45 import org
.eclipse
.jface
.action
.IAction
;
46 import org
.eclipse
.jface
.action
.IMenuListener
;
47 import org
.eclipse
.jface
.action
.IMenuManager
;
48 import org
.eclipse
.jface
.action
.MenuManager
;
49 import org
.eclipse
.jface
.action
.Separator
;
50 import org
.eclipse
.jface
.dialogs
.InputDialog
;
51 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
52 import org
.eclipse
.jface
.resource
.FontDescriptor
;
53 import org
.eclipse
.jface
.resource
.JFaceResources
;
54 import org
.eclipse
.jface
.resource
.LocalResourceManager
;
55 import org
.eclipse
.jface
.util
.OpenStrategy
;
56 import org
.eclipse
.jface
.util
.SafeRunnable
;
57 import org
.eclipse
.jface
.viewers
.ArrayContentProvider
;
58 import org
.eclipse
.jface
.viewers
.ISelection
;
59 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
60 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
61 import org
.eclipse
.jface
.viewers
.LabelProvider
;
62 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
63 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
64 import org
.eclipse
.jface
.window
.Window
;
65 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
66 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
67 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.dialogs
.MultiLineInputDialog
;
68 import org
.eclipse
.linuxtools
.tmf
.core
.component
.ITmfDataProvider
;
69 import org
.eclipse
.linuxtools
.tmf
.core
.component
.TmfComponent
;
70 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfConstants
;
71 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfCallsite
;
72 import org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
.CtfTmfEvent
;
73 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
74 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
75 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventField
;
76 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.ITmfFilter
;
77 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.ITmfFilterTreeNode
;
78 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterAndNode
;
79 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterMatchesNode
;
80 import org
.eclipse
.linuxtools
.tmf
.core
.filter
.model
.TmfFilterNode
;
81 import org
.eclipse
.linuxtools
.tmf
.core
.request
.ITmfDataRequest
.ExecutionType
;
82 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfDataRequest
;
83 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEventFilterAppliedSignal
;
84 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEventSearchAppliedSignal
;
85 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
86 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
87 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceUpdatedSignal
;
88 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
89 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
90 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
91 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
92 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
93 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsCache
.CachedEvent
;
94 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.ColorSetting
;
95 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.ColorSettingsManager
;
96 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.colors
.IColorSettingsListener
;
97 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.filter
.FilterManager
;
98 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.rawviewer
.TmfRawEventViewer
;
99 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.virtualtable
.ColumnData
;
100 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.virtualtable
.TmfVirtualTable
;
101 import org
.eclipse
.swt
.SWT
;
102 import org
.eclipse
.swt
.custom
.SashForm
;
103 import org
.eclipse
.swt
.custom
.TableEditor
;
104 import org
.eclipse
.swt
.events
.FocusAdapter
;
105 import org
.eclipse
.swt
.events
.FocusEvent
;
106 import org
.eclipse
.swt
.events
.KeyAdapter
;
107 import org
.eclipse
.swt
.events
.KeyEvent
;
108 import org
.eclipse
.swt
.events
.MouseAdapter
;
109 import org
.eclipse
.swt
.events
.MouseEvent
;
110 import org
.eclipse
.swt
.events
.SelectionAdapter
;
111 import org
.eclipse
.swt
.events
.SelectionEvent
;
112 import org
.eclipse
.swt
.graphics
.Color
;
113 import org
.eclipse
.swt
.graphics
.Font
;
114 import org
.eclipse
.swt
.graphics
.Image
;
115 import org
.eclipse
.swt
.graphics
.Point
;
116 import org
.eclipse
.swt
.graphics
.Rectangle
;
117 import org
.eclipse
.swt
.layout
.FillLayout
;
118 import org
.eclipse
.swt
.layout
.GridData
;
119 import org
.eclipse
.swt
.layout
.GridLayout
;
120 import org
.eclipse
.swt
.widgets
.Composite
;
121 import org
.eclipse
.swt
.widgets
.Display
;
122 import org
.eclipse
.swt
.widgets
.Event
;
123 import org
.eclipse
.swt
.widgets
.Label
;
124 import org
.eclipse
.swt
.widgets
.Listener
;
125 import org
.eclipse
.swt
.widgets
.Menu
;
126 import org
.eclipse
.swt
.widgets
.MessageBox
;
127 import org
.eclipse
.swt
.widgets
.Shell
;
128 import org
.eclipse
.swt
.widgets
.TableColumn
;
129 import org
.eclipse
.swt
.widgets
.TableItem
;
130 import org
.eclipse
.swt
.widgets
.Text
;
131 import org
.eclipse
.ui
.IWorkbenchPage
;
132 import org
.eclipse
.ui
.PartInitException
;
133 import org
.eclipse
.ui
.PlatformUI
;
134 import org
.eclipse
.ui
.dialogs
.ListDialog
;
135 import org
.eclipse
.ui
.ide
.IDE
;
136 import org
.eclipse
.ui
.ide
.IGotoMarker
;
137 import org
.eclipse
.ui
.themes
.ColorUtil
;
140 * The generic TMF Events table
142 * This is a view that will list events that are read from a trace.
145 * @author Francois Chouinard
146 * @author Patrick Tasse
149 public class TmfEventsTable
extends TmfComponent
implements IGotoMarker
, IColorSettingsListener
, ISelectionProvider
{
151 private static final Image BOOKMARK_IMAGE
= Activator
.getDefault().getImageFromPath(
152 "icons/elcl16/bookmark_obj.gif"); //$NON-NLS-1$
153 private static final Image SEARCH_IMAGE
= Activator
.getDefault().getImageFromPath("icons/elcl16/search.gif"); //$NON-NLS-1$
154 private static final Image SEARCH_MATCH_IMAGE
= Activator
.getDefault().getImageFromPath(
155 "icons/elcl16/search_match.gif"); //$NON-NLS-1$
156 private static final Image SEARCH_MATCH_BOOKMARK_IMAGE
= Activator
.getDefault().getImageFromPath(
157 "icons/elcl16/search_match_bookmark.gif"); //$NON-NLS-1$
158 private static final Image FILTER_IMAGE
= Activator
.getDefault()
159 .getImageFromPath("icons/elcl16/filter_items.gif"); //$NON-NLS-1$
160 private static final Image STOP_IMAGE
= Activator
.getDefault().getImageFromPath("icons/elcl16/stop.gif"); //$NON-NLS-1$
161 private static final String SEARCH_HINT
= Messages
.TmfEventsTable_SearchHint
;
162 private static final String FILTER_HINT
= Messages
.TmfEventsTable_FilterHint
;
163 private static final int MAX_CACHE_SIZE
= 1000;
166 * The events table search/filter keys
169 * @author Patrick Tasse
171 public interface Key
{
173 String SEARCH_TXT
= "$srch_txt"; //$NON-NLS-1$
176 String SEARCH_OBJ
= "$srch_obj"; //$NON-NLS-1$
179 String FILTER_TXT
= "$fltr_txt"; //$NON-NLS-1$
182 String FILTER_OBJ
= "$fltr_obj"; //$NON-NLS-1$
185 String TIMESTAMP
= "$time"; //$NON-NLS-1$
188 String RANK
= "$rank"; //$NON-NLS-1$
191 String FIELD_ID
= "$field_id"; //$NON-NLS-1$
193 /** Bookmark indicator */
194 String BOOKMARK
= "$bookmark"; //$NON-NLS-1$
198 * The events table search/filter state
201 * @author Patrick Tasse
203 public static enum HeaderState
{
204 /** A search is being run */
207 /** A filter is applied */
211 interface Direction
{
216 // ------------------------------------------------------------------------
218 // ------------------------------------------------------------------------
220 /** The virtual event table */
221 protected TmfVirtualTable fTable
;
223 private Composite fComposite
;
224 private SashForm fSashForm
;
225 private TmfRawEventViewer fRawViewer
;
226 private ITmfTrace fTrace
;
227 private boolean fPackDone
= false;
228 private HeaderState fHeaderState
= HeaderState
.SEARCH
;
229 private long fSelectedRank
= 0;
232 private long fFilterMatchCount
;
233 private long fFilterCheckCount
;
234 private FilterThread fFilterThread
;
235 private boolean fFilterThreadResume
= false;
236 private final Object fFilterSyncObj
= new Object();
237 private SearchThread fSearchThread
;
238 private final Object fSearchSyncObj
= new Object();
241 * List of selection change listeners (element type: <code>ISelectionChangedListener</code>).
243 * @see #fireSelectionChanged
245 private ListenerList selectionChangedListeners
= new ListenerList();
247 // Bookmark map <Rank, MarkerId>
248 private Map
<Long
, Long
> fBookmarksMap
= new HashMap
<Long
, Long
>();
249 private IFile fBookmarksFile
;
250 private long fPendingGotoRank
= -1;
253 private LocalResourceManager fResourceManager
= new LocalResourceManager(JFaceResources
.getResources());
254 private Color fGrayColor
;
255 private Color fGreenColor
;
256 private Font fBoldFont
;
258 // Table column names
259 private static final String
[] COLUMN_NAMES
= new String
[] { Messages
.TmfEventsTable_TimestampColumnHeader
,
260 Messages
.TmfEventsTable_SourceColumnHeader
, Messages
.TmfEventsTable_TypeColumnHeader
,
261 Messages
.TmfEventsTable_ReferenceColumnHeader
, Messages
.TmfEventsTable_ContentColumnHeader
};
263 private static final ColumnData
[] COLUMN_DATA
= new ColumnData
[] { new ColumnData(COLUMN_NAMES
[0], 100, SWT
.LEFT
),
264 new ColumnData(COLUMN_NAMES
[1], 100, SWT
.LEFT
), new ColumnData(COLUMN_NAMES
[2], 100, SWT
.LEFT
),
265 new ColumnData(COLUMN_NAMES
[3], 100, SWT
.LEFT
), new ColumnData(COLUMN_NAMES
[4], 100, SWT
.LEFT
) };
268 private final TmfEventsCache fCache
;
269 private boolean fCacheUpdateBusy
= false;
270 private boolean fCacheUpdatePending
= false;
271 private boolean fCacheUpdateCompleted
= false;
272 private final Object fCacheUpdateSyncObj
= new Object();
274 private boolean fDisposeOnClose
;
276 // ------------------------------------------------------------------------
278 // ------------------------------------------------------------------------
281 * Basic constructor, will use default column data.
284 * The parent composite UI object
286 * The size of the event table cache
288 public TmfEventsTable(final Composite parent
, final int cacheSize
) {
289 this(parent
, cacheSize
, COLUMN_DATA
);
293 * Advanced constructor, where we also define which column data to use.
296 * The parent composite UI object
298 * The size of the event table cache
300 * The column data to use for this table
302 public TmfEventsTable(final Composite parent
, int cacheSize
, final ColumnData
[] columnData
) {
303 super("TmfEventsTable"); //$NON-NLS-1$
305 fComposite
= new Composite(parent
, SWT
.NONE
);
306 final GridLayout gl
= new GridLayout(1, false);
309 gl
.verticalSpacing
= 0;
310 fComposite
.setLayout(gl
);
312 fSashForm
= new SashForm(fComposite
, SWT
.HORIZONTAL
);
313 fSashForm
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
315 // Create a virtual table
316 final int style
= SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.SINGLE
| SWT
.FULL_SELECTION
;
317 fTable
= new TmfVirtualTable(fSashForm
, style
);
319 // Set the table layout
320 final GridData layoutData
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
321 fTable
.setLayoutData(layoutData
);
323 // Some cosmetic enhancements
324 fTable
.setHeaderVisible(true);
325 fTable
.setLinesVisible(true);
328 setColumnHeaders(columnData
);
330 // Set the default column field ids if this is not a subclass
331 if (Arrays
.equals(columnData
, COLUMN_DATA
)) {
332 fTable
.getColumns()[0].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_TIMESTAMP
);
333 fTable
.getColumns()[1].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_SOURCE
);
334 fTable
.getColumns()[2].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_TYPE
);
335 fTable
.getColumns()[3].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_REFERENCE
);
336 fTable
.getColumns()[4].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_CONTENT
);
339 // Set the frozen row for header row
340 fTable
.setFrozenRowCount(1);
342 // Create the header row cell editor
343 createHeaderEditor();
345 // Handle the table item selection
346 fTable
.addSelectionListener(new SelectionAdapter() {
348 public void widgetSelected(final SelectionEvent e
) {
349 final TableItem
[] selection
= fTable
.getSelection();
350 if (selection
.length
> 0) {
351 final TableItem selectedTableItem
= selection
[0];
352 if (selectedTableItem
!= null) {
353 if (selectedTableItem
.getData(Key
.RANK
) instanceof Long
) {
354 fSelectedRank
= (Long
) selectedTableItem
.getData(Key
.RANK
);
355 fRawViewer
.selectAndReveal((Long
) selectedTableItem
.getData(Key
.RANK
));
357 if (selectedTableItem
.getData(Key
.TIMESTAMP
) instanceof TmfTimestamp
) {
358 final TmfTimestamp ts
= (TmfTimestamp
) selectedTableItem
.getData(Key
.TIMESTAMP
);
359 broadcast(new TmfTimeSynchSignal(TmfEventsTable
.this, ts
));
363 fireSelectionChanged(new SelectionChangedEvent(TmfEventsTable
.this, getSelection()));
367 int realCacheSize
= Math
.max(cacheSize
, Display
.getDefault().getBounds().height
/ fTable
.getItemHeight());
368 realCacheSize
= Math
.min(realCacheSize
, MAX_CACHE_SIZE
);
369 fCache
= new TmfEventsCache(realCacheSize
, this);
371 // Handle the table item requests
372 fTable
.addListener(SWT
.SetData
, new Listener() {
375 public void handleEvent(final Event event
) {
377 final TableItem item
= (TableItem
) event
.item
;
378 int index
= event
.index
- 1; // -1 for the header row
380 if (event
.index
== 0) {
381 setHeaderRowItemData(item
);
385 if (fTable
.getData(Key
.FILTER_OBJ
) != null) {
386 if ((event
.index
== 1) || (event
.index
== (fTable
.getItemCount() - 1))) {
387 setFilterStatusRowItemData(item
);
390 index
= index
- 1; // -1 for top filter status row
393 final CachedEvent cachedEvent
= fCache
.getEvent(index
);
394 if (cachedEvent
!= null) {
395 setItemData(item
, cachedEvent
.event
, cachedEvent
.rank
);
399 // Else, fill the cache asynchronously (and off the UI thread)
404 fTable
.addMouseListener(new MouseAdapter() {
406 public void mouseDoubleClick(final MouseEvent event
) {
407 if (event
.button
!= 1) {
410 // Identify the selected row
411 final Point point
= new Point(event
.x
, event
.y
);
412 final TableItem item
= fTable
.getItem(point
);
414 final Rectangle imageBounds
= item
.getImageBounds(0);
415 imageBounds
.width
= BOOKMARK_IMAGE
.getBounds().width
;
416 if (imageBounds
.contains(point
)) {
417 final Long rank
= (Long
) item
.getData(Key
.RANK
);
419 toggleBookmark(rank
);
426 final Listener tooltipListener
= new Listener () {
427 Shell tooltipShell
= null;
429 public void handleEvent(final Event event
) {
430 switch (event
.type
) {
432 final TableItem item
= fTable
.getItem(new Point(event
.x
, event
.y
));
436 final Long rank
= (Long
) item
.getData(Key
.RANK
);
440 final String tooltipText
= (String
) item
.getData(Key
.BOOKMARK
);
441 final Rectangle bounds
= item
.getImageBounds(0);
442 bounds
.width
= BOOKMARK_IMAGE
.getBounds().width
;
443 if (!bounds
.contains(event
.x
,event
.y
)) {
446 if ((tooltipShell
!= null) && !tooltipShell
.isDisposed()) {
447 tooltipShell
.dispose();
449 tooltipShell
= new Shell(fTable
.getShell(), SWT
.ON_TOP
| SWT
.NO_FOCUS
| SWT
.TOOL
);
450 tooltipShell
.setBackground(PlatformUI
.getWorkbench().getDisplay().getSystemColor(SWT
.COLOR_INFO_BACKGROUND
));
451 final FillLayout layout
= new FillLayout();
452 layout
.marginWidth
= 2;
453 tooltipShell
.setLayout(layout
);
454 final Label label
= new Label(tooltipShell
, SWT
.WRAP
);
455 String text
= rank
.toString() + (tooltipText
!= null ?
": " + tooltipText
: ""); //$NON-NLS-1$ //$NON-NLS-2$
456 label
.setForeground(PlatformUI
.getWorkbench().getDisplay().getSystemColor(SWT
.COLOR_INFO_FOREGROUND
));
457 label
.setBackground(PlatformUI
.getWorkbench().getDisplay().getSystemColor(SWT
.COLOR_INFO_BACKGROUND
));
459 label
.addListener(SWT
.MouseExit
, this);
460 label
.addListener(SWT
.MouseDown
, this);
461 label
.addListener(SWT
.MouseWheel
, this);
462 final Point size
= tooltipShell
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
464 * Bug in Linux. The coordinates of the event have an origin that excludes the table header but
465 * the method toDisplay() expects coordinates relative to an origin that includes the table header.
468 if (System
.getProperty("os.name").contains("Linux")) { //$NON-NLS-1$ //$NON-NLS-2$
469 y
+= fTable
.getHeaderHeight();
471 Point pt
= fTable
.toDisplay(event
.x
, y
);
472 pt
.x
+= BOOKMARK_IMAGE
.getBounds().width
;
473 pt
.y
+= item
.getBounds().height
;
474 tooltipShell
.setBounds(pt
.x
, pt
.y
, size
.x
, size
.y
);
475 tooltipShell
.setVisible(true);
483 if (tooltipShell
!= null) {
484 tooltipShell
.dispose();
494 fTable
.addListener(SWT
.MouseHover
, tooltipListener
);
495 fTable
.addListener(SWT
.Dispose
, tooltipListener
);
496 fTable
.addListener(SWT
.KeyDown
, tooltipListener
);
497 fTable
.addListener(SWT
.MouseMove
, tooltipListener
);
498 fTable
.addListener(SWT
.MouseExit
, tooltipListener
);
499 fTable
.addListener(SWT
.MouseDown
, tooltipListener
);
500 fTable
.addListener(SWT
.MouseWheel
, tooltipListener
);
505 ColorSettingsManager
.addColorSettingsListener(this);
507 fTable
.setItemCount(1); // +1 for header row
509 fRawViewer
= new TmfRawEventViewer(fSashForm
, SWT
.H_SCROLL
| SWT
.V_SCROLL
);
511 fRawViewer
.addSelectionListener(new Listener() {
513 public void handleEvent(final Event e
) {
514 if (e
.data
instanceof Long
) {
515 final long rank
= (Long
) e
.data
;
516 int index
= (int) rank
;
517 if (fTable
.getData(Key
.FILTER_OBJ
) != null) {
518 index
= fCache
.getFilteredEventIndex(rank
) + 1; // +1 for top filter status row
520 fTable
.setSelection(index
+ 1); // +1 for header row
521 fSelectedRank
= rank
;
522 } else if (e
.data
instanceof ITmfLocation
) {
523 // DOES NOT WORK: rank undefined in context from seekLocation()
524 // ITmfLocation<?> location = (ITmfLocation<?>) e.data;
525 // TmfContext context = fTrace.seekLocation(location);
526 // fTable.setSelection((int) context.getRank());
531 final TableItem
[] selection
= fTable
.getSelection();
532 if ((selection
!= null) && (selection
.length
> 0)) {
533 final TmfTimestamp ts
= (TmfTimestamp
) fTable
.getSelection()[0].getData(Key
.TIMESTAMP
);
535 broadcast(new TmfTimeSynchSignal(TmfEventsTable
.this, ts
));
541 fSashForm
.setWeights(new int[] { 1, 1 });
542 fRawViewer
.setVisible(false);
548 * Create a pop-up menu.
550 protected void createPopupMenu() {
551 final IAction showTableAction
= new Action(Messages
.TmfEventsTable_ShowTableActionText
) {
554 fTable
.setVisible(true);
559 final IAction hideTableAction
= new Action(Messages
.TmfEventsTable_HideTableActionText
) {
562 fTable
.setVisible(false);
567 final IAction showRawAction
= new Action(Messages
.TmfEventsTable_ShowRawActionText
) {
570 fRawViewer
.setVisible(true);
572 final int index
= fTable
.getSelectionIndex();
574 fRawViewer
.selectAndReveal(index
- 1);
579 final IAction hideRawAction
= new Action(Messages
.TmfEventsTable_HideRawActionText
) {
582 fRawViewer
.setVisible(false);
587 final IAction openCallsiteAction
= new Action(Messages
.TmfEventsTable_OpenCallsiteActionText
) {
590 final TableItem items
[] = fTable
.getSelection();
591 if (items
.length
!= 1) {
594 final TableItem item
= items
[0];
596 final Object data
= item
.getData();
597 if (data
instanceof CtfTmfEvent
) {
598 CtfTmfEvent event
= (CtfTmfEvent
) data
;
599 CtfTmfCallsite cs
= event
.getCallsite();
600 if (cs
== null || cs
.getFileName() == null) {
603 IMarker marker
= null;
605 String fileName
= cs
.getFileName();
606 final String trimmedPath
= fileName
.replaceAll("\\.\\./", ""); //$NON-NLS-1$ //$NON-NLS-2$
607 final ArrayList
<IFile
> files
= new ArrayList
<IFile
>();
608 ResourcesPlugin
.getWorkspace().getRoot().accept(new IResourceVisitor() {
610 public boolean visit(IResource resource
) throws CoreException
{
611 if (resource
instanceof IFile
&& resource
.getFullPath().toString().endsWith(trimmedPath
)) {
612 files
.add((IFile
) resource
);
618 if (files
.size() > 1) {
619 ListDialog dialog
= new ListDialog(getTable().getShell());
620 dialog
.setContentProvider(ArrayContentProvider
.getInstance());
621 dialog
.setLabelProvider(new LabelProvider() {
623 public String
getText(Object element
) {
624 return ((IFile
) element
).getFullPath().toString();
627 dialog
.setInput(files
);
628 dialog
.setTitle(Messages
.TmfEventsTable_OpenCallsiteSelectFileDialogTitle
);
629 dialog
.setMessage(Messages
.TmfEventsTable_OpenCallsiteSelectFileDialogTitle
+ '\n' + cs
.toString());
631 Object
[] result
= dialog
.getResult();
632 if (result
!= null && result
.length
> 0) {
633 file
= (IFile
) result
[0];
635 } else if (files
.size() == 1) {
639 marker
= file
.createMarker(IMarker
.MARKER
);
640 marker
.setAttribute(IMarker
.LINE_NUMBER
, Long
.valueOf(cs
.getLineNumber()).intValue());
641 IDE
.openEditor(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage(), marker
);
643 } else if (files
.size() == 0){
644 displayException(new FileNotFoundException('\'' + cs
.toString() + '\'' + '\n' + Messages
.TmfEventsTable_OpenCallsiteNotFound
));
646 } catch (PartInitException e
) {
647 // TODO Auto-generated catch block
649 } catch (CoreException e
) {
650 // TODO Auto-generated catch block
657 final IAction openModelAction
= new Action(Messages
.TmfEventsTable_OpenModelActionText
) {
661 final TableItem items
[] = fTable
.getSelection();
662 if (items
.length
!= 1) {
665 final TableItem item
= items
[0];
667 final Object eventData
= item
.getData();
668 if (eventData
instanceof CtfTmfEvent
) {
669 String modelURI
= ((CtfTmfEvent
) eventData
).getCustomAttribute(CtfConstants
.MODEL_URI_KEY
);
671 if (modelURI
!= null) {
672 IWorkbenchPage activePage
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
675 final URI uri
= URI
.createURI(modelURI
);
676 if (uri
.isPlatformResource()) {
677 IPath path
= new Path(uri
.toPlatformString(true));
678 file
= ResourcesPlugin
.getWorkspace().getRoot().getFile(path
);
679 } else if (uri
.isFile() && !uri
.isRelative()) {
680 file
= ResourcesPlugin
.getWorkspace().getRoot().getFileForLocation(
681 new Path(uri
.toFileString()));
687 * create a temporary validation marker on the
688 * model file, remove it afterwards thus,
689 * navigation works with all model editors
690 * supporting the navigation to a marker
692 IMarker marker
= file
.createMarker(EValidator
.MARKER
);
693 marker
.setAttribute(EValidator
.URI_ATTRIBUTE
, modelURI
);
694 marker
.setAttribute(IMarker
.SEVERITY
, IMarker
.SEVERITY_INFO
);
696 IDE
.openEditor(activePage
, marker
, OpenStrategy
.activateOnOpen());
699 catch (CoreException e
) {
703 displayException(new FileNotFoundException('\'' + modelURI
+ '\'' + '\n' + Messages
.TmfEventsTable_OpenModelUnsupportedURI
));
710 final IAction showSearchBarAction
= new Action(Messages
.TmfEventsTable_ShowSearchBarActionText
) {
713 fHeaderState
= HeaderState
.SEARCH
;
718 final IAction showFilterBarAction
= new Action(Messages
.TmfEventsTable_ShowFilterBarActionText
) {
721 fHeaderState
= HeaderState
.FILTER
;
726 final IAction clearFiltersAction
= new Action(Messages
.TmfEventsTable_ClearFiltersActionText
) {
733 class ToggleBookmarkAction
extends Action
{
736 public ToggleBookmarkAction(final String text
, final long rank
) {
743 toggleBookmark(fRank
);
747 final MenuManager tablePopupMenu
= new MenuManager();
748 tablePopupMenu
.setRemoveAllWhenShown(true);
749 tablePopupMenu
.addMenuListener(new IMenuListener() {
751 public void menuAboutToShow(final IMenuManager manager
) {
752 if (fTable
.getSelectionIndex() == 0) {
753 // Right-click on header row
754 if (fHeaderState
== HeaderState
.FILTER
) {
755 tablePopupMenu
.add(showSearchBarAction
);
757 tablePopupMenu
.add(showFilterBarAction
);
761 final Point point
= fTable
.toControl(Display
.getDefault().getCursorLocation());
762 final TableItem item
= fTable
.getSelection().length
> 0 ? fTable
.getSelection()[0] : null;
764 final Rectangle imageBounds
= item
.getImageBounds(0);
765 imageBounds
.width
= BOOKMARK_IMAGE
.getBounds().width
;
766 if (point
.x
<= (imageBounds
.x
+ imageBounds
.width
)) {
767 // Right-click on left margin
768 final Long rank
= (Long
) item
.getData(Key
.RANK
);
769 if ((rank
!= null) && (fBookmarksFile
!= null)) {
770 if (fBookmarksMap
.containsKey(rank
)) {
771 tablePopupMenu
.add(new ToggleBookmarkAction(
772 Messages
.TmfEventsTable_RemoveBookmarkActionText
, rank
));
774 tablePopupMenu
.add(new ToggleBookmarkAction(
775 Messages
.TmfEventsTable_AddBookmarkActionText
, rank
));
782 // Right-click on table
783 if (fTable
.isVisible() && fRawViewer
.isVisible()) {
784 tablePopupMenu
.add(hideTableAction
);
785 tablePopupMenu
.add(hideRawAction
);
786 } else if (!fTable
.isVisible()) {
787 tablePopupMenu
.add(showTableAction
);
788 } else if (!fRawViewer
.isVisible()) {
789 tablePopupMenu
.add(showRawAction
);
791 tablePopupMenu
.add(new Separator());
794 final Object data
= item
.getData();
795 if (data
instanceof CtfTmfEvent
) {
796 Separator separator
= null;
797 CtfTmfEvent event
= (CtfTmfEvent
) data
;
798 if (event
.getCallsite() != null) {
799 tablePopupMenu
.add(openCallsiteAction
);
800 separator
= new Separator();
802 if (event
.listCustomAttributes().contains(CtfConstants
.MODEL_URI_KEY
)) {
803 tablePopupMenu
.add(openModelAction
);
804 separator
= new Separator();
806 if (separator
!= null) {
807 tablePopupMenu
.add(separator
);
812 tablePopupMenu
.add(clearFiltersAction
);
813 final ITmfFilterTreeNode
[] savedFilters
= FilterManager
.getSavedFilters();
814 if (savedFilters
.length
> 0) {
815 final MenuManager subMenu
= new MenuManager(Messages
.TmfEventsTable_ApplyPresetFilterMenuName
);
816 for (final ITmfFilterTreeNode node
: savedFilters
) {
817 if (node
instanceof TmfFilterNode
) {
818 final TmfFilterNode filter
= (TmfFilterNode
) node
;
819 subMenu
.add(new Action(filter
.getFilterName()) {
827 tablePopupMenu
.add(subMenu
);
829 appendToTablePopupMenu(tablePopupMenu
, item
);
833 final MenuManager rawViewerPopupMenu
= new MenuManager();
834 rawViewerPopupMenu
.setRemoveAllWhenShown(true);
835 rawViewerPopupMenu
.addMenuListener(new IMenuListener() {
837 public void menuAboutToShow(final IMenuManager manager
) {
838 if (fTable
.isVisible() && fRawViewer
.isVisible()) {
839 rawViewerPopupMenu
.add(hideTableAction
);
840 rawViewerPopupMenu
.add(hideRawAction
);
841 } else if (!fTable
.isVisible()) {
842 rawViewerPopupMenu
.add(showTableAction
);
843 } else if (!fRawViewer
.isVisible()) {
844 rawViewerPopupMenu
.add(showRawAction
);
846 appendToRawPopupMenu(tablePopupMenu
);
850 Menu menu
= tablePopupMenu
.createContextMenu(fTable
);
851 fTable
.setMenu(menu
);
853 menu
= rawViewerPopupMenu
.createContextMenu(fRawViewer
);
854 fRawViewer
.setMenu(menu
);
859 * Append an item to the event table's pop-up menu.
861 * @param tablePopupMenu
863 * @param selectedItem
866 protected void appendToTablePopupMenu(final MenuManager tablePopupMenu
, final TableItem selectedItem
) {
867 // override to append more actions
871 * Append an item to the raw viewer's pop-up menu.
873 * @param rawViewerPopupMenu
876 protected void appendToRawPopupMenu(final MenuManager rawViewerPopupMenu
) {
877 // override to append more actions
881 public void dispose() {
884 ColorSettingsManager
.removeColorSettingsListener(this);
885 fComposite
.dispose();
886 if ((fTrace
!= null) && fDisposeOnClose
) {
889 fResourceManager
.dispose();
894 * Assign a layout data object to this view.
897 * The layout data to assign
899 public void setLayoutData(final Object layoutData
) {
900 fComposite
.setLayoutData(layoutData
);
904 * Get the virtual table contained in this event table.
906 * @return The TMF virtual table
908 public TmfVirtualTable
getTable() {
915 * FIXME: Add support for column selection
917 protected void setColumnHeaders(final ColumnData
[] columnData
) {
918 fTable
.setColumnHeaders(columnData
);
922 * Set a table item's data.
927 * Which trace event to link with this entry
929 * Which rank this event has in the trace/experiment
931 protected void setItemData(final TableItem item
, final ITmfEvent event
, final long rank
) {
932 final ITmfEventField
[] fields
= extractItemFields(event
);
933 final String
[] content
= new String
[fields
.length
];
934 for (int i
= 0; i
< fields
.length
; i
++) {
935 content
[i
] = fields
[i
].getValue() != null ? fields
[i
].getValue().toString() : ""; //$NON-NLS-1$
937 item
.setText(content
);
939 item
.setData(Key
.TIMESTAMP
, new TmfTimestamp(event
.getTimestamp()));
940 item
.setData(Key
.RANK
, rank
);
942 boolean bookmark
= false;
943 final Long markerId
= fBookmarksMap
.get(rank
);
944 if (markerId
!= null) {
947 final IMarker marker
= fBookmarksFile
.findMarker(markerId
);
948 item
.setData(Key
.BOOKMARK
, marker
.getAttribute(IMarker
.MESSAGE
));
949 } catch (final CoreException e
) {
953 item
.setData(Key
.BOOKMARK
, null);
956 boolean searchMatch
= false;
957 boolean searchNoMatch
= false;
958 final ITmfFilter searchFilter
= (ITmfFilter
) fTable
.getData(Key
.SEARCH_OBJ
);
959 if (searchFilter
!= null) {
960 if (searchFilter
.matches(event
)) {
963 searchNoMatch
= true;
967 final ColorSetting colorSetting
= ColorSettingsManager
.getColorSetting(event
);
969 item
.setForeground(colorSetting
.getDimmedForegroundColor());
970 item
.setBackground(colorSetting
.getDimmedBackgroundColor());
972 item
.setForeground(colorSetting
.getForegroundColor());
973 item
.setBackground(colorSetting
.getBackgroundColor());
978 item
.setImage(SEARCH_MATCH_BOOKMARK_IMAGE
);
980 item
.setImage(SEARCH_MATCH_IMAGE
);
982 } else if (bookmark
) {
983 item
.setImage(BOOKMARK_IMAGE
);
985 item
.setImage((Image
) null);
990 * Set the item data of the header row.
993 * The item to use as table header
995 protected void setHeaderRowItemData(final TableItem item
) {
996 String txtKey
= null;
997 if (fHeaderState
== HeaderState
.SEARCH
) {
998 item
.setImage(SEARCH_IMAGE
);
999 txtKey
= Key
.SEARCH_TXT
;
1000 } else if (fHeaderState
== HeaderState
.FILTER
) {
1001 item
.setImage(FILTER_IMAGE
);
1002 txtKey
= Key
.FILTER_TXT
;
1004 item
.setForeground(fGrayColor
);
1005 for (int i
= 0; i
< fTable
.getColumns().length
; i
++) {
1006 final TableColumn column
= fTable
.getColumns()[i
];
1007 final String filter
= (String
) column
.getData(txtKey
);
1008 if (filter
== null) {
1009 if (fHeaderState
== HeaderState
.SEARCH
) {
1010 item
.setText(i
, SEARCH_HINT
);
1011 } else if (fHeaderState
== HeaderState
.FILTER
) {
1012 item
.setText(i
, FILTER_HINT
);
1014 item
.setForeground(i
, fGrayColor
);
1015 item
.setFont(i
, fTable
.getFont());
1017 item
.setText(i
, filter
);
1018 item
.setForeground(i
, fGreenColor
);
1019 item
.setFont(i
, fBoldFont
);
1025 * Set the item data of the "filter status" row.
1028 * The item to use as filter status row
1030 protected void setFilterStatusRowItemData(final TableItem item
) {
1031 for (int i
= 0; i
< fTable
.getColumns().length
; i
++) {
1033 if ((fTrace
== null) || (fFilterCheckCount
== fTrace
.getNbEvents())) {
1034 item
.setImage(FILTER_IMAGE
);
1036 item
.setImage(STOP_IMAGE
);
1038 item
.setText(0, fFilterMatchCount
+ "/" + fFilterCheckCount
); //$NON-NLS-1$
1040 item
.setText(i
, ""); //$NON-NLS-1$
1044 item
.setData(Key
.TIMESTAMP
, null);
1045 item
.setData(Key
.RANK
, null);
1046 item
.setForeground(null);
1047 item
.setBackground(null);
1051 * Create an editor for the header.
1053 protected void createHeaderEditor() {
1054 final TableEditor tableEditor
= fTable
.createTableEditor();
1055 tableEditor
.horizontalAlignment
= SWT
.LEFT
;
1056 tableEditor
.verticalAlignment
= SWT
.CENTER
;
1057 tableEditor
.grabHorizontal
= true;
1058 tableEditor
.minimumWidth
= 50;
1060 // Handle the header row selection
1061 fTable
.addMouseListener(new MouseAdapter() {
1067 public void mouseDown(final MouseEvent event
) {
1068 if (event
.button
!= 1) {
1071 // Identify the selected row
1072 final Point point
= new Point(event
.x
, event
.y
);
1073 item
= fTable
.getItem(point
);
1075 // Header row selected
1076 if ((item
!= null) && (fTable
.indexOf(item
) == 0)) {
1079 if (item
.getImageBounds(0).contains(point
)) {
1080 if (fHeaderState
== HeaderState
.SEARCH
) {
1081 fHeaderState
= HeaderState
.FILTER
;
1082 } else if (fHeaderState
== HeaderState
.FILTER
) {
1083 fHeaderState
= HeaderState
.SEARCH
;
1089 // Identify the selected column
1091 for (int i
= 0; i
< fTable
.getColumns().length
; i
++) {
1092 final Rectangle rect
= item
.getBounds(i
);
1093 if (rect
.contains(point
)) {
1099 if (columnIndex
== -1) {
1103 column
= fTable
.getColumns()[columnIndex
];
1105 String txtKey
= null;
1106 if (fHeaderState
== HeaderState
.SEARCH
) {
1107 txtKey
= Key
.SEARCH_TXT
;
1108 } else if (fHeaderState
== HeaderState
.FILTER
) {
1109 txtKey
= Key
.FILTER_TXT
;
1112 // The control that will be the editor must be a child of the Table
1113 final Text newEditor
= (Text
) fTable
.createTableEditorControl(Text
.class);
1114 final String headerString
= (String
) column
.getData(txtKey
);
1115 if (headerString
!= null) {
1116 newEditor
.setText(headerString
);
1118 newEditor
.addFocusListener(new FocusAdapter() {
1120 public void focusLost(final FocusEvent e
) {
1121 final boolean changed
= updateHeader(newEditor
.getText());
1127 newEditor
.addKeyListener(new KeyAdapter() {
1129 public void keyPressed(final KeyEvent e
) {
1130 if (e
.character
== SWT
.CR
) {
1131 updateHeader(newEditor
.getText());
1133 } else if (e
.character
== SWT
.ESC
) {
1134 tableEditor
.getEditor().dispose();
1138 newEditor
.selectAll();
1139 newEditor
.setFocus();
1140 tableEditor
.setEditor(newEditor
, item
, columnIndex
);
1145 * returns true is value was changed
1147 private boolean updateHeader(final String text
) {
1148 String objKey
= null;
1149 String txtKey
= null;
1150 if (fHeaderState
== HeaderState
.SEARCH
) {
1151 objKey
= Key
.SEARCH_OBJ
;
1152 txtKey
= Key
.SEARCH_TXT
;
1153 } else if (fHeaderState
== HeaderState
.FILTER
) {
1154 objKey
= Key
.FILTER_OBJ
;
1155 txtKey
= Key
.FILTER_TXT
;
1157 if (text
.trim().length() > 0) {
1159 final String regex
= TmfFilterMatchesNode
.regexFix(text
);
1160 Pattern
.compile(regex
);
1161 if (regex
.equals(column
.getData(txtKey
))) {
1162 tableEditor
.getEditor().dispose();
1165 final TmfFilterMatchesNode filter
= new TmfFilterMatchesNode(null);
1166 String fieldId
= (String
) column
.getData(Key
.FIELD_ID
);
1167 if (fieldId
== null) {
1168 fieldId
= column
.getText();
1170 filter
.setField(fieldId
);
1171 filter
.setRegex(regex
);
1172 column
.setData(objKey
, filter
);
1173 column
.setData(txtKey
, regex
);
1174 } catch (final PatternSyntaxException ex
) {
1175 tableEditor
.getEditor().dispose();
1176 MessageDialog
.openError(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell(),
1177 ex
.getDescription(), ex
.getMessage());
1181 if (column
.getData(txtKey
) == null) {
1182 tableEditor
.getEditor().dispose();
1185 column
.setData(objKey
, null);
1186 column
.setData(txtKey
, null);
1191 private void applyHeader() {
1192 if (fHeaderState
== HeaderState
.SEARCH
) {
1194 final TmfFilterAndNode filter
= new TmfFilterAndNode(null);
1195 for (final TableColumn col
: fTable
.getColumns()) {
1196 final Object filterObj
= col
.getData(Key
.SEARCH_OBJ
);
1197 if (filterObj
instanceof ITmfFilterTreeNode
) {
1198 filter
.addChild((ITmfFilterTreeNode
) filterObj
);
1201 if (filter
.getChildrenCount() > 0) {
1202 fTable
.setData(Key
.SEARCH_OBJ
, filter
);
1205 fireSearchApplied(filter
);
1207 fTable
.setData(Key
.SEARCH_OBJ
, null);
1209 fireSearchApplied(null);
1211 } else if (fHeaderState
== HeaderState
.FILTER
) {
1212 final TmfFilterAndNode filter
= new TmfFilterAndNode(null);
1213 for (final TableColumn col
: fTable
.getColumns()) {
1214 final Object filterObj
= col
.getData(Key
.FILTER_OBJ
);
1215 if (filterObj
instanceof ITmfFilterTreeNode
) {
1216 filter
.addChild((ITmfFilterTreeNode
) filterObj
);
1219 if (filter
.getChildrenCount() > 0) {
1220 applyFilter(filter
);
1226 tableEditor
.getEditor().dispose();
1230 fTable
.addKeyListener(new KeyAdapter() {
1232 public void keyPressed(final KeyEvent e
) {
1234 if (e
.character
== SWT
.ESC
) {
1238 } else if (e
.character
== SWT
.DEL
) {
1239 if (fHeaderState
== HeaderState
.SEARCH
) {
1241 for (final TableColumn column
: fTable
.getColumns()) {
1242 column
.setData(Key
.SEARCH_OBJ
, null);
1243 column
.setData(Key
.SEARCH_TXT
, null);
1245 fTable
.setData(Key
.SEARCH_OBJ
, null);
1247 fireSearchApplied(null);
1248 } else if (fHeaderState
== HeaderState
.FILTER
) {
1251 } else if (e
.character
== SWT
.CR
) {
1252 if ((e
.stateMask
& SWT
.SHIFT
) == 0) {
1263 * Send an event indicating a filter has been applied.
1266 * The filter that was just applied
1268 protected void fireFilterApplied(final ITmfFilter filter
) {
1269 broadcast(new TmfEventFilterAppliedSignal(this, fTrace
, filter
));
1273 * Send an event indicating that a search has been applied.
1276 * The search filter that was just applied
1278 protected void fireSearchApplied(final ITmfFilter filter
) {
1279 broadcast(new TmfEventSearchAppliedSignal(this, fTrace
, filter
));
1283 * Start the filtering thread.
1285 protected void startFilterThread() {
1286 synchronized (fFilterSyncObj
) {
1287 final ITmfFilterTreeNode filter
= (ITmfFilterTreeNode
) fTable
.getData(Key
.FILTER_OBJ
);
1288 if (fFilterThread
== null || fFilterThread
.filter
!= filter
) {
1289 if (fFilterThread
!= null) {
1290 fFilterThread
.cancel();
1291 fFilterThreadResume
= false;
1293 fFilterThread
= new FilterThread(filter
);
1294 fFilterThread
.start();
1296 fFilterThreadResume
= true;
1302 * Stop the filtering thread.
1304 protected void stopFilterThread() {
1305 synchronized (fFilterSyncObj
) {
1306 if (fFilterThread
!= null) {
1307 fFilterThread
.cancel();
1308 fFilterThread
= null;
1309 fFilterThreadResume
= false;
1318 * The filter to apply
1321 protected void applyFilter(ITmfFilter filter
) {
1324 fFilterMatchCount
= 0;
1325 fFilterCheckCount
= 0;
1326 fCache
.applyFilter(filter
);
1328 fTable
.setData(Key
.FILTER_OBJ
, filter
);
1329 fTable
.setItemCount(3); // +1 for header row, +2 for top and bottom filter status rows
1330 startFilterThread();
1331 fireFilterApplied(filter
);
1335 * Clear all currently active filters.
1337 protected void clearFilters() {
1338 if (fTable
.getData(Key
.FILTER_OBJ
) == null) {
1343 fCache
.clearFilter();
1345 for (final TableColumn column
: fTable
.getColumns()) {
1346 column
.setData(Key
.FILTER_OBJ
, null);
1347 column
.setData(Key
.FILTER_TXT
, null);
1349 fTable
.setData(Key
.FILTER_OBJ
, null);
1350 if (fTrace
!= null) {
1351 fTable
.setItemCount((int) fTrace
.getNbEvents() + 1); // +1 for header row
1353 fTable
.setItemCount(1); // +1 for header row
1355 fFilterMatchCount
= 0;
1356 fFilterCheckCount
= 0;
1357 if (fSelectedRank
>= 0) {
1358 fTable
.setSelection((int) fSelectedRank
+ 1); // +1 for header row
1360 fTable
.setSelection(0);
1362 fireFilterApplied(null);
1366 * Wrapper Thread object for the filtering thread.
1368 protected class FilterThread
extends Thread
{
1369 private final ITmfFilterTreeNode filter
;
1370 private TmfDataRequest request
;
1371 private boolean refreshBusy
= false;
1372 private boolean refreshPending
= false;
1373 private final Object syncObj
= new Object();
1379 * The filter this thread will be processing
1381 public FilterThread(final ITmfFilterTreeNode filter
) {
1382 super("Filter Thread"); //$NON-NLS-1$
1383 this.filter
= filter
;
1388 if (fTrace
== null) {
1391 final int nbRequested
= (int) (fTrace
.getNbEvents() - fFilterCheckCount
);
1392 if (nbRequested
<= 0) {
1395 request
= new TmfDataRequest(ITmfEvent
.class, (int) fFilterCheckCount
,
1396 nbRequested
, fTrace
.getCacheSize(), ExecutionType
.BACKGROUND
) {
1398 public void handleData(final ITmfEvent event
) {
1399 super.handleData(event
);
1400 if (request
.isCancelled()) {
1403 if (filter
.matches(event
)) {
1404 final long rank
= fFilterCheckCount
;
1405 final int index
= (int) fFilterMatchCount
;
1406 fFilterMatchCount
++;
1407 fCache
.storeEvent(event
, rank
, index
);
1409 } else if ((fFilterCheckCount
% 100) == 0) {
1412 fFilterCheckCount
++;
1415 ((ITmfDataProvider
) fTrace
).sendRequest(request
);
1417 request
.waitForCompletion();
1418 } catch (final InterruptedException e
) {
1421 synchronized (fFilterSyncObj
) {
1422 fFilterThread
= null;
1423 if (fFilterThreadResume
) {
1424 fFilterThreadResume
= false;
1425 fFilterThread
= new FilterThread(filter
);
1426 fFilterThread
.start();
1432 * Refresh the filter.
1434 public void refreshTable() {
1435 synchronized (syncObj
) {
1437 refreshPending
= true;
1442 Display
.getDefault().asyncExec(new Runnable() {
1445 if (request
.isCancelled()) {
1448 if (fTable
.isDisposed()) {
1451 fTable
.setItemCount((int) fFilterMatchCount
+ 3); // +1 for header row, +2 for top and bottom filter status rows
1453 synchronized (syncObj
) {
1454 refreshBusy
= false;
1455 if (refreshPending
) {
1456 refreshPending
= false;
1465 * Cancel this filtering thread.
1467 public void cancel() {
1468 if (request
!= null) {
1475 * Go to the next item of a search.
1477 protected void searchNext() {
1478 synchronized (fSearchSyncObj
) {
1479 if (fSearchThread
!= null) {
1482 final ITmfFilterTreeNode searchFilter
= (ITmfFilterTreeNode
) fTable
.getData(Key
.SEARCH_OBJ
);
1483 if (searchFilter
== null) {
1486 final int selectionIndex
= fTable
.getSelectionIndex();
1488 if (selectionIndex
> 0) {
1489 startIndex
= selectionIndex
; // -1 for header row, +1 for next event
1491 // header row is selected, start at top event
1492 startIndex
= Math
.max(0, fTable
.getTopIndex() - 1); // -1 for header row
1494 final ITmfFilterTreeNode eventFilter
= (ITmfFilterTreeNode
) fTable
.getData(Key
.FILTER_OBJ
);
1495 if (eventFilter
!= null) {
1496 startIndex
= Math
.max(0, startIndex
- 1); // -1 for top filter status row
1498 fSearchThread
= new SearchThread(searchFilter
, eventFilter
, startIndex
, fSelectedRank
, Direction
.FORWARD
);
1499 fSearchThread
.schedule();
1504 * Go to the previous item of a search.
1506 protected void searchPrevious() {
1507 synchronized (fSearchSyncObj
) {
1508 if (fSearchThread
!= null) {
1511 final ITmfFilterTreeNode searchFilter
= (ITmfFilterTreeNode
) fTable
.getData(Key
.SEARCH_OBJ
);
1512 if (searchFilter
== null) {
1515 final int selectionIndex
= fTable
.getSelectionIndex();
1517 if (selectionIndex
> 0) {
1518 startIndex
= selectionIndex
- 2; // -1 for header row, -1 for previous event
1520 // header row is selected, start at precedent of top event
1521 startIndex
= fTable
.getTopIndex() - 2; // -1 for header row, -1 for previous event
1523 final ITmfFilterTreeNode eventFilter
= (ITmfFilterTreeNode
) fTable
.getData(Key
.FILTER_OBJ
);
1524 if (eventFilter
!= null) {
1525 startIndex
= startIndex
- 1; // -1 for top filter status row
1527 fSearchThread
= new SearchThread(searchFilter
, eventFilter
, startIndex
, fSelectedRank
, Direction
.BACKWARD
);
1528 fSearchThread
.schedule();
1533 * Stop the search thread.
1535 protected void stopSearchThread() {
1536 fPendingGotoRank
= -1;
1537 synchronized (fSearchSyncObj
) {
1538 if (fSearchThread
!= null) {
1539 fSearchThread
.cancel();
1540 fSearchThread
= null;
1546 * Wrapper for the search thread.
1548 protected class SearchThread
extends Job
{
1550 private ITmfFilterTreeNode searchFilter
;
1551 private ITmfFilterTreeNode eventFilter
;
1552 private int startIndex
;
1553 private int direction
;
1555 private long foundRank
= -1;
1556 private TmfDataRequest request
;
1557 private ITmfTimestamp foundTimestamp
= null;
1562 * @param searchFilter
1564 * @param eventFilter
1567 * The index at which we should start searching
1568 * @param currentRank
1571 * In which direction should we search, forward or backwards
1573 public SearchThread(final ITmfFilterTreeNode searchFilter
,
1574 final ITmfFilterTreeNode eventFilter
, final int startIndex
,
1575 final long currentRank
, final int direction
) {
1576 super(Messages
.TmfEventsTable_SearchingJobName
);
1577 this.searchFilter
= searchFilter
;
1578 this.eventFilter
= eventFilter
;
1579 this.startIndex
= startIndex
;
1580 this.rank
= currentRank
;
1581 this.direction
= direction
;
1585 protected IStatus
run(final IProgressMonitor monitor
) {
1586 if (fTrace
== null) {
1587 return Status
.OK_STATUS
;
1589 final Display display
= Display
.getDefault();
1590 if (startIndex
< 0) {
1591 rank
= (int) fTrace
.getNbEvents() - 1;
1592 } else if (startIndex
>= (fTable
.getItemCount() - (eventFilter
== null ?
1 : 3))) { // -1 for header row, -2 for top and bottom filter status rows
1595 int idx
= startIndex
;
1596 while (foundRank
== -1) {
1597 final CachedEvent event
= fCache
.peekEvent(idx
);
1598 if (event
== null) {
1602 if (searchFilter
.matches(event
.event
) && ((eventFilter
== null) || eventFilter
.matches(event
.event
))) {
1603 foundRank
= event
.rank
;
1604 foundTimestamp
= event
.event
.getTimestamp();
1607 if (direction
== Direction
.FORWARD
) {
1613 if (foundRank
== -1) {
1614 if (direction
== Direction
.FORWARD
) {
1616 if (rank
> (fTrace
.getNbEvents() - 1)) {
1622 rank
= (int) fTrace
.getNbEvents() - 1;
1627 final int startRank
= (int) rank
;
1628 boolean wrapped
= false;
1629 while (!monitor
.isCanceled() && (foundRank
== -1) && (fTrace
!= null)) {
1630 int nbRequested
= (direction
== Direction
.FORWARD ? Integer
.MAX_VALUE
: Math
.min((int) rank
+ 1, fTrace
.getCacheSize()));
1631 if (direction
== Direction
.BACKWARD
) {
1632 rank
= Math
.max(0, rank
- fTrace
.getCacheSize() + 1);
1634 request
= new TmfDataRequest(ITmfEvent
.class, (int) rank
, nbRequested
, fTrace
.getCacheSize(), ExecutionType
.BACKGROUND
) {
1635 long currentRank
= rank
;
1638 public void handleData(final ITmfEvent event
) {
1639 super.handleData(event
);
1640 if (searchFilter
.matches(event
) && ((eventFilter
== null) || eventFilter
.matches(event
))) {
1641 foundRank
= currentRank
;
1642 foundTimestamp
= event
.getTimestamp();
1643 if (direction
== Direction
.FORWARD
) {
1651 ((ITmfDataProvider
) fTrace
).sendRequest(request
);
1653 request
.waitForCompletion();
1654 if (request
.isCancelled()) {
1655 return Status
.OK_STATUS
;
1657 } catch (final InterruptedException e
) {
1658 synchronized (fSearchSyncObj
) {
1659 fSearchThread
= null;
1661 return Status
.OK_STATUS
;
1663 if (foundRank
== -1) {
1664 if (direction
== Direction
.FORWARD
) {
1666 synchronized (fSearchSyncObj
) {
1667 fSearchThread
= null;
1669 return Status
.OK_STATUS
;
1671 nbRequested
= (int) rank
;
1677 rank
= (int) fTrace
.getNbEvents() - 1;
1680 if ((rank
<= startRank
) && wrapped
) {
1681 synchronized (fSearchSyncObj
) {
1682 fSearchThread
= null;
1684 return Status
.OK_STATUS
;
1689 int index
= (int) foundRank
;
1690 if (eventFilter
!= null) {
1691 index
= fCache
.getFilteredEventIndex(foundRank
);
1693 final int selection
= index
+ 1 + (eventFilter
!= null ?
+1 : 0); // +1 for header row, +1 for top filter status row
1695 display
.asyncExec(new Runnable() {
1698 if (monitor
.isCanceled()) {
1701 if (fTable
.isDisposed()) {
1704 fTable
.setSelection(selection
);
1705 fSelectedRank
= foundRank
;
1706 fRawViewer
.selectAndReveal(fSelectedRank
);
1707 if (foundTimestamp
!= null) {
1708 broadcast(new TmfTimeSynchSignal(TmfEventsTable
.this, foundTimestamp
));
1710 fireSelectionChanged(new SelectionChangedEvent(TmfEventsTable
.this, getSelection()));
1711 synchronized (fSearchSyncObj
) {
1712 fSearchThread
= null;
1716 return Status
.OK_STATUS
;
1720 protected void canceling() {
1722 synchronized (fSearchSyncObj
) {
1723 fSearchThread
= null;
1729 * Create the resources.
1731 protected void createResources() {
1732 fGrayColor
= fResourceManager
.createColor(ColorUtil
.blend(fTable
.getBackground().getRGB(), fTable
1733 .getForeground().getRGB()));
1734 fGreenColor
= fTable
.getDisplay().getSystemColor(SWT
.COLOR_DARK_GREEN
);
1735 fBoldFont
= fResourceManager
.createFont(FontDescriptor
.createFrom(fTable
.getFont()).setStyle(SWT
.BOLD
));
1741 protected void packColumns() {
1745 boolean isLinux
= System
.getProperty("os.name").contains("Linux") ?
true : false; //$NON-NLS-1$ //$NON-NLS-2$
1747 TableColumn tableColumns
[] = fTable
.getColumns();
1748 for (int i
= 0; i
< tableColumns
.length
; i
++) {
1749 final TableColumn column
= tableColumns
[i
];
1750 final int headerWidth
= column
.getWidth();
1752 // Workaround for Linux which doesn't consider the image width of
1753 // search/filter row in TableColumn.pack() after having executed
1754 // TableItem.setImage((Image)null) for other rows than search/filter row.
1755 if (isLinux
&& (i
== 0)) {
1756 column
.setWidth(column
.getWidth() + SEARCH_IMAGE
.getBounds().width
);
1759 if (column
.getWidth() < headerWidth
) {
1760 column
.setWidth(headerWidth
);
1767 * Extract the fields of an event (item in the table).
1770 * The event to extract from
1771 * @return The array of fields
1773 * FIXME: Add support for column selection
1775 protected ITmfEventField
[] extractItemFields(final ITmfEvent event
) {
1776 ITmfEventField
[] fields
= new TmfEventField
[0];
1777 if (event
!= null) {
1778 final String timestamp
= event
.getTimestamp().toString();
1779 final String source
= event
.getSource();
1780 final String type
= event
.getType().getName();
1781 final String reference
= event
.getReference();
1782 final String content
= event
.getContent().toString();
1783 fields
= new TmfEventField
[] {
1784 new TmfEventField(ITmfEvent
.EVENT_FIELD_TIMESTAMP
, timestamp
),
1785 new TmfEventField(ITmfEvent
.EVENT_FIELD_SOURCE
, source
),
1786 new TmfEventField(ITmfEvent
.EVENT_FIELD_TYPE
, type
),
1787 new TmfEventField(ITmfEvent
.EVENT_FIELD_REFERENCE
, reference
),
1788 new TmfEventField(ITmfEvent
.EVENT_FIELD_CONTENT
, content
)
1795 * Notify this table that is got the UI focus.
1797 public void setFocus() {
1802 * Assign a new trace to this event table.
1805 * The trace to assign to this event table
1806 * @param disposeOnClose
1807 * true if the trace should be disposed when the table is
1810 public void setTrace(final ITmfTrace trace
, final boolean disposeOnClose
) {
1811 if ((fTrace
!= null) && fDisposeOnClose
) {
1817 fDisposeOnClose
= disposeOnClose
;
1819 // Perform the updates on the UI thread
1820 fTable
.getDisplay().syncExec(new Runnable() {
1824 fCache
.setTrace(fTrace
); // Clear the cache
1825 if (fTrace
!= null) {
1826 if (!fTable
.isDisposed() && (fTrace
!= null)) {
1827 if (fTable
.getData(Key
.FILTER_OBJ
) == null) {
1828 fTable
.setItemCount((int) fTrace
.getNbEvents() + 1); // +1 for header row
1831 fFilterMatchCount
= 0;
1832 fFilterCheckCount
= 0;
1833 fTable
.setItemCount(3); // +1 for header row, +2 for top and bottom filter status rows
1834 startFilterThread();
1838 fRawViewer
.setTrace(fTrace
);
1843 // ------------------------------------------------------------------------
1845 // ------------------------------------------------------------------------
1848 * Notify that the event cache has been updated
1851 * Also notify if the populating of the cache is complete, or
1854 public void cacheUpdated(final boolean completed
) {
1855 synchronized (fCacheUpdateSyncObj
) {
1856 if (fCacheUpdateBusy
) {
1857 fCacheUpdatePending
= true;
1858 fCacheUpdateCompleted
= completed
;
1861 fCacheUpdateBusy
= true;
1863 // Event cache is now updated. Perform update on the UI thread
1864 if (!fTable
.isDisposed()) {
1865 fTable
.getDisplay().asyncExec(new Runnable() {
1868 if (!fTable
.isDisposed()) {
1873 populateCompleted();
1875 synchronized (fCacheUpdateSyncObj
) {
1876 fCacheUpdateBusy
= false;
1877 if (fCacheUpdatePending
) {
1878 fCacheUpdatePending
= false;
1879 cacheUpdated(fCacheUpdateCompleted
);
1888 * Callback for when populating the table is complete.
1890 protected void populateCompleted() {
1891 // Nothing by default;
1894 // ------------------------------------------------------------------------
1895 // ISelectionProvider
1896 // ------------------------------------------------------------------------
1899 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
1905 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
1906 selectionChangedListeners
.add(listener
);
1910 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
1916 public ISelection
getSelection() {
1917 if (fTable
== null || fTable
.isDisposed()) {
1918 return StructuredSelection
.EMPTY
;
1920 List
<Object
> list
= new ArrayList
<Object
>(fTable
.getSelection().length
);
1921 for (TableItem item
: fTable
.getSelection()) {
1922 if (item
.getData() != null) {
1923 list
.add(item
.getData());
1926 return new StructuredSelection(list
);
1930 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
1936 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
1937 selectionChangedListeners
.remove(listener
);
1941 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
1947 public void setSelection(ISelection selection
) {
1952 * Notifies any selection changed listeners that the viewer's selection has changed.
1953 * Only listeners registered at the time this method is called are notified.
1955 * @param event a selection changed event
1957 * @see ISelectionChangedListener#selectionChanged
1960 protected void fireSelectionChanged(final SelectionChangedEvent event
) {
1961 Object
[] listeners
= selectionChangedListeners
.getListeners();
1962 for (int i
= 0; i
< listeners
.length
; ++i
) {
1963 final ISelectionChangedListener l
= (ISelectionChangedListener
) listeners
[i
];
1964 SafeRunnable
.run(new SafeRunnable() {
1967 l
.selectionChanged(event
);
1973 // ------------------------------------------------------------------------
1974 // Bookmark handling
1975 // ------------------------------------------------------------------------
1978 * Add a bookmark to this event table.
1980 * @param bookmarksFile
1981 * The file to use for the bookmarks
1983 public void addBookmark(final IFile bookmarksFile
) {
1984 fBookmarksFile
= bookmarksFile
;
1985 final TableItem
[] selection
= fTable
.getSelection();
1986 if (selection
.length
> 0) {
1987 final TableItem tableItem
= selection
[0];
1988 if (tableItem
.getData(Key
.RANK
) != null) {
1989 final StringBuffer defaultMessage
= new StringBuffer();
1990 for (int i
= 0; i
< fTable
.getColumns().length
; i
++) {
1992 defaultMessage
.append(", "); //$NON-NLS-1$
1994 defaultMessage
.append(tableItem
.getText(i
));
1996 final InputDialog dialog
= new MultiLineInputDialog(
1997 PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell(),
1998 Messages
.TmfEventsTable_AddBookmarkDialogTitle
,
1999 Messages
.TmfEventsTable_AddBookmarkDialogMessage
,
2000 defaultMessage
.toString());
2001 if (dialog
.open() == Window
.OK
) {
2002 final String message
= dialog
.getValue();
2004 final IMarker bookmark
= bookmarksFile
.createMarker(IMarker
.BOOKMARK
);
2005 if (bookmark
.exists()) {
2006 bookmark
.setAttribute(IMarker
.MESSAGE
, message
.toString());
2007 final long rank
= (Long
) tableItem
.getData(Key
.RANK
);
2008 final int location
= (int) rank
;
2009 bookmark
.setAttribute(IMarker
.LOCATION
, (Integer
) location
);
2010 fBookmarksMap
.put(rank
, bookmark
.getId());
2013 } catch (final CoreException e
) {
2014 displayException(e
);
2023 * Remove a bookmark from this event table.
2026 * The bookmark to remove
2028 public void removeBookmark(final IMarker bookmark
) {
2029 for (final Entry
<Long
, Long
> entry
: fBookmarksMap
.entrySet()) {
2030 if (entry
.getValue().equals(bookmark
.getId())) {
2031 fBookmarksMap
.remove(entry
.getKey());
2038 private void toggleBookmark(final long rank
) {
2039 if (fBookmarksFile
== null) {
2042 if (fBookmarksMap
.containsKey(rank
)) {
2043 final Long markerId
= fBookmarksMap
.remove(rank
);
2046 final IMarker bookmark
= fBookmarksFile
.findMarker(markerId
);
2047 if (bookmark
!= null) {
2050 } catch (final CoreException e
) {
2051 displayException(e
);
2054 addBookmark(fBookmarksFile
);
2059 * Refresh the bookmarks assigned to this trace, from the contents of a
2062 * @param bookmarksFile
2063 * The bookmark file to use
2065 public void refreshBookmarks(final IFile bookmarksFile
) {
2066 fBookmarksFile
= bookmarksFile
;
2067 if (bookmarksFile
== null) {
2068 fBookmarksMap
.clear();
2073 fBookmarksMap
.clear();
2074 for (final IMarker bookmark
: bookmarksFile
.findMarkers(IMarker
.BOOKMARK
, false, IResource
.DEPTH_ZERO
)) {
2075 final int location
= bookmark
.getAttribute(IMarker
.LOCATION
, -1);
2076 if (location
!= -1) {
2077 final long rank
= location
;
2078 fBookmarksMap
.put(rank
, bookmark
.getId());
2082 } catch (final CoreException e
) {
2083 displayException(e
);
2088 public void gotoMarker(final IMarker marker
) {
2089 final int rank
= marker
.getAttribute(IMarker
.LOCATION
, -1);
2092 if (fTable
.getData(Key
.FILTER_OBJ
) != null) {
2093 index
= fCache
.getFilteredEventIndex(rank
) + 1; // +1 for top filter status row
2094 } else if (rank
>= fTable
.getItemCount()) {
2095 fPendingGotoRank
= rank
;
2097 fSelectedRank
= rank
;
2098 fTable
.setSelection(index
+ 1); // +1 for header row
2102 // ------------------------------------------------------------------------
2104 // ------------------------------------------------------------------------
2109 * @see org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener#colorSettingsChanged(org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting[])
2112 public void colorSettingsChanged(final ColorSetting
[] colorSettings
) {
2116 // ------------------------------------------------------------------------
2118 // ------------------------------------------------------------------------
2121 * Handler for the trace updated signal
2124 * The incoming signal
2127 public void traceUpdated(final TmfTraceUpdatedSignal signal
) {
2128 if ((signal
.getTrace() != fTrace
) || fTable
.isDisposed()) {
2131 // Perform the refresh on the UI thread
2132 Display
.getDefault().asyncExec(new Runnable() {
2135 if (!fTable
.isDisposed() && (fTrace
!= null)) {
2136 if (fTable
.getData(Key
.FILTER_OBJ
) == null) {
2137 fTable
.setItemCount((int) fTrace
.getNbEvents() + 1); // +1 for header row
2138 if ((fPendingGotoRank
!= -1) && ((fPendingGotoRank
+ 1) < fTable
.getItemCount())) { // +1 for header row
2139 fTable
.setSelection((int) fPendingGotoRank
+ 1); // +1 for header row
2140 fPendingGotoRank
= -1;
2143 startFilterThread();
2146 if (!fRawViewer
.isDisposed() && (fTrace
!= null)) {
2147 fRawViewer
.refreshEventCount();
2154 * Handler for the time synch signal.
2157 * The incoming signal
2160 public void currentTimeUpdated(final TmfTimeSynchSignal signal
) {
2161 if ((signal
.getSource() != this) && (fTrace
!= null) && (!fTable
.isDisposed())) {
2163 // Create a request for one event that will be queued after other ongoing requests. When this request is completed
2164 // do the work to select the actual event with the timestamp specified in the signal. This procedure prevents
2165 // the method fTrace.getRank() from interfering and delaying ongoing requests.
2166 final TmfDataRequest subRequest
= new TmfDataRequest(ITmfEvent
.class, 0, 1, ExecutionType
.FOREGROUND
) {
2168 TmfTimestamp ts
= new TmfTimestamp(signal
.getCurrentTime());
2171 public void handleData(final ITmfEvent event
) {
2172 super.handleData(event
);
2176 public void handleCompleted() {
2177 super.handleCompleted();
2178 if (fTrace
== null) {
2182 // Verify if the event is within the trace range and adjust if necessary
2183 ITmfTimestamp timestamp
= ts
;
2184 if (timestamp
.compareTo(fTrace
.getStartTime(), true) == -1) {
2185 timestamp
= fTrace
.getStartTime();
2187 if (timestamp
.compareTo(fTrace
.getEndTime(), true) == 1) {
2188 timestamp
= fTrace
.getEndTime();
2191 // Get the rank of the selected event in the table
2192 final ITmfContext context
= fTrace
.seekEvent(timestamp
);
2193 final long rank
= context
.getRank();
2195 fSelectedRank
= rank
;
2197 fTable
.getDisplay().asyncExec(new Runnable() {
2200 // Return if table is disposed
2201 if (fTable
.isDisposed()) {
2205 int index
= (int) rank
;
2206 if (fTable
.isDisposed()) {
2209 if (fTable
.getData(Key
.FILTER_OBJ
) != null) {
2210 index
= fCache
.getFilteredEventIndex(rank
) + 1; // +1 for top filter status row
2212 fTable
.setSelection(index
+ 1); // +1 for header row
2213 fRawViewer
.selectAndReveal(rank
);
2219 ((ITmfDataProvider
) fTrace
).sendRequest(subRequest
);
2223 // ------------------------------------------------------------------------
2225 // ------------------------------------------------------------------------
2228 * Display an exception in a message box
2230 * @param e the exception
2232 private static void displayException(final Exception e
) {
2233 final MessageBox mb
= new MessageBox(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
2234 mb
.setText(e
.getClass().getSimpleName());
2235 mb
.setMessage(e
.getMessage());
2242 public void refresh() {