Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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$
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,15 +42,18 @@ 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
*
* @param parentShell
* the parent shell
* @param initialValue
* the initial input value, or <code>null</code> if none (equivalent to the empty string)
* the initial input value, or <code>null</code> if none
* (equivalent to the empty string)
*/
public AddBookmarkDialog(Shell parentShell, String initialValue) {
super(parentShell, Messages.AddBookmarkDialog_Title, Messages.AddBookmarkDialog_Message, initialValue);
Expand All @@ -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);
Expand All @@ -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;
}

Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1680,6 +1681,7 @@ private static List<IMarkerEvent> 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()) {
Expand All @@ -1689,7 +1691,7 @@ private static List<IMarkerEvent> 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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading