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