1 /*******************************************************************************
2 * Copyright (c) 2014, 2015 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
.common
.core
.NonNullUtils
;
18 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
23 * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable}. In
24 * addition to ones provided by default, trace types can extend this class to
25 * create additional columns specific to their events.
27 * Those additional columns can then be passed to the constructor
28 * {@link org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable#TmfEventsTable(org.eclipse.swt.widgets.Composite, int, java.util.Collection)}
30 * @author Alexandre Montplaisir
31 * @noextend This class should not be extended directly. You should instead
32 * implement an {@link ITmfEventAspect}.
36 public class TmfEventTableColumn
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 private final ITmfEventAspect fAspect
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
52 * The {@link ITmfEventAspect} to be used to populate this
55 public TmfEventTableColumn(ITmfEventAspect aspect
) {
59 // ------------------------------------------------------------------------
61 // ------------------------------------------------------------------------
64 * Get this column's header name, a.k.a. title
66 * @return The column's title
68 public String
getHeaderName() {
69 return fAspect
.getName();
73 * Get the tooltip text for the column header
75 * @return The header's tooltip
77 public @Nullable String
getHeaderTooltip() {
78 return fAspect
.getHelpText();
82 * Get the string that should be displayed in this column's cell for a given
83 * trace event. Basically, this defines "what to print in this column for
87 * The trace event whose element we want to display
88 * @return The string to display in the column for this event
90 public String
getItemString(ITmfEvent event
) {
91 return NonNullUtils
.nullToEmptyString(fAspect
.resolve(event
));
95 * Get the event aspect assigned to this column
97 * @return The event aspect
99 public ITmfEventAspect
getEventAspect() {
103 // ------------------------------------------------------------------------
104 // hashCode/equals (so that equivalent columns can be merged together)
105 // ------------------------------------------------------------------------
108 public int hashCode() {
109 final int prime
= 31;
111 result
= prime
* result
+ fAspect
.hashCode();
116 public boolean equals(@Nullable Object obj
) {
123 if (!(obj
instanceof TmfEventTableColumn
)) {
126 TmfEventTableColumn other
= (TmfEventTableColumn
) obj
;
127 if (!fAspect
.equals(other
.fAspect
)) {
128 /* Aspects can also define how they can be "equal" to one another */