tmf: Use same field format in properties and events views
authorGeneviève Bastien <gbastien+lttng@versatic.net>
Wed, 13 Mar 2013 18:57:10 +0000 (14:57 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 25 Mar 2013 17:27:38 +0000 (13:27 -0400)
Change-Id: I5e5e80abd0b2acb83b06e5560db6cf70c2900f8c
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/11320
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.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java

index f09b32882c749bf4d7faf29b57966c5c1f127e4c..193025efe5c85dc0b9dadd2316f163e5aa5ada2a 100644 (file)
@@ -281,6 +281,11 @@ final class CTFIntegerField extends CtfTmfEventField {
         return (Long) super.getValue();
     }
 
+    @Override
+    public String getFormattedValue() {
+        return formatNumber(getValue(), base);
+    }
+
     /**
      * Custom-format the integer values depending on their base.
      */
@@ -328,6 +333,7 @@ final class CTFStringField extends CtfTmfEventField {
 final class CTFIntegerArrayField extends CtfTmfEventField {
 
     private final int base;
+    private String formattedValue = null;
 
     /**
      * Constructor for CTFIntegerArrayField.
@@ -353,17 +359,24 @@ final class CTFIntegerArrayField extends CtfTmfEventField {
         return (List<Long>) super.getValue();
     }
 
+    @Override
+    public String getFormattedValue() {
+        if (formattedValue == null) {
+            List<String> strings = new ArrayList<String>();
+            for (Long value : getValue()) {
+                strings.add(formatNumber(value, base));
+            }
+            formattedValue = strings.toString();
+        }
+        return formattedValue;
+    }
+
     /**
      * Custom-format the integer values depending on their base.
      */
     @Override
     public String toString() {
-        List<String> strings = new ArrayList<String>();
-
-        for (Long value : getValue() ) {
-            strings.add(formatNumber(value, base));
-        }
-        return getName() + '=' + strings.toString();
+        return getName() + '=' + getFormattedValue();
     }
 }
 
index c4078573c362e7f437aaaeba6067e23da87b3dca..57a246d121dd237d6cd4ec47b6f6f9c0c94007e4 100644 (file)
@@ -47,6 +47,12 @@ public interface ITmfEventField {
      */
     public Object getValue();
 
+    /**
+     * @return the value formatted as string
+     * @since 2.0
+     */
+    public String getFormattedValue();
+
     /**
      * @return the list of subfield names (empty array if none)
      */
index e6c5f6afe3e994a521a2585fe77f477db9cd3509..eb46ae1e1f4298b4c948d6b02d963a672fcc954e 100644 (file)
@@ -282,4 +282,12 @@ public class TmfEventField implements ITmfEventField {
         }
     }
 
+    /**
+     * @since 2.0
+     */
+    @Override
+    public String getFormattedValue() {
+        return getValue().toString();
+    }
+
 }
index 47159083dcd2b8feac01bad3cf2cdefbf0823d74..25dec41510723b68f01f2a4f3f8682790337b96f 100644 (file)
@@ -132,7 +132,7 @@ public class TmfEventPropertySource implements IPropertySource {
             if (field.getFields() != null && field.getFields().length > 0) {
                 return new ContentPropertySource(field);
             }
-            return field.getValue();
+            return field.getFormattedValue();
         }
 
         @Override
This page took 0.028843 seconds and 5 git commands to generate.