| 1 | /* |
| 2 | * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com> |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | */ |
| 9 | |
| 10 | package org.lttng.scope.tmf2.views.ui.timeline.widgets.timegraph.toolbar; |
| 11 | |
| 12 | import org.lttng.scope.tmf2.views.core.TimeRange; |
| 13 | import org.lttng.scope.tmf2.views.ui.jfx.JfxImageFactory; |
| 14 | import org.lttng.scope.tmf2.views.ui.timeline.widgets.timegraph.TimeGraphWidget; |
| 15 | |
| 16 | import javafx.scene.control.Button; |
| 17 | import javafx.scene.control.Tooltip; |
| 18 | import javafx.scene.image.Image; |
| 19 | import javafx.scene.image.ImageView; |
| 20 | |
| 21 | /** |
| 22 | * Button to zoom (out) to the full trace's range. |
| 23 | * |
| 24 | * @author Alexandre Montplaisir |
| 25 | */ |
| 26 | class ZoomToFullRangeButton extends Button { |
| 27 | |
| 28 | private static final String ZOOM_TO_FULL_RANGE_ICON_PATH = "/icons/toolbar/zoom_full.gif"; //$NON-NLS-1$ |
| 29 | |
| 30 | public ZoomToFullRangeButton(TimeGraphWidget viewer) { |
| 31 | Image icon = JfxImageFactory.instance().getImageFromResource(ZOOM_TO_FULL_RANGE_ICON_PATH); |
| 32 | setGraphic(new ImageView(icon)); |
| 33 | setTooltip(new Tooltip(Messages.sfZoomToFullRangeActionDescription)); |
| 34 | setOnAction(e -> { |
| 35 | TimeRange fullRange = viewer.getControl().getViewContext().getCurrentTraceFullRange(); |
| 36 | viewer.getControl().updateVisibleTimeRange(fullRange, true); |
| 37 | }); |
| 38 | } |
| 39 | } |