Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Montplaisir2014-05-09 16:21:04 -0400
committerAlexandre Montplaisir2014-05-13 11:26:04 -0400
commit13431c76c2ac3c783ddc71f2ce7daa7328d583cb (patch)
tree5090b4f067e7b402dd83bd57bf68cffe5e0be12b
parentbe77377d232b95a1b329f10076cb02cf568b0cda (diff)
downloadorg.eclipse.linuxtools-13431c76c2ac3c783ddc71f2ce7daa7328d583cb.tar.gz
org.eclipse.linuxtools-13431c76c2ac3c783ddc71f2ce7daa7328d583cb.tar.xz
org.eclipse.linuxtools-13431c76c2ac3c783ddc71f2ce7daa7328d583cb.zip
tmf: Add a TextTraceEventTable for text traces
Current text trace implementation store all their information (timestamp, type, event content, etc.) as ITmfEventField's. Provide a standard TextTraceEventTable implementation which simply displays the contents of the event fields, one per column. Change-Id: I20989a479827f899edfa7289f6f9456cea2637f7 Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-on: https://git.eclipse.org/r/26312 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java66
2 files changed, 67 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index 635e585f62..cf7bbea22e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -37,6 +37,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
org.eclipse.linuxtools.tmf.ui.properties,
org.eclipse.linuxtools.tmf.ui.viewers,
org.eclipse.linuxtools.tmf.ui.viewers.events,
+ org.eclipse.linuxtools.tmf.ui.viewers.events.text,
org.eclipse.linuxtools.tmf.ui.viewers.statistics,
org.eclipse.linuxtools.tmf.ui.viewers.statistics.model,
org.eclipse.linuxtools.tmf.ui.viewers.tree,
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java
new file mode 100644
index 0000000000..aad2806a01
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.events.text;
+
+import java.util.List;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.trace.text.TextTraceEvent;
+import org.eclipse.linuxtools.tmf.core.trace.text.TextTraceEventContent;
+import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
+import org.eclipse.linuxtools.tmf.ui.widgets.virtualtable.ColumnData;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Event table for text traces, which has one column for every event field.
+ *
+ * @author Alexandre Montplaisir
+ * @since 3.0
+ */
+public class TmfTextEventTable extends TmfEventsTable {
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /**
+ * Constructor
+ *
+ * @param parent
+ * The parent composite UI object
+ * @param cacheSize
+ * The size of the event table cache
+ * @param columnData
+ * The column data to use for this table
+ */
+ public TmfTextEventTable(Composite parent, int cacheSize, ColumnData[] columnData) {
+ super(parent, cacheSize, columnData);
+ }
+
+ /**
+ * @param event
+ * The event to get the column strings for. It should be an
+ * instance of {@link TextTraceEvent}.
+ */
+ @Override
+ public String[] getItemStrings(ITmfEvent event) {
+ if (event instanceof TextTraceEvent) {
+ List<TextTraceEventContent> fields = ((TextTraceEvent) event).getContent().getFields();
+ String[] strings = new String[fields.size()];
+ for (int i = 0; i < strings.length; i++) {
+ Object value = fields.get(i).getValue();
+ strings[i] = (value == null ? EMPTY_STRING : value.toString());
+ }
+ return strings;
+ }
+ return EMPTY_STRING_ARRAY;
+ }
+}

Back to the top