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 * Vincent Perot - Initial API and implementation
11 * Alexandre Montplaisir - Update to new TmfEventTableColumn API
12 *******************************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.ui
.editor
;
16 import java
.util
.Collection
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
19 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 import org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.event
.PcapEvent
;
21 import org
.eclipse
.tracecompass
.internal
.tmf
.pcap
.core
.protocol
.TmfPcapProtocol
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.event
.aspect
.ITmfEventAspect
;
24 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.events
.columns
.ITmfEventTableColumns
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.viewers
.events
.columns
.TmfEventTableColumn
;
27 import com
.google
.common
.collect
.ImmutableList
;
30 * Default event table for pcap traces.
32 * @author Vincent Perot
34 public class PcapEventTableColumns
implements ITmfEventTableColumns
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
40 @SuppressWarnings("null")
41 private static final @NonNull Collection
<TmfEventTableColumn
> PCAP_COLUMNS
= ImmutableList
.of(
42 new TmfEventTableColumn(ITmfEventAspect
.BaseAspects
.TIMESTAMP
),
43 new TmfEventTableColumn(new PcapSourceAspect()),
44 new TmfEventTableColumn(new PcapDestinationAspect()),
45 new TmfEventTableColumn(new PcapReferenceAspect()),
46 new TmfEventTableColumn(new PcapProtocolAspect()),
47 new TmfEventTableColumn(ITmfEventAspect
.BaseAspects
.CONTENTS
)
51 * The "packet source" column for pcap events
53 private static class PcapSourceAspect
implements ITmfEventAspect
{
56 public String
getName() {
57 return getString(Messages
.PcapEventsTable_Source
);
61 public String
getHelpText() {
66 public String
resolve(ITmfEvent event
) {
67 if (!(event
instanceof PcapEvent
)) {
70 PcapEvent pcapEvent
= (PcapEvent
) event
;
71 TmfPcapProtocol protocol
= pcapEvent
.getMostEncapsulatedProtocol();
73 return getString(pcapEvent
.getSourceEndpoint(protocol
));
77 public @NonNull String
getFilterId() {
78 return PcapEvent
.EVENT_FIELD_PACKET_SOURCE
;
83 * The "packet destination" column for pcap events
85 private static class PcapDestinationAspect
implements ITmfEventAspect
{
88 public String
getName() {
89 return getString(Messages
.PcapEventsTable_Destination
);
93 public String
getHelpText() {
98 public String
resolve(ITmfEvent event
) {
99 if (!(event
instanceof PcapEvent
)) {
102 PcapEvent pcapEvent
= (PcapEvent
) event
;
103 TmfPcapProtocol protocol
= pcapEvent
.getMostEncapsulatedProtocol();
104 return getString(pcapEvent
.getDestinationEndpoint(protocol
));
108 public @NonNull String
getFilterId() {
109 return PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
;
114 * The "packet reference" column for pcap events
116 private static class PcapReferenceAspect
implements ITmfEventAspect
{
119 public String
getName() {
120 return getString(Messages
.PcapEventsTable_Reference
);
124 public String
getHelpText() {
129 public String
resolve(ITmfEvent event
) {
130 if (!(event
instanceof PcapEvent
)) {
133 return ((PcapEvent
) event
).getReference();
137 public @Nullable String
getFilterId() {
138 return ITmfEvent
.EVENT_FIELD_REFERENCE
;
143 * The "packet protocol" column for pcap events
145 private static class PcapProtocolAspect
implements ITmfEventAspect
{
148 public String
getName() {
149 return getString(Messages
.PcapEventsTable_Protocol
);
153 public String
getHelpText() {
158 public String
resolve(ITmfEvent event
) {
159 if (!(event
instanceof PcapEvent
)) {
162 PcapEvent pcapEvent
= (PcapEvent
) event
;
163 TmfPcapProtocol protocol
= pcapEvent
.getMostEncapsulatedProtocol();
165 @SuppressWarnings("null")
166 @NonNull String proto
= protocol
.getShortName().toUpperCase();
171 public @Nullable String
getFilterId() {
172 return PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
;
177 * Little convenience method to work around the incompatibilities between
178 * null annotations and NLS files...
180 private static String
getString(@Nullable String str
) {
181 return (str
== null ?
"" : str
); //$NON-NLS-1$
184 // ------------------------------------------------------------------------
185 // ITmfEventTableColumns
186 // ------------------------------------------------------------------------
189 public Collection
<?
extends TmfEventTableColumn
> getEventTableColumns() {