| 1 | /*******************************************************************************\r |
| 2 | * Copyright (c) 2009, 2010, 2011 Ericsson\r |
| 3 | * \r |
| 4 | * All rights reserved. This program and the accompanying materials are\r |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which\r |
| 6 | * accompanies this distribution, and is available at\r |
| 7 | * http://www.eclipse.org/legal/epl-v10.html\r |
| 8 | * \r |
| 9 | * Contributors:\r |
| 10 | * Francois Chouinard - Initial API and implementation\r |
| 11 | * Francois Chouinard - Aligned columns with domain terminology\r |
| 12 | *******************************************************************************/\r |
| 13 | \r |
| 14 | package org.eclipse.linuxtools.lttng.ui.views.events;\r |
| 15 | \r |
| 16 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventContent;\r |
| 17 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent;\r |
| 18 | import org.eclipse.linuxtools.tmf.core.event.TmfEventContent;\r |
| 19 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r |
| 20 | import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r |
| 21 | import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData;\r |
| 22 | import org.eclipse.swt.SWT;\r |
| 23 | import org.eclipse.swt.widgets.Composite;\r |
| 24 | \r |
| 25 | public class EventsTable extends TmfEventsTable {\r |
| 26 | \r |
| 27 | // ------------------------------------------------------------------------\r |
| 28 | // Table data\r |
| 29 | // ------------------------------------------------------------------------\r |
| 30 | \r |
| 31 | // Table column names\r |
| 32 | static private final String TIMESTAMP_COLUMN = Messages.EventsTable_timestampColumn;\r |
| 33 | static private final String TRACE_COLUMN = Messages.EventsTable_traceColumn;\r |
| 34 | static private final String MARKER_COLUMN = Messages.EventsTable_markerColumn;\r |
| 35 | static private final String CONTENT_COLUMN = Messages.EventsTable_contentColumn;\r |
| 36 | static private final String[] COLUMN_NAMES = new String[] {\r |
| 37 | TIMESTAMP_COLUMN,\r |
| 38 | TRACE_COLUMN,\r |
| 39 | MARKER_COLUMN,\r |
| 40 | CONTENT_COLUMN\r |
| 41 | };\r |
| 42 | \r |
| 43 | static private final ColumnData[] COLUMN_DATA = new ColumnData[] {\r |
| 44 | new ColumnData(COLUMN_NAMES[0], 150, SWT.LEFT),\r |
| 45 | new ColumnData(COLUMN_NAMES[1], 120, SWT.LEFT),\r |
| 46 | new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT),\r |
| 47 | new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT)\r |
| 48 | };\r |
| 49 | \r |
| 50 | // ------------------------------------------------------------------------\r |
| 51 | // Constructor\r |
| 52 | // ------------------------------------------------------------------------\r |
| 53 | \r |
| 54 | public EventsTable(Composite parent, int cacheSize) {\r |
| 55 | super(parent, cacheSize, COLUMN_DATA);\r |
| 56 | fTable.getColumns()[0].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TIMESTAMP);\r |
| 57 | fTable.getColumns()[1].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_REFERENCE);\r |
| 58 | fTable.getColumns()[2].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_TYPE);\r |
| 59 | fTable.getColumns()[3].setData(Key.FIELD_ID, TmfEventContent.FIELD_ID_CONTENT);\r |
| 60 | }\r |
| 61 | \r |
| 62 | /**\r |
| 63 | * @param event\r |
| 64 | * @return\r |
| 65 | */\r |
| 66 | @Override\r |
| 67 | protected TmfEventField[] extractItemFields(TmfEvent event) {\r |
| 68 | TmfEventField[] fields = new TmfEventField[0];\r |
| 69 | if (event != null) {\r |
| 70 | ITmfEventContent content = event.getContent();\r |
| 71 | fields = new TmfEventField[] {\r |
| 72 | new TmfEventField(content, TmfEventContent.FIELD_ID_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()),\r |
| 73 | new TmfEventField(content, TmfEventContent.FIELD_ID_REFERENCE, event.getReference()),\r |
| 74 | new TmfEventField(content, TmfEventContent.FIELD_ID_TYPE, event.getType().getId()),\r |
| 75 | new TmfEventField(content, TmfEventContent.FIELD_ID_CONTENT, event.getContent().toString())\r |
| 76 | };\r |
| 77 | }\r |
| 78 | return fields;\r |
| 79 | }\r |
| 80 | \r |
| 81 | }\r |