| 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.internal.lttng.ui.views.events;\r |
| 15 | \r |
| 16 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r |
| 17 | import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;\r |
| 18 | import org.eclipse.linuxtools.tmf.core.event.TmfEventField;\r |
| 19 | import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r |
| 20 | import org.eclipse.linuxtools.tmf.ui.widgets.ColumnData;\r |
| 21 | import org.eclipse.swt.SWT;\r |
| 22 | import org.eclipse.swt.widgets.Composite;\r |
| 23 | \r |
| 24 | public class EventsTable extends TmfEventsTable {\r |
| 25 | \r |
| 26 | // ------------------------------------------------------------------------\r |
| 27 | // Table data\r |
| 28 | // ------------------------------------------------------------------------\r |
| 29 | \r |
| 30 | // Table column names\r |
| 31 | static private final String TIMESTAMP_COLUMN = Messages.EventsTable_timestampColumn;\r |
| 32 | static private final String TRACE_COLUMN = Messages.EventsTable_traceColumn;\r |
| 33 | static private final String MARKER_COLUMN = Messages.EventsTable_markerColumn;\r |
| 34 | static private final String CONTENT_COLUMN = Messages.EventsTable_contentColumn;\r |
| 35 | static private final String[] COLUMN_NAMES = new String[] {\r |
| 36 | TIMESTAMP_COLUMN,\r |
| 37 | TRACE_COLUMN,\r |
| 38 | MARKER_COLUMN,\r |
| 39 | CONTENT_COLUMN\r |
| 40 | };\r |
| 41 | \r |
| 42 | static private final ColumnData[] COLUMN_DATA = new ColumnData[] {\r |
| 43 | new ColumnData(COLUMN_NAMES[0], 150, SWT.LEFT),\r |
| 44 | new ColumnData(COLUMN_NAMES[1], 120, SWT.LEFT),\r |
| 45 | new ColumnData(COLUMN_NAMES[2], 200, SWT.LEFT),\r |
| 46 | new ColumnData(COLUMN_NAMES[3], 100, SWT.LEFT)\r |
| 47 | };\r |
| 48 | \r |
| 49 | // ------------------------------------------------------------------------\r |
| 50 | // Constructor\r |
| 51 | // ------------------------------------------------------------------------\r |
| 52 | \r |
| 53 | public EventsTable(Composite parent, int cacheSize) {\r |
| 54 | super(parent, cacheSize, COLUMN_DATA);\r |
| 55 | fTable.getColumns()[0].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TIMESTAMP);\r |
| 56 | fTable.getColumns()[1].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_REFERENCE);\r |
| 57 | fTable.getColumns()[2].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_TYPE);\r |
| 58 | fTable.getColumns()[3].setData(Key.FIELD_ID, ITmfEvent.EVENT_FIELD_CONTENT);\r |
| 59 | }\r |
| 60 | \r |
| 61 | /**\r |
| 62 | * @param event\r |
| 63 | * @return\r |
| 64 | */\r |
| 65 | @Override\r |
| 66 | protected ITmfEventField[] extractItemFields(ITmfEvent event) {\r |
| 67 | ITmfEventField[] fields = new TmfEventField[0];\r |
| 68 | if (event != null) {\r |
| 69 | fields = new TmfEventField[] {\r |
| 70 | new TmfEventField(ITmfEvent.EVENT_FIELD_TIMESTAMP, ((Long) event.getTimestamp().getValue()).toString()),\r |
| 71 | new TmfEventField(ITmfEvent.EVENT_FIELD_REFERENCE, event.getReference()),\r |
| 72 | new TmfEventField(ITmfEvent.EVENT_FIELD_TYPE, event.getType().getName()),\r |
| 73 | new TmfEventField(ITmfEvent.EVENT_FIELD_CONTENT, event.getContent().toString())\r |
| 74 | };\r |
| 75 | }\r |
| 76 | return fields;\r |
| 77 | }\r |
| 78 | \r |
| 79 | }\r |