Adapt views plugins to TMF
[deliverable/tracecompass.git] / tmf / org.lttng.scope.tmf2.views.ui / src / org / lttng / scope / tmf2 / views / ui / timeline / TimelineView.java
1 /*******************************************************************************
2 * Copyright (c) 2016 EfficiOS Inc., Alexandre Montplaisir
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;
11
12 import static java.util.Objects.requireNonNull;
13
14 import java.util.Collection;
15 import java.util.stream.Collectors;
16
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.tracecompass.common.core.StreamUtils;
21 import org.eclipse.tracecompass.tmf.ui.views.TmfView;
22 import org.lttng.scope.tmf2.views.core.context.ViewGroupContext;
23
24 import javafx.embed.swt.FXCanvas;
25 import javafx.geometry.Orientation;
26 import javafx.scene.Node;
27 import javafx.scene.Scene;
28 import javafx.scene.control.SplitPane;
29
30 public class TimelineView extends TmfView {
31
32 public static final String VIEW_ID = "org.lttng.scope.views.timeline"; //$NON-NLS-1$
33
34 private static final String VIEW_NAME = requireNonNull(Messages.timelineViewName);
35
36 private @Nullable TimelineManager fManager;
37
38 public TimelineView() {
39 super(VIEW_NAME);
40 }
41
42 @Override
43 public void createPartControl(@Nullable Composite parent) {
44 if (parent == null) {
45 return;
46 }
47
48 FXCanvas fxCanvas = new FXCanvas(parent, SWT.NONE);
49 SplitPane sp = new SplitPane();
50 sp.setOrientation(Orientation.VERTICAL);
51
52 /* Add the widget to the view */
53 TimelineManager manager = new TimelineManager(ViewGroupContext.getCurrent());
54 Collection<Node> nodes = StreamUtils.getStream(manager.getWidgets())
55 .map(widget -> widget.getRootNode())
56 .collect(Collectors.toList());
57 sp.getItems().addAll(nodes);
58
59 fxCanvas.setScene(new Scene(sp));
60
61 /*
62 * Set the initial divider positions. Has to be done *after* the
63 * Stage/Scene is initialized.
64 */
65 manager.resetInitialSeparatorPosition();
66
67 fManager = manager;
68 }
69
70 @Override
71 public void dispose() {
72 if (fManager != null) {
73 fManager.dispose();
74 }
75 }
76
77 @Override
78 public void setFocus() {
79 }
80
81 }
This page took 0.03177 seconds and 5 git commands to generate.