ctf: make Declarations have some NonNull annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.btf.ui / src / org / eclipse / tracecompass / btf / ui / BtfEventTableColumns.java
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
11 * Alexandre Montplaisir - Update to new Event Table API
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.btf.ui;
15
16 import java.util.Collection;
17
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.eclipse.tracecompass.btf.core.event.BtfEvent;
20 import org.eclipse.tracecompass.btf.core.trace.BtfColumnNames;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
22 import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
23 import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
24 import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
25 import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
26
27 import com.google.common.collect.ImmutableList;
28
29 /**
30 * Columns to use in the BTF event table
31 *
32 * @author Alexandre Montplaisir
33 */
34 public class BtfEventTableColumns implements ITmfEventTableColumns {
35
36 // ------------------------------------------------------------------------
37 // Column definition
38 // ------------------------------------------------------------------------
39
40 @SuppressWarnings("null")
41 private static final @NonNull Collection<TmfEventTableColumn> BTF_COLUMNS = ImmutableList.of(
42 new TmfEventTableColumn(ITmfEventAspect.BaseAspects.TIMESTAMP),
43 new TmfEventTableColumn(new BtfSourceAspect()),
44 new TmfEventTableColumn(new BtfSourceInstanceAspect()),
45 new TmfEventTableColumn(ITmfEventAspect.BaseAspects.EVENT_TYPE),
46 new TmfEventTableColumn(new BtfTargetAspect()),
47 new TmfEventTableColumn(new BtfTargetInstanceAspect()),
48 new TmfEventTableColumn(new BtfEventAspect()),
49 new TmfEventTableColumn(new BtfNotesAspect())
50 );
51
52 /**
53 * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
54 */
55 private static class BtfSourceAspect implements ITmfEventAspect {
56
57 @Override
58 public String getName() {
59 return BtfColumnNames.SOURCE.toString();
60 }
61
62 @Override
63 public String getHelpText() {
64 return EMPTY_STRING;
65 }
66
67 @Override
68 public String resolve(ITmfEvent event) {
69 if (!(event instanceof BtfEvent)) {
70 return EMPTY_STRING;
71 }
72 String ret = ((BtfEvent) event).getSource();
73 return (ret == null ? EMPTY_STRING : ret);
74 }
75
76 @Override
77 public String getFilterId() {
78 return ITmfEvent.EVENT_FIELD_SOURCE;
79 }
80 }
81
82 /**
83 * The "source instance" aspect, whose value comes from the field of the
84 * same name.
85 */
86 private static class BtfSourceInstanceAspect extends TmfEventFieldAspect {
87 public BtfSourceInstanceAspect() {
88 super(BtfColumnNames.SOURCE_INSTANCE.toString(),
89 BtfColumnNames.SOURCE_INSTANCE.toString());
90 }
91 }
92
93 /**
94 * The "target" aspect, taking its value from
95 * {@link ITmfEvent#getReference()}.
96 */
97 private static class BtfTargetAspect implements ITmfEventAspect {
98
99 @Override
100 public String getName() {
101 return BtfColumnNames.TARGET.toString();
102 }
103
104 @Override
105 public String getHelpText() {
106 return EMPTY_STRING;
107 }
108
109 @Override
110 public String resolve(ITmfEvent event) {
111 if (!(event instanceof BtfEvent)) {
112 return EMPTY_STRING;
113 }
114 String ret = ((BtfEvent) event).getReference();
115 return (ret == null ? EMPTY_STRING : ret);
116 }
117
118 @Override
119 public String getFilterId() {
120 return ITmfEvent.EVENT_FIELD_REFERENCE;
121 }
122 }
123
124 /**
125 * The "target instance" aspect, whose value comes from the field of the
126 * same name.
127 */
128 private static class BtfTargetInstanceAspect extends TmfEventFieldAspect {
129 public BtfTargetInstanceAspect() {
130 super(BtfColumnNames.TARGET_INSTANCE.toString(),
131 BtfColumnNames.TARGET_INSTANCE.toString());
132 }
133 }
134
135 /**
136 * The "event" aspect, whose value comes from the field of the same name.
137 */
138 private static class BtfEventAspect extends TmfEventFieldAspect {
139 public BtfEventAspect() {
140 super(BtfColumnNames.EVENT.toString(),
141 BtfColumnNames.EVENT.toString());
142 }
143 }
144
145 /**
146 * The "notes" column, whose value comes from the field of the same name, if
147 * present.
148 */
149 private static class BtfNotesAspect extends TmfEventFieldAspect {
150 public BtfNotesAspect() {
151 super(BtfColumnNames.NOTES.toString(),
152 BtfColumnNames.NOTES.toString());
153 }
154 }
155
156 // ------------------------------------------------------------------------
157 // ITmfEventTableColumns
158 // ------------------------------------------------------------------------
159
160 @Override
161 public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
162 return BTF_COLUMNS;
163 }
164 }
This page took 0.040734 seconds and 5 git commands to generate.