1 /*******************************************************************************
2 * Copyright (c) 2010 Ericsson
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
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
;
15 import java
.util
.LinkedList
;
16 import java
.util
.List
;
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
;
27 * Events table for custom text parsers.
29 * @author Patrick Tassé
31 public class CustomEventsTable
extends TmfEventsTable
{
33 private final CustomTraceDefinition fDefinition
;
39 * Trace definition object
41 * Parent composite of the view
43 * How many events to keep in cache
45 public CustomEventsTable(CustomTraceDefinition definition
, Composite parent
, int cacheSize
) {
46 super(parent
, cacheSize
, new ColumnData
[0]);
47 fDefinition
= definition
;
48 createColumnHeaders();
52 * Create the table's headers.
54 protected void createColumnHeaders() {
55 if (fDefinition
== null) {
58 List
<ColumnData
> columnData
= new LinkedList
<ColumnData
>();
59 for (OutputColumn outputColumn
: fDefinition
.outputs
) {
60 ColumnData column
= new ColumnData(outputColumn
.name
, 0, SWT
.LEFT
);
61 columnData
.add(column
);
63 setColumnHeaders(columnData
.toArray(new ColumnData
[0]));
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();
76 return new TmfEventField
[0];