1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Alexandre Montplaisir - Initial API and implementation
11 ******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.events
.columns
;
15 import org
.eclipse
.jdt
.annotation
.NonNullByDefault
;
16 import org
.eclipse
.jdt
.annotation
.Nullable
;
17 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.viewers
.events
.columns
.TmfContentsColumn
;
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
;
24 * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable}. In
25 * addition to ones provided by default, trace types can extend this class to
26 * create additional columns specific to their events.
28 * Those additional columns can then be passed to the constructor
29 * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable#TmfEventsTable(org.eclipse.swt.widgets.Composite, int, java.util.Collection)}
31 * @author Alexandre Montplaisir
35 public abstract class TmfEventTableColumn
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
42 * The base set of columns, which can apply to any trace type.
44 public static interface BaseColumns
{
46 /** Column showing the event timestamp */
47 TmfEventTableColumn TIMESTAMP
= new TmfTimestampColumn();
49 /** Column showing the event type */
50 TmfEventTableColumn EVENT_TYPE
= new TmfTypeColumn();
52 /** Column showing the aggregated event contents (fields) */
53 TmfEventTableColumn CONTENTS
= new TmfContentsColumn();
57 * Static definition of an empty string. Return this instead of returning
60 protected static final String EMPTY_STRING
= ""; //$NON-NLS-1$
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
66 private final String fHeaderName
;
67 private final @Nullable String fHeaderTooltip
;
69 // ------------------------------------------------------------------------
71 // ------------------------------------------------------------------------
74 * Constructor with no tooltip.
77 * The name (title) of this column. Should ideally be short.
79 public TmfEventTableColumn(String headerName
) {
80 fHeaderName
= headerName
;
81 fHeaderTooltip
= null;
85 * Constructor with a tooltip.
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
93 public TmfEventTableColumn(String headerName
, @Nullable String headerTooltip
) {
94 fHeaderName
= headerName
;
95 fHeaderTooltip
= headerTooltip
;
98 // ------------------------------------------------------------------------
100 // ------------------------------------------------------------------------
103 * Get this column's header name, a.k.a. title
105 * @return The column's title
107 public String
getHeaderName() {
112 * Get the tooltip text for the column header
114 * @return The header's tooltip
116 public @Nullable String
getHeaderTooltip() {
117 return fHeaderTooltip
;
120 // ------------------------------------------------------------------------
122 // ------------------------------------------------------------------------
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
129 * Note to implementers:
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
138 * The trace event whose element we want to display
139 * @return The string to display in the column for this event
141 public abstract String
getItemString(ITmfEvent event
);
144 * Return the FILTER_ID used by the filters to search this column.
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.)
150 public abstract @Nullable String
getFilterFieldId();