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