1 /*******************************************************************************
2 * Copyright (c) 2014 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 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Updated to new Event Table API
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.btf
.ui
;
16 import org
.eclipse
.linuxtools
.btf
.core
.event
.BtfEvent
;
17 import org
.eclipse
.linuxtools
.btf
.core
.trace
.BtfColumnNames
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEventField
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEventField
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.virtualtable
.ColumnData
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
29 * @author Matthew Khouzam
31 public class BtfEventViewer
extends TmfEventsTable
{
33 private static final TmfEventField NULL_NOTE_FIELD
=
34 new TmfEventField(BtfColumnNames
.NOTES
.toString(), null, null);
36 private static final String
[] COLUMN_NAMES
= new String
[] {
37 BtfColumnNames
.TIMESTAMP
.toString(),
38 BtfColumnNames
.SOURCE
.toString(),
39 BtfColumnNames
.SOURCE_INSTANCE
.toString(),
40 BtfColumnNames
.EVENT_TYPE
.toString(),
41 BtfColumnNames
.TARGET
.toString(),
42 BtfColumnNames
.TARGET_INSTANCE
.toString(),
43 BtfColumnNames
.EVENT
.toString(),
44 BtfColumnNames
.NOTES
.toString()
47 private static final ColumnData
[] COLUMN_DATA
= new ColumnData
[] {
48 new ColumnData(COLUMN_NAMES
[0], 150, SWT
.LEFT
),
49 new ColumnData(COLUMN_NAMES
[1], 120, SWT
.LEFT
),
50 new ColumnData(COLUMN_NAMES
[2], 100, SWT
.LEFT
),
51 new ColumnData(COLUMN_NAMES
[3], 120, SWT
.LEFT
),
52 new ColumnData(COLUMN_NAMES
[4], 90, SWT
.LEFT
),
53 new ColumnData(COLUMN_NAMES
[5], 100, SWT
.LEFT
),
54 new ColumnData(COLUMN_NAMES
[6], 110, SWT
.LEFT
),
55 new ColumnData(COLUMN_NAMES
[7], 100, SWT
.LEFT
),
59 * Basic constructor, will use default column data.
62 * The parent composite UI object
64 * The size of the event table cache
66 public BtfEventViewer(Composite parent
, int cacheSize
) {
67 super(parent
, cacheSize
, COLUMN_DATA
);
68 fTable
.getColumns()[0].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_TIMESTAMP
);
69 fTable
.getColumns()[1].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_SOURCE
);
70 fTable
.getColumns()[3].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_TYPE
);
71 fTable
.getColumns()[4].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_REFERENCE
);
75 public String
[] getItemStrings(ITmfEvent event
) {
76 if (!(event
instanceof BtfEvent
)) {
77 return EMPTY_STRING_ARRAY
;
79 final BtfEvent btfEvent
= (BtfEvent
) event
;
80 final ITmfEventField content
= btfEvent
.getContent();
81 final ITmfEventField notesField
= content
.getField(BtfColumnNames
.NOTES
.toString());
84 event
.getTimestamp().toString(),
86 content
.getField(BtfColumnNames
.SOURCE_INSTANCE
.toString()).toString(),
87 btfEvent
.getType().getName(),
89 content
.getField(BtfColumnNames
.TARGET_INSTANCE
.toString()).toString(),
90 content
.getField(BtfColumnNames
.EVENT
.toString()).toString(),
91 ((notesField
!= null) ? notesField
: NULL_NOTE_FIELD
).toString()