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