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 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.pcap
.ui
.editor
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.pcap
.core
.event
.PcapEvent
;
18 import org
.eclipse
.linuxtools
.tmf
.pcap
.core
.protocol
.TmfProtocol
;
19 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.virtualtable
.ColumnData
;
21 import org
.eclipse
.swt
.SWT
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
25 * Default event table for pcap traces.
27 * @author Vincent Perot
29 public class PcapEventsTable
extends TmfEventsTable
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
36 private static final String
[] COLUMN_NAMES
= new String
[] {
37 Messages
.PcapEventsTable_Timestamp
,
38 Messages
.PcapEventsTable_Source
,
39 Messages
.PcapEventsTable_Destination
,
40 Messages
.PcapEventsTable_Reference
,
41 Messages
.PcapEventsTable_Protocol
,
42 Messages
.PcapEventsTable_Content
45 private static final ColumnData
[] COLUMN_DATA
= new ColumnData
[] {
46 new ColumnData(COLUMN_NAMES
[0], 150, SWT
.LEFT
),
47 new ColumnData(COLUMN_NAMES
[1], 120, SWT
.LEFT
),
48 new ColumnData(COLUMN_NAMES
[2], 200, SWT
.LEFT
),
49 new ColumnData(COLUMN_NAMES
[3], 100, SWT
.LEFT
),
50 new ColumnData(COLUMN_NAMES
[4], 100, SWT
.LEFT
),
51 new ColumnData(COLUMN_NAMES
[5], 100, SWT
.LEFT
)
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
62 * The parent composite
64 * The size of the rows cache
66 public PcapEventsTable(Composite parent
, int cacheSize
) {
67 super(parent
, cacheSize
, COLUMN_DATA
);
68 fTable
.getColumns()[0].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_TIMESTAMP
);
69 fTable
.getColumns()[1].setData(Key
.FIELD_ID
, PcapEvent
.EVENT_FIELD_PACKET_SOURCE
);
70 fTable
.getColumns()[2].setData(Key
.FIELD_ID
, PcapEvent
.EVENT_FIELD_PACKET_DESTINATION
);
71 fTable
.getColumns()[3].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_REFERENCE
);
72 fTable
.getColumns()[4].setData(Key
.FIELD_ID
, PcapEvent
.EVENT_FIELD_PACKET_PROTOCOL
);
73 fTable
.getColumns()[5].setData(Key
.FIELD_ID
, ITmfEvent
.EVENT_FIELD_CONTENT
);
77 public String
[] getItemStrings(@Nullable ITmfEvent event
) {
79 if (event
== null || !(event
instanceof PcapEvent
)) {
80 return EMPTY_STRING_ARRAY
;
83 PcapEvent pcapEvent
= (PcapEvent
) event
;
84 TmfProtocol protocol
= pcapEvent
.getMostEncapsulatedProtocol();
87 pcapEvent
.getTimestamp().toString(),
88 pcapEvent
.getSourceEndpoint(protocol
),
89 pcapEvent
.getDestinationEndpoint(protocol
),
90 pcapEvent
.getReference(),
91 protocol
.getShortName().toUpperCase(),
92 pcapEvent
.getContent().toString()