1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
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 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.analysis
.xml
.ui
.views
.xychart
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.jface
.util
.IPropertyChangeListener
;
17 import org
.eclipse
.jface
.util
.PropertyChangeEvent
;
18 import org
.eclipse
.linuxtools
.internal
.tmf
.analysis
.xml
.ui
.TmfXmlUiStrings
;
19 import org
.eclipse
.linuxtools
.internal
.tmf
.analysis
.xml
.ui
.views
.XmlViewInfo
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.xycharts
.TmfXYChartViewer
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfChartView
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Display
;
24 import org
.w3c
.dom
.Element
;
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.
32 * @author Geneviève Bastien
34 public class XmlXYView
extends TmfChartView
{
37 public static final String ID
= "org.eclipse.linuxtools.internal.tmf.analysis.xml.ui.views.xyview"; //$NON-NLS-1$
39 private final XmlViewInfo fViewInfo
= new XmlViewInfo(ID
);
45 super(Messages
.XmlXYView_DefaultTitle
);
47 this.addPartPropertyListener(new IPropertyChangeListener() {
49 public void propertyChange(@Nullable PropertyChangeEvent event
) {
53 if (event
.getProperty().equals(TmfXmlUiStrings
.XML_OUTPUT_DATA
)) {
54 Object newValue
= event
.getNewValue();
55 if (newValue
instanceof String
) {
56 fViewInfo
.setViewData((String
) newValue
);
58 TmfXYChartViewer viewer
= getChartViewer();
59 if (viewer
instanceof XmlXYViewer
) {
60 ((XmlXYViewer
) viewer
).viewInfoUpdated();
72 public void createPartControl(@Nullable Composite parent
) {
73 setChartViewer(new XmlXYViewer(parent
, fViewInfo
));
74 super.createPartControl(parent
);
78 public void setFocus() {
82 private void setViewTitle() {
84 * Get the view element from the XML file. If the element can't be
87 Element viewElement
= fViewInfo
.getViewElement(TmfXmlUiStrings
.XY_VIEW
);
88 if (viewElement
== null) {
92 String title
= fViewInfo
.getViewTitle(viewElement
);
94 title
= Messages
.XmlXYView_DefaultTitle
;
96 final String viewTitle
= title
;
97 Display
.getDefault().asyncExec(new Runnable() {
100 setPartName(viewTitle
);