2 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
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
10 package org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.toolbar
;
12 import org
.lttng
.scope
.tmf2
.views
.ui
.jfx
.JfxImageFactory
;
13 import org
.lttng
.scope
.tmf2
.views
.ui
.jfx
.JfxUtils
;
14 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.StateRectangle
;
15 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.TimeGraphWidget
;
16 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.toolbar
.debugopts
.DebugOptionsButton
;
17 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.toolbar
.drawnevents
.EventSeriesMenuButton
;
18 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.toolbar
.modelconfig
.ModelConfigButton
;
19 import org
.lttng
.scope
.tmf2
.views
.ui
.timeline
.widgets
.timegraph
.toolbar
.nav
.NavigationButtons
;
21 import javafx
.scene
.control
.Alert
;
22 import javafx
.scene
.control
.Alert
.AlertType
;
23 import javafx
.scene
.control
.Button
;
24 import javafx
.scene
.control
.Label
;
25 import javafx
.scene
.control
.Separator
;
26 import javafx
.scene
.control
.TextField
;
27 import javafx
.scene
.control
.ToolBar
;
28 import javafx
.scene
.control
.Tooltip
;
29 import javafx
.scene
.image
.Image
;
30 import javafx
.scene
.image
.ImageView
;
31 import javafx
.scene
.layout
.HBox
;
34 * Toolbar for the time graph viewer.
36 * @author Alexandre Montplaisir
38 public class ViewerToolBar
extends ToolBar
{
40 private static final String HELP_ICON_PATH
= "/icons/toolbar/help.gif"; //$NON-NLS-1$
46 * The time graph viewer to which this toolbar belongs.
48 public ViewerToolBar(TimeGraphWidget viewer
) {
51 NavigationButtons navButtons
= new NavigationButtons(viewer
);
54 new Label(viewer
.getName()),
57 new ZoomInButton(viewer
),
58 new ZoomOutButton(viewer
),
59 new ZoomToSelectionButton(viewer
),
60 new ZoomToFullRangeButton(viewer
),
64 navButtons
.getBackButton(),
65 navButtons
.getForwardButton(),
66 navButtons
.getMenuButton()
68 getStateInfoButton(viewer
),
71 new ModelConfigButton(viewer
),
72 new ArrowSeriesMenuButton(viewer
),
73 new EventSeriesMenuButton(viewer
),
74 new SortingModeMenuButton(viewer
),
75 new FilterModeMenuButton(viewer
),
78 new DebugOptionsButton(viewer
));
81 // FIXME Temporary, should be moved to tooltip
82 private Button
getStateInfoButton(TimeGraphWidget viewer
) {
83 Button button
= new Button();
84 Image helpIcon
= JfxImageFactory
.instance().getImageFromResource(HELP_ICON_PATH
);
85 button
.setGraphic(new ImageView(helpIcon
));
86 button
.setTooltip(new Tooltip("Get State Info")); //$NON-NLS-1$
87 button
.setOnAction(e
-> {
88 StateRectangle state
= viewer
.getSelectedState();
92 Alert alert
= new Alert(AlertType
.INFORMATION
);
93 /* Use a read-only TextField so the text can be copy-pasted */
94 TextField content
= new TextField(state
.toString());
95 content
.setEditable(false);
96 content
.setPrefWidth(1000.0);
97 alert
.getDialogPane().setContent(content
);
98 alert
.setResizable(true);
101 JfxUtils
.centerDialogOnScreen(alert
, this);