tmf: Integration of the pcap parser within TMF
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.pcap.ui / src / org / eclipse / linuxtools / tmf / pcap / ui / editor / PcapEventsTable.java
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 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.pcap.ui.editor;
14
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;
23
24 /**
25 * Default event table for pcap traces.
26 *
27 * @author Vincent Perot
28 */
29 public class PcapEventsTable extends TmfEventsTable {
30
31 // ------------------------------------------------------------------------
32 // Table data
33 // ------------------------------------------------------------------------
34
35 // Table column names
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
43 };
44
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)
52 };
53
54 // ------------------------------------------------------------------------
55 // Constructor
56 // ------------------------------------------------------------------------
57
58 /**
59 * Constructor
60 *
61 * @param parent
62 * The parent composite
63 * @param cacheSize
64 * The size of the rows cache
65 */
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);
74 }
75
76 @Override
77 public String[] getItemStrings(@Nullable ITmfEvent event) {
78
79 if (event == null || !(event instanceof PcapEvent)) {
80 return EMPTY_STRING_ARRAY;
81 }
82
83 PcapEvent pcapEvent = (PcapEvent) event;
84 TmfProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
85
86 return new String[] {
87 pcapEvent.getTimestamp().toString(),
88 pcapEvent.getSourceEndpoint(protocol),
89 pcapEvent.getDestinationEndpoint(protocol),
90 pcapEvent.getReference(),
91 protocol.getShortName().toUpperCase(),
92 pcapEvent.getContent().toString()
93 };
94 }
95 }
This page took 0.03177 seconds and 5 git commands to generate.