Commit | Line | Data |
---|---|---|
c8e5d00e JCK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2016 Ericsson | |
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 | package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.latency; | |
10 | ||
11 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; | |
12 | ||
13 | import org.eclipse.jdt.annotation.NonNull; | |
14 | import org.eclipse.jface.util.IPropertyChangeListener; | |
15 | import org.eclipse.jface.util.PropertyChangeEvent; | |
16 | import org.eclipse.swt.widgets.Composite; | |
17 | import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings; | |
18 | import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlLatencyViewInfo; | |
19 | import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer; | |
20 | import org.eclipse.tracecompass.tmf.ui.views.TmfChartView; | |
21 | ||
22 | /** | |
23 | * The scatter graph view for pattern latency | |
24 | * | |
25 | * @author Jean-Christian Kouame | |
26 | */ | |
27 | public class PatternScatterGraphView extends TmfChartView { | |
28 | ||
29 | /** The view's ID */ | |
30 | public static final @NonNull String ID = "org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.scattergraph"; //$NON-NLS-1$ | |
31 | ||
32 | private final XmlLatencyViewInfo fViewInfo = new XmlLatencyViewInfo(ID); | |
33 | ||
34 | private PatternScatterGraphViewer fViewer; | |
35 | ||
36 | /** | |
37 | * Constructor | |
38 | */ | |
39 | public PatternScatterGraphView() { | |
40 | super(ID); | |
41 | this.addPartPropertyListener(new IPropertyChangeListener() { | |
42 | @Override | |
43 | public void propertyChange(PropertyChangeEvent event) { | |
44 | if (event.getProperty().equals(TmfXmlUiStrings.XML_LATENCY_OUTPUT_DATA)) { | |
45 | Object newValue = event.getNewValue(); | |
46 | if (newValue instanceof String) { | |
47 | String data = (String) newValue; | |
48 | fViewInfo.setViewData(data); | |
49 | loadLatencyView(); | |
50 | } | |
51 | } | |
52 | } | |
53 | }); | |
54 | } | |
55 | ||
56 | private void loadLatencyView() { | |
57 | if (fViewer != null) { | |
58 | fViewer.updateViewer(fViewInfo.getViewAnalysisId()); | |
59 | } | |
60 | } | |
61 | ||
62 | @Override | |
63 | protected TmfXYChartViewer createChartViewer(Composite parent) { | |
64 | PatternScatterGraphViewer viewer = new PatternScatterGraphViewer(checkNotNull(parent), checkNotNull(Messages.PatternLatencyViews_ScatterGraphTitle), checkNotNull(Messages.PatternLatencyViews_ScatterGraphXLabel), checkNotNull(Messages.PatternLatencyViews_ScatterGraphYLabel)); | |
65 | fViewer = viewer; | |
66 | loadLatencyView(); | |
67 | return viewer; | |
68 | } | |
69 | } |