tmf: Show trace environment variables in the Properties view
authorJean-Christian Kouamé <kadjo.gwandy.jean-christian.kouame@ericsson.com>
Fri, 17 May 2013 20:14:02 +0000 (16:14 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Tue, 2 Jul 2013 14:47:44 +0000 (10:47 -0400)
Fixes bug 407756

Change-Id: Ie90a3094ea8adc335a82182127d7bc0e3b727616
Signed-off-by: Jean-Christian Kouame
Reviewed-on: https://git.eclipse.org/r/12829
Tested-by: Hudson CI
Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
IP-Clean: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceElement.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/messages.properties [new file with mode: 0644]

diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/Messages.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/Messages.java
new file mode 100644 (file)
index 0000000..f510694
--- /dev/null
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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:
+ *   Jean-Christian Kouamé - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.project.model;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Message strings for TMF model handling.
+ *
+ * @author Jean-Christian Kouamé
+ * @since 2.1
+ */
+public class Messages extends NLS {
+
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.project.model.messages"; //$NON-NLS-1$
+
+    /** The category of the resource properties */
+    public static String TmfTraceElement_ResourceProperties;
+
+    /** The category of the trace properties */
+    public static String TmfTraceElement_TraceProperties;
+
+    /** The descriptor for the name property */
+    public static String TmfTraceElement_Name;
+
+    /** The descriptor for the path property */
+    public static String TmfTraceElement_Path;
+
+    /** The descriptor for the location properties */
+    public static String TmfTraceElement_Location;
+
+    /** The descriptor for the event type property */
+    public static String TmfTraceElement_EventType;
+
+    /** The description for the linked property */
+    public static String TmfTraceElement_IsLinked;
+
+    static {
+        // initialize resource bundle
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+    }
+
+    private Messages() {
+    }
+}
index 2a81f93472c5ccb4e72a8766ebf4044bb86a6344..bb0c361a54747ca62d12c55d686ffa2e29c73bdf 100644 (file)
@@ -12,6 +12,8 @@
  *   Geneviève Bastien - Moved supplementary files handling to parent class,
  *                       added code to copy trace
  *   Patrick Tasse - Close editors to release resources
+ *   Jean-Christian Kouame - added trace properties to be shown into
+ *                           the properties view
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.project.model;
@@ -38,7 +40,9 @@ import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefin
 import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTraceProperties;
 import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
+import org.eclipse.linuxtools.tmf.core.trace.TmfTraceManager;
 import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor;
 import org.eclipse.linuxtools.tmf.ui.properties.ReadOnlyTextPropertyDescriptor;
 import org.eclipse.ui.IActionFilter;
@@ -77,12 +81,13 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
     public static final String IS_LINKED = "isLinked"; //$NON-NLS-1$
 
     // Property View stuff
-    private static final String sfInfoCategory = "Info"; //$NON-NLS-1$
-    private static final String sfName = "name"; //$NON-NLS-1$
-    private static final String sfPath = "path"; //$NON-NLS-1$
-    private static final String sfLocation = "location"; //$NON-NLS-1$
-    private static final String sfEventType = "type"; //$NON-NLS-1$
-    private static final String sfIsLinked = "linked"; //$NON-NLS-1$
+    private static final String sfResourcePropertiesCategory = Messages.TmfTraceElement_ResourceProperties;
+    private static final String sfName = Messages.TmfTraceElement_Name;
+    private static final String sfPath = Messages.TmfTraceElement_Path;
+    private static final String sfLocation = Messages.TmfTraceElement_Location;
+    private static final String sfEventType = Messages.TmfTraceElement_EventType;
+    private static final String sfIsLinked = Messages.TmfTraceElement_IsLinked;
+    private static final String sfTracePropertiesCategory = Messages.TmfTraceElement_TraceProperties;
 
     private static final ReadOnlyTextPropertyDescriptor sfNameDescriptor = new ReadOnlyTextPropertyDescriptor(sfName, sfName);
     private static final ReadOnlyTextPropertyDescriptor sfPathDescriptor = new ReadOnlyTextPropertyDescriptor(sfPath, sfPath);
@@ -94,11 +99,11 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
             sfTypeDescriptor, sfIsLinkedDescriptor };
 
     static {
-        sfNameDescriptor.setCategory(sfInfoCategory);
-        sfPathDescriptor.setCategory(sfInfoCategory);
-        sfLocationDescriptor.setCategory(sfInfoCategory);
-        sfTypeDescriptor.setCategory(sfInfoCategory);
-        sfIsLinkedDescriptor.setCategory(sfInfoCategory);
+        sfNameDescriptor.setCategory(sfResourcePropertiesCategory);
+        sfPathDescriptor.setCategory(sfResourcePropertiesCategory);
+        sfLocationDescriptor.setCategory(sfResourcePropertiesCategory);
+        sfTypeDescriptor.setCategory(sfResourcePropertiesCategory);
+        sfIsLinkedDescriptor.setCategory(sfResourcePropertiesCategory);
     }
 
     private static final String BOOKMARKS_HIDDEN_FILE = ".bookmarks"; //$NON-NLS-1$
@@ -408,8 +413,43 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
         return null;
     }
 
+    /**
+     * Get the trace properties of this traceElement if the corresponding trace
+     * is opened in an editor
+     *
+     * @return a map with the names and values of the trace properties
+     *         respectively as keys and values
+     */
+    private Map<String, String> getTraceProperties() {
+        for (ITmfTrace trace : TmfTraceManager.getInstance().getOpenedTraces()) {
+            if (trace.getResource().equals(this.getResource())) {
+                if (trace instanceof ITmfTraceProperties) {
+                    ITmfTraceProperties traceProperties = (ITmfTraceProperties) trace;
+                    return traceProperties.getTraceProperties();
+                }
+            }
+        }
+        return new HashMap<String, String>();
+    }
+
     @Override
     public IPropertyDescriptor[] getPropertyDescriptors() {
+        Map<String, String> traceProperties = getTraceProperties();
+        if (!traceProperties.isEmpty()) {
+            IPropertyDescriptor[] propertyDescriptorArray = new IPropertyDescriptor[traceProperties.size() + sfDescriptors.length];
+            int index = 0;
+            for (Map.Entry<String, String> varName : traceProperties.entrySet()) {
+                ReadOnlyTextPropertyDescriptor descriptor = new ReadOnlyTextPropertyDescriptor(this.getName() + "_" + varName.getKey(), varName.getKey()); //$NON-NLS-1$
+                descriptor.setCategory(sfTracePropertiesCategory);
+                propertyDescriptorArray[index] = descriptor;
+                index++;
+            }
+            for (int i = 0; i < sfDescriptors.length; i++) {
+                propertyDescriptorArray[index] = sfDescriptors[i];
+                index++;
+            }
+            return propertyDescriptorArray;
+        }
         return Arrays.copyOf(sfDescriptors, sfDescriptors.length);
     }
 
@@ -439,6 +479,14 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
             }
         }
 
+        Map<String, String> traceProperties = getTraceProperties();
+        if (id != null && !traceProperties.isEmpty()) {
+            String key = (String) id;
+            key = key.replaceFirst(this.getName() + "_", ""); //$NON-NLS-1$ //$NON-NLS-2$
+            String value = traceProperties.get(key);
+            return value;
+        }
+
         return null;
     }
 
@@ -488,6 +536,7 @@ public class TmfTraceElement extends TmfWithFolderElement implements IActionFilt
 
     /**
      * Close opened editors associated with this trace.
+     *
      * @since 2.0
      */
     public void closeEditors() {
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/messages.properties b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/messages.properties
new file mode 100644 (file)
index 0000000..03ba4b3
--- /dev/null
@@ -0,0 +1,20 @@
+###############################################################################
+# 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
+###############################################################################
+
+# Environment properties dialog
+TmfTraceElement_ResourceProperties = Resource properties
+TmfTraceElement_TraceProperties = Trace properties
+TmfTraceElement_Name = name
+TmfTraceElement_Path = path
+TmfTraceElement_Location = location
+TmfTraceElement_EventType = type
+TmfTraceElement_IsLinked = linked
\ No newline at end of file
This page took 0.027793 seconds and 5 git commands to generate.