Commit | Line | Data |
---|---|---|
ff71e543 MK |
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 | * Matthew Khouzam - Initial API and implementation | |
99d7adc6 | 11 | * Alexandre Montplaisir - Update to new Event Table API |
ff71e543 MK |
12 | *******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.btf.ui; | |
15 | ||
baafe54c AM |
16 | import java.util.Collection; |
17 | ||
99d7adc6 | 18 | import org.eclipse.jdt.annotation.NonNull; |
ff71e543 | 19 | import org.eclipse.linuxtools.btf.core.trace.BtfColumnNames; |
2bdf0193 AM |
20 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
21 | import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns; | |
22 | import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn; | |
23 | import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableFieldColumn; | |
ff71e543 | 24 | |
baafe54c AM |
25 | import com.google.common.collect.ImmutableList; |
26 | ||
ff71e543 | 27 | /** |
99d7adc6 | 28 | * Columns to use in the BTF event table |
ff71e543 | 29 | * |
99d7adc6 | 30 | * @author Alexandre Montplaisir |
ff71e543 | 31 | */ |
99d7adc6 | 32 | public class BtfEventTableColumns implements ITmfEventTableColumns { |
ff71e543 | 33 | |
baafe54c AM |
34 | // ------------------------------------------------------------------------ |
35 | // Column definition | |
36 | // ------------------------------------------------------------------------ | |
37 | ||
99d7adc6 AM |
38 | @SuppressWarnings("null") |
39 | private static final @NonNull Collection<TmfEventTableColumn> BTF_COLUMNS = ImmutableList.of( | |
baafe54c AM |
40 | TmfEventTableColumn.BaseColumns.TIMESTAMP, |
41 | new BtfSourceColumn(), | |
42 | new BtfSourceInstanceColumn(), | |
43 | TmfEventTableColumn.BaseColumns.EVENT_TYPE, | |
44 | new BtfTargetColumn(), | |
45 | new BtfTargetInstanceColumn(), | |
46 | new BtfEventColumn(), | |
47 | new BtfNotesColumn() | |
48 | ); | |
49 | ||
50 | /** | |
51 | * The "source" column, whose value comes from {@link ITmfEvent#getSource()} | |
52 | */ | |
53 | private static class BtfSourceColumn extends TmfEventTableColumn { | |
54 | ||
55 | public BtfSourceColumn() { | |
56 | super(BtfColumnNames.SOURCE.toString(), null); | |
57 | } | |
58 | ||
59 | @Override | |
60 | public String getItemString(ITmfEvent event) { | |
61 | String ret = event.getSource(); | |
62 | return (ret == null ? EMPTY_STRING : ret); | |
63 | } | |
64 | ||
65 | @Override | |
66 | public String getFilterFieldId() { | |
67 | return ITmfEvent.EVENT_FIELD_SOURCE; | |
68 | } | |
69 | } | |
70 | ||
71 | /** | |
72 | * The "source instance" column, whose value comes from the field of the | |
73 | * same name. | |
74 | */ | |
75 | private static class BtfSourceInstanceColumn extends TmfEventTableFieldColumn { | |
76 | public BtfSourceInstanceColumn() { | |
77 | super(BtfColumnNames.SOURCE_INSTANCE.toString()); | |
78 | } | |
79 | } | |
80 | ||
81 | /** | |
82 | * The "target" column, taking its value from | |
83 | * {@link ITmfEvent#getReference()}. | |
84 | */ | |
85 | private static class BtfTargetColumn extends TmfEventTableColumn { | |
86 | ||
87 | public BtfTargetColumn() { | |
88 | super(BtfColumnNames.TARGET.toString()); | |
89 | } | |
90 | ||
91 | @Override | |
92 | public String getItemString(ITmfEvent event) { | |
93 | String ret = event.getReference(); | |
94 | return (ret == null ? EMPTY_STRING : ret); | |
95 | } | |
96 | ||
97 | @Override | |
98 | public String getFilterFieldId() { | |
99 | return ITmfEvent.EVENT_FIELD_REFERENCE; | |
100 | } | |
101 | } | |
102 | ||
103 | /** | |
104 | * The "target instance" column, whose value comes from the field of the | |
105 | * same name. | |
106 | */ | |
107 | private static class BtfTargetInstanceColumn extends TmfEventTableFieldColumn { | |
108 | public BtfTargetInstanceColumn() { | |
109 | super(BtfColumnNames.TARGET_INSTANCE.toString()); | |
110 | } | |
111 | } | |
112 | ||
113 | /** | |
114 | * The "event" column, whose value comes from the field of the same name. | |
115 | */ | |
116 | private static class BtfEventColumn extends TmfEventTableFieldColumn { | |
117 | public BtfEventColumn() { | |
118 | super(BtfColumnNames.EVENT.toString()); | |
119 | } | |
120 | } | |
121 | ||
122 | /** | |
123 | * The "notes" column, whose value comes from the field of the same name, if | |
124 | * present. | |
125 | */ | |
126 | private static class BtfNotesColumn extends TmfEventTableFieldColumn { | |
127 | public BtfNotesColumn() { | |
128 | super(BtfColumnNames.NOTES.toString()); | |
129 | } | |
130 | } | |
131 | ||
132 | // ------------------------------------------------------------------------ | |
99d7adc6 | 133 | // ITmfEventTableColumns |
baafe54c | 134 | // ------------------------------------------------------------------------ |
ff71e543 | 135 | |
99d7adc6 AM |
136 | @Override |
137 | public Collection<? extends TmfEventTableColumn> getEventTableColumns() { | |
138 | return BTF_COLUMNS; | |
ff71e543 | 139 | } |
baafe54c | 140 | } |