tmf: Specify extended trace properties with an interface
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 14 May 2013 19:15:56 +0000 (15:15 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Thu, 16 May 2013 19:42:28 +0000 (15:42 -0400)
Introduce a new ITmfTraceProperties that traces can implement when
they can provide additional trace properties. Also make the the
Enviornment Variables view use this interface, so it is not specific
to CTF traces.

Change-Id: I9a6901f720bc028f28ce5c180b778701a8ec0f5b
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/12789
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfTraceTest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTraceProperties.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java

index c64cc3f3ec788cea22563ebc697469052fb38c2a..4eb16037e4b7486eb7b09ce86fe4805f1aab48ee 100644 (file)
@@ -180,7 +180,7 @@ public class CtfTmfTraceTest {
     @Test
     public void testGetEnvValue() {
         String key = "tracer_name";
-        String result = fixture.getEnvironment().get(key);
+        String result = fixture.getTraceProperties().get(key);
         assertEquals("\"lttng-modules\"",result);
     }
 
@@ -219,7 +219,7 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testGetNbEnvVars() {
-        int result = fixture.getEnvironment().size();
+        int result = fixture.getTraceProperties().size();
         assertEquals(8, result);
     }
 
index 7e6a89923f8323551017cf4f5d0d8af3f3989bd5..1cfa63b3c3e80e574608bb0585997daac9f98481 100644 (file)
@@ -29,6 +29,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
@@ -39,7 +40,8 @@ import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
  * @version 1.0
  * @author Matthew khouzam
  */
-public class CtfTmfTrace extends TmfTrace implements ITmfEventParser {
+public class CtfTmfTrace extends TmfTrace
+        implements ITmfEventParser, ITmfTraceProperties {
 
     // -------------------------------------------
     // Constants
@@ -278,16 +280,14 @@ public class CtfTmfTrace extends TmfTrace implements ITmfEventParser {
     }
 
     // -------------------------------------------
-    // Environment Parameters
+    // ITmfTraceProperties
     // -------------------------------------------
 
     /**
-     * Get the map of environment variables of this trace.
-     *
-     * @return The map of env vars
      * @since 2.0
      */
-    public Map<String, String> getEnvironment() {
+    @Override
+    public Map<String, String> getTraceProperties() {
         return Collections.unmodifiableMap(fTrace.getEnvironment());
     }
 
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTraceProperties.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTraceProperties.java
new file mode 100644 (file)
index 0000000..6838b38
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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:
+ *   Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.trace;
+
+import java.util.Map;
+
+/**
+ * Interface for trace types to implement when they can provide additional
+ * trace-wide properties.
+ *
+ * This information will be displayed in the trace's Properties View, among
+ * other things.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+public interface ITmfTraceProperties {
+
+    /**
+     * Get the properties related to this trace.
+     *
+     * @return The map of properties, <name, value>
+     */
+    public Map<String, String> getTraceProperties();
+}
index 836a588c73cdcbde354be964e748cee1da7d5cc4..82f31727bbb61c3faf1d3a1db15a0ac1631adaa1 100644 (file)
@@ -9,15 +9,17 @@
  * Contributors:
  *   Matthew Khouzam - Initial API and implementation
  *   Bernd Hufmann - Updated to use Tree with columns to be able to group traces
+ *   Alexandre Montplaisir - Display info for any ITmfTraceProperties trace
  *******************************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.environment;
 
 import java.util.Map;
 
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
@@ -28,7 +30,7 @@ import org.eclipse.swt.widgets.TreeColumn;
 import org.eclipse.swt.widgets.TreeItem;
 
 /**
- * Displays the CTF trace properties.
+ * Displays the trace's properties.
  *
  * @version 1.1
  * @author Matthew Khouzam
@@ -80,15 +82,13 @@ public class TmfEnvironmentView extends TmfView {
         }
 
         for (ITmfTrace trace : TmfTraceManager.getTraceSet(fTrace)) {
-            // FIXME This should be replaced with a method in ITmfTrace maybe?
-            // Other trace types might want to supply environment variables.
-            if (trace instanceof CtfTmfTrace) {
+            if (trace instanceof ITmfTraceProperties) {
                 TreeItem item = new TreeItem(fTree, SWT.NONE);
                 item.setText(0, trace.getName());
 
-                CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
-                Map <String, String> env = ctfTrace.getEnvironment();
-                for (Map.Entry<String, String> entry : env.entrySet()) {
+                ITmfTraceProperties propTrace = (ITmfTraceProperties) trace;
+                Map <String, String> properties = propTrace.getTraceProperties();
+                for (Map.Entry<String, String> entry : properties.entrySet()) {
                     TreeItem subItem = new TreeItem(item, SWT.NONE);
                     subItem.setText(0, entry.getKey()); // Variable name
                     subItem.setText(1, entry.getValue()); // Variable value
This page took 0.028985 seconds and 5 git commands to generate.