From bb7c657f3d2b182c4130e583341fc9504f144172 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Thu, 2 Apr 2015 16:42:56 -0400 Subject: [PATCH] tmf: Add color preference for event table search and filter highlight The color settings can be changed in Window > Preferences > General > Appearance > Colors and Fonts > Tracing. Change-Id: I3bda3530657797cf434e86a7e6055a64066a4e51 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/45177 Reviewed-by: Hudson CI Reviewed-by: Matthew Khouzam Tested-by: Matthew Khouzam --- .../plugin.properties | 1 + org.eclipse.tracecompass.tmf.ui/plugin.xml | 7 ++++++ .../tmf/ui/viewers/events/TmfEventsTable.java | 22 +++++++++++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/org.eclipse.tracecompass.tmf.ui/plugin.properties b/org.eclipse.tracecompass.tmf.ui/plugin.properties index ca5c17718a..1c9ceb0562 100644 --- a/org.eclipse.tracecompass.tmf.ui/plugin.properties +++ b/org.eclipse.tracecompass.tmf.ui/plugin.properties @@ -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 diff --git a/org.eclipse.tracecompass.tmf.ui/plugin.xml b/org.eclipse.tracecompass.tmf.ui/plugin.xml index da23aa24b2..28c1874427 100644 --- a/org.eclipse.tracecompass.tmf.ui/plugin.xml +++ b/org.eclipse.tracecompass.tmf.ui/plugin.xml @@ -1851,5 +1851,12 @@ isEditable="true" label="%font.eventraw.label"> + + diff --git a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java index 58152c093c..ee22141b84 100644 --- a/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java +++ b/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/events/TmfEventsTable.java @@ -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(); + } } /** -- 2.34.1