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
.tmf
.ui
.parsers
.custom
;
15 import java
.text
.SimpleDateFormat
;
16 import java
.util
.LinkedList
;
17 import java
.util
.List
;
18 import java
.util
.TimeZone
;
20 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.parsers
.custom
.CustomTraceDefinition
.OutputColumn
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.ColumnData
;
24 import org
.eclipse
.swt
.SWT
;
25 import org
.eclipse
.swt
.widgets
.Composite
;
27 public class CustomEventsTable
extends TmfEventsTable
{
29 private CustomTraceDefinition fDefinition
;
31 public CustomEventsTable(CustomTraceDefinition definition
, Composite parent
, int cacheSize
) {
32 super(parent
, cacheSize
);
33 fDefinition
= definition
;
34 createColumnHeaders();
37 public static final String TIMESTAMP_FORMAT
= "yyyy-MM-dd HH:mm:ss.SSS";
38 private static final SimpleDateFormat TIMESTAMP_SIMPLE_DATE_FORMAT
= new SimpleDateFormat(TIMESTAMP_FORMAT
);
40 TIMESTAMP_SIMPLE_DATE_FORMAT
.setTimeZone(TimeZone
.getTimeZone("GMT"));
43 protected void createColumnHeaders() {
44 if (fDefinition
== null)
46 List
<ColumnData
> columnData
= new LinkedList
<ColumnData
>();
47 for (OutputColumn outputColumn
: fDefinition
.outputs
) {
48 ColumnData column
= new ColumnData(outputColumn
.name
, 0, SWT
.LEFT
);
49 columnData
.add(column
);
51 setColumnHeaders((ColumnData
[]) columnData
.toArray());
55 // public void createColumnHeaders(final Table table) {
56 // if (fDefinition == null) return; // ignore when called by the super constructor
57 // for (OutputColumn outputColumn : fDefinition.outputs) {
58 // TableColumn column = new TableColumn(table, SWT.LEFT);
59 // column.setText(outputColumn.name);
65 public String
[] extractItemFields(TmfEvent event
) {
66 if (event
instanceof CustomEvent
) {
67 return ((CustomEvent
) event
).extractItemFields();