Skip to content

Commit 5276201

Browse files
tmf.ui: Add the option for markers to be in the background
Addresses bug 211 [Added] Ability to have background markers Change-Id: Ie681f5577b5e9abdb8ebeb75c456f860625af1cb Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
1 parent 122b3ea commit 5276201

File tree

6 files changed

+63
-11
lines changed

6 files changed

+63
-11
lines changed

tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/resources/ITmfMarker.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ public interface ITmfMarker {
3434
/** Duration marker attribute. The format is the output of Long.toString(). */
3535
String MARKER_DURATION = "duration"; //$NON-NLS-1$
3636

37+
/** Duration marker attribute. The format is the output of Long.toString(). */
38+
String MARKER_FOREGROUND = "foreground"; //$NON-NLS-1$
3739
}

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/Messages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class Messages extends NLS {
2323

2424
public static String AddBookmarkDialog_Alpha;
2525
public static String AddBookmarkDialog_Color;
26+
27+
public static String AddBookmarkDialog_Foreground;
2628
public static String AddBookmarkDialog_Message;
2729
public static String AddBookmarkDialog_Title;
2830

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/dialogs/AddBookmarkDialog.java

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414

1515
package org.eclipse.tracecompass.internal.tmf.ui.dialogs;
1616

17+
18+
import org.eclipse.jface.layout.GridDataFactory;
1719
import org.eclipse.jface.preference.ColorSelector;
1820
import org.eclipse.swt.SWT;
1921
import org.eclipse.swt.events.SelectionAdapter;
2022
import org.eclipse.swt.events.SelectionEvent;
2123
import org.eclipse.swt.graphics.RGB;
2224
import org.eclipse.swt.graphics.RGBA;
23-
import org.eclipse.swt.layout.RowLayout;
25+
import org.eclipse.swt.layout.GridData;
26+
import org.eclipse.swt.layout.GridLayout;
27+
import org.eclipse.swt.widgets.Button;
2428
import org.eclipse.swt.widgets.Composite;
2529
import org.eclipse.swt.widgets.Control;
2630
import org.eclipse.swt.widgets.Label;
@@ -38,15 +42,18 @@ public class AddBookmarkDialog extends MultiLineInputDialog {
3842
private ColorSelector fColorSelector;
3943
private Scale fAlphaScale;
4044
private Label fAlphaLabel;
45+
private Button fForgroundButton;
4146
private int fAlpha = 128;
47+
private boolean fForeground;
4248

4349
/**
4450
* Constructor
4551
*
4652
* @param parentShell
4753
* the parent shell
4854
* @param initialValue
49-
* the initial input value, or <code>null</code> if none (equivalent to the empty string)
55+
* the initial input value, or <code>null</code> if none
56+
* (equivalent to the empty string)
5057
*/
5158
public AddBookmarkDialog(Shell parentShell, String initialValue) {
5259
super(parentShell, Messages.AddBookmarkDialog_Title, Messages.AddBookmarkDialog_Message, initialValue);
@@ -56,17 +63,26 @@ public AddBookmarkDialog(Shell parentShell, String initialValue) {
5663
protected Control createDialogArea(Composite parent) {
5764
Composite areaComposite = (Composite) super.createDialogArea(parent);
5865
Composite colorComposite = new Composite(areaComposite, SWT.NONE);
59-
RowLayout layout = new RowLayout();
60-
layout.center = true;
66+
colorComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
67+
GridLayout layout = new GridLayout(1, false);
6168
colorComposite.setLayout(layout);
6269
colorComposite.moveBelow(getText());
63-
Label colorLabel = new Label(colorComposite, SWT.NONE);
70+
71+
Composite colorPicker = new Composite(colorComposite, SWT.NONE);
72+
colorPicker.setLayout(new GridLayout(2, false));
73+
Label colorLabel = new Label(colorPicker, SWT.NONE);
6474
colorLabel.setText(Messages.AddBookmarkDialog_Color);
65-
fColorSelector = new ColorSelector(colorComposite);
75+
fColorSelector = new ColorSelector(colorPicker);
6676
fColorSelector.setColorValue(new RGB(255, 0, 0));
67-
Label alphaLabel = new Label(colorComposite, SWT.NONE);
77+
78+
Composite alphaComposite = new Composite(colorComposite, SWT.NONE);
79+
alphaComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // Ensure it expands
80+
alphaComposite.setLayout(new GridLayout(3, false));
81+
82+
Label alphaLabel = new Label(alphaComposite, SWT.NONE);
6883
alphaLabel.setText(Messages.AddBookmarkDialog_Alpha);
69-
fAlphaScale = new Scale(colorComposite, SWT.NONE);
84+
85+
fAlphaScale = new Scale(alphaComposite, SWT.NONE);
7086
fAlphaScale.setMaximum(255);
7187
fAlphaScale.setSelection(fAlpha);
7288
fAlphaScale.setIncrement(1);
@@ -78,8 +94,27 @@ public void widgetSelected(SelectionEvent e) {
7894
fAlphaLabel.setText(Integer.toString(fAlpha));
7995
}
8096
});
81-
fAlphaLabel = new Label(colorComposite, SWT.NONE);
97+
98+
// Make the scale take all available horizontal space
99+
fAlphaScale.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
100+
101+
fAlphaLabel = new Label(alphaComposite, SWT.NONE);
82102
fAlphaLabel.setText(Integer.toString(fAlpha));
103+
104+
Composite fgComposite = new Composite(colorComposite, SWT.NONE);
105+
fgComposite.setLayout(new GridLayout(2, false));
106+
fForgroundButton = new Button(fgComposite, SWT.CHECK);
107+
fForgroundButton.addSelectionListener(new SelectionAdapter() {
108+
@Override
109+
public void widgetSelected(SelectionEvent e) {
110+
fForeground = fForgroundButton.getSelection();
111+
super.widgetSelected(e);
112+
}
113+
});
114+
fForeground = true;
115+
fForgroundButton.setSelection(fForeground);
116+
new Label(fgComposite, SWT.NONE).setText(Messages.AddBookmarkDialog_Foreground);
117+
83118
return areaComposite;
84119
}
85120

@@ -92,4 +127,13 @@ public RGBA getColorValue() {
92127
RGB rgb = fColorSelector.getColorValue();
93128
return new RGBA(rgb.red, rgb.green, rgb.blue, fAlpha);
94129
}
130+
131+
/**
132+
* Returns if the marker is in the foreground.
133+
*
134+
* @return true if foreground
135+
*/
136+
public boolean getForeground() {
137+
return fForeground;
138+
}
95139
}

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/internal/tmf/ui/messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# org.eclipse.tracecompass.tmf.ui.dialogs
1616
AddBookmarkDialog_Alpha=alpha:
1717
AddBookmarkDialog_Color=Color:
18+
AddBookmarkDialog_Foreground=Foreground
1819
AddBookmarkDialog_Message=Bookmark Description:
1920
AddBookmarkDialog_Title=Add Bookmark
2021
ManageCustomParsersDialog_ConflictMessage=Trace type ''{0} : {1}'' already exists.\nDo you want to rename to ''{2}'' or skip?

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ public void run(IProgressMonitor monitor) throws CoreException {
14621462
TmfTimestamp.fromNanos(bookmark.getTime())));
14631463
}
14641464
marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString());
1465+
marker.setAttribute(ITmfMarker.MARKER_FOREGROUND, bookmark.isForeground());
14651466
}
14661467
}, null);
14671468
} catch (CoreException e) {
@@ -1679,6 +1680,7 @@ private static List<IMarkerEvent> refreshBookmarks(final IFile editorFile) {
16791680
String time = marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null);
16801681
String duration = marker.getAttribute(ITmfMarker.MARKER_DURATION, Long.toString(0));
16811682
String rgba = marker.getAttribute(ITmfMarker.MARKER_COLOR, (String) null);
1683+
boolean fg = marker.getAttribute(ITmfMarker.MARKER_FOREGROUND, Boolean.TRUE);
16821684
if (label != null && time != null && rgba != null) {
16831685
Matcher matcher = RGBA_PATTERN.matcher(rgba);
16841686
if (matcher.matches()) {
@@ -1688,7 +1690,7 @@ private static List<IMarkerEvent> refreshBookmarks(final IFile editorFile) {
16881690
int blue = Integer.valueOf(matcher.group(3));
16891691
int alpha = Integer.valueOf(matcher.group(4));
16901692
RGBA color = new RGBA(red, green, blue, alpha);
1691-
bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARKS, color, label, true));
1693+
bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARKS, color, label, fg));
16921694
} catch (NumberFormatException e) {
16931695
Activator.getDefault().logError(e.getMessage());
16941696
}

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphViewer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2498,7 +2498,8 @@ public void runWithEvent(Event event) {
24982498
if (dialog.open() == Window.OK) {
24992499
final String label = dialog.getValue();
25002500
final RGBA rgba = dialog.getColorValue();
2501-
IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, true);
2501+
final boolean foreground = dialog.getForeground();
2502+
IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, foreground);
25022503
fBookmarks.add(bookmark);
25032504
updateMarkerList();
25042505
updateMarkerActions();

0 commit comments

Comments
 (0)