Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
c8422608 | 2 | * Copyright (c) 2010, 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 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom; | |
14 | ||
15 | import java.util.LinkedList; | |
16 | import java.util.List; | |
17 | ||
18 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn; | |
19 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; | |
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; | |
25 | ||
a0a88f65 AM |
26 | /** |
27 | * Events table for custom text parsers. | |
28 | * | |
29 | * @author Patrick Tassé | |
30 | */ | |
be222f56 PT |
31 | public class CustomEventsTable extends TmfEventsTable { |
32 | ||
33 | private final CustomTraceDefinition fDefinition; | |
34 | ||
a0a88f65 AM |
35 | /** |
36 | * Constructor. | |
37 | * | |
38 | * @param definition | |
39 | * Trace definition object | |
40 | * @param parent | |
41 | * Parent composite of the view | |
42 | * @param cacheSize | |
43 | * How many events to keep in cache | |
44 | */ | |
be222f56 PT |
45 | public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) { |
46 | super(parent, cacheSize, new ColumnData[0]); | |
47 | fDefinition = definition; | |
48 | createColumnHeaders(); | |
49 | } | |
50 | ||
a0a88f65 AM |
51 | /** |
52 | * Create the table's headers. | |
53 | */ | |
be222f56 | 54 | protected void createColumnHeaders() { |
a0a88f65 | 55 | if (fDefinition == null) { |
be222f56 PT |
56 | return; |
57 | } | |
507b1336 | 58 | List<ColumnData> columnData = new LinkedList<>(); |
a0a88f65 AM |
59 | for (OutputColumn outputColumn : fDefinition.outputs) { |
60 | ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT); | |
61 | columnData.add(column); | |
62 | } | |
63 | setColumnHeaders(columnData.toArray(new ColumnData[0])); | |
be222f56 PT |
64 | } |
65 | ||
66 | @Override | |
67 | public TmfEventField[] extractItemFields(ITmfEvent event) { | |
68 | if (event instanceof CustomEvent) { | |
69 | TmfEventField[] fields = ((CustomEvent) event).extractItemFields(); | |
70 | // String[] labels = new String[fields.length]; | |
71 | // for (int i = 0; i < fields.length; i++) { | |
72 | // labels[i] = (String) fields[i].getValue(); | |
73 | // } | |
74 | return fields; | |
75 | } | |
76 | return new TmfEventField[0]; | |
77 | } | |
78 | } |