aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Delisle2013-05-09 10:40:35 (EDT)
committerAlexandre Montplaisir2013-05-10 13:50:18 (EDT)
commitbd379f15ca418310bd9df91d75ff34c02e1bb3a6 (patch)
tree5711030c7e7397917f096a1dead623b9c481a266
parentbc07d87b5637f8f130734842bec1441cc9b45a0d (diff)
downloadorg.eclipse.linuxtools-bd379f15ca418310bd9df91d75ff34c02e1bb3a6.zip
org.eclipse.linuxtools-bd379f15ca418310bd9df91d75ff34c02e1bb3a6.tar.gz
org.eclipse.linuxtools-bd379f15ca418310bd9df91d75ff34c02e1bb3a6.tar.bz2
ctf: Read and display custom event attributesrefs/changes/78/12678/9
Fixes bug #391055. Change-Id: Ie4a1b672201dbcec9e9b147348844a8d18ea7789 Signed-off-by: Simon Delisle <simon.delisle@ericsson.com> Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Reviewed-on: https://git.eclipse.org/r/12678 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>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java16
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfCustomAttributes.java43
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java70
3 files changed, 115 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
index 9d84889..1b3a609 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
@@ -18,6 +18,7 @@ import java.util.Set;
import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
+import org.eclipse.linuxtools.tmf.core.event.ITmfCustomAttributes;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
@@ -36,7 +37,8 @@ import org.eclipse.ui.views.properties.IPropertySource;
* @author Alexandre Montplaisir
* @since 2.0
*/
-public final class CtfTmfEvent extends TmfEvent implements ITmfSourceLookup, ITmfModelLookup {
+public final class CtfTmfEvent extends TmfEvent
+ implements ITmfSourceLookup, ITmfModelLookup, ITmfCustomAttributes {
// ------------------------------------------------------------------------
// Constants
@@ -152,12 +154,9 @@ public final class CtfTmfEvent extends TmfEvent implements ITmfSourceLookup, ITm
}
/**
- * List the custom CTF attributes for events of this type.
- *
- * @return The list of custom attribute names. Should not be null, but could
- * be empty.
* @since 2.0
*/
+ @Override
public Set<String> listCustomAttributes() {
if (fDeclaration == null) {
return new HashSet<String>();
@@ -166,14 +165,9 @@ public final class CtfTmfEvent extends TmfEvent implements ITmfSourceLookup, ITm
}
/**
- * Get the value of a custom CTF attributes for this event's type.
- *
- * @param name
- * Name of the the custom attribute
- * @return Value of this attribute, or null if there is no attribute with
- * that name
* @since 2.0
*/
+ @Override
public String getCustomAttribute(String name) {
if (fDeclaration == null) {
return null;
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfCustomAttributes.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfCustomAttributes.java
new file mode 100644
index 0000000..35b1d73
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/ITmfCustomAttributes.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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:
+ * Simon Delisle - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+import java.util.Set;
+
+/**
+ * Interface for events to implement to provide information about custom
+ * attributes.
+ *
+ * @author Simon Delisle
+ * @since 2.0
+ */
+public interface ITmfCustomAttributes {
+
+ /**
+ * List the custom attributes of this event.
+ *
+ * @return The list of custom attribute names. Should not be null, but could
+ * be empty.
+ */
+ public Set<String> listCustomAttributes();
+
+ /**
+ * Get the value of a custom attribute.
+ *
+ * @param name
+ * Name of the the custom attribute
+ * @return Value of this attribute, or null if there is no attribute with
+ * that name
+ */
+ public String getCustomAttribute(String name);
+} \ No newline at end of file
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 2ede1e1..539d10d 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
@@ -37,15 +37,18 @@ public class TmfEventPropertySource implements IPropertySource {
private static final String ID_CONTENT = "event_content"; //$NON-NLS-1$
private static final String ID_SOURCE_LOOKUP = "event_lookup"; //$NON-NLS-1$
private static final String ID_MODEL_URI = "model_uri"; //$NON-NLS-1$
+ private static final String ID_CUSTOM_ATTRIBUTE = "custom_attribute"; //$NON-NLS-1$
private static final String NAME_TIMESTAMP = "Timestamp"; //$NON-NLS-1$
private static final String NAME_SOURCE = "Source"; //$NON-NLS-1$
private static final String NAME_TYPE = "Type"; //$NON-NLS-1$
private static final String NAME_REFERENCE = "Reference"; //$NON-NLS-1$
private static final String NAME_CONTENT = "Content"; //$NON-NLS-1$
- private static final String NAME_SOURCE_LOOKUP = "Call Site"; //$NON-NLS-1$
+ private static final String NAME_SOURCE_LOOKUP = "Source Lookup"; //$NON-NLS-1$
private static final String NAME_MODEL_URI = "Model URI"; //$NON-NLS-1$
+ private static final String NAME_CUSTOM_ATTRIBUTES = "Custom Attributes"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private ITmfEvent fEvent;
@@ -214,6 +217,48 @@ public class TmfEventPropertySource implements IPropertySource {
}
}
+ private class CustomAttributePropertySource implements IPropertySource {
+
+ private final ITmfCustomAttributes event;
+
+ public CustomAttributePropertySource(ITmfCustomAttributes event) {
+ this.event = event;
+ }
+
+ @Override
+ public Object getEditableValue() {
+ return EMPTY_STRING;
+ }
+
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
+
+ for (String customAttribute : event.listCustomAttributes()) {
+ descriptors.add(new ReadOnlyTextPropertyDescriptor(customAttribute, customAttribute));
+ }
+
+ return descriptors.toArray(new IPropertyDescriptor[0]);
+ }
+
+ @Override
+ public Object getPropertyValue(Object id) {
+ return event.getCustomAttribute((String) id);
+ }
+
+ @Override
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ @Override
+ public void resetPropertyValue(Object id) {
+ }
+
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+ }
+ }
/**
* Default constructor
@@ -233,17 +278,34 @@ public class TmfEventPropertySource implements IPropertySource {
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
+
+ /* Display basic event information */
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP));
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE, NAME_SOURCE));
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_TYPE, NAME_TYPE));
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_REFERENCE, NAME_REFERENCE));
+
+ /* Display event fields */
+ descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CONTENT, NAME_CONTENT));
+
+ /* Display source lookup information, if the event supplies it */
if ((fEvent instanceof ITmfSourceLookup) && (((ITmfSourceLookup)fEvent).getCallsite() != null)) {
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
}
- if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup)fEvent).getModelUri() != null)) {
+
+ /* Display Model URI information, if the event supplies it */
+ if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup) fEvent).getModelUri() != null)) {
descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
}
- descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CONTENT, NAME_CONTENT));
+
+ /* Display custom attributes, if available */
+ if (fEvent instanceof ITmfCustomAttributes) {
+ ITmfCustomAttributes event = (ITmfCustomAttributes) fEvent;
+ if (event.listCustomAttributes() != null && !event.listCustomAttributes().isEmpty()) {
+ descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CUSTOM_ATTRIBUTE, NAME_CUSTOM_ATTRIBUTES));
+ }
+ }
+
return descriptors.toArray(new IPropertyDescriptor[0]);
}
@@ -263,6 +325,8 @@ public class TmfEventPropertySource implements IPropertySource {
return new SourceLookupPropertySource(((ITmfSourceLookup)fEvent));
} else if (id.equals(ID_CONTENT) && fEvent.getContent() != null) {
return new ContentPropertySource(fEvent.getContent());
+ } else if (id.equals(ID_CUSTOM_ATTRIBUTE)) {
+ return new CustomAttributePropertySource((ITmfCustomAttributes) fEvent);
}
return null;
}