1818
1919package org .eclipse .tracecompass .tmf .ui .views .histogram ;
2020
21+ import java .util .logging .Level ;
22+ import java .util .logging .Logger ;
23+
2124import org .eclipse .jdt .annotation .NonNull ;
2225import org .eclipse .jface .action .IStatusLineManager ;
2326import org .eclipse .jface .layout .GridDataFactory ;
4851import org .eclipse .swt .widgets .Control ;
4952import org .eclipse .swt .widgets .Display ;
5053import 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 ;
5157import org .eclipse .tracecompass .internal .tmf .ui .views .histogram .HistogramTimeAdapter ;
5258import org .eclipse .tracecompass .tmf .core .signal .TmfSignalHandler ;
5359import 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