aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeneviève Bastien2013-03-13 14:57:10 (EDT)
committerAlexandre Montplaisir2013-03-25 13:27:38 (EDT)
commitb93c562a4f7e3080159cafa81fa8f552a4ade4bd (patch)
treea423b9e11702bf1a9ac6dcf0b538b82691c293eb
parentf4f0c28318d8058a13a2d5b693e621dfa7f00787 (diff)
downloadorg.eclipse.linuxtools-b93c562a4f7e3080159cafa81fa8f552a4ade4bd.zip
org.eclipse.linuxtools-b93c562a4f7e3080159cafa81fa8f552a4ade4bd.tar.gz
org.eclipse.linuxtools-b93c562a4f7e3080159cafa81fa8f552a4ade4bd.tar.bz2
tmf: Use same field format in properties and events viewsrefs/changes/20/11320/5
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>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java25
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java6
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java8
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java2
4 files changed, 34 insertions, 7 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
index f09b328..193025e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEventField.java
@@ -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();
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
index c407857..57a246d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfEventField.java
@@ -48,6 +48,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)
*/
public String[] getFieldNames();
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
index e6c5f6a..eb46ae1 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventField.java
@@ -282,4 +282,12 @@ public class TmfEventField implements ITmfEventField {
}
}
+ /**
+ * @since 2.0
+ */
+ @Override
+ public String getFormattedValue() {
+ return getValue().toString();
+ }
+
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
index 4715908..25dec41 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
@@ -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