diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/resources/ITmfMarker.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/resources/ITmfMarker.java index 7a38474f29..0573ae46b7 100644 --- a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/resources/ITmfMarker.java +++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/resources/ITmfMarker.java @@ -34,4 +34,9 @@ public interface ITmfMarker { /** Duration marker attribute. The format is the output of Long.toString(). */ String MARKER_DURATION = "duration"; //$NON-NLS-1$ + /** + * Duration marker attribute. The format is the output of Long.toString(). + * @since 10.2 + */ + String MARKER_FOREGROUND = "foreground"; //$NON-NLS-1$ } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java index 75ee73d61a..7c4664ad48 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java @@ -23,6 +23,8 @@ public class Messages extends NLS { public static String AddBookmarkDialog_Alpha; public static String AddBookmarkDialog_Color; + + public static String AddBookmarkDialog_Foreground; public static String AddBookmarkDialog_Message; public static String AddBookmarkDialog_Title; diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/AddBookmarkDialog.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/AddBookmarkDialog.java index d46537a3cc..8c636826ac 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/AddBookmarkDialog.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/AddBookmarkDialog.java @@ -14,13 +14,17 @@ package org.eclipse.tracecompass.internal.tmf.ui.dialogs; + +import org.eclipse.jface.layout.GridDataFactory; import org.eclipse.jface.preference.ColorSelector; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGBA; -import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; @@ -38,7 +42,9 @@ public class AddBookmarkDialog extends MultiLineInputDialog { private ColorSelector fColorSelector; private Scale fAlphaScale; private Label fAlphaLabel; - private int fAlpha = 128; + private Button fForgroundButton; + private int fAlpha = 32; + private boolean fForeground; /** * Constructor @@ -46,7 +52,8 @@ public class AddBookmarkDialog extends MultiLineInputDialog { * @param parentShell * the parent shell * @param initialValue - * the initial input value, or null if none (equivalent to the empty string) + * the initial input value, or null if none + * (equivalent to the empty string) */ public AddBookmarkDialog(Shell parentShell, String initialValue) { super(parentShell, Messages.AddBookmarkDialog_Title, Messages.AddBookmarkDialog_Message, initialValue); @@ -56,17 +63,26 @@ public AddBookmarkDialog(Shell parentShell, String initialValue) { protected Control createDialogArea(Composite parent) { Composite areaComposite = (Composite) super.createDialogArea(parent); Composite colorComposite = new Composite(areaComposite, SWT.NONE); - RowLayout layout = new RowLayout(); - layout.center = true; + colorComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); + GridLayout layout = new GridLayout(1, false); colorComposite.setLayout(layout); colorComposite.moveBelow(getText()); - Label colorLabel = new Label(colorComposite, SWT.NONE); + + Composite colorPicker = new Composite(colorComposite, SWT.NONE); + colorPicker.setLayout(new GridLayout(2, false)); + Label colorLabel = new Label(colorPicker, SWT.NONE); colorLabel.setText(Messages.AddBookmarkDialog_Color); - fColorSelector = new ColorSelector(colorComposite); + fColorSelector = new ColorSelector(colorPicker); fColorSelector.setColorValue(new RGB(255, 0, 0)); - Label alphaLabel = new Label(colorComposite, SWT.NONE); + + Composite alphaComposite = new Composite(colorComposite, SWT.NONE); + alphaComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // Ensure it expands + alphaComposite.setLayout(new GridLayout(3, false)); + + Label alphaLabel = new Label(alphaComposite, SWT.NONE); alphaLabel.setText(Messages.AddBookmarkDialog_Alpha); - fAlphaScale = new Scale(colorComposite, SWT.NONE); + + fAlphaScale = new Scale(alphaComposite, SWT.NONE); fAlphaScale.setMaximum(255); fAlphaScale.setSelection(fAlpha); fAlphaScale.setIncrement(1); @@ -78,8 +94,27 @@ public void widgetSelected(SelectionEvent e) { fAlphaLabel.setText(Integer.toString(fAlpha)); } }); - fAlphaLabel = new Label(colorComposite, SWT.NONE); + + // Make the scale take all available horizontal space + fAlphaScale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + + fAlphaLabel = new Label(alphaComposite, SWT.NONE); fAlphaLabel.setText(Integer.toString(fAlpha)); + + Composite fgComposite = new Composite(colorComposite, SWT.NONE); + fgComposite.setLayout(new GridLayout(2, false)); + fForgroundButton = new Button(fgComposite, SWT.CHECK); + fForgroundButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fForeground = fForgroundButton.getSelection(); + super.widgetSelected(e); + } + }); + fForeground = true; + fForgroundButton.setSelection(fForeground); + new Label(fgComposite, SWT.NONE).setText(Messages.AddBookmarkDialog_Foreground); + return areaComposite; } @@ -92,4 +127,13 @@ public RGBA getColorValue() { RGB rgb = fColorSelector.getColorValue(); return new RGBA(rgb.red, rgb.green, rgb.blue, fAlpha); } + + /** + * Returns if the marker is in the foreground. + * + * @return true if foreground + */ + public boolean getForeground() { + return fForeground; + } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties index 7fa3f54518..29699bd42b 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties @@ -15,6 +15,7 @@ # org.eclipse.tracecompass.tmf.ui.dialogs AddBookmarkDialog_Alpha=alpha: AddBookmarkDialog_Color=Color: +AddBookmarkDialog_Foreground=Foreground AddBookmarkDialog_Message=Bookmark Description: AddBookmarkDialog_Title=Add Bookmark ManageCustomParsersDialog_ConflictMessage=Trace type ''{0} : {1}'' already exists.\nDo you want to rename to ''{2}'' or skip? diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java index c924ad49d7..4ae1466d10 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java @@ -1463,6 +1463,7 @@ public void run(IProgressMonitor monitor) throws CoreException { TmfTimestamp.fromNanos(bookmark.getTime()))); } marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString()); + marker.setAttribute(ITmfMarker.MARKER_FOREGROUND, bookmark.isForeground()); } }, null); } catch (CoreException e) { @@ -1680,6 +1681,7 @@ private static List refreshBookmarks(final IFile editorFile) { String time = marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null); String duration = marker.getAttribute(ITmfMarker.MARKER_DURATION, Long.toString(0)); String rgba = marker.getAttribute(ITmfMarker.MARKER_COLOR, (String) null); + boolean fg = marker.getAttribute(ITmfMarker.MARKER_FOREGROUND, Boolean.TRUE); if (label != null && time != null && rgba != null) { Matcher matcher = RGBA_PATTERN.matcher(rgba); if (matcher.matches()) { @@ -1689,7 +1691,7 @@ private static List refreshBookmarks(final IFile editorFile) { int blue = Integer.valueOf(matcher.group(3)); int alpha = Integer.valueOf(matcher.group(4)); RGBA color = new RGBA(red, green, blue, alpha); - bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARKS, color, label, true)); + bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARKS, color, label, fg)); } catch (NumberFormatException e) { Activator.getDefault().logError(e.getMessage()); } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java index dd42509c46..4db41c5e6d 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java @@ -2498,7 +2498,8 @@ public void runWithEvent(Event event) { if (dialog.open() == Window.OK) { final String label = dialog.getValue(); final RGBA rgba = dialog.getColorValue(); - IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, true); + final boolean foreground = dialog.getForeground(); + IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, foreground); fBookmarks.add(bookmark); updateMarkerList(); updateMarkerActions();