Fix for bug 380961: Filter viewer not getting fields for CTF traces
authorPatrick Tasse <patrick.tasse@gmail.com>
Tue, 29 May 2012 20:42:08 +0000 (16:42 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 29 May 2012 21:15:31 +0000 (17:15 -0400)
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java

index e70aa882b72d8383d688fb85ad964cc08737c261..e36752842729d6266763dbb96ed5a96da0e45608 100644 (file)
@@ -237,6 +237,8 @@ public class Messages extends NLS {
     public static String FilterView_FileDialogFilterName;\r
     public static String FilterView_ImportActionToolTipText;\r
     public static String FilterView_SaveActionToolTipText;\r
+    public static String FilterViewer_EmptyTreeHintText;\r
+    public static String FilterViewer_CommonCategory;\r
     public static String FilterViewer_AlphaButtonText;\r
     public static String FilterViewer_DeleteActionText;\r
     public static String FilterViewer_FieldLabel;\r
index 525db6224333680a8e3779a5e1d5431d9ca3f053..20e0417031132577706f727b2e1f764417e4e7ad 100644 (file)
@@ -240,6 +240,8 @@ FilterView_ExportActionToolTipText=Export filters
 FilterView_FileDialogFilterName=TMF Filter files\r
 FilterView_ImportActionToolTipText=Import filters\r
 FilterView_SaveActionToolTipText=Save filters\r
+FilterViewer_EmptyTreeHintText=<Right-click to add filter node>\r
+FilterViewer_EmptyTreeHintText=[common]\r
 FilterViewer_AlphaButtonText=Alpha\r
 FilterViewer_DeleteActionText=Delete\r
 FilterViewer_FieldLabel=field:\r
index c611080d1dda8d2a9da089ff34b1b4931783190e..7fb527de7d79214be80c7394b49ef38ffbcc7979 100644 (file)
@@ -49,6 +49,7 @@ import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;\r
 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;\r
 import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;\r
+import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;\r
 import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.SashForm;\r
@@ -56,6 +57,8 @@ import org.eclipse.swt.events.FocusEvent;
 import org.eclipse.swt.events.FocusListener;\r
 import org.eclipse.swt.events.ModifyEvent;\r
 import org.eclipse.swt.events.ModifyListener;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.PaintListener;\r
 import org.eclipse.swt.events.SelectionAdapter;\r
 import org.eclipse.swt.events.SelectionEvent;\r
 import org.eclipse.swt.layout.FillLayout;\r
@@ -118,6 +121,17 @@ class FilterViewer extends Composite {
                 }\r
             }\r
         });\r
+\r
+        fViewer.getTree().addPaintListener(new PaintListener() {\r
+            @Override\r
+            public void paintControl(PaintEvent e) {\r
+                TmfFilterTreeNode root = (TmfFilterTreeNode) fViewer.getInput();\r
+                if (root == null || root.getChildrenCount() == 0) {\r
+                    e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));\r
+                    e.gc.drawText(Messages.FilterViewer_EmptyTreeHintText, 5, 0);\r
+                }\r
+            }\r
+        });\r
     }\r
     \r
     /**\r
@@ -347,10 +361,17 @@ class FilterViewer extends Composite {
                                 }\r
                             } catch (CoreException e) {\r
                             }\r
+                            if (fieldsList.size() == 0) {\r
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);\r
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);\r
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);\r
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);\r
+                                fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);\r
+                            }\r
                             return fieldsList.toArray(new String[0]);\r
                         }\r
                     }\r
-                    if (eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) {\r
+                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomTxtEvent.class.getCanonicalName())) {\r
                         for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
                             if (eventTypeNode.getEventType().equals(CustomTxtEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r
                                 for (OutputColumn output : def.outputs) {\r
@@ -360,7 +381,7 @@ class FilterViewer extends Composite {
                             }\r
                         }\r
                     }\r
-                    if (eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) {\r
+                    if (eventTypeNode.getEventType() != null && eventTypeNode.getEventType().startsWith(CustomXmlEvent.class.getCanonicalName())) {\r
                         for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
                             if (eventTypeNode.getEventType().equals(CustomXmlEvent.class.getCanonicalName() + ":" + def.definitionName)) { //$NON-NLS-1$\r
                                 for (OutputColumn output : def.outputs) {\r
@@ -373,11 +394,20 @@ class FilterViewer extends Composite {
                 }\r
                 node = node.getParent();\r
             }\r
+\r
+            fieldsList.add(Messages.FilterViewer_CommonCategory);\r
+            fieldsList.add(ITmfEvent.EVENT_FIELD_TIMESTAMP);\r
+            fieldsList.add(ITmfEvent.EVENT_FIELD_SOURCE);\r
+            fieldsList.add(ITmfEvent.EVENT_FIELD_TYPE);\r
+            fieldsList.add(ITmfEvent.EVENT_FIELD_REFERENCE);\r
+            fieldsList.add(ITmfEvent.EVENT_FIELD_CONTENT);\r
+            fieldsList.add(""); //$NON-NLS-1$\r
+\r
             for (IConfigurationElement ce : TmfTraceType.getTypeElements()) {\r
                 try {\r
                     ITmfEvent event = (ITmfEvent) ce.createExecutableExtension(TmfTraceType.EVENT_TYPE_ATTR);\r
                     ITmfEventType eventType = event.getType();\r
-                    if (eventType != null) {\r
+                    if (eventType != null && eventType.getFieldNames().length > 0) {\r
                         fieldsList.add("[" + TmfTraceType.getCategoryName(ce.getAttribute(TmfTraceType.CATEGORY_ATTR)) + //$NON-NLS-1$\r
                                 " : " + ce.getAttribute(TmfTraceType.NAME_ATTR) + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
                         for (String field : eventType.getFieldNames()) {\r
@@ -389,20 +419,24 @@ class FilterViewer extends Composite {
                 }\r
             }\r
             for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {\r
-                fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$\r
-                        " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
-                for (OutputColumn output : def.outputs) {\r
-                    fieldsList.add(output.name);\r
+                if (def.outputs.size() > 0) {\r
+                    fieldsList.add("[" + CUSTOM_TXT_CATEGORY + //$NON-NLS-1$\r
+                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
+                    for (OutputColumn output : def.outputs) {\r
+                        fieldsList.add(output.name);\r
+                    }\r
+                    fieldsList.add(""); //$NON-NLS-1$\r
                 }\r
-                fieldsList.add(""); //$NON-NLS-1$\r
             }\r
             for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$\r
-                        " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
-                for (OutputColumn output : def.outputs) {\r
-                    fieldsList.add(output.name);\r
+                if (def.outputs.size() > 0) {\r
+                    fieldsList.add("[" + CUSTOM_XML_CATEGORY + //$NON-NLS-1$\r
+                            " : " + def.definitionName + "]"); //$NON-NLS-1$ //$NON-NLS-2$\r
+                    for (OutputColumn output : def.outputs) {\r
+                        fieldsList.add(output.name);\r
+                    }\r
+                    fieldsList.add(""); //$NON-NLS-1$\r
                 }\r
-                fieldsList.add(""); //$NON-NLS-1$\r
             }\r
             return fieldsList.toArray(new String[0]);\r
         }\r
This page took 0.049107 seconds and 5 git commands to generate.