Skip to content

Commit 6b5cb85

Browse files
tmf.ui: Instrument Histogram
Add two flow scope logs and one scope log. Change-Id: I1b59629da5f7f417880d8f35694fb296eaaddc62 Signed-off-by: Matthew Khouzam <[email protected]>
1 parent 0a0b76d commit 6b5cb85

File tree

1 file changed

+32
-18
lines changed
  • tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram

1 file changed

+32
-18
lines changed

tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/histogram/Histogram.java

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
package org.eclipse.tracecompass.tmf.ui.views.histogram;
2020

21+
import java.util.logging.Level;
22+
import java.util.logging.Logger;
23+
2124
import org.eclipse.jdt.annotation.NonNull;
2225
import org.eclipse.jface.action.IStatusLineManager;
2326
import org.eclipse.jface.layout.GridDataFactory;
@@ -48,6 +51,9 @@
4851
import org.eclipse.swt.widgets.Control;
4952
import org.eclipse.swt.widgets.Display;
5053
import org.eclipse.swt.widgets.Label;
54+
import org.eclipse.tracecompass.common.core.log.TraceCompassLog;
55+
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils;
56+
import org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog;
5157
import org.eclipse.tracecompass.internal.tmf.ui.views.histogram.HistogramTimeAdapter;
5258
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
5359
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
@@ -110,6 +116,7 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
110116
// ------------------------------------------------------------------------
111117

112118
private static final int TIME_SCALE_HEIGHT = 27;
119+
private static final Logger LOGGER = TraceCompassLog.getLogger(Histogram.class);
113120

114121
// Histogram colors
115122

@@ -250,7 +257,6 @@ public abstract class Histogram implements ControlListener, PaintListener, KeyLi
250257
*/
251258
static boolean showTraces = true;
252259

253-
254260
private boolean fSendTimeAlignSignals = false;
255261

256262
private IStatusLineManager fStatusLineManager;
@@ -655,17 +661,25 @@ protected void moveCursor(final int keyCode) {
655661
*/
656662
@Override
657663
public void modelUpdated() {
658-
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
659-
fCanvas.getDisplay().asyncExec(() -> {
660-
if (!fCanvas.isDisposed()) {
661-
// Retrieve and normalize the data
662-
final int canvasWidth = fCanvas.getBounds().width;
663-
final int canvasHeight = fCanvas.getBounds().height;
664-
if (canvasWidth <= 0 || canvasHeight <= 0) {
665-
return;
664+
try (TraceCompassLogUtils.FlowScopeLog fs = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ModelUpdated").setCategory("Histogram").build()) { //$NON-NLS-1$ //$NON-NLS-2$
665+
if (!fCanvas.isDisposed() && fCanvas.getDisplay() != null) {
666+
fCanvas.getDisplay().asyncExec(() -> {
667+
int canvasWidth = -1;
668+
int canvasHeight = -1;
669+
try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:getbounds").setParentScope(fs).build()) { //$NON-NLS-1$
670+
if (!fCanvas.isDisposed()) {
671+
// Retrieve and normalize the data
672+
canvasWidth = fCanvas.getBounds().width;
673+
canvasHeight = fCanvas.getBounds().height;
666674
}
667-
fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
668-
fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
675+
}
676+
677+
if (canvasHeight <= 0 || canvasWidth <= 0) {
678+
return;
679+
}
680+
fDataModel.setSelection(fSelectionBegin, fSelectionEnd);
681+
fScaledData = fDataModel.scaleTo(canvasWidth, canvasHeight, 1);
682+
try (TraceCompassLogUtils.FlowScopeLog fs1 = new TraceCompassLogUtils.FlowScopeLogBuilder(LOGGER, Level.FINER, "Histogram:ui").setParentScope(fs).build()) { //$NON-NLS-1$
669683
synchronized (fDataModel) {
670684
if (fScaledData != null) {
671685
fCanvas.redraw();
@@ -679,16 +693,16 @@ public void modelUpdated() {
679693
GridData gd = (GridData) fMaxNbEventsLabel.getLayoutData();
680694
gd.widthHint = Math.max(gd.widthHint, fMaxNbEventsLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT).x);
681695
fMaxNbEventsLabel.getParent().layout();
682-
if (old.length() < fMaxNbEventsLabel.getText().length()) {
683-
if ((fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
684-
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
685-
}
696+
if (old.length() < fMaxNbEventsLabel.getText().length() && (fSendTimeAlignSignals) && (fParentView instanceof ITmfTimeAligned)) {
697+
TmfSignalManager.dispatchSignal(new TmfTimeViewAlignmentSignal(this, ((ITmfTimeAligned) fParentView).getTimeViewAlignmentInfo(), true));
686698
}
699+
687700
}
688701
fTimeLineScale.redraw();
689702
}
690-
}
691-
});
703+
}
704+
});
705+
}
692706
}
693707
}
694708

@@ -786,7 +800,7 @@ private void formatImage(final GC imageGC, final Image image) {
786800

787801
final HistogramScaledData scaledData = new HistogramScaledData(fScaledData);
788802

789-
try {
803+
try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINER, "Histogram:FmtImg")) { //$NON-NLS-1$
790804
final int height = image.getBounds().height;
791805

792806
// Clear the drawing area

0 commit comments

Comments
 (0)