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