tmf: Add color preference for event table search and filter highlight
authorPatrick Tasse <patrick.tasse@gmail.com>
Thu, 2 Apr 2015 20:42:56 +0000 (16:42 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 7 Apr 2015 22:54:59 +0000 (18:54 -0400)
The color settings can be changed in Window > Preferences > General >
Appearance > Colors and Fonts > Tracing.

Change-Id: I3bda3530657797cf434e86a7e6055a64066a4e51
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/45177
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.tracecompass.tmf.ui/plugin.properties
org.eclipse.tracecompass.tmf.ui/plugin.xml
org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java

index ca5c17718a848add7304e0ebf5a3ec12df96d3b3..1c9ceb05625eac3b30260d777d66c13887a58e53 100644 (file)
@@ -36,6 +36,7 @@ synchronization.view.name = Synchronization
 themes.category.label = Tracing
 font.eventtable.label = Trace event table font
 font.eventraw.label = Trace event raw text font
+color.eventtable.highlight.label = Trace event table highlight color
 
 # Tracing wizards
 project.new.category.name = Tracing
index da23aa24b2fb378a1965710430ba76a808faab2b..28c1874427e3f6bccaba8633519b966ed2317c67 100644 (file)
             isEditable="true"
             label="%font.eventraw.label">
       </fontDefinition>
+      <colorDefinition
+            categoryId="org.eclipse.tracecompass.tmf.ui.theme.category"
+            id="org.eclipse.tracecompass.tmf.ui.color.eventtable.highlight"
+            isEditable="true"
+            label="%color.eventtable.highlight.label"
+            value="COLOR_YELLOW">
+      </colorDefinition>
    </extension>
 </plugin>
index 58152c093c1a2a61a29080c00a6fe54ef5b2c90f..ee22141b84ab0ef877c906bf62bf7eab2f522f3b 100644 (file)
@@ -62,6 +62,7 @@ import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.dialogs.InputDialog;
 import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ColorRegistry;
 import org.eclipse.jface.resource.FontRegistry;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.resource.LocalResourceManager;
@@ -136,8 +137,8 @@ import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
 import org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfEventSearchAppliedSignal;
 import org.eclipse.tracecompass.tmf.core.signal.TmfEventSelectedSignal;
-import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal;
+import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceUpdatedSignal;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
@@ -193,6 +194,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     private static final boolean IS_LINUX = System.getProperty("os.name").contains("Linux") ? true : false; //$NON-NLS-1$ //$NON-NLS-2$
 
     private static final String FONT_DEFINITION_ID = "org.eclipse.tracecompass.tmf.ui.font.eventtable"; //$NON-NLS-1$
+    private static final String HIGHLIGHT_COLOR_DEFINITION_ID = "org.eclipse.tracecompass.tmf.ui.color.eventtable.highlight"; //$NON-NLS-1$
 
     private static final Image BOOKMARK_IMAGE = Activator.getDefault().getImageFromPath(
             "icons/elcl16/bookmark_obj.gif"); //$NON-NLS-1$
@@ -309,6 +311,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
     private LocalResourceManager fResourceManager = new LocalResourceManager(JFaceResources.getResources());
     private Color fGrayColor;
     private Color fGreenColor;
+    private Color fHighlightColor;
     private Font fFont;
     private Font fBoldFont;
 
@@ -745,6 +748,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         createResources();
 
         initializeFonts();
+        initializeColors();
         PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(this);
 
         ColorSettingsManager.addColorSettingsListener(this);
@@ -1331,7 +1335,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                         int start = matcher.start();
                         int length = matcher.end() - start;
                         Color foreground = colorSetting.getForegroundColor();
-                        Color background = item.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
+                        Color background = fHighlightColor;
                         StyleRange styleRange = new StyleRange(start, length, foreground, background);
                         styleRange.data = index;
                         styleRanges.add(styleRange);
@@ -2133,6 +2137,15 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         /* Column header font cannot be set. See Bug 63038 */
     }
 
+    /**
+     * Initialize the colors.
+     * @since 1.0
+     */
+    protected void initializeColors() {
+        ColorRegistry colorRegistry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
+        fHighlightColor = colorRegistry.get(HIGHLIGHT_COLOR_DEFINITION_ID);
+    }
+
     /**
      * @since 1.0
      */
@@ -2143,6 +2156,11 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
             initializeFonts();
             fTable.refresh();
         }
+        if ((IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty())) ||
+                (HIGHLIGHT_COLOR_DEFINITION_ID.equals(event.getProperty()))) {
+            initializeColors();
+            fTable.refresh();
+        }
     }
 
     /**
This page took 0.031081 seconds and 5 git commands to generate.