ctf: fix windows regression
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.analysis.xml.ui / src / org / eclipse / tracecompass / internal / tmf / analysis / xml / ui / views / xychart / XmlXYView.java
CommitLineData
87c5447c
GB
1/*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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 * Contributors:
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
12
2bdf0193 13package org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.xychart;
87c5447c
GB
14
15import org.eclipse.jdt.annotation.Nullable;
16import org.eclipse.jface.util.IPropertyChangeListener;
17import org.eclipse.jface.util.PropertyChangeEvent;
87c5447c
GB
18import org.eclipse.swt.widgets.Composite;
19import org.eclipse.swt.widgets.Display;
2bdf0193
AM
20import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.TmfXmlUiStrings;
21import org.eclipse.tracecompass.internal.tmf.analysis.xml.ui.views.XmlViewInfo;
22import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
23import org.eclipse.tracecompass.tmf.ui.views.TmfChartView;
87c5447c
GB
24import org.w3c.dom.Element;
25
26/**
27 * This view displays state system data in an xy chart. It uses an XML
28 * {@link TmfXmlUiStrings#XY_VIEW} element from an XML file. This element
29 * defines which entries from the state system will be shown and also gives
30 * additional information on the presentation of the view.
31 *
32 * @author Geneviève Bastien
33 */
34public class XmlXYView extends TmfChartView {
35
36 /** View ID. */
37 public static final String ID = "org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xyview"; //$NON-NLS-1$
38
39 private final XmlViewInfo fViewInfo = new XmlViewInfo(ID);
40
41 /**
42 * Default constructor
43 */
44 public XmlXYView() {
45 super(Messages.XmlXYView_DefaultTitle);
46
47 this.addPartPropertyListener(new IPropertyChangeListener() {
48 @Override
49 public void propertyChange(@Nullable PropertyChangeEvent event) {
50 if (event == null) {
51 return;
52 }
53 if (event.getProperty().equals(TmfXmlUiStrings.XML_OUTPUT_DATA)) {
54 Object newValue = event.getNewValue();
55 if (newValue instanceof String) {
56 fViewInfo.setViewData((String) newValue);
57 setViewTitle();
58 TmfXYChartViewer viewer = getChartViewer();
59 if (viewer instanceof XmlXYViewer) {
60 ((XmlXYViewer) viewer).viewInfoUpdated();
61 }
62
63 }
64 }
65 }
66
67 });
68 setViewTitle();
69 }
70
87c5447c
GB
71 @Override
72 public void setFocus() {
73
74 }
75
76 private void setViewTitle() {
77 /*
78 * Get the view element from the XML file. If the element can't be
79 * found, return.
80 */
81 Element viewElement = fViewInfo.getViewElement(TmfXmlUiStrings.XY_VIEW);
82 if (viewElement == null) {
83 return;
84 }
85
86 String title = fViewInfo.getViewTitle(viewElement);
87 if (title == null) {
88 title = Messages.XmlXYView_DefaultTitle;
89 }
90 final String viewTitle = title;
91 Display.getDefault().asyncExec(new Runnable() {
92 @Override
93 public void run() {
94 setPartName(viewTitle);
95 }
96 });
97 }
98
4c5e027b
MAL
99 @Override
100 protected TmfXYChartViewer createChartViewer(@Nullable Composite parent) {
101 return new XmlXYViewer(parent, fViewInfo);
102 }
103
87c5447c 104}
This page took 0.065087 seconds and 5 git commands to generate.