| 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 | * Alexandre Montplaisir - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.internal.gdbtrace.ui.views.events; |
| 14 | |
| 15 | import java.util.Collection; |
| 16 | |
| 17 | import org.eclipse.jdt.annotation.NonNull; |
| 18 | import org.eclipse.linuxtools.internal.gdbtrace.core.event.GdbTraceEventContent; |
| 19 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
| 20 | import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.ITmfEventTableColumns; |
| 21 | import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.TmfEventTableColumn; |
| 22 | import org.eclipse.linuxtools.tmf.ui.viewers.events.columns.TmfEventTableFieldColumn; |
| 23 | |
| 24 | import com.google.common.collect.ImmutableList; |
| 25 | |
| 26 | /** |
| 27 | * Event table column definition for GDB traces. |
| 28 | * |
| 29 | * @author Alexandre Montplaisir |
| 30 | */ |
| 31 | public class GdbEventTableColumns implements ITmfEventTableColumns { |
| 32 | |
| 33 | // ------------------------------------------------------------------------ |
| 34 | // Column definition |
| 35 | // ------------------------------------------------------------------------ |
| 36 | |
| 37 | @SuppressWarnings("null") |
| 38 | static final @NonNull Collection<TmfEventTableColumn> GDB_COLUMNS = ImmutableList.of( |
| 39 | new GdbTraceFrameColumn(), |
| 40 | new GdbTracepointColumn(), |
| 41 | new GdbFileColumn() |
| 42 | ); |
| 43 | |
| 44 | private static class GdbTraceFrameColumn extends TmfEventTableFieldColumn { |
| 45 | public GdbTraceFrameColumn() { |
| 46 | super(GdbTraceEventContent.TRACE_FRAME); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | private static class GdbTracepointColumn extends TmfEventTableFieldColumn { |
| 51 | public GdbTracepointColumn() { |
| 52 | super(GdbTraceEventContent.TRACEPOINT); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | private static class GdbFileColumn extends TmfEventTableColumn { |
| 57 | |
| 58 | public GdbFileColumn() { |
| 59 | super("File"); //$NON-NLS-1$ |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public String getItemString(ITmfEvent event) { |
| 64 | String ret = event.getReference(); |
| 65 | return (ret == null ? EMPTY_STRING : ret); |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public String getFilterFieldId() { |
| 70 | return ITmfEvent.EVENT_FIELD_REFERENCE; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // ------------------------------------------------------------------------ |
| 75 | // ITmfEventTableColumns |
| 76 | // ------------------------------------------------------------------------ |
| 77 | |
| 78 | @Override |
| 79 | public Collection<? extends TmfEventTableColumn> getEventTableColumns() { |
| 80 | return GDB_COLUMNS; |
| 81 | } |
| 82 | } |