Commit | Line | Data |
---|---|---|
13d34fc6 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2014 Ericsson | |
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 | * Alexandre Montplaisir - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
2bdf0193 | 13 | package org.eclipse.tracecompass.tmf.ui.viewers.events.text; |
13d34fc6 AM |
14 | |
15 | import java.util.List; | |
16 | ||
13d34fc6 | 17 | import org.eclipse.swt.widgets.Composite; |
2bdf0193 AM |
18 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
19 | import org.eclipse.tracecompass.tmf.core.trace.text.TextTraceEvent; | |
20 | import org.eclipse.tracecompass.tmf.core.trace.text.TextTraceEventContent; | |
21 | import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable; | |
22 | import org.eclipse.tracecompass.tmf.ui.widgets.virtualtable.ColumnData; | |
13d34fc6 AM |
23 | |
24 | /** | |
25 | * Event table for text traces, which has one column for every event field. | |
26 | * | |
27 | * @author Alexandre Montplaisir | |
baafe54c AM |
28 | * @deprecated Users of this class should instead use |
29 | * {@link TmfEventsTable#TmfEventsTable(Composite, int, java.util.Collection)} | |
30 | * , by passing | |
2bdf0193 | 31 | * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn} |
baafe54c | 32 | * . |
13d34fc6 | 33 | */ |
baafe54c | 34 | @Deprecated |
13d34fc6 AM |
35 | public class TmfTextEventTable extends TmfEventsTable { |
36 | ||
13d34fc6 AM |
37 | /** |
38 | * Constructor | |
39 | * | |
40 | * @param parent | |
41 | * The parent composite UI object | |
42 | * @param cacheSize | |
43 | * The size of the event table cache | |
44 | * @param columnData | |
45 | * The column data to use for this table | |
46 | */ | |
47 | public TmfTextEventTable(Composite parent, int cacheSize, ColumnData[] columnData) { | |
48 | super(parent, cacheSize, columnData); | |
49 | } | |
50 | ||
51 | /** | |
52 | * @param event | |
53 | * The event to get the column strings for. It should be an | |
54 | * instance of {@link TextTraceEvent}. | |
55 | */ | |
56 | @Override | |
57 | public String[] getItemStrings(ITmfEvent event) { | |
58 | if (event instanceof TextTraceEvent) { | |
59 | List<TextTraceEventContent> fields = ((TextTraceEvent) event).getContent().getFields(); | |
60 | String[] strings = new String[fields.size()]; | |
61 | for (int i = 0; i < strings.length; i++) { | |
62 | Object value = fields.get(i).getValue(); | |
63 | strings[i] = (value == null ? EMPTY_STRING : value.toString()); | |
64 | } | |
65 | return strings; | |
66 | } | |
67 | return EMPTY_STRING_ARRAY; | |
68 | } | |
69 | } |