X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Fevent%2FTmfEventPropertySource.java;h=539d10d8360e0ef49459ad2f580b17df91b75cac;hb=1a98a65c23797ccb9fac74c0cc1f5b547e902df1;hp=2ede1e1aae6be84c0b599faa39891e4a4e08b75f;hpb=0505c6fc6182f16853eadf2d3ce72e3c9de5c740;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java index 2ede1e1aae..539d10d836 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java +++ b/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 descriptors = new ArrayList(); + + 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 descriptors= new ArrayList(); + + /* 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; }