Commit | Line | Data |
---|---|---|
baafe54c 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.columns; |
baafe54c AM |
14 | |
15 | import org.eclipse.jdt.annotation.NonNullByDefault; | |
16 | import org.eclipse.jdt.annotation.Nullable; | |
2bdf0193 | 17 | import org.eclipse.tracecompass.internal.tmf.ui.viewers.events.columns.TmfContentsColumn; |
2bdf0193 AM |
18 | import org.eclipse.tracecompass.internal.tmf.ui.viewers.events.columns.TmfTimestampColumn; |
19 | import org.eclipse.tracecompass.internal.tmf.ui.viewers.events.columns.TmfTypeColumn; | |
20 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
baafe54c AM |
21 | |
22 | /** | |
23 | * A column in the | |
2bdf0193 | 24 | * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable}. In |
baafe54c AM |
25 | * addition to ones provided by default, trace types can extend this class to |
26 | * create additional columns specific to their events. | |
27 | * | |
28 | * Those additional columns can then be passed to the constructor | |
2bdf0193 | 29 | * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable#TmfEventsTable(org.eclipse.swt.widgets.Composite, int, java.util.Collection)} |
baafe54c AM |
30 | * |
31 | * @author Alexandre Montplaisir | |
32 | * @since 3.1 | |
33 | */ | |
34 | @NonNullByDefault | |
35 | public abstract class TmfEventTableColumn { | |
36 | ||
37 | // ------------------------------------------------------------------------ | |
38 | // Class attributes | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
41 | /** | |
42 | * The base set of columns, which can apply to any trace type. | |
43 | */ | |
44 | public static interface BaseColumns { | |
45 | ||
46 | /** Column showing the event timestamp */ | |
47 | TmfEventTableColumn TIMESTAMP = new TmfTimestampColumn(); | |
48 | ||
baafe54c AM |
49 | /** Column showing the event type */ |
50 | TmfEventTableColumn EVENT_TYPE = new TmfTypeColumn(); | |
51 | ||
baafe54c AM |
52 | /** Column showing the aggregated event contents (fields) */ |
53 | TmfEventTableColumn CONTENTS = new TmfContentsColumn(); | |
54 | } | |
55 | ||
56 | /** | |
57 | * Static definition of an empty string. Return this instead of returning | |
58 | * 'null'! | |
59 | */ | |
60 | protected static final String EMPTY_STRING = ""; //$NON-NLS-1$ | |
61 | ||
62 | // ------------------------------------------------------------------------ | |
63 | // Fields | |
64 | // ------------------------------------------------------------------------ | |
65 | ||
66 | private final String fHeaderName; | |
67 | private final @Nullable String fHeaderTooltip; | |
68 | ||
69 | // ------------------------------------------------------------------------ | |
70 | // Constructors | |
71 | // ------------------------------------------------------------------------ | |
72 | ||
73 | /** | |
74 | * Constructor with no tooltip. | |
75 | * | |
76 | * @param headerName | |
77 | * The name (title) of this column. Should ideally be short. | |
78 | */ | |
79 | public TmfEventTableColumn(String headerName) { | |
80 | fHeaderName = headerName; | |
81 | fHeaderTooltip = null; | |
82 | } | |
83 | ||
84 | /** | |
85 | * Constructor with a tooltip. | |
86 | * | |
87 | * @param headerName | |
88 | * The name (title) of this column. Should ideally be short. | |
89 | * @param headerTooltip | |
90 | * The tooltip text for the column header. Use 'null' for no | |
91 | * tooltip. | |
92 | */ | |
93 | public TmfEventTableColumn(String headerName, @Nullable String headerTooltip) { | |
94 | fHeaderName = headerName; | |
95 | fHeaderTooltip = headerTooltip; | |
96 | } | |
97 | ||
98 | // ------------------------------------------------------------------------ | |
99 | // Getters | |
100 | // ------------------------------------------------------------------------ | |
101 | ||
102 | /** | |
103 | * Get this column's header name, a.k.a. title | |
104 | * | |
105 | * @return The column's title | |
106 | */ | |
107 | public String getHeaderName() { | |
108 | return fHeaderName; | |
109 | } | |
110 | ||
111 | /** | |
112 | * Get the tooltip text for the column header | |
113 | * | |
114 | * @return The header's tooltip | |
115 | */ | |
116 | public @Nullable String getHeaderTooltip() { | |
117 | return fHeaderTooltip; | |
118 | } | |
119 | ||
120 | // ------------------------------------------------------------------------ | |
121 | // Abstract methods | |
122 | // ------------------------------------------------------------------------ | |
123 | ||
124 | /** | |
125 | * Get the string that should be displayed in this column's cell for a given | |
126 | * trace event. Basically, this defines "what to print in this column for | |
127 | * this event". | |
128 | * <p> | |
129 | * Note to implementers: | |
130 | * <p> | |
131 | * This method takes an {@link ITmfEvent}, because any type of event could | |
132 | * potentially be present in the table at the time. Do not assume that you | |
133 | * will only receive events of your trace type. You'd probably want to | |
134 | * return an empty string for event that don't match your expected class | |
135 | * type here. | |
136 | * | |
137 | * @param event | |
138 | * The trace event whose element we want to display | |
139 | * @return The string to display in the column for this event | |
140 | */ | |
141 | public abstract String getItemString(ITmfEvent event); | |
142 | ||
143 | /** | |
144 | * Return the FILTER_ID used by the filters to search this column. | |
145 | * | |
146 | * @return The filter ID for this column, or 'null' to not provide a filter | |
147 | * ID (which will mean this column will probably not be | |
148 | * searchable/filterable.) | |
149 | */ | |
150 | public abstract @Nullable String getFilterFieldId(); | |
151 | } |