Commit | Line | Data |
---|---|---|
c3c5c786 FC |
1 | /*******************************************************************************\r |
2 | * Copyright (c) 2010 Ericsson\r | |
ce2388e0 | 3 | *\r |
c3c5c786 FC |
4 | * All rights reserved. This program and the accompanying materials are\r |
5 | * made available under the terms of the Eclipse Public License v1.0 which\r | |
6 | * accompanies this distribution, and is available at\r | |
7 | * http://www.eclipse.org/legal/epl-v10.html\r | |
ce2388e0 | 8 | *\r |
c3c5c786 FC |
9 | * Contributors:\r |
10 | * Patrick Tasse - Initial API and implementation\r | |
11 | *******************************************************************************/\r | |
12 | \r | |
d34665f9 | 13 | package org.eclipse.linuxtools.internal.tmf.ui.parsers.custom;\r |
c3c5c786 | 14 | \r |
9ccc6d01 FC |
15 | import java.util.LinkedList;\r |
16 | import java.util.List;\r | |
c3c5c786 | 17 | \r |
d34665f9 | 18 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition.OutputColumn;\r |
ce2388e0 | 19 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r |
5d3e8747 | 20 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r |
c3c5c786 | 21 | import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r |
fb5cad3d | 22 | import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;\r |
c3c5c786 FC |
23 | import org.eclipse.swt.SWT;\r |
24 | import org.eclipse.swt.widgets.Composite;\r | |
c3c5c786 FC |
25 | \r |
26 | public class CustomEventsTable extends TmfEventsTable {\r | |
27 | \r | |
ce2388e0 FC |
28 | private final CustomTraceDefinition fDefinition;\r |
29 | \r | |
c3c5c786 | 30 | public CustomEventsTable(CustomTraceDefinition definition, Composite parent, int cacheSize) {\r |
d7fcacc9 | 31 | super(parent, cacheSize, new ColumnData[0]);\r |
c3c5c786 | 32 | fDefinition = definition;\r |
9ccc6d01 | 33 | createColumnHeaders();\r |
c3c5c786 FC |
34 | }\r |
35 | \r | |
9ccc6d01 | 36 | protected void createColumnHeaders() {\r |
ce2388e0 FC |
37 | if (fDefinition == null) {\r |
38 | return;\r | |
39 | }\r | |
9ccc6d01 FC |
40 | List<ColumnData> columnData = new LinkedList<ColumnData>();\r |
41 | for (OutputColumn outputColumn : fDefinition.outputs) {\r | |
42 | ColumnData column = new ColumnData(outputColumn.name, 0, SWT.LEFT);\r | |
43 | columnData.add(column);\r | |
44 | }\r | |
ce2388e0 | 45 | setColumnHeaders(columnData.toArray(new ColumnData[0]));\r |
c3c5c786 FC |
46 | }\r |
47 | \r | |
48 | @Override\r | |
ce2388e0 | 49 | public TmfEventField[] extractItemFields(ITmfEvent event) {\r |
c3c5c786 | 50 | if (event instanceof CustomEvent) {\r |
5d3e8747 | 51 | TmfEventField[] fields = ((CustomEvent) event).extractItemFields();\r |
52 | // String[] labels = new String[fields.length];\r | |
53 | // for (int i = 0; i < fields.length; i++) {\r | |
54 | // labels[i] = (String) fields[i].getValue();\r | |
55 | // }\r | |
56 | return fields;\r | |
c3c5c786 | 57 | }\r |
5d3e8747 | 58 | return new TmfEventField[0];\r |
c3c5c786 FC |
59 | }\r |
60 | }\r |