59a959202d99783d63fa2e2192e656e9598f26da
[deliverable/tracecompass.git] / org.eclipse.linuxtools.btf.ui / src / org / eclipse / linuxtools / 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.linuxtools.btf.ui;
15
16 import java.util.Collection;
17
18 import org.eclipse.jdt.annotation.NonNull;
19 import org.eclipse.linuxtools.btf.core.trace.BtfColumnNames;
20 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
21 import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
22 import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.TmfEventTableColumn;
23 import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.TmfEventTableFieldColumn;
24
25 import com.google.common.collect.ImmutableList;
26
27 /**
28 * Columns to use in the BTF event table
29 *
30 * @author Alexandre Montplaisir
31 */
32 public class BtfEventTableColumns implements ITmfEventTableColumns {
33
34 // ------------------------------------------------------------------------
35 // Column definition
36 // ------------------------------------------------------------------------
37
38 @SuppressWarnings("null")
39 private static final @NonNull Collection<TmfEventTableColumn> BTF_COLUMNS = ImmutableList.of(
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 // ------------------------------------------------------------------------
133 // ITmfEventTableColumns
134 // ------------------------------------------------------------------------
135
136 @Override
137 public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
138 return BTF_COLUMNS;
139 }
140 }
This page took 0.04183 seconds and 4 git commands to generate.