Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
be222f56 PT |
3 | * |
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 | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.lttng2.kernel.ui.viewers.events; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; | |
16 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventField; | |
17 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField; | |
18 | import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; | |
19 | import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData; | |
20 | import org.eclipse.swt.SWT; | |
21 | import org.eclipse.swt.widgets.Composite; | |
22 | ||
23 | /** | |
24 | * Events table specific for LTTng 2.0 kernel traces | |
25 | */ | |
26 | public class LTTng2EventsTable extends TmfEventsTable { | |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Table data | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
32 | // Table column names | |
33 | static private final String TIMESTAMP_COLUMN = Messages.EventsTable_timestampColumn; | |
34 | static private final String CHANNEL_COLUMN = Messages.EventsTable_channelColumn; | |
35 | static private final String TYPE_COLUMN = Messages.EventsTable_typeColumn; | |
36 | static private final String CONTENT_COLUMN = Messages.EventsTable_contentColumn; | |
37 | static private final String[] COLUMN_NAMES = new String[] { | |
38 | TIMESTAMP_COLUMN, | |
39 | CHANNEL_COLUMN, | |
40 | TYPE_COLUMN, | |
41 | CONTENT_COLUMN | |
42 | }; | |
43 | ||
44 | static private final ColumnData[] COLUMN_DATA = new ColumnData[] { | |
45 | new ColumnData(COLUMN_NAMES[0], 150, SWT.LEFT), | |
46 | new ColumnData(COLUMN_NAMES[1], 120, SWT.LEFT), | |
47 | new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT), | |
48 | new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT) | |
49 | }; | |
50 | ||
51 | // ------------------------------------------------------------------------ | |
52 | // Constructor | |
53 | // ------------------------------------------------------------------------ | |
54 | ||
55 | /** | |
56 | * Constructor | |
57 | * | |
58 | * @param parent | |
59 | * The parent composite | |
60 | * @param cacheSize | |
61 | * The size of the rows cache | |
62 | */ | |
63 | public LTTng2EventsTable(Composite parent, int cacheSize) { | |
64 | super(parent, cacheSize, COLUMN_DATA); | |
65 | fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP); | |
66 | fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE); | |
67 | fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE); | |
68 | fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT); | |
69 | } | |
70 | ||
be222f56 PT |
71 | @Override |
72 | protected ITmfEventField[] extractItemFields(ITmfEvent event) { | |
73 | ITmfEventField[] fields = new TmfEventField[0]; | |
74 | if (event != null) { | |
75 | fields = new TmfEventField[] { | |
214cc822 AM |
76 | new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, event.getTimestamp().toString(), null), |
77 | new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference(), null), | |
78 | new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName(), null), | |
79 | new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString(), null) | |
be222f56 PT |
80 | }; |
81 | } | |
82 | return fields; | |
83 | } | |
84 | ||
85 | } |