tmf: Remove the ITmfEventTableColumns extension point
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 11 Nov 2014 20:33:28 +0000 (15:33 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 27 Nov 2014 22:17:40 +0000 (17:17 -0500)
Add a getEventAspects() method in ITmfTrace, which allows trace types
to define which aspects can be relevant for their own events.

This becomes redundant with the ITmfEventTableColumn extension point:
now that we build columns directly from aspects, the TmfEventsEditor
can simply call trace.getEventAspects() instead of reading extension
point data. The trace type is already defined in a core extension point,
so we'll pass the event aspect information through that now.

The combination of careful equals() methods in aspects and the use
of a Set in the TmfEventsEditor will allow "merging" aspects/columns
together, like was already the case.

Change-Id: Ic5b6126a50b1b1fdb4b2d5d23eb6a47a57555594
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/36364
Tested-by: Hudson CI
51 files changed:
org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java [new file with mode: 0644]
org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfTrace.java
org.eclipse.tracecompass.btf.ui/build.properties
org.eclipse.tracecompass.btf.ui/plugin.xml
org.eclipse.tracecompass.btf.ui/src/org/eclipse/tracecompass/btf/ui/BtfEventTableColumns.java [deleted file]
org.eclipse.tracecompass.gdbtrace.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/GdbEventAspects.java [new file with mode: 0644]
org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/GdbTrace.java
org.eclipse.tracecompass.gdbtrace.ui/plugin.xml
org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventTableColumns.java [deleted file]
org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventsTable.java
org.eclipse.tracecompass.lttng2.kernel.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/LttngEventAspects.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/Messages.java [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/messages.properties [new file with mode: 0644]
org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/lttng2/kernel/core/trace/LttngKernelTrace.java
org.eclipse.tracecompass.lttng2.kernel.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.lttng2.kernel.ui/plugin.xml
org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/LttngEventTableColumns.java [deleted file]
org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/Messages.java [deleted file]
org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/messages.properties [deleted file]
org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomTxtTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomXmlTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTrace.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfTrace.java
org.eclipse.tracecompass.tmf.pcap.core/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/Messages.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapDestinationAspect.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapProtocolAspect.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapReferenceAspect.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapSourceAspect.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/messages.properties [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/package-info.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/trace/PcapTrace.java
org.eclipse.tracecompass.tmf.pcap.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.pcap.ui/plugin.xml
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/Messages.java [deleted file]
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/PcapEventTableColumns.java [deleted file]
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/messages.properties [deleted file]
org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/package-info.java [deleted file]
org.eclipse.tracecompass.tmf.ui/META-INF/MANIFEST.MF
org.eclipse.tracecompass.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetypeui.exsd
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/custom/CustomEventTableColumns.java [deleted file]
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomTxtParserOutputWizardPage.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/wizards/CustomXmlParserOutputWizardPage.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/editors/TmfEventsEditor.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/project/model/TmfTraceTypeUIUtils.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/ITmfEventTableColumns.java [deleted file]

diff --git a/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java b/org.eclipse.tracecompass.btf.core/src/org/eclipse/tracecompass/btf/core/trace/BtfEventAspects.java
new file mode 100644 (file)
index 0000000..45b5a46
--- /dev/null
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * 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:
+ *   Matthew Khouzam - Initial API and implementation
+ *   Alexandre Montplaisir - Update to new Event Table API
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.btf.core.trace;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.btf.core.event.BtfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Columns to use in the BTF event table
+ *
+ * @author Alexandre Montplaisir
+ */
+public final class BtfEventAspects {
+
+    private BtfEventAspects() {}
+
+    @SuppressWarnings("null")
+    private static final @NonNull Iterable<ITmfEventAspect> BTF_ASPECTS = ImmutableList.of(
+            ITmfEventAspect.BaseAspects.TIMESTAMP,
+            new BtfSourceAspect(),
+            new BtfSourceInstanceAspect(),
+            ITmfEventAspect.BaseAspects.EVENT_TYPE,
+            new BtfTargetAspect(),
+            new BtfTargetInstanceAspect(),
+            new BtfEventAspect(),
+            new BtfNotesAspect()
+            );
+
+    /**
+     * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
+     */
+    private static class BtfSourceAspect implements ITmfEventAspect {
+
+        @Override
+        public String getName() {
+            return BtfColumnNames.SOURCE.toString();
+        }
+
+        @Override
+        public String getHelpText() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String resolve(ITmfEvent event) {
+            if (!(event instanceof BtfEvent)) {
+                return EMPTY_STRING;
+            }
+            String ret = ((BtfEvent) event).getSource();
+            return (ret == null ? EMPTY_STRING : ret);
+        }
+
+        @Override
+        public String getFilterId() {
+            return ITmfEvent.EVENT_FIELD_SOURCE;
+        }
+    }
+
+    /**
+     * The "source instance" aspect, whose value comes from the field of the
+     * same name.
+     */
+    private static class BtfSourceInstanceAspect extends TmfEventFieldAspect {
+        public BtfSourceInstanceAspect() {
+            super(BtfColumnNames.SOURCE_INSTANCE.toString(),
+                    BtfColumnNames.SOURCE_INSTANCE.toString());
+        }
+    }
+
+    /**
+     * The "target" aspect, taking its value from
+     * {@link ITmfEvent#getReference()}.
+     */
+    private static class BtfTargetAspect implements ITmfEventAspect {
+
+        @Override
+        public String getName() {
+             return BtfColumnNames.TARGET.toString();
+        }
+
+        @Override
+        public String getHelpText() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String resolve(ITmfEvent event) {
+            if (!(event instanceof BtfEvent)) {
+                return EMPTY_STRING;
+            }
+            String ret = ((BtfEvent) event).getReference();
+            return (ret == null ? EMPTY_STRING : ret);
+        }
+
+        @Override
+        public String getFilterId() {
+            return ITmfEvent.EVENT_FIELD_REFERENCE;
+        }
+    }
+
+    /**
+     * The "target instance" aspect, whose value comes from the field of the
+     * same name.
+     */
+    private static class BtfTargetInstanceAspect extends TmfEventFieldAspect {
+        public BtfTargetInstanceAspect() {
+            super(BtfColumnNames.TARGET_INSTANCE.toString(),
+                    BtfColumnNames.TARGET_INSTANCE.toString());
+        }
+    }
+
+    /**
+     * The "event" aspect, whose value comes from the field of the same name.
+     */
+    private static class BtfEventAspect extends TmfEventFieldAspect {
+        public BtfEventAspect() {
+            super(BtfColumnNames.EVENT.toString(),
+                    BtfColumnNames.EVENT.toString());
+        }
+    }
+
+    /**
+     * The "notes" column, whose value comes from the field of the same name, if
+     * present.
+     */
+    private static class BtfNotesAspect extends TmfEventFieldAspect {
+        public BtfNotesAspect() {
+            super(BtfColumnNames.NOTES.toString(),
+                    BtfColumnNames.NOTES.toString());
+        }
+    }
+
+    /**
+     * Return the event aspects defined for BTF traces.
+     *
+     * @return The aspects
+     */
+    public static Iterable<ITmfEventAspect> getAspects() {
+        return BTF_ASPECTS;
+    }
+}
\ No newline at end of file
index 079969a32151372a2a84efb5278daadecc29adb4..90e326aa3b7769650829b8b89eeccbbf03e8c9d6 100644 (file)
@@ -33,6 +33,7 @@ import org.eclipse.tracecompass.btf.core.event.BtfEvent;
 import org.eclipse.tracecompass.btf.core.event.BtfEventType;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceContext;
@@ -436,6 +437,11 @@ public class BtfTrace extends TmfTrace implements ITmfEventParser, ITmfPersisten
         return ImmutableMap.copyOf(fProperties);
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return BtfEventAspects.getAspects();
+    }
+
     @Override
     public void close() throws IOException {
         if (fFileInput != null) {
index 748e4f916bd33b24843b5b1657a16c82faf2081b..eb8eb768245b0f73d76e6ba0ac3f10028df72f2b 100644 (file)
@@ -16,8 +16,7 @@ bin.includes = META-INF/,\
                plugin.properties,\
                plugin.xml,\
                about.html,\
-               .,\
-               plugin.xml
+               .
 src.includes = about.html
 additional.bundles = org.eclipse.jdt.annotation
 jars.extra.classpath = platform:/plugin/org.eclipse.jdt.annotation
index 8e476e1d85700118fc730aecd7d86a6a396ccf78..594c5fa0ba31cd73ab64232f022558fd89da220f 100644 (file)
@@ -6,9 +6,6 @@
       <type
             icon="icons/btf.png"
             tracetype="org.eclipse.linuxtools.btf.trace">
-         <eventTableColumns
-               class="org.eclipse.tracecompass.btf.ui.BtfEventTableColumns">
-         </eventTableColumns>
       </type>
    </extension>
 </plugin>
diff --git a/org.eclipse.tracecompass.btf.ui/src/org/eclipse/tracecompass/btf/ui/BtfEventTableColumns.java b/org.eclipse.tracecompass.btf.ui/src/org/eclipse/tracecompass/btf/ui/BtfEventTableColumns.java
deleted file mode 100644 (file)
index 7bcbfb2..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * 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:
- *   Matthew Khouzam - Initial API and implementation
- *   Alexandre Montplaisir - Update to new Event Table API
- *******************************************************************************/
-
-package org.eclipse.tracecompass.btf.ui;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.btf.core.event.BtfEvent;
-import org.eclipse.tracecompass.btf.core.trace.BtfColumnNames;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Columns to use in the BTF event table
- *
- * @author Alexandre Montplaisir
- */
-public class BtfEventTableColumns implements ITmfEventTableColumns {
-
-    // ------------------------------------------------------------------------
-    // Column definition
-    // ------------------------------------------------------------------------
-
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<TmfEventTableColumn> BTF_COLUMNS = ImmutableList.of(
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.TIMESTAMP),
-            new TmfEventTableColumn(new BtfSourceAspect()),
-            new TmfEventTableColumn(new BtfSourceInstanceAspect()),
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.EVENT_TYPE),
-            new TmfEventTableColumn(new BtfTargetAspect()),
-            new TmfEventTableColumn(new BtfTargetInstanceAspect()),
-            new TmfEventTableColumn(new BtfEventAspect()),
-            new TmfEventTableColumn(new BtfNotesAspect())
-            );
-
-    /**
-     * The "source" aspect, whose value comes from {@link ITmfEvent#getSource()}
-     */
-    private static class BtfSourceAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return BtfColumnNames.SOURCE.toString();
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof BtfEvent)) {
-                return EMPTY_STRING;
-            }
-            String ret = ((BtfEvent) event).getSource();
-            return (ret == null ? EMPTY_STRING : ret);
-        }
-
-        @Override
-        public String getFilterId() {
-            return ITmfEvent.EVENT_FIELD_SOURCE;
-        }
-    }
-
-    /**
-     * The "source instance" aspect, whose value comes from the field of the
-     * same name.
-     */
-    private static class BtfSourceInstanceAspect extends TmfEventFieldAspect {
-        public BtfSourceInstanceAspect() {
-            super(BtfColumnNames.SOURCE_INSTANCE.toString(),
-                    BtfColumnNames.SOURCE_INSTANCE.toString());
-        }
-    }
-
-    /**
-     * The "target" aspect, taking its value from
-     * {@link ITmfEvent#getReference()}.
-     */
-    private static class BtfTargetAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-             return BtfColumnNames.TARGET.toString();
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof BtfEvent)) {
-                return EMPTY_STRING;
-            }
-            String ret = ((BtfEvent) event).getReference();
-            return (ret == null ? EMPTY_STRING : ret);
-        }
-
-        @Override
-        public String getFilterId() {
-            return ITmfEvent.EVENT_FIELD_REFERENCE;
-        }
-    }
-
-    /**
-     * The "target instance" aspect, whose value comes from the field of the
-     * same name.
-     */
-    private static class BtfTargetInstanceAspect extends TmfEventFieldAspect {
-        public BtfTargetInstanceAspect() {
-            super(BtfColumnNames.TARGET_INSTANCE.toString(),
-                    BtfColumnNames.TARGET_INSTANCE.toString());
-        }
-    }
-
-    /**
-     * The "event" aspect, whose value comes from the field of the same name.
-     */
-    private static class BtfEventAspect extends TmfEventFieldAspect {
-        public BtfEventAspect() {
-            super(BtfColumnNames.EVENT.toString(),
-                    BtfColumnNames.EVENT.toString());
-        }
-    }
-
-    /**
-     * The "notes" column, whose value comes from the field of the same name, if
-     * present.
-     */
-    private static class BtfNotesAspect extends TmfEventFieldAspect {
-        public BtfNotesAspect() {
-            super(BtfColumnNames.NOTES.toString(),
-                    BtfColumnNames.NOTES.toString());
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfEventTableColumns
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
-        return BTF_COLUMNS;
-    }
-}
\ No newline at end of file
index 041f22e0ff31189c011c111aeeaeafe79472d869..b9ead48963d7f16faadabc526a53847120345222 100644 (file)
@@ -20,3 +20,4 @@ Bundle-Vendor: %Bundle-Vendor
 Export-Package: org.eclipse.tracecompass.internal.gdbtrace.core;x-friends:="org.eclipse.tracecompass.gdbtrace.core.tests",
  org.eclipse.tracecompass.internal.gdbtrace.core.event;x-friends:="org.eclipse.tracecompass.gdbtrace.ui",
  org.eclipse.tracecompass.internal.gdbtrace.core.trace;x-friends:="org.eclipse.tracecompass.gdbtrace.ui"
+Import-Package: com.google.common.collect
diff --git a/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/GdbEventAspects.java b/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/GdbEventAspects.java
new file mode 100644 (file)
index 0000000..2d5f21d
--- /dev/null
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.tracecompass.internal.gdbtrace.core.trace;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
+import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Event table column definition for GDB traces.
+ *
+ * @author Alexandre Montplaisir
+ */
+public final class GdbEventAspects {
+
+    private GdbEventAspects() {}
+
+    @SuppressWarnings("null")
+    private static final @NonNull Iterable<ITmfEventAspect> GDB_ASPECTS = ImmutableList.of(
+            new GdbTraceFrameAspect(),
+            new GdbTracepointAspect(),
+            new GdbFileAspect()
+            );
+
+    private static class GdbTraceFrameAspect extends TmfEventFieldAspect {
+        public GdbTraceFrameAspect() {
+            super(GdbTraceEventContent.TRACE_FRAME,
+                    GdbTraceEventContent.TRACE_FRAME);
+        }
+    }
+
+    private static class GdbTracepointAspect extends TmfEventFieldAspect {
+        public GdbTracepointAspect() {
+            super(GdbTraceEventContent.TRACEPOINT,
+                    GdbTraceEventContent.TRACEPOINT);
+        }
+    }
+
+    private static class GdbFileAspect implements ITmfEventAspect {
+
+        @Override
+        public String getName() {
+            return "File"; //$NON-NLS-1$
+        }
+
+        @Override
+        public String getHelpText() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String resolve(ITmfEvent event) {
+            if (!(event instanceof GdbTraceEvent)) {
+                return EMPTY_STRING;
+            }
+            String ret = ((GdbTraceEvent) event).getReference();
+            return (ret == null ? EMPTY_STRING : ret);
+        }
+
+        @Override
+        public String getFilterId() {
+            return ITmfEvent.EVENT_FIELD_REFERENCE;
+        }
+    }
+
+    /**
+     * Get the event aspects specific to GDB traces.
+     *
+     * @return The set of aspects
+     */
+    public static Iterable<ITmfEventAspect> getAspects() {
+        return GDB_ASPECTS;
+    }
+}
index 515285b591012ab555834e93d3d7cd2763856aea..3c0b78cf82479dae4adbb9515a9a847b989a1adf 100644 (file)
@@ -36,6 +36,7 @@ import org.eclipse.tracecompass.internal.gdbtrace.core.Activator;
 import org.eclipse.tracecompass.internal.gdbtrace.core.GdbTraceCorePlugin;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
@@ -165,6 +166,11 @@ public class GdbTrace extends TmfTrace implements ITmfEventParser {
     // TmfTrace
     // ------------------------------------------------------------------------
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return GdbEventAspects.getAspects();
+    }
+
     @Override
     public synchronized TmfContext seekEvent(ITmfLocation location) {
         fLocation = (location != null) ? ((Long) location.getLocationInfo()) : 0;
index 6505f0e7a67c413bb8248627c0459301a6c96744..851ef30887deb30c0cd1a988b96db93caed89a28 100644 (file)
@@ -92,9 +92,6 @@
          <eventsTableType
                class="org.eclipse.tracecompass.internal.gdbtrace.ui.views.events.GdbEventsTable">
          </eventsTableType>
-         <eventTableColumns
-               class="org.eclipse.tracecompass.internal.gdbtrace.ui.views.events.GdbEventTableColumns">
-         </eventTableColumns>
       </type>
    </extension>
 
diff --git a/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventTableColumns.java b/org.eclipse.tracecompass.gdbtrace.ui/src/org/eclipse/tracecompass/internal/gdbtrace/ui/views/events/GdbEventTableColumns.java
deleted file mode 100644 (file)
index a3afc54..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * 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.tracecompass.internal.gdbtrace.ui.views.events;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
-import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.core.event.aspect.TmfEventFieldAspect;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Event table column definition for GDB traces.
- *
- * @author Alexandre Montplaisir
- */
-public class GdbEventTableColumns implements ITmfEventTableColumns {
-
-    // ------------------------------------------------------------------------
-    // Column definition
-    // ------------------------------------------------------------------------
-
-    @SuppressWarnings("null")
-    static final @NonNull Collection<TmfEventTableColumn> GDB_COLUMNS = ImmutableList.of(
-            new TmfEventTableColumn(new GdbTraceFrameAspect()),
-            new TmfEventTableColumn(new GdbTracepointAspect()),
-            new TmfEventTableColumn(new GdbFileAspect())
-            );
-
-    private static class GdbTraceFrameAspect extends TmfEventFieldAspect {
-        public GdbTraceFrameAspect() {
-            super(GdbTraceEventContent.TRACE_FRAME,
-                    GdbTraceEventContent.TRACE_FRAME);
-        }
-    }
-
-    private static class GdbTracepointAspect extends TmfEventFieldAspect {
-        public GdbTracepointAspect() {
-            super(GdbTraceEventContent.TRACEPOINT,
-                    GdbTraceEventContent.TRACEPOINT);
-        }
-    }
-
-    private static class GdbFileAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return "File"; //$NON-NLS-1$
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof GdbTraceEvent)) {
-                return EMPTY_STRING;
-            }
-            String ret = ((GdbTraceEvent) event).getReference();
-            return (ret == null ? EMPTY_STRING : ret);
-        }
-
-        @Override
-        public String getFilterId() {
-            return ITmfEvent.EVENT_FIELD_REFERENCE;
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfEventTableColumns
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
-        return GDB_COLUMNS;
-    }
-}
index 5c3e5d0eaf6810e2215ef5dde6219e1b2e87009d..f69017d2b6e3b4363af513675b3ea68f3346eca6 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
+import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbEventAspects;
 import org.eclipse.tracecompass.internal.gdbtrace.core.trace.GdbTrace;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTimeSynchSignal;
@@ -58,7 +59,7 @@ public class GdbEventsTable extends TmfEventsTable {
      *            the cache size
      */
     public GdbEventsTable(Composite parent, int cacheSize) {
-        super(parent, cacheSize, GdbEventTableColumns.GDB_COLUMNS);
+        super(parent, cacheSize, GdbEventAspects.getAspects());
         // Set the alignment of the first two columns
         fTable.getColumns()[0].setAlignment(SWT.RIGHT);
         fTable.getColumns()[1].setAlignment(SWT.RIGHT);
index a5340e28c0a76021fb576019bbf33608b289032d..64ff78123345ccb5e71cb853da89054643aaffa5 100644 (file)
@@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.tmf.ctf.core,
  org.eclipse.tracecompass.lttng2.control.core
 Export-Package: org.eclipse.tracecompass.internal.lttng2.kernel.core;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui,org.eclipse.tracecompass.lttng2.kernel.core.tests",
+ org.eclipse.tracecompass.internal.lttng2.kernel.core.event.aspect;x-internal:=true,
  org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout;x-friends:="org.eclipse.tracecompass.lttng2.kernel.core.tests,org.eclipse.tracecompass.lttng2.kernel.ui",
  org.eclipse.tracecompass.lttng2.kernel.core.analysis.cpuusage,
  org.eclipse.tracecompass.lttng2.kernel.core.analysis.kernel,
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/LttngEventAspects.java b/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/LttngEventAspects.java
new file mode 100644 (file)
index 0000000..f45f3e7
--- /dev/null
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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.tracecompass.internal.lttng2.kernel.core.event.aspect;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Event aspects for LTTng kernel traces.
+ *
+ * @author Alexandre Montplaisir
+ */
+public final class LttngEventAspects {
+
+    private LttngEventAspects() {}
+
+    @SuppressWarnings("null")
+    private static final @NonNull Iterable<ITmfEventAspect> LTTNG_ASPECTS =
+            ImmutableList.of(
+                    ITmfEventAspect.BaseAspects.TIMESTAMP,
+                    new LttngChannelAspect(),
+                    ITmfEventAspect.BaseAspects.EVENT_TYPE,
+                    ITmfEventAspect.BaseAspects.CONTENTS);
+
+    private static class LttngChannelAspect implements ITmfEventAspect {
+
+        @Override
+        public String getName() {
+            String ret = Messages.AspectName_Channel;
+            return (ret == null ? EMPTY_STRING : ret);
+        }
+
+        @Override
+        public String getHelpText() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String resolve(ITmfEvent event) {
+            if (!(event instanceof CtfTmfEvent)) {
+                return EMPTY_STRING;
+            }
+            String ret = ((CtfTmfEvent) event).getReference();
+            return (ret == null ? EMPTY_STRING : ret);
+        }
+
+        @Override
+        public String getFilterId() {
+            return ITmfEvent.EVENT_FIELD_REFERENCE;
+        }
+    }
+
+    /**
+     * Get the event aspects defined for LTTng kernel traces.
+     *
+     * @return The set of aspects
+     */
+    public static Iterable<ITmfEventAspect> getAspects() {
+        return LTTNG_ASPECTS;
+    }
+}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/Messages.java b/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/Messages.java
new file mode 100644 (file)
index 0000000..e2c50ef
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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:
+ *     Patrick Tassé - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.kernel.core.event.aspect;
+
+import org.eclipse.osgi.util.NLS;
+
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+
+    private static final String BUNDLE_NAME =
+            "org.eclipse.tracecompass.internal.lttng2.kernel.core.event.aspect.messages"; //$NON-NLS-1$
+
+    public static String AspectName_Channel;
+
+    static {
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/messages.properties b/org.eclipse.tracecompass.lttng2.kernel.core/src/org/eclipse/tracecompass/internal/lttng2/kernel/core/event/aspect/messages.properties
new file mode 100644 (file)
index 0000000..cb4cfbd
--- /dev/null
@@ -0,0 +1,13 @@
+###############################################################################
+# 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:
+#     Ericsson - Initial API and implementation
+###############################################################################
+
+AspectName_Channel=Channel
index 03a09b9f2230005477f172352ab2a5bde9373fd5..be454c3af110dfe91987180430cbc9eb8f21373d 100644 (file)
@@ -24,12 +24,14 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.trace.CTFTrace;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.Activator;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.event.aspect.LttngEventAspects;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.Lttng26EventLayout;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.PerfEventLayout;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.Lttng26EventLayout;
 import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
 import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
 
@@ -143,4 +145,9 @@ public class LttngKernelTrace extends CtfTmfTrace {
         }
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return LttngEventAspects.getAspects();
+    }
+
 }
index ebf598cb35bc9a267481b6867be3e795c9db4107..6281287e35205a2c68ef81daeff27ad1ee8c0089 100644 (file)
@@ -19,7 +19,6 @@ Require-Bundle: org.eclipse.ui,
  org.eclipse.tracecompass.lttng2.control.ui;bundle-version="0.1.0",
  org.eclipse.tracecompass.lttng2.kernel.core;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.internal.lttng2.kernel.ui;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui.tests",
- org.eclipse.tracecompass.internal.lttng2.kernel.ui.viewers.events;x-internal:=true,
  org.eclipse.tracecompass.internal.lttng2.kernel.ui.views;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.lttng2.kernel.ui.views.controlflow;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests",
  org.eclipse.tracecompass.internal.lttng2.kernel.ui.views.cpuusage;x-friends:="org.eclipse.tracecompass.lttng2.kernel.ui.swtbot.tests",
index 52aece233483c1bb3347e1904e03613f17c75c21..e23019eb30c65bdec5c14d8823aa90a3ba6bc091 100644 (file)
@@ -84,9 +84,6 @@
       <type
             icon="icons/obj16/garland16.png"
             tracetype="org.eclipse.linuxtools.lttng2.kernel.tracetype">
-         <eventTableColumns
-               class="org.eclipse.tracecompass.internal.lttng2.kernel.ui.viewers.events.LttngEventTableColumns">
-         </eventTableColumns>
       </type>
    </extension>
 </plugin>
diff --git a/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/LttngEventTableColumns.java b/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/LttngEventTableColumns.java
deleted file mode 100644 (file)
index f9e0168..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * 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.tracecompass.internal.lttng2.kernel.ui.viewers.events;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Event table columns for LTTng 2.x kernel traces
- */
-public class LttngEventTableColumns implements ITmfEventTableColumns {
-
-    // ------------------------------------------------------------------------
-    // Column definition
-    // ------------------------------------------------------------------------
-
-    @SuppressWarnings("null")
-    private static final @NonNull String CHANNEL_HEADER = Messages.EventsTable_channelColumn;
-
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<TmfEventTableColumn> LTTNG_COLUMNS =
-            ImmutableList.<TmfEventTableColumn> of(
-                    new TmfEventTableColumn(ITmfEventAspect.BaseAspects.TIMESTAMP),
-                    new TmfEventTableColumn(new LttngChannelAspect()),
-                    new TmfEventTableColumn(ITmfEventAspect.BaseAspects.EVENT_TYPE),
-                    new TmfEventTableColumn(ITmfEventAspect.BaseAspects.CONTENTS));
-
-    private static class LttngChannelAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return CHANNEL_HEADER;
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof CtfTmfEvent)) {
-                return EMPTY_STRING;
-            }
-            String ret = ((CtfTmfEvent) event).getReference();
-            return (ret == null ? EMPTY_STRING : ret);
-        }
-
-        @Override
-        public String getFilterId() {
-            return ITmfEvent.EVENT_FIELD_REFERENCE;
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // Constructor
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
-        return LTTNG_COLUMNS;
-    }
-}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/Messages.java b/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/Messages.java
deleted file mode 100644 (file)
index c3ba87b..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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:
- *     Patrick Tassé - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.kernel.ui.viewers.events;
-
-import org.eclipse.osgi.util.NLS;
-
-@SuppressWarnings("javadoc")
-public class Messages extends NLS {
-    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.lttng2.kernel.ui.viewers.events.messages"; //$NON-NLS-1$
-    public static String EventsTable_channelColumn;
-    public static String EventsTable_timestampColumn;
-    public static String EventsTable_typeColumn;
-    public static String EventsTable_contentColumn;
-    static {
-        // initialize resource bundle
-        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
-    }
-
-    private Messages() {
-    }
-}
diff --git a/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/messages.properties b/org.eclipse.tracecompass.lttng2.kernel.ui/src/org/eclipse/tracecompass/internal/lttng2/kernel/ui/viewers/events/messages.properties
deleted file mode 100644 (file)
index faeb249..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-###############################################################################
-# Copyright (c) 2013 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:
-#     Ericsson - Initial API and implementation
-###############################################################################
-
-EventsTable_channelColumn=Channel
-EventsTable_timestampColumn=Timestamp
-EventsTable_typeColumn=Event Type
-EventsTable_contentColumn=Content
index 92f0a59d8d45ba168d8dc939876d582417a335eb..a8238207b37a38ba0be5cd600d55f0dfd55081ea 100644 (file)
@@ -15,6 +15,7 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.core;x-friends:="org.eclip
  org.eclipse.tracecompass.internal.tmf.core.analysis;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
  org.eclipse.tracecompass.internal.tmf.core.component;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
  org.eclipse.tracecompass.internal.tmf.core.filter;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.tmf.ui",
+ org.eclipse.tracecompass.internal.tmf.core.parsers.custom;x-friends:="org.eclipse.tracecompass.tmf.ui",
  org.eclipse.tracecompass.internal.tmf.core.request;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
  org.eclipse.tracecompass.internal.tmf.core.statesystem.backends.partial;x-friends:="org.eclipse.tracecompass.statesystem.core.tests",
  org.eclipse.tracecompass.internal.tmf.core.statesystem.mipmap;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/parsers/custom/CustomEventAspects.java
new file mode 100644 (file)
index 0000000..d0956c9
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2010, 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:
+ *   Patrick Tasse - Initial API and implementation
+ *   Alexandre Montplaisir - Update for TmfEventTableColumn
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.core.parsers.custom;
+
+import java.util.List;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomEvent;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Event aspects for Custom {Text|XML} traces.
+ *
+ * Since this definition will be different for every single custom trace, we
+ * cannot define specific {@link ITmfEventAspect} in advance.
+ *
+ * Instead, one has to call {@link #generateAspects(CustomTraceDefinition)}
+ * with the CustomTraceDefinition of the the particular trace to display.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class CustomEventAspects {
+
+    /**
+     * Aspects for custom events, which use an integer ID to represent each
+     * field.
+     */
+    private static final class CustomEventFieldAspect implements ITmfEventAspect {
+
+        private final @NonNull String fName;
+        private final int fIndex;
+
+        /**
+         * Constructor
+         *
+         * @param name
+         *            The name of this aspect
+         * @param idx
+         *            The index of this field in the event's content to display
+         */
+        public CustomEventFieldAspect(@NonNull String name, int idx) {
+            fName = name;
+            fIndex = idx;
+        }
+
+        @Override
+        public String getName() {
+            return fName;
+        }
+
+        @Override
+        public String getHelpText() {
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String resolve(ITmfEvent event) {
+            if (event instanceof CustomEvent) {
+                String ret = ((CustomEvent) event).getEventString(fIndex);
+                return (ret == null ? EMPTY_STRING : ret);
+            }
+            return EMPTY_STRING;
+        }
+
+        @Override
+        public String getFilterId() {
+            return fName;
+        }
+    }
+
+    /**
+     * Build a set of event aspects for a given trace definition
+     *
+     * @param definition
+     *            The {@link CustomTraceDefinition} of the trace for which you
+     *            want the aspects
+     * @return The set of event aspects for the given trace
+     */
+    public static Iterable<ITmfEventAspect> generateAspects(CustomTraceDefinition definition) {
+        ImmutableList.Builder<ITmfEventAspect> builder = new ImmutableList.Builder<>();
+        List<OutputColumn> outputs = definition.outputs;
+        for (int i = 0; i < outputs.size(); i++) {
+            String name = outputs.get(i).name;
+            if (name != null) {
+                builder.add(new CustomEventFieldAspect(name, i));
+            }
+        }
+        return builder.build();
+    }
+}
index 4932929ac3b0a0906f69102e8ea3cbbec4ae7843..4d44aca0c3c6a71e10cee0c432ac4363750a1623 100644 (file)
@@ -27,7 +27,9 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine;
@@ -124,6 +126,11 @@ public class CustomTxtTrace extends TmfTrace implements ITmfEventParser, ITmfPer
         return super.getIndexer();
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return CustomEventAspects.generateAspects(fDefinition);
+    }
+
     @Override
     public synchronized TmfContext seekEvent(final ITmfLocation location) {
         final CustomTxtTraceContext context = new CustomTxtTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
index 117b86c76f743107d6ae887203beac7a29ceeaff..2add4825e4e54b6ba84c66e841c617d280bf219b 100644 (file)
@@ -27,7 +27,9 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
@@ -134,6 +136,11 @@ public class CustomXmlTrace extends TmfTrace implements ITmfEventParser, ITmfPer
         return super.getIndexer();
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return CustomEventAspects.generateAspects(fDefinition);
+    }
+
     @Override
     public synchronized TmfContext seekEvent(final ITmfLocation location) {
         final CustomXmlTraceContext context = new CustomXmlTraceContext(NULL_LOCATION, ITmfContext.UNKNOWN_RANK);
index 4a61fe1a9c8e915c17dce4652bc3a4c48ce71e48..15b491e1f319658073697a5737ad700a74870b15 100644 (file)
@@ -24,6 +24,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
 import org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
@@ -283,6 +284,17 @@ public interface ITmfTrace extends ITmfEventProvider {
     @NonNull
     <T> Iterable<T> getAnalysisModulesOfClass(Class<T> moduleClass);
 
+    // ------------------------------------------------------------------------
+    // Aspect getters
+    // ------------------------------------------------------------------------
+
+    /**
+     * Return the pre-defined set of event aspects exposed by this trace.
+     *
+     * @return The event aspects for this trace
+     */
+    Iterable<ITmfEventAspect> getEventAspects();
+
     // ------------------------------------------------------------------------
     // Trace characteristics getters
     // ------------------------------------------------------------------------
index 2d6421897a2868b9453c2b9eb3a77ea512d293c1..fd3b7481145cc4a7b18c0d119234c9fbcfb3e129 100644 (file)
@@ -17,6 +17,7 @@
 package org.eclipse.tracecompass.tmf.core.trace;
 
 import java.io.File;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -36,6 +37,7 @@ import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper;
 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisManager;
 import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
@@ -54,6 +56,8 @@ import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
 import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
 
+import com.google.common.collect.ImmutableList;
+
 /**
  * Abstract implementation of ITmfTrace.
  * <p>
@@ -88,7 +92,21 @@ import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
 public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, ITmfTraceCompleteness {
 
     // ------------------------------------------------------------------------
-    // Attributes
+    // Class attributes
+    // ------------------------------------------------------------------------
+
+    /**
+     * Basic aspects that should be valid for all trace types.
+     */
+    public static final Collection<ITmfEventAspect> BASE_ASPECTS =
+            ImmutableList.of(
+                    ITmfEventAspect.BaseAspects.TIMESTAMP,
+                    ITmfEventAspect.BaseAspects.EVENT_TYPE,
+                    ITmfEventAspect.BaseAspects.CONTENTS
+                    );
+
+    // ------------------------------------------------------------------------
+    // Instance attributes
     // ------------------------------------------------------------------------
 
     // The resource used for persistent properties for this trace
@@ -351,6 +369,12 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace, IT
         return modules;
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        /* By default we provide only the base aspects valid for all trace types */
+        return BASE_ASPECTS;
+    }
+
     /**
      * Clears the trace
      */
index 0f692b303f58ee3f3cbb2f04c697ebed20c72c01..518c5ceb69321a79b9f8f8eb2467ab197b2715c6 100644 (file)
@@ -15,6 +15,7 @@ Require-Bundle: org.eclipse.core.runtime,
 Export-Package: org.eclipse.tracecompass.internal.tmf.pcap.core;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.pcap.core.analysis;x-friends:="org.eclipse.tracecompass.tmf.pcap.core.tests,org.eclipse.tracecompass.tmf.pcap.ui",
  org.eclipse.tracecompass.internal.tmf.pcap.core.event;x-friends:="org.eclipse.tracecompass.tmf.pcap.core.tests,org.eclipse.tracecompass.tmf.pcap.ui",
+ org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.pcap.core.protocol;x-friends:="org.eclipse.tracecompass.tmf.pcap.core.tests,org.eclipse.tracecompass.tmf.pcap.ui",
  org.eclipse.tracecompass.internal.tmf.pcap.core.signal;x-friends:="org.eclipse.tracecompass.tmf.pcap.ui",
  org.eclipse.tracecompass.internal.tmf.pcap.core.trace;x-friends:="org.eclipse.tracecompass.tmf.pcap.core.tests,org.eclipse.tracecompass.tmf.pcap.ui,org.eclipse.tracecompass.tmf.pcap.ui.swtbot.tests",
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/Messages.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/Messages.java
new file mode 100644 (file)
index 0000000..583e1ad
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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:
+ *   Vincent Perot - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.osgi.util.NLS;
+
+@SuppressWarnings("javadoc")
+public class Messages extends NLS {
+
+    private static final String BUNDLE_NAME =
+            "org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.messages"; //$NON-NLS-1$
+
+    public static @Nullable String PcapAspectName_Destination;
+    public static @Nullable String PcapAspectName_Protocol;
+    public static @Nullable String PcapAspectName_Reference;
+    public static @Nullable String PcapAspectName_Source;
+
+    static {
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+
+    /**
+     * Helper method to expose externalized strings as non-null objects.
+     */
+    static String getMessage(@Nullable String msg) {
+        if (msg == null) {
+            return ""; //$NON-NLS-1$
+        }
+        return msg;
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapDestinationAspect.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapDestinationAspect.java
new file mode 100644 (file)
index 0000000..dfb478e
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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:
+ *   Vincent Perot - Initial API and implementation
+ *   Alexandre Montplaisir - Update to new ITmfEventAspect API
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+
+/**
+ * The "packet destination" aspect for pcap events.
+ *
+ * @author Alexandre Montplaisir
+ */
+public class PcapDestinationAspect implements ITmfEventAspect {
+
+    @Override
+    public String getName() {
+        return Messages.getMessage(Messages.PcapAspectName_Destination);
+    }
+
+    @Override
+    public String getHelpText() {
+        return EMPTY_STRING;
+    }
+
+    @Override
+    public String resolve(ITmfEvent event) {
+        if (!(event instanceof PcapEvent)) {
+            return EMPTY_STRING;
+        }
+        PcapEvent pcapEvent = (PcapEvent) event;
+        TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
+
+        String ret = pcapEvent.getDestinationEndpoint(protocol);
+        return (ret == null ? EMPTY_STRING : ret);
+    }
+
+    @Override
+    public @NonNull String getFilterId() {
+        return PcapEvent.EVENT_FIELD_PACKET_DESTINATION;
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapProtocolAspect.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapProtocolAspect.java
new file mode 100644 (file)
index 0000000..c71fb30
--- /dev/null
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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:
+ *   Vincent Perot - Initial API and implementation
+ *   Alexandre Montplaisir - Update to new ITmfEventAspect API
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+
+/**
+ * The "packet protocol" aspect for pcap events
+ *
+ * @author Alexandre Montplaisir
+ */
+public class PcapProtocolAspect implements ITmfEventAspect {
+
+    @Override
+    public String getName() {
+        return Messages.getMessage(Messages.PcapAspectName_Protocol);
+    }
+
+    @Override
+    public String getHelpText() {
+        return EMPTY_STRING;
+    }
+
+    @Override
+    public String resolve(ITmfEvent event) {
+        if (!(event instanceof PcapEvent)) {
+            return EMPTY_STRING;
+        }
+        PcapEvent pcapEvent = (PcapEvent) event;
+        TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
+
+        @SuppressWarnings("null")
+        @NonNull String proto = protocol.getShortName().toUpperCase();
+        return proto;
+    }
+
+    @Override
+    public @Nullable String getFilterId() {
+        return PcapEvent.EVENT_FIELD_PACKET_PROTOCOL;
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapReferenceAspect.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapReferenceAspect.java
new file mode 100644 (file)
index 0000000..216475d
--- /dev/null
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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:
+ *   Vincent Perot - Initial API and implementation
+ *   Alexandre Montplaisir - Update to new ITmfEventAspect API
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+
+/**
+ * The "packet reference" aspect for pcap events
+ *
+ * @author Alexandre Montplaisir
+ */
+public class PcapReferenceAspect implements ITmfEventAspect {
+
+    @Override
+    public String getName() {
+        return Messages.getMessage(Messages.PcapAspectName_Reference);
+    }
+
+    @Override
+    public String getHelpText() {
+        return EMPTY_STRING;
+    }
+
+    @Override
+    public String resolve(ITmfEvent event) {
+        if (!(event instanceof PcapEvent)) {
+            return EMPTY_STRING;
+        }
+        return ((PcapEvent) event).getReference();
+    }
+
+    @Override
+    public @Nullable String getFilterId() {
+        return ITmfEvent.EVENT_FIELD_REFERENCE;
+    }
+}
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapSourceAspect.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/PcapSourceAspect.java
new file mode 100644 (file)
index 0000000..c27d3c7
--- /dev/null
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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:
+ *   Vincent Perot - Initial API and implementation
+ *   Alexandre Montplaisir - Update to new ITmfEventAspect API
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+
+/**
+ * The packet source aspect for pcap events.
+ *
+ * This normally represents the source address of the packet, and the format
+ * depends on the protocol (e.g. source IP address, source port, etc.)
+ *
+ * @author Alexandre Montplaisir
+ */
+public class PcapSourceAspect implements ITmfEventAspect {
+
+    @Override
+    public String getName() {
+        return Messages.getMessage(Messages.PcapAspectName_Source);
+    }
+
+    @Override
+    public String getHelpText() {
+        return EMPTY_STRING;
+    }
+
+    @Override
+    public String resolve(ITmfEvent event) {
+        if (!(event instanceof PcapEvent)) {
+            return EMPTY_STRING;
+        }
+        PcapEvent pcapEvent = (PcapEvent) event;
+        TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
+
+        String ret = pcapEvent.getSourceEndpoint(protocol);
+        return (ret == null ? EMPTY_STRING : ret);
+    }
+
+    @Override
+    public @NonNull String getFilterId() {
+        return PcapEvent.EVENT_FIELD_PACKET_SOURCE;
+    }
+}
\ No newline at end of file
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/messages.properties b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/messages.properties
new file mode 100644 (file)
index 0000000..21ab85b
--- /dev/null
@@ -0,0 +1,16 @@
+###############################################################################
+# 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:
+#     Ericsson - Initial API and implementation
+###############################################################################
+
+PcapAspectName_Destination=Destination
+PcapAspectName_Protocol=Protocol
+PcapAspectName_Reference=Reference
+PcapAspectName_Source=Source
diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/package-info.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/aspect/package-info.java
new file mode 100644 (file)
index 0000000..e17f94d
--- /dev/null
@@ -0,0 +1,14 @@
+/*******************************************************************************
+ * 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:
+ *    Ericsson - Initial API and implementation
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect;
\ No newline at end of file
index 56d4f81d334a42a56cbf19414a65b58d52aca492..c904c0297ca2c9612df9a804e0fbdfbf9766e8cb 100644 (file)
@@ -16,6 +16,7 @@ import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.file.FileSystems;
 import java.nio.file.Path;
+import java.util.Collection;
 import java.util.Map;
 
 import org.eclipse.core.resources.IProject;
@@ -31,8 +32,13 @@ import org.eclipse.tracecompass.internal.pcap.core.trace.PcapFile;
 import org.eclipse.tracecompass.internal.pcap.core.util.LinkTypeHelper;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.Activator;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.PcapDestinationAspect;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.PcapProtocolAspect;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.PcapReferenceAspect;
+import org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect.PcapSourceAspect;
 import org.eclipse.tracecompass.internal.tmf.pcap.core.util.PcapEventFactory;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfEventParser;
@@ -43,6 +49,7 @@ import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
 import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
 import org.eclipse.tracecompass.tmf.core.trace.location.TmfLongLocation;
 
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 
 /**
@@ -55,6 +62,16 @@ import com.google.common.collect.ImmutableMap;
  */
 public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTraceProperties, AutoCloseable {
 
+    @SuppressWarnings("null")
+    private static final @NonNull Collection<ITmfEventAspect> PCAP_ASPECTS = ImmutableList.of(
+            ITmfEventAspect.BaseAspects.TIMESTAMP,
+            new PcapSourceAspect(),
+            new PcapDestinationAspect(),
+            new PcapReferenceAspect(),
+            new PcapProtocolAspect(),
+            ITmfEventAspect.BaseAspects.CONTENTS
+            );
+
     @SuppressWarnings("null")
     private static final @NonNull Map<String, String> EMPTY_MAP = ImmutableMap.of();
     private static final String EMPTY_STRING = ""; //$NON-NLS-1$
@@ -106,6 +123,11 @@ public class PcapTrace extends TmfTrace implements ITmfEventParser, ITmfTracePro
         }
     }
 
+    @Override
+    public Iterable<ITmfEventAspect> getEventAspects() {
+        return PCAP_ASPECTS;
+    }
+
     @Override
     public synchronized @Nullable PcapEvent parseEvent(@Nullable ITmfContext context) {
         if (context == null) {
index 305022d9c463cc10e6a4aa680f57bc05a66a01b9..e237528407e25e46fd816fadd7553cd166cad5a6 100644 (file)
@@ -16,6 +16,5 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.tracecompass.tmf.ui;bundle-version="0.1.0",
  org.eclipse.tracecompass.tmf.pcap.core;bundle-version="0.1.0"
 Export-Package: org.eclipse.tracecompass.internal.tmf.pcap.ui;x-friends:="org.eclipse.tracecompass.tmf.pcap.ui.swtbot.tests",
- org.eclipse.tracecompass.internal.tmf.pcap.ui.editor;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.pcap.ui.stream;x-friends:="org.eclipse.tracecompass.tmf.pcap.ui.swtbot.tests"
 Import-Package: com.google.common.collect
index d8723ba052aef8874cd53652d946ec6cea098437..84ccf311f5b9f62489e0ad5b38e482d4211c76b4 100644 (file)
@@ -6,9 +6,6 @@
       <type
             icon="icons/pcap.png"
             tracetype="org.eclipse.linuxtools.tmf.pcap.core.pcaptrace">
-         <eventTableColumns
-               class="org.eclipse.tracecompass.internal.tmf.pcap.ui.editor.PcapEventTableColumns">
-         </eventTableColumns>
       </type>
    </extension>
    <extension
diff --git a/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/Messages.java b/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/Messages.java
deleted file mode 100644 (file)
index 7d8fdc9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * 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:
- *   Vincent Perot - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.pcap.ui.editor;
-
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.osgi.util.NLS;
-
-@SuppressWarnings("javadoc")
-public class Messages extends NLS {
-
-    private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tmf.pcap.ui.editor.messages"; //$NON-NLS-1$
-
-    public static @Nullable String PcapEventsTable_Content;
-    public static @Nullable String PcapEventsTable_Destination;
-    public static @Nullable String PcapEventsTable_Protocol;
-    public static @Nullable String PcapEventsTable_Reference;
-    public static @Nullable String PcapEventsTable_Source;
-    public static @Nullable String PcapEventsTable_Timestamp;
-
-    static {
-        // initialize resource bundle
-        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
-    }
-
-    private Messages() {
-    }
-}
diff --git a/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/PcapEventTableColumns.java b/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/PcapEventTableColumns.java
deleted file mode 100644 (file)
index a5a2b55..0000000
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * 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:
- *   Vincent Perot - Initial API and implementation
- *   Alexandre Montplaisir - Update to new TmfEventTableColumn API
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.pcap.ui.editor;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
-import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent;
-import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Default event table for pcap traces.
- *
- * @author Vincent Perot
- */
-public class PcapEventTableColumns implements ITmfEventTableColumns {
-
-    // ------------------------------------------------------------------------
-    // Table data
-    // ------------------------------------------------------------------------
-
-    @SuppressWarnings("null")
-    private static final @NonNull Collection<TmfEventTableColumn> PCAP_COLUMNS = ImmutableList.of(
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.TIMESTAMP),
-            new TmfEventTableColumn(new PcapSourceAspect()),
-            new TmfEventTableColumn(new PcapDestinationAspect()),
-            new TmfEventTableColumn(new PcapReferenceAspect()),
-            new TmfEventTableColumn(new PcapProtocolAspect()),
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.CONTENTS)
-            );
-
-    /**
-     * The "packet source" column for pcap events
-     */
-    private static class PcapSourceAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return getString(Messages.PcapEventsTable_Source);
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof PcapEvent)) {
-                return EMPTY_STRING;
-            }
-            PcapEvent pcapEvent = (PcapEvent) event;
-            TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
-
-            return getString(pcapEvent.getSourceEndpoint(protocol));
-        }
-
-        @Override
-        public @NonNull String getFilterId() {
-            return PcapEvent.EVENT_FIELD_PACKET_SOURCE;
-        }
-    }
-
-    /**
-     * The "packet destination" column for pcap events
-     */
-    private static class PcapDestinationAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return getString(Messages.PcapEventsTable_Destination);
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof PcapEvent)) {
-                return EMPTY_STRING;
-            }
-            PcapEvent pcapEvent = (PcapEvent) event;
-            TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
-            return getString(pcapEvent.getDestinationEndpoint(protocol));
-        }
-
-        @Override
-        public @NonNull String getFilterId() {
-            return PcapEvent.EVENT_FIELD_PACKET_DESTINATION;
-        }
-    }
-
-    /**
-     * The "packet reference" column for pcap events
-     */
-    private static class PcapReferenceAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return getString(Messages.PcapEventsTable_Reference);
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof PcapEvent)) {
-                return EMPTY_STRING;
-            }
-            return ((PcapEvent) event).getReference();
-        }
-
-        @Override
-        public @Nullable String getFilterId() {
-            return ITmfEvent.EVENT_FIELD_REFERENCE;
-        }
-    }
-
-    /**
-     * The "packet protocol" column for pcap events
-     */
-    private static class PcapProtocolAspect implements ITmfEventAspect {
-
-        @Override
-        public String getName() {
-            return getString(Messages.PcapEventsTable_Protocol);
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (!(event instanceof PcapEvent)) {
-                return EMPTY_STRING;
-            }
-            PcapEvent pcapEvent = (PcapEvent) event;
-            TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol();
-
-            @SuppressWarnings("null")
-            @NonNull String proto = protocol.getShortName().toUpperCase();
-            return proto;
-        }
-
-        @Override
-        public @Nullable String getFilterId() {
-            return PcapEvent.EVENT_FIELD_PACKET_PROTOCOL;
-        }
-    }
-
-    /**
-     * Little convenience method to work around the incompatibilities between
-     * null annotations and NLS files...
-     */
-    private static String getString(@Nullable String str) {
-        return (str == null ? "" : str); //$NON-NLS-1$
-    }
-
-    // ------------------------------------------------------------------------
-    // ITmfEventTableColumns
-    // ------------------------------------------------------------------------
-
-    @Override
-    public Collection<? extends TmfEventTableColumn> getEventTableColumns() {
-        return PCAP_COLUMNS;
-    }
-}
diff --git a/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/messages.properties b/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/messages.properties
deleted file mode 100644 (file)
index fe4006d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# 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:
-#     Ericsson - Initial API and implementation
-###############################################################################
-
-PcapEventsTable_Content=Content
-PcapEventsTable_Destination=Destination
-PcapEventsTable_Protocol=Protocol
-PcapEventsTable_Reference=Reference
-PcapEventsTable_Source=Source
-PcapEventsTable_Timestamp=Timestamp
diff --git a/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/package-info.java b/org.eclipse.tracecompass.tmf.pcap.ui/src/org/eclipse/tracecompass/internal/tmf/pcap/ui/editor/package-info.java
deleted file mode 100644 (file)
index 0018229..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*******************************************************************************
- * 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:
- *    Ericsson - Initial API and implementation
- *******************************************************************************/
-
-@org.eclipse.jdt.annotation.NonNullByDefault
-package org.eclipse.tracecompass.internal.tmf.pcap.ui.editor;
\ No newline at end of file
index b208b8c5c9c54ec7861f1f1a86677d9e2d2c1838..f41da53a233b921281fb8341e97aad35e60fedfd 100644 (file)
@@ -24,7 +24,6 @@ Export-Package: org.eclipse.tracecompass.internal.tmf.ui;x-friends:="org.eclipse
  org.eclipse.tracecompass.internal.tmf.ui.commands;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.ui.dialogs;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.ui.editors.handlers;x-internal:=true,
- org.eclipse.tracecompass.internal.tmf.ui.parsers.custom;x-friends:="org.eclipse.tracecompass.tmf.ui.tests",
  org.eclipse.tracecompass.internal.tmf.ui.parsers.wizards;x-friends:="org.eclipse.tracecompass.tmf.ui.tests",
  org.eclipse.tracecompass.internal.tmf.ui.preferences;x-internal:=true,
  org.eclipse.tracecompass.internal.tmf.ui.project.dialogs;x-internal:=true,
index 1a1dba8572259f06813d48216a69634b2ae1e8bf..87baa2995fe6969cc9a83e31c9094980b2e6cc92 100644 (file)
@@ -58,7 +58,6 @@
          <sequence>
             <element ref="eventsTableType" minOccurs="0" maxOccurs="1"/>
             <element ref="defaultEditor" minOccurs="0" maxOccurs="1"/>
-            <element ref="eventTableColumns" minOccurs="0" maxOccurs="1"/>
          </sequence>
          <attribute name="tracetype" type="string" use="required">
             <annotation>
@@ -158,30 +157,6 @@ If empty, the default events editor will be used.
       </complexType>
    </element>
 
-   <element name="eventTableColumns">
-      <annotation>
-         <documentation>
-            The event table columns to use with this trace type.
-If omitted, the default columns will be used.
-
-If the &quot;eventsTableType&quot; element is present, we will first try to provide a table of that type (ignoring the contents of &quot;eventTableColumns&quot;). If the requested table type cannot be provided, then we will fall-back to using a default table with the columns defined in &quot;eventTableColumns&quot;.
-         </documentation>
-      </annotation>
-      <complexType>
-         <attribute name="class" type="string">
-            <annotation>
-               <documentation>
-                  The fully qualified name of a class that implements &lt;samp&gt;ITmfEventTableColumns&lt;/samp&gt; .
-If empty, the default columns will be used.
-               </documentation>
-               <appinfo>
-                  <meta.attribute kind="java" basedOn=":org.eclipse.linuxtools.tmf.ui.viewers.events.columns.ITmfEventTableColumns"/>
-               </appinfo>
-            </annotation>
-         </attribute>
-      </complexType>
-   </element>
-
    <annotation>
       <appinfo>
          <meta.section type="since"/>
diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/custom/CustomEventTableColumns.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/parsers/custom/CustomEventTableColumns.java
deleted file mode 100644 (file)
index 78db09d..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 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:
- *   Patrick Tasse - Initial API and implementation
- *   Alexandre Montplaisir - Update for TmfEventTableColumn
- *******************************************************************************/
-
-package org.eclipse.tracecompass.internal.tmf.ui.parsers.custom;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
-import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomEvent;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Event table column definition for Custom {Text|XML} traces.
- *
- * Since this definition will be different for every single custom trace, this
- * does not work the same as with {@link ITmfEventTableColumns}.
- *
- * Instead, one has to call {@link #generateColumns(CustomTraceDefinition)} with
- * the CustomTraceDefinition of the the particular trace to display. Then the
- * returned collection can be passed to the constructor
- * {@link TmfEventsTable#TmfEventsTable(org.eclipse.swt.widgets.Composite, int, Collection)}
- * as usual.
- *
- * @author Alexandre Montplaisir
- */
-public class CustomEventTableColumns {
-
-    /**
-     * Column for custom events, which uses an integer ID to represent each
-     * column.
-     */
-    private static final class CustomEventFieldAspect implements ITmfEventAspect {
-
-        private final @NonNull String fName;
-        private final int fIndex;
-
-        /**
-         * Constructor
-         *
-         * @param name
-         *            The name (title) of this aspect
-         * @param idx
-         *            The "index" of this aspect, which should be the index of
-         *            the field in the event's content to display.
-         */
-        public CustomEventFieldAspect(@NonNull String name, int idx) {
-            fName = name;
-            fIndex = idx;
-        }
-
-        @Override
-        public String getName() {
-            return fName;
-        }
-
-        @Override
-        public String getHelpText() {
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String resolve(ITmfEvent event) {
-            if (event instanceof CustomEvent) {
-                String ret = ((CustomEvent) event).getEventString(fIndex);
-                return (ret == null ? EMPTY_STRING : ret);
-            }
-            return EMPTY_STRING;
-        }
-
-        @Override
-        public String getFilterId() {
-            return fName;
-        }
-    }
-
-    /**
-     * Get the event table columns for a given trace definition
-     *
-     * @param definition The {@link CustomTraceDefinition} of the trace for which you want the columns
-     * @return The set of columns for the given trace.
-     */
-    public static Collection<TmfEventTableColumn> generateColumns(CustomTraceDefinition definition) {
-        ImmutableList.Builder<TmfEventTableColumn> builder = new ImmutableList.Builder<>();
-        List<OutputColumn> outputs = definition.outputs;
-        for (int i = 0; i < outputs.size(); i++) {
-            String name = outputs.get(i).name;
-            if (name != null) {
-                builder.add(new TmfEventTableColumn(new CustomEventFieldAspect(name, i)));
-            }
-        }
-        return builder.build();
-    }
-}
index af426e2be8de61de8e1cf79ba2ed49dcdd0a47c1..aea1ac827bfe3880812a74924d97dcd010c61877 100644 (file)
@@ -31,13 +31,13 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.Messages;
-import org.eclipse.tracecompass.internal.tmf.ui.parsers.custom.CustomEventTableColumns;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTrace;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
@@ -106,7 +106,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
         tableLayout.marginHeight = 0;
         tableLayout.marginWidth = 0;
         tableContainer.setLayout(tableLayout);
-        previewTable = new TmfEventsTable(tableContainer, 0, CustomEventTableColumns.generateColumns(new CustomTxtTraceDefinition()));
+        previewTable = new TmfEventsTable(tableContainer, 0, CustomEventAspects.generateAspects(new CustomTxtTraceDefinition()));
         previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         if (wizard.definition != null) {
@@ -233,7 +233,7 @@ public class CustomTxtParserOutputWizardPage extends WizardPage {
             };
             trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
             previewTable.dispose();
-            previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventTableColumns.generateColumns(definition));
+            previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventAspects.generateAspects(definition));
             previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
             previewTable.setTrace(trace, true);
         } catch (final TmfTraceException e) {
index 653f904517bd7d14b9a8d514073e0887aa35c9aa..a74ab58d75ab640ba28de5250c3e1f30d70beb35 100644 (file)
@@ -31,14 +31,14 @@ import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Text;
+import org.eclipse.tracecompass.internal.tmf.core.parsers.custom.CustomEventAspects;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.internal.tmf.ui.Messages;
-import org.eclipse.tracecompass.internal.tmf.ui.parsers.custom.CustomEventTableColumns;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition;
+import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
 import org.eclipse.tracecompass.tmf.core.trace.indexer.checkpoint.TmfCheckpointIndexer;
@@ -107,7 +107,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage {
         tableLayout.marginHeight = 0;
         tableLayout.marginWidth = 0;
         tableContainer.setLayout(tableLayout);
-        previewTable = new TmfEventsTable(tableContainer, 0, CustomEventTableColumns.generateColumns(new CustomXmlTraceDefinition()));
+        previewTable = new TmfEventsTable(tableContainer, 0, CustomEventAspects.generateAspects(new CustomXmlTraceDefinition()));
         previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
 
         if (wizard.definition != null) {
@@ -234,7 +234,7 @@ public class CustomXmlParserOutputWizardPage extends WizardPage {
             };
             trace.getIndexer().buildIndex(0, TmfTimeRange.ETERNITY, false);
             previewTable.dispose();
-            previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventTableColumns.generateColumns(definition));
+            previewTable = new TmfEventsTable(tableContainer, CACHE_SIZE, CustomEventAspects.generateAspects(definition));
             previewTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
             previewTable.setTrace(trace, true);
         } catch (final TmfTraceException e) {
index 3f8e289fc122c082d5e47c8dd3bda5bcf91dab50..34ac6d5fe6d306f6b37629125e31b1b022952276 100644 (file)
@@ -13,7 +13,6 @@
 
 package org.eclipse.tracecompass.tmf.ui.editors;
 
-import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.Set;
 
@@ -42,6 +41,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.tracecompass.internal.tmf.ui.Activator;
 import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTimestampFormatUpdateSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
@@ -59,7 +59,6 @@ import org.eclipse.tracecompass.tmf.ui.project.model.TmfProjectRegistry;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement;
 import org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceTypeUIUtils;
 import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IEditorSite;
@@ -319,12 +318,12 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus
         }
 
         /*
-         * The trace type did not specify an event table, we will use a default
-         * table with the columns it asked for (if any).
+         * The trace type did not specify an event table, we will use a standard
+         * table with the trace's advertised aspects (if any).
          */
-        Collection<? extends TmfEventTableColumn> columns = TmfTraceTypeUIUtils.getEventTableColumns(trace);
-        if (columns != null) {
-            return new TmfEventsTable(parent, cacheSize, columns);
+        Iterable<ITmfEventAspect> aspects = trace.getEventAspects();
+        if (aspects != null) {
+            return new TmfEventsTable(parent, cacheSize, aspects);
         }
 
         /*
@@ -367,19 +366,20 @@ public class TmfEventsEditor extends TmfEditor implements ITmfTraceEditor, IReus
          * trace types.
          */
         ITmfTrace[] traces = experiment.getTraces();
-        Set<TmfEventTableColumn> cols = new LinkedHashSet<>();
+        Set<ITmfEventAspect> aspects = new LinkedHashSet<>();
 
         for (ITmfTrace trace : traces) {
-            Collection<? extends TmfEventTableColumn> traceCols =
-                    TmfTraceTypeUIUtils.getEventTableColumns(trace);
-            if (traceCols == null) {
-                cols.addAll(TmfEventsTable.DEFAULT_COLUMNS);
+            Iterable<ITmfEventAspect> traceAspects = trace.getEventAspects();
+            if (traceAspects == null) {
+                aspects.addAll(TmfTrace.BASE_ASPECTS);
             } else {
-                cols.addAll(traceCols);
+                for (ITmfEventAspect aspect : traceAspects) {
+                    aspects.add(aspect);
+                }
             }
         }
 
-        return new TmfEventsTable(parent, cacheSize, cols);
+        return new TmfEventsTable(parent, cacheSize, aspects);
     }
 
     /**
index b5ce37319399d21bac66bda93bdde6d35f6c76ec..5859ba3b2b46f2d59082e38180af2dd8e349fc7f 100644 (file)
@@ -16,7 +16,6 @@ package org.eclipse.tracecompass.tmf.ui.project.model;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -40,19 +39,16 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tracecompass.internal.tmf.ui.parsers.custom.CustomEventTableColumns;
 import org.eclipse.tracecompass.tmf.core.TmfCommonConstants;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomTxtTrace;
 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceImportException;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType;
-import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.tracecompass.tmf.core.project.model.TmfTraceType.TraceElementType;
+import org.eclipse.tracecompass.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.core.util.Pair;
 import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsTable;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.ITmfEventTableColumns;
-import org.eclipse.tracecompass.tmf.ui.viewers.events.columns.TmfEventTableColumn;
 import org.osgi.framework.Bundle;
 
 /**
@@ -414,61 +410,6 @@ public final class TmfTraceTypeUIUtils {
         return null;
     }
 
-    /**
-     * Get the Event Table columns specified by the trace type's extension
-     * point, if there are any.
-     *
-     * @param trace
-     *            The trace for which we want the columns.
-     * @return The corresponding event table columns, or 'null' if this trace
-     *         type did not specify any.
-     * @since 3.2
-     */
-    public static @Nullable Collection<? extends TmfEventTableColumn> getEventTableColumns(ITmfTrace trace) {
-        final String traceType = getTraceType(trace);
-        if (traceType == null) {
-            return null;
-        }
-
-        /*
-         * Custom traces are a special case : the columns are defined by the
-         * trace definition.
-         */
-        if (traceType.startsWith(CustomTxtTrace.class.getCanonicalName())) {
-            return CustomEventTableColumns.generateColumns(((CustomTxtTrace) trace).getDefinition());
-        }
-        if (traceType.startsWith(CustomXmlTrace.class.getCanonicalName())) {
-            return CustomEventTableColumns.generateColumns(((CustomXmlTrace) trace).getDefinition());
-        }
-
-        /* For all other trace types, we will go look into the extension point */
-        for (final IConfigurationElement ce : TmfTraceTypeUIUtils.getTypeUIElements(TraceElementType.TRACE)) {
-            if (ce.getAttribute(TmfTraceTypeUIUtils.TRACETYPE_ATTR).equals(traceType)) {
-                final IConfigurationElement[] eventTableColumnsCE = ce.getChildren(TmfTraceTypeUIUtils.EVENT_TABLE_COLUMNS);
-
-                if (eventTableColumnsCE.length != 1) {
-                    break;
-                }
-                final String eventTableColumnsClass = eventTableColumnsCE[0].getAttribute(TmfTraceTypeUIUtils.CLASS_ATTR);
-                if ((eventTableColumnsClass == null) || (eventTableColumnsClass.isEmpty())) {
-                    break;
-                }
-                try {
-                    final Bundle bundle = Platform.getBundle(ce.getContributor().getName());
-                    final Class<?> c = bundle.loadClass(eventTableColumnsClass);
-                    final Constructor<?> ctor = c.getConstructor();
-                    ITmfEventTableColumns cols = (ITmfEventTableColumns) ctor.newInstance();
-                    return cols.getEventTableColumns();
-
-                } catch (NoSuchMethodException | ClassNotFoundException | InstantiationException |
-                        IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-                    return null;
-                }
-            }
-        }
-        return null;
-    }
-
     /**
      * Get the trace type (as a String) for the given trace
      *
index 7d63ad8ee534c26b64846dd269468e3b8ccc87f5..ba59d67d243371c7d95fb8ca0dbda35f1f550021 100644 (file)
@@ -136,6 +136,7 @@ import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
 import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
 import org.eclipse.tracecompass.tmf.core.trace.location.ITmfLocation;
 import org.eclipse.tracecompass.tmf.ui.viewers.events.TmfEventsCache.CachedEvent;
@@ -203,17 +204,6 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     private static final int FILTER_SUMMARY_INDEX = 1;
     private static final int EVENT_COLUMNS_START_INDEX = MARGIN_COLUMN_INDEX + 1;
 
-    /**
-     * Default set of columns to use for trace types that do not specify
-     * anything
-     * @since 3.2
-     */
-    public static final Collection<TmfEventTableColumn> DEFAULT_COLUMNS = ImmutableList.of(
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.TIMESTAMP),
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.EVENT_TYPE),
-            new TmfEventTableColumn(ITmfEventAspect.BaseAspects.CONTENTS)
-            );
-
     /**
      * The events table search/filter keys
      *
@@ -333,7 +323,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
      *            The size of the event table cache
      */
     public TmfEventsTable(final Composite parent, final int cacheSize) {
-        this(parent, cacheSize, DEFAULT_COLUMNS);
+        this(parent, cacheSize, TmfTrace.BASE_ASPECTS);
     }
 
     /**
@@ -360,14 +350,14 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     }
 
     @Deprecated
-    private static Collection<TmfEventTableColumn> convertFromColumnData(
+    private static Iterable<ITmfEventAspect> convertFromColumnData(
             org.eclipse.tracecompass.tmf.ui.widgets.virtualtable.ColumnData[] columnData) {
 
-        ImmutableList.Builder<TmfEventTableColumn> builder = new ImmutableList.Builder<>();
+        ImmutableList.Builder<ITmfEventAspect> builder = new ImmutableList.Builder<>();
         for (org.eclipse.tracecompass.tmf.ui.widgets.virtualtable.ColumnData col : columnData) {
             String fieldName = col.header;
             if (fieldName != null) {
-                builder.add(new TmfEventTableColumn(new TmfEventFieldAspect(fieldName, fieldName)));
+                builder.add(new TmfEventFieldAspect(fieldName, fieldName));
             }
         }
         return builder.build();
@@ -380,16 +370,17 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
      *            The parent composite UI object
      * @param cacheSize
      *            The size of the event table cache
-     * @param columns
-     *            The columns to use in this table.
+     * @param aspects
+     *            The event aspects to display in this table. One column per
+     *            aspect will be created.
      *            <p>
      *            The iteration order of this collection will correspond to the
-     *            initial ordering of this series of columns in the table.
+     *            initial ordering of the columns in the table.
      *            </p>
      * @since 3.1
      */
     public TmfEventsTable(final Composite parent, int cacheSize,
-            Collection<? extends TmfEventTableColumn> columns) {
+            Iterable<ITmfEventAspect> aspects) {
         super("TmfEventsTable"); //$NON-NLS-1$
 
         fComposite = new Composite(parent, SWT.NONE);
@@ -415,8 +406,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         fTable.setLinesVisible(true);
 
         // Setup the columns
-        if (columns != null) {
-            fColumns.addAll(columns);
+        if (aspects != null) {
+            for (ITmfEventAspect aspect : aspects) {
+                if (aspect != null) {
+                    fColumns.add(new TmfEventTableColumn(aspect));
+                }
+            }
         }
 
         TmfMarginColumn collapseCol = new TmfMarginColumn();
diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/ITmfEventTableColumns.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/columns/ITmfEventTableColumns.java
deleted file mode 100644 (file)
index fa1ca42..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * 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.tracecompass.tmf.ui.viewers.events.columns;
-
-import java.util.Collection;
-
-import org.eclipse.jdt.annotation.NonNull;
-
-/**
- * This class allows a trace type to specify which columns it wants to display
- * in the Event Table. The "function" to populate the column for any given event
- * is defined in each {@link TmfEventTableColumn}.
- *
- * @author Alexandre Montplaisir
- * @since 3.2
- */
-public interface ITmfEventTableColumns {
-
-    /**
-     * Return the columns specified by this trace type.
-     *
-     * The iteration order of the returned collection will correspond to the
-     * initial order of these columns in the view (from left to right).
-     * <p>
-     * Note to implementers:
-     * <p>
-     * Even if many traces of the same type can be opened at the same time, the
-     * column objects can (and probably should) be singleton instances. This
-     * means you do not need to create new column objects every time this method
-     * is called.
-     *
-     * @return The Event Table columns advertised by this trace type
-     */
-    @NonNull Collection<? extends TmfEventTableColumn> getEventTableColumns();
-}
This page took 0.062365 seconds and 5 git commands to generate.