tmf: Remove function name from ITmfCallsite
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / viewers / events / TmfEventPropertySource.java
index 2e88c5a80c64dd007fa6f04a16e9baac66beeb92..ef02db0252029900e5532a64fb690c2e1868df8a 100644 (file)
@@ -13,6 +13,8 @@
 
 package org.eclipse.tracecompass.tmf.ui.viewers.events;
 
+import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -52,7 +54,7 @@ public class TmfEventPropertySource implements IPropertySource {
 
     private ITmfEvent fEvent;
 
-    private class TimestampPropertySource implements IPropertySource {
+    private static class TimestampPropertySource implements IPropertySource {
         private static final String ID_TIMESTAMP_VALUE = "timestamp_value"; //$NON-NLS-1$
         private static final String ID_TIMESTAMP_SCALE = "timestamp_scale"; //$NON-NLS-1$
         private static final String NAME_TIMESTAMP_VALUE = "value"; //$NON-NLS-1$
@@ -101,7 +103,7 @@ public class TmfEventPropertySource implements IPropertySource {
         }
     }
 
-    private class ContentPropertySource implements IPropertySource {
+    private static class ContentPropertySource implements IPropertySource {
         private ITmfEventField fContent;
 
         public ContentPropertySource(ITmfEventField content) {
@@ -147,14 +149,12 @@ public class TmfEventPropertySource implements IPropertySource {
         }
     }
 
-    private class SourceLookupPropertySource implements IPropertySource {
+    private static class SourceLookupPropertySource implements IPropertySource {
 
         private static final String ID_FILE_NAME = "callsite_file"; //$NON-NLS-1$
-        private static final String ID_FUNCTION_NAME = "callsite_function"; //$NON-NLS-1$
         private static final String ID_LINE_NUMBER = "callsite_line"; //$NON-NLS-1$
 
         private static final String NAME_FILE_NAME = "File"; //$NON-NLS-1$
-        private static final String NAME_FUNCTION_NAME = "Function"; //$NON-NLS-1$
         private static final String NAME_LINE_NUMBER = "Line"; //$NON-NLS-1$
 
         private final ITmfSourceLookup fSourceLookup;
@@ -179,16 +179,12 @@ public class TmfEventPropertySource implements IPropertySource {
             if (cs != null) {
                 descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FILE_NAME, NAME_FILE_NAME));
                 descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_LINE_NUMBER, NAME_LINE_NUMBER));
-                // only display function if available
-                if (cs.getFunctionName() != null) {
-                    descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
-                }
             }
             return descriptors.toArray(new IPropertyDescriptor[0]);
         }
 
         @Override
-        public Object getPropertyValue(Object id) {
+        public String getPropertyValue(Object id) {
             ITmfCallsite cs = fSourceLookup.getCallsite();
             if (cs == null) {
                 /*
@@ -205,10 +201,8 @@ public class TmfEventPropertySource implements IPropertySource {
             switch ((String) id) {
             case ID_FILE_NAME:
                 return cs.getFileName();
-            case ID_FUNCTION_NAME:
-                return cs.getFunctionName();
             case ID_LINE_NUMBER:
-                return Long.valueOf(cs.getLineNumber());
+                return nullToEmptyString(cs.getLineNo());
             default:
                 return null;
             }
@@ -255,6 +249,9 @@ public class TmfEventPropertySource implements IPropertySource {
 
         @Override
         public Object getPropertyValue(Object id) {
+            if (!(id instanceof String)) {
+                return null;
+            }
             return event.getCustomAttribute((String) id);
         }
 
@@ -312,7 +309,7 @@ public class TmfEventPropertySource implements IPropertySource {
         /* Display custom attributes, if available */
         if (fEvent instanceof ITmfCustomAttributes) {
             ITmfCustomAttributes event = (ITmfCustomAttributes) fEvent;
-            if (event.listCustomAttributes() != null && !event.listCustomAttributes().isEmpty()) {
+            if (!event.listCustomAttributes().isEmpty()) {
                 descriptors.add(new ReadOnlyTextPropertyDescriptor(ID_CUSTOM_ATTRIBUTE, NAME_CUSTOM_ATTRIBUTES));
             }
         }
This page took 0.027108 seconds and 5 git commands to generate.