tmf.ui: Make XYChart's time axis' visibility toggleable

Commit 64cd744efa06452d694f29762fee31624e37c0cd implemented this for the
now deprecated TmfXYChartViewer but it was lost in the migration to
org.eclipse.swtchart.

Bug: 566797

[Added] Make XYChart's time axis visibility toggleable

Change-Id: Ie50c37ad231eaec4c37fd3954e7ecc2ec0d97442
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/168491
Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
(cherry picked from commit a85df40aaaad38edfd371b8d52f3431658464ba9)
Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/168908
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/TmfXYChartViewer.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/TmfXYChartViewer.java
index 028e7ff..e938cfe 100644
--- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/TmfXYChartViewer.java
+++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xychart/TmfXYChartViewer.java
@@ -83,6 +83,8 @@
     // ------------------------------------------------------------------------
     private static final int DEFAULT_SCALE_HEIGHT = 22;
 
+    /** The composite to house the chart and time graph scale */
+    private Composite fCommonComposite;
     /** The color scheme for the chart */
     private @NonNull TimeGraphColorScheme fColorScheme = new TimeGraphColorScheme();
     /** The SWT Chart reference */
@@ -136,6 +138,7 @@
                 fTimeScaleCtrl.redraw();
             }
         };
+        fCommonComposite = commonComposite;
         commonComposite.addDisposeListener(e -> {
             fColorScheme.dispose();
         });
@@ -256,6 +259,21 @@
     }
 
     /**
+     * Switches visibility of the time axis on and off.
+     *
+     * @param visible
+     *            {@code true} to make the time axis visible.
+     *            {@code false} to make it invisible
+     * @since 6.1
+     */
+    public void setTimeAxisVisible(boolean visible) {
+        GridData gridData = (GridData) fTimeScaleCtrl.getLayoutData();
+        gridData.exclude = !visible;
+        fTimeScaleCtrl.setVisible(visible);
+        fCommonComposite.requestLayout();
+    }
+
+    /**
      * Sets a mouse selection provider. An existing provider will be disposed. Use
      * <code>null</code> to disable the mouse selection provider.
      *